87 lines · c
1// RUN: rm -rf %t2// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s3// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -DLOCAL_VISIBILITY4 5// This test checks some of the same things as macros.c, but imports modules in6// a different order.7 8@import macros_other;9 10int n0 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok11 12@import macros_top;13 14TOP_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'}}17 18@import macros_right;19@import macros_left;20 21#ifdef TOP_LEFT_UNDEF22# error TOP_LEFT_UNDEF should not be defined23#endif24 25#ifndef TOP_RIGHT_UNDEF26# error TOP_RIGHT_UNDEF should still be defined27#endif28 29void test(void) {30 float f;31 TOP_RIGHT_REDEF *fp = &f; // ok, right's definition overrides top's definition32 33 // Note, left's definition wins here, whereas right's definition wins in34 // macros.c.35 int i;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_DIFFERENT344 int LEFT_RIGHT_DIFFERENT3;45}46 47@import macros_right.undef;48 49// See macros.c.50#ifdef LOCAL_VISIBILITY51# ifndef TOP_RIGHT_UNDEF52# error TOP_RIGHT_UNDEF should still be defined53# endif54#else55# ifdef TOP_RIGHT_UNDEF56# error TOP_RIGHT_UNDEF should not be defined57# endif58#endif59 60#ifndef TOP_OTHER_UNDEF161# error TOP_OTHER_UNDEF1 should still be defined62#endif63 64#ifndef TOP_OTHER_UNDEF265# error TOP_OTHER_UNDEF2 should still be defined66#endif67 68#ifndef TOP_OTHER_REDEF169# error TOP_OTHER_REDEF1 should still be defined70#endif71int 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}}74 75#ifndef TOP_OTHER_REDEF276# error TOP_OTHER_REDEF2 should still be defined77#endif78int n2 = TOP_OTHER_REDEF2; // ok79 80int n3 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok81 82int top_redef_in_submodules = TOP_REDEF_IN_SUBMODULES;83@import macros_top.c;84void test2(void) {85 int TOP_REDEF_IN_SUBMODULES = top_redef_in_submodules;86}87