summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/PPDirectives.cpp11
-rw-r--r--clang/test/Index/preamble-conditionals-inverted-with-error.cpp8
-rw-r--r--clang/test/Index/preamble-conditionals-inverted.cpp8
3 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 556e76356da..eb9f11f3d4d 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -383,15 +383,8 @@ void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken,
// If this is the end of the buffer, we have an error.
if (Tok.is(tok::eof)) {
- // Emit errors for each unterminated conditional on the stack, including
- // the current one.
- while (!CurPPLexer->ConditionalStack.empty()) {
- if (CurLexer->getFileLoc() != CodeCompletionFileLoc)
- Diag(CurPPLexer->ConditionalStack.back().IfLoc,
- diag::err_pp_unterminated_conditional);
- CurPPLexer->ConditionalStack.pop_back();
- }
-
+ // We don't emit errors for unterminated conditionals here,
+ // Lexer::LexEndOfFile can do that propertly.
// Just return and let the caller lex after this #include.
break;
}
diff --git a/clang/test/Index/preamble-conditionals-inverted-with-error.cpp b/clang/test/Index/preamble-conditionals-inverted-with-error.cpp
new file mode 100644
index 00000000000..95b0695b873
--- /dev/null
+++ b/clang/test/Index/preamble-conditionals-inverted-with-error.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN: local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s
+#ifdef FOO_H
+
+void foo();
+
+// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive
diff --git a/clang/test/Index/preamble-conditionals-inverted.cpp b/clang/test/Index/preamble-conditionals-inverted.cpp
new file mode 100644
index 00000000000..1d67ccb61a0
--- /dev/null
+++ b/clang/test/Index/preamble-conditionals-inverted.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN: local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "error:"
+#ifdef FOO_H
+
+void foo();
+
+#endif
OpenPOWER on IntegriCloud