blob: a21914c6d5ccb6b0aa200bc5d72c7ab2387a0725 [file] [log] [blame]
Steve Naroffb6d54e52008-01-08 01:11:38 +00001// RUN: clang -fsyntax-only -verify -pedantic %s
2void foo() {
3 *(0 ? (double *)0 : (void *)0) = 0;
Steve Naroff890d93e2008-01-30 21:50:43 +00004 // FIXME: GCC doesn't consider the the following two statements to be errors.
Steve Naroffaa58f002008-01-14 16:10:57 +00005 *(0 ? (double *)0 : (void *)(int *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
6 *(0 ? (double *)0 : (void *)(double *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
Steve Naroff890d93e2008-01-30 21:50:43 +00007 *(0 ? (double *)0 : (int *)(void *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} expected-warning {{pointer type mismatch ('double *' and 'int *')}}
Steve Naroffaaffbf72008-01-14 02:53:34 +00008 *(0 ? (double *)0 : (double *)(void *)0) = 0;
9 *((void *) 0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
Steve Naroffb6d54e52008-01-08 01:11:38 +000010 double *dp;
11 int *ip;
12 void *vp;
13
14 dp = vp;
15 vp = dp;
Steve Naroffaaffbf72008-01-14 02:53:34 +000016 ip = dp; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
17 dp = ip; // expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}}
Steve Naroffb6d54e52008-01-08 01:11:38 +000018 dp = 0 ? (double *)0 : (void *)0;
19 vp = 0 ? (double *)0 : (void *)0;
Steve Naroffaaffbf72008-01-14 02:53:34 +000020 ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
Eli Friedmanf76f5ed2008-02-10 23:14:16 +000021
22 const int *cip;
23 vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
24 vp = (0 ? cip : vp); // expected-warning {{discards qualifiers}}
Eli Friedman4c721d32008-02-12 08:23:06 +000025
26 int i = 2;
27 int (*pf)[2];
28 int (*pv)[i];
29 pf = (i ? pf : pv);
Eli Friedmanbab96962008-02-12 08:46:17 +000030
31 enum {xxx,yyy,zzz} e, *ee;
32 short x;
33 ee = ee ? &x : ee ? &i : &e; // expected-warning {{pointer type mismatch}}
Eli Friedman4b3f9b32008-02-13 17:29:58 +000034
35 typedef void *asdf;
36 *(0 ? (asdf) 0 : &x) = 10;
Steve Naroffb6d54e52008-01-08 01:11:38 +000037}
38