Richard Smith | 053f6c6 | 2014-05-16 23:01:30 +0000 | [diff] [blame^] | 1 | // RUN: rm -rf %t |
| 2 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 |
| 3 | |
| 4 | typedef struct A B; |
| 5 | extern const int variable; |
| 6 | extern constexpr int function(); |
| 7 | constexpr int test(bool b) { return b ? variable : function(); } |
| 8 | |
| 9 | namespace N { |
| 10 | typedef struct A B; |
| 11 | extern const int variable; |
| 12 | extern constexpr int function(); |
| 13 | } |
| 14 | typedef N::B NB; |
| 15 | constexpr int N_test(bool b) { return b ? N::variable : N::function(); } |
| 16 | |
| 17 | @import redecl_add_after_load_top; |
| 18 | typedef C::A CB; |
| 19 | constexpr int C_test(bool b) { return b ? C::variable : C::function(); } |
| 20 | |
| 21 | struct D { |
| 22 | struct A; // expected-note {{forward}} |
| 23 | static const int variable; |
| 24 | static constexpr int function(); // expected-note {{here}} |
| 25 | }; |
| 26 | typedef D::A DB; |
| 27 | constexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}} |
| 28 | |
| 29 | @import redecl_add_after_load; |
| 30 | |
| 31 | B tu_struct_test; |
| 32 | constexpr int tu_variable_test = test(true); |
| 33 | constexpr int tu_function_test = test(false); |
| 34 | |
| 35 | NB ns_struct_test; |
| 36 | constexpr int ns_variable_test = N_test(true); |
| 37 | constexpr int ns_function_test = N_test(false); |
| 38 | |
| 39 | CB struct_struct_test; |
| 40 | constexpr int struct_variable_test = C_test(true); |
| 41 | constexpr int struct_function_test = C_test(false); |
| 42 | |
| 43 | // FIXME: We should accept this, but we're currently too lazy when merging class |
| 44 | // definitions to determine that the definitions in redecl_add_after_load are |
| 45 | // definitions of these entities. |
| 46 | DB merged_struct_struct_test; // expected-error {{incomplete}} |
| 47 | constexpr int merged_struct_variable_test = D_test(true); // expected-error {{constant}} expected-note {{in call to}} |
| 48 | constexpr int merged_struct_function_test = D_test(false); // expected-error {{constant}} expected-note {{in call to}} |