conditional-expr.c revision 4c721d381fb279899337d120edd4a24d405e56b2
1// RUN: clang -fsyntax-only -verify -pedantic %s 2void foo() { 3 *(0 ? (double *)0 : (void *)0) = 0; 4 // FIXME: GCC doesn't consider the the following two statements to be errors. 5 *(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}} 7 *(0 ? (double *)0 : (int *)(void *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} expected-warning {{pointer type mismatch ('double *' and 'int *')}} 8 *(0 ? (double *)0 : (double *)(void *)0) = 0; 9 *((void *) 0) = 0; // expected-error {{incomplete type 'void' is not assignable}} 10 double *dp; 11 int *ip; 12 void *vp; 13 14 dp = vp; 15 vp = dp; 16 ip = dp; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} 17 dp = ip; // expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}} 18 dp = 0 ? (double *)0 : (void *)0; 19 vp = 0 ? (double *)0 : (void *)0; 20 ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}} 21 22 const int *cip; 23 vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}} 24 vp = (0 ? cip : vp); // expected-warning {{discards qualifiers}} 25 26 int i = 2; 27 int (*pf)[2]; 28 int (*pv)[i]; 29 pf = (i ? pf : pv); 30} 31 32