1 // Clear and create directories
5 // RUN: mkdir %t/Inputs
7 // Build first header file
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
9 // RUN: cat %s >> %t/Inputs/first.h
11 // Build second header file
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
13 // RUN: cat %s >> %t/Inputs/second.h
15 // Test that each header can compile
16 // RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/first.h
17 // RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/second.h
19 // Build module map file
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.modulemap
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.modulemap
22 // RUN: echo "}" >> %t/Inputs/module.modulemap
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.modulemap
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.modulemap
25 // RUN: echo "}" >> %t/Inputs/module.modulemap
28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c -I%t/Inputs -verify %s
30 #if !defined(FIRST) && !defined(SECOND)
36 enum DifferentEnumConstants
{ kDifferentEnumConstantsValueFirst
};
38 enum DifferentEnumConstants
{ kDifferentEnumConstantsValueSecond
};
40 enum DifferentEnumConstants differentEnumConstants
;
41 // expected-error@second.h:* {{'kDifferentEnumConstantsValueSecond' from module 'SecondModule' is not present in definition of 'enum DifferentEnumConstants' in module 'FirstModule'}}
42 // expected-note@first.h:* {{definition has no member 'kDifferentEnumConstantsValueSecond'}}
46 enum DifferentEnumValues
{ kDifferentEnumValue
= 0 };
48 enum DifferentEnumValues
{ kDifferentEnumValue
= 1 };
50 enum DifferentEnumValues differentEnumValue
;
51 // expected-error@first.h:* {{'DifferentEnumValues' has different definitions in different modules; definition in module 'FirstModule' first difference is 1st element 'kDifferentEnumValue' has an initializer}}
52 // expected-note@second.h:* {{but in 'SecondModule' found 1st element 'kDifferentEnumValue' has different initializer}}
57 kAnonymousEnumValueFirst
= 1,
61 kAnonymousEnumValueSecond
= 2,
64 // Anonymous enums don't have to match, no errors expected.
65 int anonymousEnumValue
= kAnonymousEnumValueFirst
+ kAnonymousEnumValueSecond
;
68 // Keep macros contained to one file.