summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-09-26 21:27:23 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-09-26 21:27:23 +0000
commit3b66056a3f50a1d965b14fd36099f3da0dbd6463 (patch)
tree5d118af57592ff581f2f7e8e12bf7c7f673621c7 /clang/lib
parent92d300eb8f1ec51ae3e5b0b4230e781a06d1e4bf (diff)
downloadbcm5719-llvm-3b66056a3f50a1d965b14fd36099f3da0dbd6463.tar.gz
bcm5719-llvm-3b66056a3f50a1d965b14fd36099f3da0dbd6463.zip
[Modules TS] Diagnose 'export' declaration within 'export' declaration.
llvm-svn: 282443
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclBase.cpp16
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index cea511b5118..77e74b044fd 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -377,6 +377,22 @@ bool Decl::isReferenced() const {
return false;
}
+bool Decl::isExported() const {
+ if (isModulePrivate())
+ return false;
+ // Namespaces are always exported.
+ if (isa<TranslationUnitDecl>(this) || isa<NamespaceDecl>(this))
+ return true;
+ // Otherwise, this is a strictly lexical check.
+ for (auto *DC = getLexicalDeclContext(); DC; DC = DC->getLexicalParent()) {
+ if (cast<Decl>(DC)->isModulePrivate())
+ return false;
+ if (isa<ExportDecl>(DC))
+ return true;
+ }
+ return false;
+}
+
bool Decl::hasDefiningAttr() const {
return hasAttr<AliasAttr>() || hasAttr<IFuncAttr>();
}
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3eb00625a45..cfb1f99b07c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15465,14 +15465,17 @@ void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
/// (if present).
Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
SourceLocation LBraceLoc) {
- // FIXME: C++ Modules TS:
+ ExportDecl *D = ExportDecl::Create(Context, CurContext, ExportLoc);
+
+ // C++ Modules TS draft:
// An export-declaration [...] shall not contain more than one
// export keyword.
//
// The intent here is that an export-declaration cannot appear within another
// export-declaration.
+ if (D->isExported())
+ Diag(ExportLoc, diag::err_export_within_export);
- ExportDecl *D = ExportDecl::Create(Context, CurContext, ExportLoc);
CurContext->addDecl(D);
PushDeclContext(S, D);
return D;
OpenPOWER on IntegriCloud