From: Chris Lattner Date: Sat, 18 Apr 2009 01:34:22 +0000 (+0000) Subject: Fix PR3938 by taking into account C99 6.10p4. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fe00e783eda289c28a25eea452fd4d467963a82;p=clang Fix PR3938 by taking into account C99 6.10p4. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69413 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 502da73842..be4da35f93 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -268,7 +268,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // #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. - CheckEndOfDirective("else"); + DiscardUntilEndOfDirective(); // C99 6.10p4. PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel(); // If this is a #else with a #else before it, report the error. diff --git a/test/Preprocessor/if_warning.c b/test/Preprocessor/if_warning.c index acb6d5ea42..5fc8c347a6 100644 --- a/test/Preprocessor/if_warning.c +++ b/test/Preprocessor/if_warning.c @@ -11,3 +11,10 @@ extern int x; #if defined(foo) #endif + +// PR3938 +#if 0 +#ifdef D +#else 1 // Should not warn due to C99 6.10p4 +#endif +#endif