diff --git a/source/declarations.tex b/source/declarations.tex index d1696e2313..79d94c5019 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -9323,6 +9323,57 @@ \end{codeblock} \end{example} +\pnum +A \grammarterm{using-declarator} $U$ is \defn{reflection-transparent} if +\begin{itemize} +\item +$U$ inhabits a scope associated with a namespace and +\item +for each declaration $D$ named by $U$, +\begin{itemize} +\item +the target scope of $U$ is or contains the target scope of $D$ and +\item +each scope (if any) that intervenes between the locus of $U$ +and the target scope of $D$ +is associated with an inline or unnamed namespace. +\end{itemize} +\end{itemize} +\begin{example} +\begin{codeblock} +namespace NS { + enum class Enum1 { E1 }; + using Enum1::E1; // not reflection-transparent + + enum Enum2 { E2 }; + using Enum2::E2; // not reflection-transparent + + inline namespace Inline { + void f(); + } + inline namespace Sibling { + using Inline::f; // not reflection-transparent + } + using Sibling::f; // reflection-transparent + + void g(); + using NS::g; // reflection-transparent + + inline namespace Inline { + using NS::g; // not reflection-transparent + } +} + +constexpr auto R1 = ^^NS::f; // OK +constexpr auto R2 = ^^NS::g; // OK + +constexpr auto R3 = ^^NS::E1; // error: \grammarterm{using-declarator} is not reflection-transparent +constexpr auto R4 = ^^NS::E2; // error: \grammarterm{using-declarator} is not reflection-transparent +constexpr auto R5 = ^^NS::Sibling::f; // error: \grammarterm{using-declarator} is not reflection-transparent +constexpr auto R6 = ^^NS::Inline::g; // error: \grammarterm{using-declarator} is not reflection-transparent +\end{codeblock} +\end{example} + \indextext{using-declaration|)} \rSec1[dcl.asm]{The \tcode{asm} declaration}% diff --git a/source/expressions.tex b/source/expressions.tex index 66f884c64d..7892db65ba 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -6964,9 +6964,9 @@ \begin{itemize} \item If lookup finds a declaration -that replaced a \grammarterm{using-declarator} -during a single search\iref{basic.lookup.general,namespace.udecl}, -$R$ is ill-formed. +that replaced a \grammarterm{using-declarator} $U$ +during a single search\iref{basic.lookup.general}, +$U$ shall be reflection-transparent\iref{namespace.udecl}. \begin{example} \begin{codeblock} struct A { struct S {}; }; @@ -6980,7 +6980,7 @@ \end{codeblock} \end{example} \item -Otherwise, if lookup finds a namespace alias\iref{namespace.alias}, +If lookup finds a namespace alias\iref{namespace.alias}, all declarations found by name lookup shall have the same target scope, and $R$ represents the namespace alias. \item