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