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