blob: b544c548ae9bb11d205b753695ac4ba9828f1313 [file] [log] [blame]
Douglas Gregord6a49bb2011-03-18 16:10:52 +00001
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.
8namespace warn_in_header_in_global_context {}
9using 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
13namespace dont_warn_here {
14using namespace warn_in_header_in_global_context;
15}
Douglas Gregor9172aa62011-03-26 22:25:30 +000016
17// We should warn in toplevel extern contexts.
18namespace warn_inside_linkage {}
19extern "C++" {
20using namespace warn_inside_linkage;
21}
22
23// This is really silly, but we should warn on it:
24extern "C++" {
25extern "C" {
26extern "C++" {
27using namespace warn_inside_linkage;
28}
29}
30}
31
32// But we shouldn't warn in extern contexts inside namespaces.
33namespace dont_warn_here {
34extern "C++" {
35using namespace warn_in_header_in_global_context;
36}
37}
38
39// We also shouldn't warn in case of functions.
40inline void foo() {
41 using namespace warn_in_header_in_global_context;
42}
Nico Weber21669482011-04-02 19:45:15 +000043
44
45namespace 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.
50USING_MACRO