unused-expr.c revision 9f3d942e9970bc8f51add390b2a2c46b5a2ab747
1// RUN: clang -parse-ast -verify %s 2 3int foo(int X, int Y); 4 5void bar(volatile int *VP, int *P, int A, 6 _Complex double C, volatile _Complex double VC) { 7 8 VP == P; // expected-warning {{expression result unused}} 9 (void)A; 10 (void)foo(1,2); // no warning. 11 12 A == foo(1, 2); // expected-warning {{expression result unused}} 13 14 foo(1,2)+foo(4,3); // expected-warning {{expression result unused}} 15 16 17 *P; // expected-warning {{expression result unused}} 18 *VP; // no warning. 19 P[4]; // expected-warning {{expression result unused}} 20 VP[4]; // no warning. 21 22 // FIXME: SEMA explodes on these. 23 //__real__ C; 24 //__real__ VC; 25} 26 27extern void t1(); 28extern void t2(); 29void t3(int c) { 30 c ? t1() : t2(); 31} 32 33// This shouldn't warn: the expr at the end of the stmtexpr really is used. 34int stmt_expr(int x, int y) { 35 return ({int _a = x, _b = y; _a > _b ? _a : _b; }); 36} 37 38