]> git.proxmox.com Git - rustc.git/blob - src/llvm/tools/clang/test/Preprocessor/pragma_diagnostic_sections.cpp
Imported Upstream version 0.6
[rustc.git] / src / llvm / tools / clang / test / Preprocessor / pragma_diagnostic_sections.cpp
1 // RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s
2
3 // rdar://8365684
4 struct S {
5 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"
9 void m2() { int b; while (b==b); }
10 #pragma clang diagnostic pop
11
12 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 {
21 void m() { T b; while (b==b); }
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 //------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------