brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.8 KiB · 1e067ca Raw
198 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 -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -DALT4// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record5// RUN: not %clang_cc1 -E -fmodules -fimplicit-module-maps -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s6// 7// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s8// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -DALT9// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record10// RUN: not %clang_cc1 -E -fmodules -fimplicit-module-maps -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s11//12// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -DLOCAL_VISIBILITY -fmodules-local-submodule-visibility -x objective-c++ -verify -fmodules-cache-path=%t -I %S/Inputs %s13// FIXME: When we have a syntax for modules in C, use that.14// These notes come from headers in modules, and are bogus.15 16// FIXME: expected-note@Inputs/macros_left.h:11{{previous definition is here}}17// FIXME: expected-note@Inputs/macros_right.h:12{{previous definition is here}}18// expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}}19// expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}}20// expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}}21 22@import macros;23 24#ifndef INTEGER25#  error INTEGER macro should be visible26#endif27 28#ifdef FLOAT29#  error FLOAT macro should not be visible30#endif31 32#ifdef MODULE33#  error MODULE macro should not be visible34#endif35 36#ifndef INDIRECTLY_IN_MACROS37#  error INDIRECTLY_IN_MACROS should be visible38#endif39 40// CHECK-PREPROCESSED: double d41double d;42DOUBLE *dp = &d;43 44#__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}}45 46void f(void) {47  // CHECK-PREPROCESSED: int i = INTEGER;48  int i = INTEGER; // the value was exported, the macro was not.49  i += macros; // expanded from __MODULE__ within the 'macros' module.50}51 52#ifdef __MODULE__53# error Not building a module!54#endif55 56#if __building_module(macros)57# error Not building a module58#endif59 60// None of the modules we depend on have been imported, and therefore61// their macros should not be visible.62#ifdef LEFT63#  error LEFT should not be visible64#endif65 66#ifdef RIGHT67#  error RIGHT should not be visible68#endif69 70#ifdef TOP71#  error TOP should not be visible72#endif73 74#undef INTEGER75#define INTEGER int76 77// Import left module (which also imports top)78@import macros_left;79 80INTEGER my_integer = 0;81 82#ifndef LEFT83#  error LEFT should be visible84#endif85 86#ifdef RIGHT87#  error RIGHT should not be visible88#endif89 90#ifndef TOP91#  error TOP should be visible92#endif93 94#ifdef TOP_LEFT_UNDEF95#  error TOP_LEFT_UNDEF should not be defined96#endif97 98void test1(void) {99  int i;100  TOP_RIGHT_REDEF *ip = &i;101}102 103#define LEFT_RIGHT_DIFFERENT2 double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT2' macro redefined}} \104                                     // expected-note{{other definition of 'LEFT_RIGHT_DIFFERENT2'}}105 106// Import right module (which also imports top)107@import macros_right;108 109#undef LEFT_RIGHT_DIFFERENT3110 111#ifndef LEFT112#  error LEFT should be visible113#endif114 115#ifndef RIGHT116#  error RIGHT should be visible117#endif118 119#ifndef TOP120#  error TOP should be visible121#endif122 123void test2(void) {124  int i;125  float f;126  double d;127  TOP_RIGHT_REDEF *fp = &f; // ok, right's definition overrides top's definition128  129  LEFT_RIGHT_IDENTICAL *ip = &i;130  LEFT_RIGHT_DIFFERENT *ip2 = &i; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}}131  LEFT_RIGHT_DIFFERENT2 *ip3 = &i; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT2}}132  int LEFT_RIGHT_DIFFERENT3;133}134 135#define LEFT_RIGHT_DIFFERENT double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT' macro redefined}}136 137void test3(void) {138  double d;139  LEFT_RIGHT_DIFFERENT *dp = &d; // okay140  int x = FN_ADD(1,2);141}142 143#ifndef TOP_RIGHT_UNDEF144#  error TOP_RIGHT_UNDEF should still be defined145#endif146 147@import macros_bottom;148 149TOP_DEF_RIGHT_UNDEF *TDRUf(void) { return TDRUp; }150 151@import macros_right.undef;152 153int TOP_DEF_RIGHT_UNDEF; // ok, no longer defined154 155#ifdef LOCAL_VISIBILITY156// TOP_RIGHT_UNDEF should not be undefined, because macros_right.undef does157// not undefine macros_right's macro.158# ifndef TOP_RIGHT_UNDEF159#  error TOP_RIGHT_UNDEF should still be defined160# endif161#else162// When macros_right.undef is built and local submodule visibility is not163// enabled, macros_top is visible because the state from building164// macros_right leaks through, so macros_right.undef undefines macros_top's165// macro.166# ifdef TOP_RIGHT_UNDEF167#  error TOP_RIGHT_UNDEF should not be defined168# endif169#endif170 171#ifdef ALT172int tmp = TOP_OTHER_REDEF1;173#endif174 175@import macros_other;176 177#ifndef TOP_OTHER_UNDEF1178# error TOP_OTHER_UNDEF1 should still be defined179#endif180 181#ifndef TOP_OTHER_UNDEF2182# error TOP_OTHER_UNDEF2 should still be defined183#endif184#pragma clang __debug macro TOP_OTHER_REDEF1185#ifndef TOP_OTHER_REDEF1186# error TOP_OTHER_REDEF1 should still be defined187#endif188int n1 = TOP_OTHER_REDEF1; // expected-warning{{ambiguous expansion of macro 'TOP_OTHER_REDEF1'}}189// expected-note@macros_other.h:4 {{expanding this definition}}190// expected-note@macros_top.h:19 {{other definition}}191 192#ifndef TOP_OTHER_REDEF2193# error TOP_OTHER_REDEF2 should still be defined194#endif195int n2 = TOP_OTHER_REDEF2; // ok196 197int n3 = TOP_OTHER_DEF_RIGHT_UNDEF; // ok198