1*0a6a1f1dSLionel Sambuc // RUN: rm -rf %t 2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DIMPORT_DECLS 4*0a6a1f1dSLionel Sambuc 5*0a6a1f1dSLionel Sambuc #ifdef IMPORT_DECLS 6*0a6a1f1dSLionel Sambuc // expected-no-diagnostics 7*0a6a1f1dSLionel Sambuc @import redecl_add_after_load_decls; 8*0a6a1f1dSLionel Sambuc #else 9*0a6a1f1dSLionel Sambuc typedef struct A B; 10*0a6a1f1dSLionel Sambuc extern const int variable; 11*0a6a1f1dSLionel Sambuc extern constexpr int function(); test(bool b)12*0a6a1f1dSLionel Sambucconstexpr int test(bool b) { return b ? variable : function(); } 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuc namespace N { 15*0a6a1f1dSLionel Sambuc typedef struct A B; 16*0a6a1f1dSLionel Sambuc extern const int variable; 17*0a6a1f1dSLionel Sambuc extern constexpr int function(); 18*0a6a1f1dSLionel Sambuc } 19*0a6a1f1dSLionel Sambuc typedef N::B NB; N_test(bool b)20*0a6a1f1dSLionel Sambucconstexpr int N_test(bool b) { return b ? N::variable : N::function(); } 21*0a6a1f1dSLionel Sambuc 22*0a6a1f1dSLionel Sambuc @import redecl_add_after_load_top; 23*0a6a1f1dSLionel Sambuc typedef C::A CB; C_test(bool b)24*0a6a1f1dSLionel Sambucconstexpr int C_test(bool b) { return b ? C::variable : C::function(); } 25*0a6a1f1dSLionel Sambuc 26*0a6a1f1dSLionel Sambuc struct D { 27*0a6a1f1dSLionel Sambuc struct A; // expected-note {{forward}} 28*0a6a1f1dSLionel Sambuc static const int variable; 29*0a6a1f1dSLionel Sambuc static constexpr int function(); // expected-note {{here}} 30*0a6a1f1dSLionel Sambuc }; 31*0a6a1f1dSLionel Sambuc typedef D::A DB; D_test(bool b)32*0a6a1f1dSLionel Sambucconstexpr int D_test(bool b) { return b ? D::variable : D::function(); } // expected-note {{subexpression}} expected-note {{undefined}} 33*0a6a1f1dSLionel Sambuc #endif 34*0a6a1f1dSLionel Sambuc 35*0a6a1f1dSLionel Sambuc @import redecl_add_after_load; 36*0a6a1f1dSLionel Sambuc 37*0a6a1f1dSLionel Sambuc B tu_struct_test; 38*0a6a1f1dSLionel Sambuc constexpr int tu_variable_test = test(true); 39*0a6a1f1dSLionel Sambuc constexpr int tu_function_test = test(false); 40*0a6a1f1dSLionel Sambuc 41*0a6a1f1dSLionel Sambuc NB ns_struct_test; 42*0a6a1f1dSLionel Sambuc constexpr int ns_variable_test = N_test(true); 43*0a6a1f1dSLionel Sambuc constexpr int ns_function_test = N_test(false); 44*0a6a1f1dSLionel Sambuc 45*0a6a1f1dSLionel Sambuc CB struct_struct_test; 46*0a6a1f1dSLionel Sambuc constexpr int struct_variable_test = C_test(true); 47*0a6a1f1dSLionel Sambuc constexpr int struct_function_test = C_test(false); 48*0a6a1f1dSLionel Sambuc 49*0a6a1f1dSLionel Sambuc // FIXME: We should accept this, but we're currently too lazy when merging class 50*0a6a1f1dSLionel Sambuc // definitions to determine that the definitions in redecl_add_after_load are 51*0a6a1f1dSLionel Sambuc // definitions of these entities. 52*0a6a1f1dSLionel Sambuc DB merged_struct_struct_test; 53*0a6a1f1dSLionel Sambuc constexpr int merged_struct_variable_test = D_test(true); 54*0a6a1f1dSLionel Sambuc constexpr int merged_struct_function_test = D_test(false); 55*0a6a1f1dSLionel Sambuc #ifndef IMPORT_DECLS 56*0a6a1f1dSLionel Sambuc // expected-error@-4 {{incomplete}} 57*0a6a1f1dSLionel Sambuc // expected-error@-4 {{constant}} expected-note@-4 {{in call to}} 58*0a6a1f1dSLionel Sambuc // expected-error@-4 {{constant}} expected-note@-4 {{in call to}} 59*0a6a1f1dSLionel Sambuc #endif 60