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