Home | History | Annotate | Download | only in Modules
      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
      9 typedef struct A B;
     10 extern const int variable;
     11 extern constexpr int function();
     12 constexpr int test(bool b) { return b ? variable : function(); }
     13 
     14 namespace N {
     15   typedef struct A B;
     16   extern const int variable;
     17   extern constexpr int function();
     18 }
     19 typedef N::B NB;
     20 constexpr int N_test(bool b) { return b ? N::variable : N::function(); }
     21 
     22 @import redecl_add_after_load_top;
     23 typedef C::A CB;
     24 constexpr int C_test(bool b) { return b ? C::variable : C::function(); }
     25 
     26 struct D {
     27   struct A; // expected-note {{forward}}
     28   static const int variable;
     29   static constexpr int function(); // expected-note {{here}}
     30 };
     31 typedef D::A DB;
     32 constexpr 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 
     37 B tu_struct_test;
     38 constexpr int tu_variable_test = test(true);
     39 constexpr int tu_function_test = test(false);
     40 
     41 NB ns_struct_test;
     42 constexpr int ns_variable_test = N_test(true);
     43 constexpr int ns_function_test = N_test(false);
     44 
     45 CB struct_struct_test;
     46 constexpr int struct_variable_test = C_test(true);
     47 constexpr 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.
     52 DB merged_struct_struct_test;
     53 constexpr int merged_struct_variable_test = D_test(true);
     54 constexpr 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