summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-04 02:57:01 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-04 02:57:01 +0000
commit4a1049c8a2292e796f452ff5bf128aa3e095f1a0 (patch)
tree76b6d2d21686c68225b2ad0f2cc26aea09dd2520 /clang
parentb73bc9af60367d5a0b11764082e561fade422194 (diff)
downloadbcm5719-llvm-4a1049c8a2292e796f452ff5bf128aa3e095f1a0.tar.gz
bcm5719-llvm-4a1049c8a2292e796f452ff5bf128aa3e095f1a0.zip
[preprocessor] In Preprocessor::CachingLex() check whether there were more tokens
cached during the non-cached lex, otherwise we are going to drop them. Fixes a bogus "_Pragma takes a parenthesized string literal" error when expanding consecutive _Pragmas in a macro argument. Part of rdar://11168596 llvm-svn: 153994
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PPCaching.cpp18
-rw-r--r--clang/test/Preprocessor/_Pragma-in-macro-arg.c2
2 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Lex/PPCaching.cpp b/clang/lib/Lex/PPCaching.cpp
index 0d5e34f0bfe..6f4c189b4f6 100644
--- a/clang/lib/Lex/PPCaching.cpp
+++ b/clang/lib/Lex/PPCaching.cpp
@@ -57,17 +57,21 @@ void Preprocessor::CachingLex(Token &Result) {
ExitCachingLexMode();
Lex(Result);
- if (!isBacktrackEnabled()) {
+ if (isBacktrackEnabled()) {
+ // Cache the lexed token.
+ EnterCachingLexMode();
+ CachedTokens.push_back(Result);
+ ++CachedLexPos;
+ return;
+ }
+
+ if (CachedLexPos < CachedTokens.size()) {
+ EnterCachingLexMode();
+ } else {
// All cached tokens were consumed.
CachedTokens.clear();
CachedLexPos = 0;
- return;
}
-
- // Cache the lexed token.
- EnterCachingLexMode();
- CachedTokens.push_back(Result);
- ++CachedLexPos;
}
void Preprocessor::EnterCachingLexMode() {
diff --git a/clang/test/Preprocessor/_Pragma-in-macro-arg.c b/clang/test/Preprocessor/_Pragma-in-macro-arg.c
index 99a33a9e1b3..2877bcb7bfe 100644
--- a/clang/test/Preprocessor/_Pragma-in-macro-arg.c
+++ b/clang/test/Preprocessor/_Pragma-in-macro-arg.c
@@ -15,7 +15,7 @@ B(_Pragma("clang diagnostic ignored \"-Wparentheses\""))
// This should be ignored..
INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
-#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"")
+#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"") _Pragma("clang diagnostic ignored \"-Wconversion\"")
// ..as should this.
INACTIVE(IGNORE_CONV)
OpenPOWER on IntegriCloud