Ted Kremenek | fd6b874 | 2011-01-26 04:49:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 2 | |
| 3 | // rdar://8365684 |
| 4 | struct S { |
Chandler Carruth | a7689ef | 2011-03-27 09:46:56 +0000 | [diff] [blame] | 5 | void m1() { int b; while (b==b); } // expected-warning {{always evaluates to true}} |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 6 | |
| 7 | #pragma clang diagnostic push |
| 8 | #pragma clang diagnostic ignored "-Wtautological-compare" |
Chandler Carruth | a7689ef | 2011-03-27 09:46:56 +0000 | [diff] [blame] | 9 | void m2() { int b; while (b==b); } |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 10 | #pragma clang diagnostic pop |
| 11 | |
Chandler Carruth | a7689ef | 2011-03-27 09:46:56 +0000 | [diff] [blame] | 12 | void m3() { int b; while (b==b); } // expected-warning {{always evaluates to true}} |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | //------------------------------------------------------------------------------ |
| 16 | |
| 17 | #pragma clang diagnostic push |
| 18 | #pragma clang diagnostic ignored "-Wtautological-compare" |
| 19 | template <typename T> |
| 20 | struct TS { |
Chandler Carruth | a7689ef | 2011-03-27 09:46:56 +0000 | [diff] [blame] | 21 | void m() { T b; while (b==b); } |
Argyrios Kyrtzidis | 0827408 | 2010-12-15 18:44:22 +0000 | [diff] [blame] | 22 | }; |
| 23 | #pragma clang diagnostic pop |
| 24 | |
| 25 | void f() { |
| 26 | TS<int> ts; |
| 27 | ts.m(); |
| 28 | } |
| 29 | |
| 30 | //------------------------------------------------------------------------------ |
| 31 | |
| 32 | #define UNUSED_MACRO1 // expected-warning {{macro is not used}} |
| 33 | |
| 34 | #pragma clang diagnostic push |
| 35 | #pragma clang diagnostic ignored "-Wunused-macros" |
| 36 | #define UNUSED_MACRO2 |
| 37 | #pragma clang diagnostic pop |
| 38 | |
| 39 | //------------------------------------------------------------------------------ |
| 40 | |
| 41 | #pragma clang diagnostic push |
| 42 | #pragma clang diagnostic ignored "-Wreturn-type" |
| 43 | int g() { } |
| 44 | #pragma clang diagnostic pop |
| 45 | |
| 46 | //------------------------------------------------------------------------------ |
| 47 | |
| 48 | void ww( |
| 49 | #pragma clang diagnostic push |
| 50 | #pragma clang diagnostic ignored "-Wunused-parameter" |
| 51 | int x, |
| 52 | #pragma clang diagnostic pop |
| 53 | int y) // expected-warning {{unused}} |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | //------------------------------------------------------------------------------ |
| 58 | |
| 59 | struct S2 { |
| 60 | int x, y; |
| 61 | S2() : |
| 62 | #pragma clang diagnostic push |
| 63 | #pragma clang diagnostic ignored "-Wreorder" |
| 64 | y(), |
| 65 | x() |
| 66 | #pragma clang diagnostic pop |
| 67 | {} |
| 68 | }; |
| 69 | |
| 70 | //------------------------------------------------------------------------------ |
Argyrios Kyrtzidis | ee933e1 | 2010-12-24 02:53:53 +0000 | [diff] [blame] | 71 | |
| 72 | // rdar://8790245 |
| 73 | #define MYMACRO \ |
| 74 | _Pragma("clang diagnostic push") \ |
| 75 | _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \ |
| 76 | _Pragma("clang diagnostic pop") |
| 77 | MYMACRO |
| 78 | #undef MYMACRO |
| 79 | |
| 80 | //------------------------------------------------------------------------------ |