1 // RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s 2 3 // rdar://8365684 4 struct S { m1S5 void m1() { int b; while (b==b); } // expected-warning {{always evaluates to true}} 6 7 #pragma clang diagnostic push 8 #pragma clang diagnostic ignored "-Wtautological-compare" m2S9 void m2() { int b; while (b==b); } 10 #pragma clang diagnostic pop 11 m3S12 void m3() { int b; while (b==b); } // expected-warning {{always evaluates to true}} 13 }; 14 15 //------------------------------------------------------------------------------ 16 17 #pragma clang diagnostic push 18 #pragma clang diagnostic ignored "-Wtautological-compare" 19 template <typename T> 20 struct TS { mTS21 void m() { T b; while (b==b); } 22 }; 23 #pragma clang diagnostic pop 24 f()25void 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" g()43int g() { } 44 #pragma clang diagnostic pop 45 46 //------------------------------------------------------------------------------ 47 ww(int x,int y)48void 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; S2S261 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 //------------------------------------------------------------------------------ 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 //------------------------------------------------------------------------------ 81