[cfe-commits] r131788 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Preprocessor/if_warning.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri May 20 21:26:04 PDT 2011
Author: akirtzidis
Date: Fri May 20 23:26:04 2011
New Revision: 131788
URL: http://llvm.org/viewvc/llvm-project?rev=131788&view=rev
Log:
Only ignore extra tokens after #else if we skip it, otherwise warn. Fixes rdar://9475098.
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/Preprocessor/if_warning.c
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=131788&r1=131787&r2=131788&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri May 20 23:26:04 2011
@@ -323,7 +323,6 @@
// #else directive in a skipping conditional. If not in some other
// skipping conditional, and if #else hasn't already been seen, enter it
// as a non-skipping conditional.
- DiscardUntilEndOfDirective(); // C99 6.10p4.
PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
// If this is a #else with a #else before it, report the error.
@@ -339,7 +338,10 @@
// entered, enter the #else block now.
if (!CondInfo.WasSkipping && !CondInfo.FoundNonSkip) {
CondInfo.FoundNonSkip = true;
+ CheckEndOfDirective("else");
break;
+ } else {
+ DiscardUntilEndOfDirective(); // C99 6.10p4.
}
} else if (Sub == "lif") { // "elif".
PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
Modified: cfe/trunk/test/Preprocessor/if_warning.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/if_warning.c?rev=131788&r1=131787&r2=131788&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/if_warning.c (original)
+++ cfe/trunk/test/Preprocessor/if_warning.c Fri May 20 23:26:04 2011
@@ -20,6 +20,10 @@
#endif
#endif
+// rdar://9475098
+#if 0
+#else 1 // expected-warning {{extra tokens}}
+#endif
// PR6852
#if 'somesillylongthing' // expected-warning {{character constant too long for its type}} \
More information about the cfe-commits
mailing list