diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-04-22 22:50:11 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-04-22 22:50:11 +0000 |
commit | 30cd644f80ad3c0b8c3bbbf38f20f31f602b2505 (patch) | |
tree | d38bd027f1e0cb970fef1f27b4bbbed42701cdf8 /include | |
parent | 9779aa41dd73984edb7f3641bd019c54ede3c977 (diff) |
[c++2a] Implement semantic restrictions for 'export' declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Decl.h | 4 | ||||
-rw-r--r-- | include/clang/AST/DeclBase.h | 4 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 1 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 19 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 3 |
5 files changed, 26 insertions, 5 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 2c914fee72..dc7d5657e9 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -4239,8 +4239,10 @@ public: SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } + bool hasBraces() const { return RBraceLoc.isValid(); } + SourceLocation getEndLoc() const LLVM_READONLY { - if (RBraceLoc.isValid()) + if (hasBraces()) return RBraceLoc; // No braces: get the end location of the (only) declaration in context // (if present). diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 9fa9f00800..64adf304c6 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -600,10 +600,6 @@ public: return getModuleOwnershipKind() == ModuleOwnershipKind::ModulePrivate; } - /// Whether this declaration is exported (by virtue of being lexically - /// within an ExportDecl or by being a NamespaceDecl). - bool isExported() const; - /// Return true if this declaration has an attribute which acts as /// definition of the entity, such as 'alias' or 'ifunc'. bool hasDefiningAttr() const; diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index d11bf58acd..d46f82f2a5 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -168,6 +168,7 @@ def ExtraTokens : DiagGroup<"extra-tokens">; def CXX98CompatExtraSemi : DiagGroup<"c++98-compat-extra-semi">; def CXX11ExtraSemi : DiagGroup<"c++11-extra-semi">; def EmptyInitStatement : DiagGroup<"empty-init-stmt">; +def ExportUnnamed : DiagGroup<"export-unnamed">; def ExtraSemiStmt : DiagGroup<"extra-semi-stmt", [EmptyInitStatement]>; def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi, CXX11ExtraSemi]>; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f8aef6f627..a44c682471 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -9273,8 +9273,27 @@ def err_module_decl_not_at_start : Error< def note_global_module_introducer_missing : Note< "add 'module;' to the start of the file to introduce a " "global module fragment">; +def err_export_within_anonymous_namespace : Error< + "export declaration appears within anonymous namespace">; +def note_anonymous_namespace : Note<"anonymous namespace begins here">; +def ext_export_no_name_block : ExtWarn< + "ISO C++20 does not permit %select{an empty|a static_assert}0 declaration " + "to appear in an export block">, InGroup<ExportUnnamed>; +def ext_export_no_names : ExtWarn< + "ISO C++20 does not permit a declaration that does not introduce any names " + "to be exported">, InGroup<ExportUnnamed>; +def note_export : Note<"export block begins here">; +def err_export_no_name : Error< + "%select{empty|static_assert|asm}0 declaration cannot be exported">; +def ext_export_using_directive : ExtWarn< + "ISO C++20 does not permit using directive to be exported">, + InGroup<DiagGroup<"export-using-directive">>; def err_export_within_export : Error< "export declaration appears within another export declaration">; +def err_export_internal : Error< + "declaration of %0 with internal linkage cannot be exported">; +def err_export_using_internal : Error< + "using declaration referring to %0 with internal linkage cannot be exported">; def err_export_not_in_module_interface : Error< "export declaration can only be used within a module interface unit" "%select{ after the module declaration|}0">; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index a2f43118df..1a5c756f90 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1651,6 +1651,9 @@ private: /// The modules we're currently parsing. llvm::SmallVector<ModuleScope, 16> ModuleScopes; + /// Namespace definitions that we will export when they finish. + llvm::SmallPtrSet<const NamespaceDecl*, 8> DeferredExportedNamespaces; + /// Get the module whose scope we are currently within. Module *getCurrentModule() const { return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module; |