2 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -DLOCAL_VISIBILITY
5 // This test checks some of the same things as macros.c, but imports modules in
10 int n0
= TOP_OTHER_DEF_RIGHT_UNDEF
; // ok
14 TOP_OTHER_DEF_RIGHT_UNDEF
*n0b
; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
15 // expected-note@macros_top.h:22 {{expanding this definition of 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
16 // expected-note@macros_other.h:6 {{other definition of 'TOP_OTHER_DEF_RIGHT_UNDEF'}}
22 # error TOP_LEFT_UNDEF should not be defined
25 #ifndef TOP_RIGHT_UNDEF
26 # error TOP_RIGHT_UNDEF should still be defined
31 TOP_RIGHT_REDEF
*fp
= &f
; // ok, right's definition overrides top's definition
33 // Note, left's definition wins here, whereas right's definition wins in
36 LEFT_RIGHT_IDENTICAL
*ip
= &i
;
37 LEFT_RIGHT_DIFFERENT
*ip2
= &f
; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}}
38 // expected-note@macros_left.h:14 {{expanding this}}
39 // expected-note@macros_right.h:12 {{other}}
40 LEFT_RIGHT_DIFFERENT2
*ip3
= &f
; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT2}}
41 // expected-note@macros_left.h:11 {{expanding this}}
42 // expected-note@macros_right.h:13 {{other}}
43 #undef LEFT_RIGHT_DIFFERENT3
44 int LEFT_RIGHT_DIFFERENT3
;
47 @import macros_right
.undef
;
50 #ifdef LOCAL_VISIBILITY
51 # ifndef TOP_RIGHT_UNDEF
52 # error TOP_RIGHT_UNDEF should still be defined
55 # ifdef TOP_RIGHT_UNDEF
56 # error TOP_RIGHT_UNDEF should not be defined
60 #ifndef TOP_OTHER_UNDEF1
61 # error TOP_OTHER_UNDEF1 should still be defined
64 #ifndef TOP_OTHER_UNDEF2
65 # error TOP_OTHER_UNDEF2 should still be defined
68 #ifndef TOP_OTHER_REDEF1
69 # error TOP_OTHER_REDEF1 should still be defined
71 int n1
= TOP_OTHER_REDEF1
; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_REDEF1'}}
72 // expected-note@macros_top.h:19 {{expanding this definition}}
73 // expected-note@macros_other.h:4 {{other definition}}
75 #ifndef TOP_OTHER_REDEF2
76 # error TOP_OTHER_REDEF2 should still be defined
78 int n2
= TOP_OTHER_REDEF2
; // ok
80 int n3
= TOP_OTHER_DEF_RIGHT_UNDEF
; // ok
82 int top_redef_in_submodules
= TOP_REDEF_IN_SUBMODULES
;
85 int TOP_REDEF_IN_SUBMODULES
= top_redef_in_submodules
;