blob: 04e57dec3acc3d0220c02a19c3bd47f8a67daa0f [file] [log] [blame]
Benjamin Kramer054faa52013-03-29 21:43:21 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89 -Wno-sizeof-array-decay
Chris Lattnere174acc2008-07-25 20:02:29 +00002// rdar://6095180
3
Chris Lattnere174acc2008-07-25 20:02:29 +00004struct s { char c[17]; };
Chris Lattnerf6e1e302008-07-25 20:54:07 +00005extern struct s foo(void);
Chris Lattnere174acc2008-07-25 20:02:29 +00006
Chris Lattnerf6e1e302008-07-25 20:54:07 +00007struct s a, b, c;
Chris Lattnere174acc2008-07-25 20:02:29 +00008
Chris Lattnerf6e1e302008-07-25 20:54:07 +00009int A[sizeof((foo().c)) == 17 ? 1 : -1];
10int B[sizeof((a.c)) == 17 ? 1 : -1];
11
12
Chris Lattner61f60a02008-07-25 21:33:13 +000013// comma does not promote array/function in c90 unless they are lvalues.
Douglas Gregorcb2b6622010-07-15 18:47:04 +000014int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1];
15int X[sizeof(0, (foo().c)) == 17 ? 1 : -1];
16int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1];
Aaron Ballman6c93b3e2014-12-17 21:57:17 +000017int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; // expected-warning {{expression with side effects has no effect in an unevaluated context}}