]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Preprocessor/_Pragma-in-macro-arg.c
Vendor import of clang trunk r154661:
[FreeBSD/FreeBSD.git] / test / Preprocessor / _Pragma-in-macro-arg.c
1 // RUN: %clang_cc1 %s -verify -Wconversion
2
3 // Don't crash (rdar://11168596)
4 #define A(desc) _Pragma("clang diagnostic push")  _Pragma("clang diagnostic ignored \"-Wparentheses\"") _Pragma("clang diagnostic pop")
5 #define B(desc) A(desc)
6 B(_Pragma("clang diagnostic ignored \"-Wparentheses\""))
7
8
9 #define EMPTY(x)
10 #define INACTIVE(x) EMPTY(x)
11
12 #define ID(x) x
13 #define ACTIVE(x) ID(x)
14
15 // This should be ignored..
16 INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
17
18 #define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"") _Pragma("clang diagnostic ignored \"-Wconversion\"")
19
20 // ..as should this.
21 INACTIVE(IGNORE_CONV)
22
23 #define IGNORE_POPPUSH(Pop, Push, W, D) Push W D Pop
24 IGNORE_POPPUSH(_Pragma("clang diagnostic pop"), _Pragma("clang diagnostic push"),
25                _Pragma("clang diagnostic ignored \"-Wconversion\""), int q = (double)1.0);
26
27 int x1 = (double)1.0; // expected-warning {{implicit conversion}}
28
29 ACTIVE(_Pragma) ("clang diagnostic ignored \"-Wconversion\"")) // expected-error {{_Pragma takes a parenthesized string literal}} \
30                                       expected-error {{expected identifier or '('}} expected-error {{expected ')'}} expected-note {{to match this '('}}
31
32 // This should disable the warning.
33 ACTIVE(IGNORE_CONV)
34
35 int x2 = (double)1.0;