summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/PPDirectives.cpp9
-rw-r--r--clang/test/Modules/malformed.cpp6
2 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index ec06e790f01..aaed6b92d48 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1737,13 +1737,12 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
std::max(HeaderInfo.getFileDirFlavor(File),
SourceMgr.getFileCharacteristic(FilenameTok.getLocation()));
- // FIXME: If we have a suggested module, and we've already visited this file,
- // don't bother entering it again. We know it has no further effect.
-
// Ask HeaderInfo if we should enter this #include file. If not, #including
- // this file will have no effect.
+ // this file will have no effect. We treat any textual inclusion of a modular
+ // header as a #import here.
if (ShouldEnter &&
- !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport)) {
+ !HeaderInfo.ShouldEnterIncludeFile(
+ *this, File, isImport || SuggestedModule.getModule())) {
ShouldEnter = false;
if (Callbacks)
Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
diff --git a/clang/test/Modules/malformed.cpp b/clang/test/Modules/malformed.cpp
index 2d07c4cd0da..6d49850ccee 100644
--- a/clang/test/Modules/malformed.cpp
+++ b/clang/test/Modules/malformed.cpp
@@ -23,9 +23,9 @@
// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: to match this '{'
// CHECK-B: {{^}}Inputs/malformed/b1.h:3:{{.*}} error: extraneous closing brace ('}')
//
-// CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: redefinition of 'g'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} note: previous definition is here
+// We don't see another definition of 'g' because we don't re-enter b2.h
+// (even though it has no include guards).
+// CHECK-B-NOT: redefinition of 'g'
void test() { f<int>(); }
// Test that we use relative paths to name files within an imported module.
OpenPOWER on IntegriCloud