]> granicus.if.org Git - clang/commitdiff
[modules] Don't reject multiple modules providing contents for the same embedded...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 1 Dec 2015 03:32:49 +0000 (03:32 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 1 Dec 2015 03:32:49 +0000 (03:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254365 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp
test/Modules/embed-files.cpp [new file with mode: 0644]

index 2defd38e27a6ff91503d229216b9496820fe4022..8043cf8e90c196d854723a85a0962964b05f2d47 100644 (file)
@@ -1963,7 +1963,8 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // can lead to problems when lexing using the source locations from the
   // PCH.
   SourceManager &SM = getSourceManager();
-  if (!Overridden && SM.isFileOverridden(File)) {
+  // FIXME: Reject if the overrides are different.
+  if ((!Overridden && !Transient) && SM.isFileOverridden(File)) {
     if (Complain)
       Error(diag::err_fe_pch_file_overridden, Filename);
     // After emitting the diagnostic, recover by disabling the override so
diff --git a/test/Modules/embed-files.cpp b/test/Modules/embed-files.cpp
new file mode 100644 (file)
index 0000000..a1db218
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'module a { header "a.h" } module b { header "b.h" }' > %t/modulemap
+// RUN: echo 'extern int t;' > %t/t.h
+// RUN: echo '#include "t.h"' > %t/a.h
+// RUN: echo '#include "t.h"' > %t/b.h
+
+// RUN: %clang_cc1 -fmodules -I%t -fmodules-cache-path=%t -fmodule-map-file=%t/modulemap -fmodules-embed-all-files %s -verify
+#include "a.h"
+char t; // expected-error {{different type}}
+// expected-note@t.h:1 {{here}}
+#include "t.h"
+#include "b.h"
+char t; // expected-error {{different type}}
+// expected-note@t.h:1 {{here}}