diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /test/Preprocessor/warning_tests.c | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/Preprocessor/warning_tests.c')
-rw-r--r-- | test/Preprocessor/warning_tests.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/Preprocessor/warning_tests.c b/test/Preprocessor/warning_tests.c index 3f2865c..c0c22ef 100644 --- a/test/Preprocessor/warning_tests.c +++ b/test/Preprocessor/warning_tests.c @@ -11,7 +11,9 @@ #warning Should have -Wparentheses #endif -#if __has_warning(-Wfoo) // expected-error {{builtin warning check macro requires a parenthesized string}} +// expected-error@+2 {{expected string literal in '__has_warning'}} +// expected-error@+1 {{expected value in expression}} +#if __has_warning(-Wfoo) #endif // expected-warning@+3 {{Not a valid warning flag}} @@ -19,3 +21,26 @@ #else #warning Not a valid warning flag #endif + +// expected-error@+2 {{builtin warning check macro requires a parenthesized string}} +// expected-error@+1 {{invalid token}} +#if __has_warning "not valid" +#endif + +// Macro expansion does not occur in the parameter to __has_warning +// (as is also expected behaviour for ordinary macros), so the +// following should not expand: + +#define MY_ALIAS "-Wparentheses" + +// expected-error@+1 2{{expected}} +#if __has_warning(MY_ALIAS) +#error Alias expansion not allowed +#endif + +// But deferring should expand: +#define HAS_WARNING(X) __has_warning(X) + +#if !HAS_WARNING(MY_ALIAS) +#error Expansion should have occurred +#endif |