1 // RUN: %clang_cc1 -fsyntax-only -Wheader-hygiene -verify %s
4 namespace warn_in_header_in_global_context
{}
5 using namespace warn_in_header_in_global_context
; // expected-warning {{using namespace directive in global context in header}}
7 // While we want to error on the previous using directive, we don't when we are
9 namespace dont_warn_here
{
10 using namespace warn_in_header_in_global_context
;
13 // We should warn in toplevel extern contexts.
14 namespace warn_inside_linkage
{}
16 using namespace warn_inside_linkage
; // expected-warning {{using namespace directive in global context in header}}
19 // This is really silly, but we should warn on it:
23 using namespace warn_inside_linkage
; // expected-warning {{using namespace directive in global context in header}}
28 // But we shouldn't warn in extern contexts inside namespaces.
29 namespace dont_warn_here
{
31 using namespace warn_in_header_in_global_context
;
35 // We also shouldn't warn in case of functions.
37 using namespace warn_in_header_in_global_context
;
41 namespace macronamespace
{}
42 #define USING_MACRO using namespace macronamespace;
44 // |using namespace| through a macro should warn if the instantiation is in a
46 USING_MACRO
// expected-warning {{using namespace directive in global context in header}}
53 namespace dont_warn
{}
54 using namespace dont_warn
;
56 // |using namespace| through a macro shouldn't warn if the instantiation is in a
60 // Check behavior of line markers.
61 namespace warn_header_with_line_marker
{}
63 using namespace warn_header_with_line_marker
; // expected-warning {{using namespace directive in global context in header}}
64 # 70 "warn-using-namespace-in-header.cpp" 2
66 namespace nowarn_after_line_marker
{}
67 using namespace nowarn_after_line_marker
;