1*0a6a1f1dSLionel Sambuc // RUN: rm -rf %t 2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s 3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C 4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_CXX 5*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C -DEXTERN_CXX 6*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DEXTERN_C -DNAMESPACE 7*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER 8*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C 9*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_CXX 10*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DEXTERN_CXX 11*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DNAMESPACE 12*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs -x c %s 13*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs/elsewhere -I %S/Inputs %s -DEXTERN_C -DINDIRECT 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc #ifdef INDIRECT 16*0a6a1f1dSLionel Sambuc #include "c-header-indirect.h" 17*0a6a1f1dSLionel Sambuc #endif 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambuc #ifdef NAMESPACE 20*0a6a1f1dSLionel Sambuc namespace M { 21*0a6a1f1dSLionel Sambuc #endif 22*0a6a1f1dSLionel Sambuc 23*0a6a1f1dSLionel Sambuc #ifdef EXTERN_C 24*0a6a1f1dSLionel Sambuc extern "C" { 25*0a6a1f1dSLionel Sambuc #endif 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc #ifdef EXTERN_CXX 28*0a6a1f1dSLionel Sambuc extern "C++" { 29*0a6a1f1dSLionel Sambuc #endif 30*0a6a1f1dSLionel Sambuc 31*0a6a1f1dSLionel Sambuc #ifdef CXX_HEADER 32*0a6a1f1dSLionel Sambuc #define HEADER "cxx-header.h" 33*0a6a1f1dSLionel Sambuc #else 34*0a6a1f1dSLionel Sambuc #define HEADER "c-header.h" 35*0a6a1f1dSLionel Sambuc #endif 36*0a6a1f1dSLionel Sambuc 37*0a6a1f1dSLionel Sambuc #include HEADER 38*0a6a1f1dSLionel Sambuc 39*0a6a1f1dSLionel Sambuc #if defined(EXTERN_C) && !defined(EXTERN_CXX) && defined(CXX_HEADER) 40*0a6a1f1dSLionel Sambuc // expected-error@-3 {{import of C++ module 'cxx_library' appears within extern "C" language linkage specification}} 41*0a6a1f1dSLionel Sambuc // expected-note@-17 {{extern "C" language linkage specification begins here}} 42*0a6a1f1dSLionel Sambuc #elif defined(NAMESPACE) 43*0a6a1f1dSLionel Sambuc // expected-error-re@-6 {{import of module '{{c_library.inner|cxx_library}}' appears within namespace 'M'}} 44*0a6a1f1dSLionel Sambuc // expected-note@-24 {{namespace 'M' begins here}} 45*0a6a1f1dSLionel Sambuc #endif 46*0a6a1f1dSLionel Sambuc 47*0a6a1f1dSLionel Sambuc #ifdef EXTERN_CXX 48*0a6a1f1dSLionel Sambuc } 49*0a6a1f1dSLionel Sambuc #endif 50*0a6a1f1dSLionel Sambuc 51*0a6a1f1dSLionel Sambuc #ifdef EXTERN_C 52*0a6a1f1dSLionel Sambuc } 53*0a6a1f1dSLionel Sambuc #endif 54*0a6a1f1dSLionel Sambuc 55*0a6a1f1dSLionel Sambuc #ifdef NAMESPACE 56*0a6a1f1dSLionel Sambuc } 57*0a6a1f1dSLionel Sambuc using namespace M; 58*0a6a1f1dSLionel Sambuc #endif 59*0a6a1f1dSLionel Sambuc 60*0a6a1f1dSLionel Sambuc #ifdef __cplusplus 61*0a6a1f1dSLionel Sambuc namespace N { 62*0a6a1f1dSLionel Sambuc #endif g()63*0a6a1f1dSLionel Sambuc void g() { 64*0a6a1f1dSLionel Sambuc int k = f(); 65*0a6a1f1dSLionel Sambuc } 66*0a6a1f1dSLionel Sambuc 67*0a6a1f1dSLionel Sambuc #ifdef __cplusplus 68*0a6a1f1dSLionel Sambuc extern "C" { 69*0a6a1f1dSLionel Sambuc #endif 70*0a6a1f1dSLionel Sambuc int f; 71*0a6a1f1dSLionel Sambuc #if !defined(CXX_HEADER) 72*0a6a1f1dSLionel Sambuc // expected-error@-2 {{redefinition of 'f' as different kind of symbol}} 73*0a6a1f1dSLionel Sambuc // expected-note@c-header.h:1 {{previous}} 74*0a6a1f1dSLionel Sambuc #endif 75*0a6a1f1dSLionel Sambuc 76*0a6a1f1dSLionel Sambuc #ifdef __cplusplus 77*0a6a1f1dSLionel Sambuc } 78*0a6a1f1dSLionel Sambuc } 79*0a6a1f1dSLionel Sambuc #endif 80*0a6a1f1dSLionel Sambuc 81*0a6a1f1dSLionel Sambuc suppress_expected_no_diagnostics_error error_here; // expected-error {{}} 82