diff options
| author | Andy Gibbs <andyg1001@hotmail.co.uk> | 2012-11-17 19:15:38 +0000 |
|---|---|---|
| committer | Andy Gibbs <andyg1001@hotmail.co.uk> | 2012-11-17 19:15:38 +0000 |
| commit | 58905d251bc053ea836183080c7b0a11577c0fb0 (patch) | |
| tree | b32a10eaa0f1f4381f9e1171c580cf776458b925 /clang/test/Preprocessor | |
| parent | f591982bb2908a80be2aebc52c98d9befc9b5937 (diff) | |
| download | bcm5719-llvm-58905d251bc053ea836183080c7b0a11577c0fb0.tar.gz bcm5719-llvm-58905d251bc053ea836183080c7b0a11577c0fb0.zip | |
Refactored duplicate string literal lexing code within Preprocessor, into a
common LexStringLiteral function. In doing so, some consistency problems have
been ironed out (e.g. where the first token in the string literal was lexed
with macro expansion, but subsequent ones were not) and also an erroneous
diagnostic has been corrected.
LexStringLiteral is complemented by a FinishLexStringLiteral function which
can be used in the situation where the first token of the string literal has
already been lexed.
llvm-svn: 168266
Diffstat (limited to 'clang/test/Preprocessor')
| -rw-r--r-- | clang/test/Preprocessor/invalid-__has_warning1.c | 2 | ||||
| -rw-r--r-- | clang/test/Preprocessor/invalid-__has_warning2.c | 2 | ||||
| -rw-r--r-- | clang/test/Preprocessor/pragma_diagnostic.c | 2 | ||||
| -rw-r--r-- | clang/test/Preprocessor/pragma_microsoft.c | 2 | ||||
| -rw-r--r-- | clang/test/Preprocessor/warning_tests.c | 25 |
5 files changed, 28 insertions, 5 deletions
diff --git a/clang/test/Preprocessor/invalid-__has_warning1.c b/clang/test/Preprocessor/invalid-__has_warning1.c index 40491d4767f..b6a0b2e8ee3 100644 --- a/clang/test/Preprocessor/invalid-__has_warning1.c +++ b/clang/test/Preprocessor/invalid-__has_warning1.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -verify %s // These must be the last lines in this test. -// expected-error@+1{{requires a parenthesized string}} expected-error@+1 2{{expected}} +// expected-error@+1{{expected string literal}} expected-error@+1 2{{expected}} int i = __has_warning( diff --git a/clang/test/Preprocessor/invalid-__has_warning2.c b/clang/test/Preprocessor/invalid-__has_warning2.c index 7d85e5376f9..8aba530c875 100644 --- a/clang/test/Preprocessor/invalid-__has_warning2.c +++ b/clang/test/Preprocessor/invalid-__has_warning2.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -verify %s // These must be the last lines in this test. -// expected-error@+1{{requires a parenthesized string}} expected-error@+1{{expected}} +// expected-error@+1{{expected string literal}} expected-error@+1{{expected}} int i = __has_warning(); diff --git a/clang/test/Preprocessor/pragma_diagnostic.c b/clang/test/Preprocessor/pragma_diagnostic.c index 818f02f0b90..5c91079619e 100644 --- a/clang/test/Preprocessor/pragma_diagnostic.c +++ b/clang/test/Preprocessor/pragma_diagnostic.c @@ -23,7 +23,7 @@ #define foo error #pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} -#pragma GCC diagnostic error 42 // expected-warning {{unexpected token in pragma diagnostic}} +#pragma GCC diagnostic error 42 // expected-error {{expected string literal}} #pragma GCC diagnostic error "-Wundef" 42 // expected-warning {{unexpected token in pragma diagnostic}} #pragma GCC diagnostic error "invalid-name" // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}} diff --git a/clang/test/Preprocessor/pragma_microsoft.c b/clang/test/Preprocessor/pragma_microsoft.c index e461c707a9a..782f986f7e6 100644 --- a/clang/test/Preprocessor/pragma_microsoft.c +++ b/clang/test/Preprocessor/pragma_microsoft.c @@ -11,7 +11,7 @@ #pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ ) #pragma comment(foo) // expected-error {{unknown kind of pragma comment}} -#pragma comment(compiler,) // expected-error {{pragma comment requires}} +#pragma comment(compiler,) // expected-error {{expected string literal}} #define foo compiler #pragma comment(foo) // macro expand kind. #pragma comment(foo) x // expected-error {{pragma comment requires}} diff --git a/clang/test/Preprocessor/warning_tests.c b/clang/test/Preprocessor/warning_tests.c index ac0b37b645a..77b84562694 100644 --- a/clang/test/Preprocessor/warning_tests.c +++ b/clang/test/Preprocessor/warning_tests.c @@ -11,7 +11,7 @@ #warning Should have -Wparentheses #endif -// expected-error@+2 {{builtin warning check macro requires a parenthesized string}} +// expected-error@+2 {{expected string literal}} // expected-error@+1 {{expected value in expression}} #if __has_warning(-Wfoo) #endif @@ -21,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 |

