blob: ae973d6b2b8494864c1dc7b06f1feb881052f486 [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
Steve Naroffe701c0a2008-05-12 21:44:38 +000039int Postgresql() {
40 char x;
41 return ((((&x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
42}