Home | History | Annotate | Download | only in SemaCXX
      1 
      2 
      3 
      4 
      5 
      6 // Lots of vertical space to make the error line match up with the line of the
      7 // expected line in the source file.
      8 namespace warn_in_header_in_global_context {}
      9 using namespace warn_in_header_in_global_context;
     10 
     11 // While we want to error on the previous using directive, we don't when we are
     12 // inside a namespace
     13 namespace dont_warn_here {
     14 using namespace warn_in_header_in_global_context;
     15 }
     16 
     17 // We should warn in toplevel extern contexts.
     18 namespace warn_inside_linkage {}
     19 extern "C++" {
     20 using namespace warn_inside_linkage;
     21 }
     22 
     23 // This is really silly, but we should warn on it:
     24 extern "C++" {
     25 extern "C" {
     26 extern "C++" {
     27 using namespace warn_inside_linkage;
     28 }
     29 }
     30 }
     31 
     32 // But we shouldn't warn in extern contexts inside namespaces.
     33 namespace dont_warn_here {
     34 extern "C++" {
     35 using namespace warn_in_header_in_global_context;
     36 }
     37 }
     38 
     39 // We also shouldn't warn in case of functions.
     40 inline void foo() {
     41   using namespace warn_in_header_in_global_context;
     42 }
     43 
     44 
     45 namespace macronamespace {}
     46 #define USING_MACRO using namespace macronamespace;
     47 
     48 // |using namespace| through a macro should warn if the instantiation is in a
     49 // header.
     50 USING_MACRO
     51