aboutsummaryrefslogtreecommitdiff
path: root/test/Modules
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-02-06 22:40:31 +0000
committerDouglas Gregor <dgregor@apple.com>2013-02-06 22:40:31 +0000
commit8bf778eb9c0afb0a4c63a97ce504f50759c08d5f (patch)
treec2103331a484b301473ecab3ca98e6bb174ee222 /test/Modules
parent474e46211a141e4566c399b80ae26e3580b70c90 (diff)
Detect when we end up trying to load conflicting module files.
This can happen when one abuses precompiled headers by passing more -D options when using a precompiled hedaer than when it was built. This is intentionally permitted by precompiled headers (and is exploited by some build environments), but causes problems for modules. First part of <rdar://problem/13165109>, detecting when something when horribly wrong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules')
-rw-r--r--test/Modules/Inputs/ignored_macros.h8
-rw-r--r--test/Modules/Inputs/module.map4
-rw-r--r--test/Modules/ignored_macros.m22
3 files changed, 34 insertions, 0 deletions
diff --git a/test/Modules/Inputs/ignored_macros.h b/test/Modules/Inputs/ignored_macros.h
new file mode 100644
index 0000000000..250b58c2f7
--- /dev/null
+++ b/test/Modules/Inputs/ignored_macros.h
@@ -0,0 +1,8 @@
+struct Point {
+ double x, y;
+};
+
+#ifdef IGNORED
+int *has_ignored(void);
+#endif
+
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
index 55496fa35a..234bfcc2b0 100644
--- a/test/Modules/Inputs/module.map
+++ b/test/Modules/Inputs/module.map
@@ -159,3 +159,7 @@ module autolink {
module weird_objc {
header "weird_objc.h"
}
+
+module ignored_macros {
+ header "ignored_macros.h"
+}
diff --git a/test/Modules/ignored_macros.m b/test/Modules/ignored_macros.m
new file mode 100644
index 0000000000..1f9c27c2a3
--- /dev/null
+++ b/test/Modules/ignored_macros.m
@@ -0,0 +1,22 @@
+// First trial: pass -DIGNORED=1 to both. It should be ignored in both
+// RUN: rm -rf %t.modules
+// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
+// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules -I %S/Inputs -include-pch %t.pch %s -verify
+
+// Second trial: pass -DIGNORED=1 only to the second invocation.
+// RUN: rm -rf %t.modules
+// RUN: %clang_cc1 -fmodule-cache-path %t.modules -fmodules -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
+// RUN: not %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules -I %S/Inputs -include-pch %t.pch %s > %t.err 2>&1
+// RUN: FileCheck -check-prefix=CHECK-CONFLICT %s < %t.err
+// CHECK-CONFLICT: module 'ignored_macros' found in both
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+@import ignored_macros;
+#endif
+
+@import ignored_macros;
+
+struct Point p;