| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: cd %S |
| 3 |
// |
| 4 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 5 |
// RUN: -v \ |
| 6 |
// RUN: -iquote Inputs/macro-ambiguity/a/quote \ |
| 7 |
// RUN: -isystem Inputs/macro-ambiguity/a/system \ |
| 8 |
// RUN: -fno-implicit-modules \ |
| 9 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 10 |
// RUN: -emit-module -fmodule-name=a -o %t/a.pcm \ |
| 11 |
// RUN: Inputs/macro-ambiguity/module.modulemap |
| 12 |
// |
| 13 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 14 |
// RUN: -v \ |
| 15 |
// RUN: -iquote Inputs/macro-ambiguity/b/quote \ |
| 16 |
// RUN: -isystem Inputs/macro-ambiguity/b/system \ |
| 17 |
// RUN: -fno-implicit-modules \ |
| 18 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 19 |
// RUN: -emit-module -fmodule-name=b -o %t/b.pcm \ |
| 20 |
// RUN: Inputs/macro-ambiguity/module.modulemap |
| 21 |
// |
| 22 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 23 |
// RUN: -v \ |
| 24 |
// RUN: -iquote Inputs/macro-ambiguity/c/quote \ |
| 25 |
// RUN: -isystem Inputs/macro-ambiguity/c/system \ |
| 26 |
// RUN: -fno-implicit-modules \ |
| 27 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 28 |
// RUN: -emit-module -fmodule-name=c -o %t/c.pcm \ |
| 29 |
// RUN: Inputs/macro-ambiguity/module.modulemap |
| 30 |
// |
| 31 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 32 |
// RUN: -v \ |
| 33 |
// RUN: -iquote Inputs/macro-ambiguity/d/quote \ |
| 34 |
// RUN: -isystem Inputs/macro-ambiguity/d/system \ |
| 35 |
// RUN: -fno-implicit-modules \ |
| 36 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 37 |
// RUN: -emit-module -fmodule-name=d -o %t/d.pcm \ |
| 38 |
// RUN: Inputs/macro-ambiguity/module.modulemap |
| 39 |
// |
| 40 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 41 |
// RUN: -v \ |
| 42 |
// RUN: -iquote Inputs/macro-ambiguity/a/quote \ |
| 43 |
// RUN: -isystem Inputs/macro-ambiguity/a/system \ |
| 44 |
// RUN: -iquote Inputs/macro-ambiguity/b/quote \ |
| 45 |
// RUN: -isystem Inputs/macro-ambiguity/b/system \ |
| 46 |
// RUN: -iquote Inputs/macro-ambiguity/c/quote \ |
| 47 |
// RUN: -isystem Inputs/macro-ambiguity/c/system \ |
| 48 |
// RUN: -iquote Inputs/macro-ambiguity/d/quote \ |
| 49 |
// RUN: -isystem Inputs/macro-ambiguity/d/system \ |
| 50 |
// RUN: -iquote Inputs/macro-ambiguity/e/quote \ |
| 51 |
// RUN: -isystem Inputs/macro-ambiguity/e/system \ |
| 52 |
// RUN: -fno-implicit-modules \ |
| 53 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 54 |
// RUN: -fmodule-map-file=Inputs/macro-ambiguity/module.modulemap \ |
| 55 |
// RUN: -fmodule-file=%t/a.pcm \ |
| 56 |
// RUN: -fmodule-file=%t/b.pcm \ |
| 57 |
// RUN: -fmodule-file=%t/c.pcm \ |
| 58 |
// RUN: -fmodule-file=%t/d.pcm \ |
| 59 |
// RUN: -Wambiguous-macro -verify macro-ambiguity.cpp |
| 60 |
// |
| 61 |
// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ |
| 62 |
// RUN: -v -fmodules-local-submodule-visibility \ |
| 63 |
// RUN: -iquote Inputs/macro-ambiguity/a/quote \ |
| 64 |
// RUN: -isystem Inputs/macro-ambiguity/a/system \ |
| 65 |
// RUN: -iquote Inputs/macro-ambiguity/b/quote \ |
| 66 |
// RUN: -isystem Inputs/macro-ambiguity/b/system \ |
| 67 |
// RUN: -iquote Inputs/macro-ambiguity/c/quote \ |
| 68 |
// RUN: -isystem Inputs/macro-ambiguity/c/system \ |
| 69 |
// RUN: -iquote Inputs/macro-ambiguity/d/quote \ |
| 70 |
// RUN: -isystem Inputs/macro-ambiguity/d/system \ |
| 71 |
// RUN: -iquote Inputs/macro-ambiguity/e/quote \ |
| 72 |
// RUN: -isystem Inputs/macro-ambiguity/e/system \ |
| 73 |
// RUN: -fno-implicit-modules \ |
| 74 |
// RUN: -fmodule-map-file-home-is-cwd \ |
| 75 |
// RUN: -fmodule-map-file=Inputs/macro-ambiguity/module.modulemap \ |
| 76 |
// RUN: -fmodule-file=%t/a.pcm \ |
| 77 |
// RUN: -fmodule-file=%t/b.pcm \ |
| 78 |
// RUN: -fmodule-file=%t/c.pcm \ |
| 79 |
// RUN: -fmodule-file=%t/d.pcm \ |
| 80 |
// RUN: -Wambiguous-macro -verify macro-ambiguity.cpp |
| 81 |
|
| 82 |
// Include the textual headers first to maximize the ways in which things can |
| 83 |
// become ambiguous. |
| 84 |
#include "e_quote.h" |
| 85 |
#include <e_system.h> |
| 86 |
|
| 87 |
#include "a_quote.h" |
| 88 |
#include <a_system.h> |
| 89 |
#include "b_quote.h" |
| 90 |
#include <b_system.h> |
| 91 |
#include "c_quote.h" |
| 92 |
#include <c_system.h> |
| 93 |
#include "d_quote.h" |
| 94 |
#include <d_system.h> |
| 95 |
|
| 96 |
int test(int x) { |
| 97 |
// We expect to get warnings for all of the quoted includes but none of the |
| 98 |
// system includes here because the first module is a non-system module and |
| 99 |
// the quote macros come from non-system-headers. |
| 100 |
x = FOO1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} |
| 101 |
// expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:4 {{expanding this definition}} |
| 102 |
// expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:4 {{other definition}} |
| 103 |
|
| 104 |
x = FOO1_SYSTEM(x); |
| 105 |
|
| 106 |
x = BAR1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} |
| 107 |
// expected-note@Inputs/macro-ambiguity/d/quote/d_quote.h:4 {{expanding this definition}} |
| 108 |
// expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:5 {{other definition}} |
| 109 |
|
| 110 |
x = BAR1_SYSTEM(x); |
| 111 |
|
| 112 |
x = BAZ1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} |
| 113 |
// expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:6 {{expanding this definition}} |
| 114 |
// expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:4 {{other definition}} |
| 115 |
|
| 116 |
x = BAZ1_SYSTEM(x); |
| 117 |
|
| 118 |
// Here, we don't even warn on bar because in that cas both b and d are |
| 119 |
// system modules and so the use of non-system headers is irrelevant. |
| 120 |
x = FOO2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} |
| 121 |
// expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:5 {{expanding this definition}} |
| 122 |
// expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:4 {{other definition}} |
| 123 |
|
| 124 |
x = FOO2_SYSTEM(x); |
| 125 |
|
| 126 |
x = BAR2_QUOTE(x); |
| 127 |
|
| 128 |
x = BAR2_SYSTEM(x); |
| 129 |
|
| 130 |
x = BAZ2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}} |
| 131 |
// expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:6 {{expanding this definition}} |
| 132 |
// expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:5 {{other definition}} |
| 133 |
|
| 134 |
x = BAZ2_SYSTEM(x); |
| 135 |
return x; |
| 136 |
} |