summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index b193c602184..07d60caf435 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3817,6 +3817,19 @@ NamespaceDecl *Sema::getOrCreateStdNamespace() {
return getStdNamespace();
}
+/// \brief Determine whether a using statement is in a context where it will be
+/// apply in all contexts.
+static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext) {
+ switch (CurContext->getDeclKind()) {
+ case Decl::TranslationUnit:
+ return true;
+ case Decl::LinkageSpec:
+ return IsUsingDirectiveInToplevelContext(CurContext->getParent());
+ default:
+ return false;
+ }
+}
+
Decl *Sema::ActOnUsingDirective(Scope *S,
SourceLocation UsingLoc,
SourceLocation NamespcLoc,
@@ -3902,7 +3915,7 @@ Decl *Sema::ActOnUsingDirective(Scope *S,
SS.getWithLocInContext(Context),
IdentLoc, Named, CommonAncestor);
- if (CurContext->getDeclKind() == Decl::TranslationUnit &&
+ if (IsUsingDirectiveInToplevelContext(CurContext) &&
!SourceMgr.isFromMainFile(IdentLoc)) {
Diag(IdentLoc, diag::warn_using_directive_in_header);
}
OpenPOWER on IntegriCloud