blob: a5e5ec4e1491c42138cf35fb01a2fde7d1e9a39f [file] [log] [blame]
Daniel Dunbar48d1ef72009-04-07 21:16:11 +00001// RUN: clang-cc -fsyntax-only -verify -fmath-errno=0 %s
Reid Spencer5f016e22007-07-11 17:01:13 +00002
3int foo(int X, int Y);
4
Chris Lattner5bef8dd2009-02-17 00:35:09 +00005double sqrt(double X); // implicitly const because of -fno-math-errno!
6
Reid Spencer5f016e22007-07-11 17:01:13 +00007void bar(volatile int *VP, int *P, int A,
8 _Complex double C, volatile _Complex double VC) {
9
Steve Naroff77878cc2007-08-27 04:08:11 +000010 VP == P; // expected-warning {{expression result unused}}
Chris Lattner6e844ad2007-08-26 17:32:59 +000011 (void)A;
Reid Spencer5f016e22007-07-11 17:01:13 +000012 (void)foo(1,2); // no warning.
13
14 A == foo(1, 2); // expected-warning {{expression result unused}}
15
16 foo(1,2)+foo(4,3); // expected-warning {{expression result unused}}
17
18
19 *P; // expected-warning {{expression result unused}}
20 *VP; // no warning.
21 P[4]; // expected-warning {{expression result unused}}
22 VP[4]; // no warning.
23
Chris Lattner7d84c762009-02-17 00:32:04 +000024 __real__ C; // expected-warning {{expression result unused}}
25 __real__ VC;
Chris Lattner5bef8dd2009-02-17 00:35:09 +000026
27 // We know this can't change errno because of -fno-math-errno.
28 sqrt(A); // expected-warning {{expression result unused}}
Reid Spencer5f016e22007-07-11 17:01:13 +000029}
30
Chris Lattner6e844ad2007-08-26 17:32:59 +000031extern void t1();
32extern void t2();
33void t3(int c) {
34 c ? t1() : t2();
35}
36
Chris Lattner98414c12007-08-31 21:49:55 +000037// This shouldn't warn: the expr at the end of the stmtexpr really is used.
38int stmt_expr(int x, int y) {
39 return ({int _a = x, _b = y; _a > _b ? _a : _b; });
40}
41
Eli Friedman4be1f472008-05-19 21:24:43 +000042void nowarn(unsigned char* a, unsigned char* b)
43{
44 unsigned char c = 1;
45 *a |= c, *b += c;
Chris Lattnerfb846642009-07-28 18:25:28 +000046
47
48 // PR4633
49 int y, x;
50 ((void)0), y = x;
Eli Friedman4be1f472008-05-19 21:24:43 +000051}
Chris Lattnerfb846642009-07-28 18:25:28 +000052
53