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