From f3ffeb4f05fe4302d8ecee129e72f4e99e10dc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Wed, 16 Nov 2022 07:11:43 +0000 Subject: [PATCH] P2615R1 Meaningful exports Fixes NB GB 059 (C++23 CD). --- source/basic.tex | 6 +----- source/declarations.tex | 21 ++++++++++++++------- source/modules.tex | 20 ++++++++------------ source/templates.tex | 2 ++ 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 05a74fd816..4fd0641fdb 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -48,7 +48,7 @@ Every name is introduced by a \defn{declaration}, which is a \begin{itemize} \item -\grammarterm{declaration}, +\grammarterm{name-declaration}, \grammarterm{block-declaration}, or \grammarterm{member-declaration}\iref{dcl.pre,class.mem}, \item @@ -1753,10 +1753,6 @@ if it precedes $P$ and inhabits either $S$ or the scope of a namespace nominated by a \grammarterm{using-directive} that is active in $S$ at $P$. -\begin{note} -A \grammarterm{using-directive} is exported if and only if -it appears in a header unit. -\end{note} \pnum An \term{unqualified search} in a scope $S$ from a program point $P$ diff --git a/source/declarations.tex b/source/declarations.tex index b89dd84b04..a63c317a72 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -19,14 +19,17 @@ \begin{bnf} \nontermdef{declaration}\br + name-declaration\br + special-declaration +\end{bnf} + +\begin{bnf} +\nontermdef{name-declaration}\br block-declaration\br nodeclspec-function-declaration\br function-definition\br template-declaration\br deduction-guide\br - explicit-instantiation\br - explicit-specialization\br - export-declaration\br linkage-specification\br namespace-definition\br empty-declaration\br @@ -34,6 +37,13 @@ module-import-declaration \end{bnf} +\begin{bnf} +\nontermdef{special-declaration}\br + explicit-instantiation\br + explicit-specialization\br + export-declaration +\end{bnf} + \begin{bnf} \nontermdef{block-declaration}\br simple-declaration\br @@ -8151,7 +8161,7 @@ \begin{bnf} \nontermdef{linkage-specification}\br \keyword{extern} string-literal \terminal{\{} \opt{declaration-seq} \terminal{\}}\br - \keyword{extern} string-literal declaration + \keyword{extern} string-literal name-declaration \end{bnf} The \grammarterm{string-literal} indicates the required language linkage. @@ -8185,9 +8195,6 @@ \end{example} \pnum -A \grammarterm{module-import-declaration} -shall not be directly contained in -a \grammarterm{linkage-specification}. A \grammarterm{module-import-declaration} appearing in a linkage specification with other than \Cpp{} language linkage is conditionally-supported with diff --git a/source/modules.tex b/source/modules.tex index d82d1b0cfc..0a65f8c069 100644 --- a/source/modules.tex +++ b/source/modules.tex @@ -196,7 +196,7 @@ \begin{bnf} \nontermdef{export-declaration}\br - \keyword{export} declaration\br + \keyword{export} name-declaration\br \keyword{export} \terminal{\{} \opt{declaration-seq} \terminal{\}}\br export-keyword module-import-declaration \end{bnf} @@ -209,10 +209,12 @@ or a \grammarterm{private-module-fragment}. An \grammarterm{export-declaration} has the declarative effects of its -\grammarterm{declaration}, +\grammarterm{name-declaration}, \grammarterm{declaration-seq} (if any), or \grammarterm{module-import-declaration}. -The \grammarterm{declaration} or \grammarterm{declaration-seq} of +The \grammarterm{name-declaration} of an \grammarterm{export-declaration} +shall not declare a partial specialization\iref{temp.decls.general}. +The \grammarterm{declaration-seq} of an \grammarterm{export-declaration} shall not contain an \grammarterm{export-declaration} or \grammarterm{module-import-declaration}. @@ -232,10 +234,7 @@ \end{itemize} \pnum -An exported declaration -that is not a \grammarterm{module-import-declaration} -shall declare at least one name. -If the declaration is not within a header unit, +If an exported declaration is not within a header unit, it shall not declare a name with internal linkage. \pnum @@ -249,17 +248,14 @@ #include "a.h" // error: declaration of \tcode{x} is not in the // purview of a module interface unit export module M; -export namespace {} // error: does not introduce any names -export namespace { - int a1; // error: export of name with internal linkage -} +export namespace {} // error: namespace has internal linkage namespace { export int a2; // error: export of name with internal linkage } export static int b; // error: b explicitly declared static export int f(); // OK export namespace N { } // OK -export using namespace N; // error: does not declare a name +export using namespace N; // OK \end{codeblocktu} \end{example} diff --git a/source/templates.tex b/source/templates.tex index 38c5aac700..c726e771ff 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -6379,6 +6379,8 @@ \end{example} \pnum +The \grammarterm{declaration} in an \grammarterm{explicit-specialization} +shall not be an \grammarterm{export-declaration}. An explicit specialization shall not use a \grammarterm{storage-class-specifier}\iref{dcl.stc} other than \keyword{thread_local}.