Author: Aaron Ballman
Date: 2021-06-01T14:06:39-04:00
New Revision: baa2b8d08502acfa91a8dfd699d25f7b4e25edbb

URL: 
https://github.com/llvm/llvm-project/commit/baa2b8d08502acfa91a8dfd699d25f7b4e25edbb
DIFF: 
https://github.com/llvm/llvm-project/commit/baa2b8d08502acfa91a8dfd699d25f7b4e25edbb.diff

LOG: Fix a git apply that went bad somehow.

When applying the changes in 8edd3464afbff65d7d5945b3a8b20009d6ff5deb,
it seems that this bit got merged incorrectly and no test coverage
caught the issue. This fixes the diagnostic and adds a test.

Added: 
    

Modified: 
    clang/lib/Lex/PPDirectives.cpp
    clang/test/Preprocessor/elifdef.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 8fe70668a4060..87741b0a024a2 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -587,7 +587,7 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
 
         // If this is a #else with a #else before it, report the error.
         if (CondInfo.FoundElse)
-          Diag(Tok, diag::pp_err_else_after_else) << PED_Elif;
+          Diag(Tok, diag::pp_err_else_after_else);
 
         // Note that we've seen a #else in this conditional.
         CondInfo.FoundElse = true;
@@ -611,7 +611,8 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
         PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
 
         // If this is a #elif with a #else before it, report the error.
-        if (CondInfo.FoundElse) Diag(Tok, diag::pp_err_elif_after_else);
+        if (CondInfo.FoundElse)
+          Diag(Tok, diag::pp_err_elif_after_else) << PED_Elif;
 
         // If this is in a skipping block or if we're already handled this #if
         // block, don't bother parsing the condition.

diff  --git a/clang/test/Preprocessor/elifdef.c 
b/clang/test/Preprocessor/elifdef.c
index 3954159c5e08e..6bc467d70011f 100644
--- a/clang/test/Preprocessor/elifdef.c
+++ b/clang/test/Preprocessor/elifdef.c
@@ -105,3 +105,9 @@
 #elifdef
 #elifndef
 #endif
+
+/* expected-error@+3 {{#elif after #else}}*/
+#if 1
+#else
+#elif
+#endif


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to