Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fimplicit-module-maps -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 |
| 3 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fimplicit-module-maps -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DIMPORT_DECLS |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 4 | |
Richard Smith | 851072e | 2014-05-19 20:59:20 +0000 | [diff] [blame] | 5 | // expected-no-diagnostics |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 6 | |
| 7 | #ifdef IMPORT_DECLS |
Richard Smith | 851072e | 2014-05-19 20:59:20 +0000 | [diff] [blame] | 8 | @import redecl_add_after_load_decls; |
| 9 | #else |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 10 | typedef struct A B; |
| 11 | extern const int variable; |
| 12 | extern constexpr int function(); |
| 13 | constexpr int test(bool b) { return b ? variable : function(); } |
| 14 | |
| 15 | namespace N { |
| 16 | typedef struct A B; |
| 17 | extern const int variable; |
| 18 | extern constexpr int function(); |
| 19 | } |
| 20 | typedef N::B NB; |
| 21 | constexpr int N_test(bool b) { return b ? N::variable : N::function(); } |
| 22 | |
| 23 | @import redecl_add_after_load_top; |
| 24 | typedef C::A CB; |
| 25 | constexpr int C_test(bool b) { return b ? C::variable : C::function(); } |
| 26 | |
| 27 | struct D { |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 28 | struct A; |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 29 | static const int variable; |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 30 | static constexpr int function(); |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 31 | }; |
| 32 | typedef D::A DB; |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 33 | constexpr int D_test(bool b) { return b ? D::variable : D::function(); } |
Richard Smith | 851072e | 2014-05-19 20:59:20 +0000 | [diff] [blame] | 34 | #endif |
Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame] | 35 | |
| 36 | @import redecl_add_after_load; |
| 37 | |
| 38 | B tu_struct_test; |
| 39 | constexpr int tu_variable_test = test(true); |
| 40 | constexpr int tu_function_test = test(false); |
| 41 | |
| 42 | NB ns_struct_test; |
| 43 | constexpr int ns_variable_test = N_test(true); |
| 44 | constexpr int ns_function_test = N_test(false); |
| 45 | |
| 46 | CB struct_struct_test; |
| 47 | constexpr int struct_variable_test = C_test(true); |
| 48 | constexpr int struct_function_test = C_test(false); |
| 49 | |
Richard Smith | 851072e | 2014-05-19 20:59:20 +0000 | [diff] [blame] | 50 | DB merged_struct_struct_test; |
| 51 | constexpr int merged_struct_variable_test = D_test(true); |
| 52 | constexpr int merged_struct_function_test = D_test(false); |