diff options
-rw-r--r-- | lib/Analysis/ReachableCode.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/warn-using-namespace-in-header.cpp | 27 | ||||
-rw-r--r-- | test/SemaCXX/warn-using-namespace-in-header.h | 8 |
4 files changed, 37 insertions, 2 deletions
diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index 9659e9ec3e..9ac456f53a 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -193,7 +193,7 @@ unsigned ScanReachableFromBlock(const CFGBlock &Start, unsigned count = 0; llvm::SmallVector<const CFGBlock*, 32> WL; - // Prep work queue + // Prep work queue Reachable.set(Start.getBlockID()); ++count; WL.push_back(&Start); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 7ae104a542..67396be3b0 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3927,7 +3927,7 @@ Decl *Sema::ActOnUsingDirective(Scope *S, IdentLoc, Named, CommonAncestor); if (IsUsingDirectiveInToplevelContext(CurContext) && - !SourceMgr.isFromMainFile(IdentLoc)) { + !SourceMgr.isFromMainFile(SourceMgr.getInstantiationLoc(IdentLoc))) { Diag(IdentLoc, diag::warn_using_directive_in_header); } diff --git a/test/SemaCXX/warn-using-namespace-in-header.cpp b/test/SemaCXX/warn-using-namespace-in-header.cpp index e040ca74cb..72c25529b4 100644 --- a/test/SemaCXX/warn-using-namespace-in-header.cpp +++ b/test/SemaCXX/warn-using-namespace-in-header.cpp @@ -25,3 +25,30 @@ using namespace dont_warn; // expected-warning {{using namespace directive in global context in header}} + + + + + + + + + + + + + + + + + + + + + + +// expected-warning {{using namespace directive in global context in header}} + +// |using namespace| through a macro shouldn't warn if the instantiation is in a +// cc file. +USING_MACRO diff --git a/test/SemaCXX/warn-using-namespace-in-header.h b/test/SemaCXX/warn-using-namespace-in-header.h index 57bb5d91be..b544c548ae 100644 --- a/test/SemaCXX/warn-using-namespace-in-header.h +++ b/test/SemaCXX/warn-using-namespace-in-header.h @@ -40,3 +40,11 @@ using namespace warn_in_header_in_global_context; inline void foo() { using namespace warn_in_header_in_global_context; } + + +namespace macronamespace {} +#define USING_MACRO using namespace macronamespace; + +// |using namespace| through a macro should warn if the instantiation is in a +// header. +USING_MACRO |