diff --git a/source/declarations.tex b/source/declarations.tex index 9e8e963379..e328606f55 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -1718,8 +1718,6 @@ each of which shall be followed by a non-empty \grammarterm{initializer}. -If the \grammarterm{initializer} is a parenthesized \grammarterm{expression-list}, -the \grammarterm{expression-list} shall be a single \grammarterm{assignment-expression}. \begin{example} \begin{codeblock} auto x = 5; // OK: \tcode{x} has type \tcode{int} @@ -1905,45 +1903,63 @@ \pnum A type \tcode{T} containing a placeholder type, -and a corresponding initializer $E$, +and a corresponding \grammarterm{initializer-clause} $E$, are determined as follows: \begin{itemize} \item -for a non-discarded \tcode{return} statement that occurs +For a non-discarded \tcode{return} statement that occurs in a function declared with a return type that contains a placeholder type, -\tcode{T} is the declared return type -and $E$ is the operand of the \tcode{return} statement. -If the \tcode{return} statement -has no operand, -then $E$ is \tcode{void()}; +\tcode{T} is the declared return type. +\begin{itemize} +\item +If the \tcode{return} statement has no operand, +then $E$ is \tcode{void()}. +\item +If the operand is a \grammarterm{braced-init-list}\iref{dcl.init.list}, +the program is ill-formed. +\item +If the operand is an \grammarterm{expression} $X$ +that is not an \grammarterm{assignment-expression}, +$E$ is \tcode{($X$)}. +\begin{note} +A comma expression\iref{expr.comma} is not +an \grammarterm{assignment-expression}. +\end{note} +\item +Otherwise, $E$ is the operand of the \tcode{return} statement. +\end{itemize} +If $E$ has type \keyword{void}, +\tcode{T} shall be either +\opt{\grammarterm{type-constraint}} \tcode{decltype(auto)} or +\cv{}~\opt{\grammarterm{type-constraint}} \keyword{auto}. \item -for a variable declared with a type +For a variable declared with a type that contains a placeholder type, -\tcode{T} is the declared type of the variable -and $E$ is the initializer. -If the initialization is direct-list-initialization, -the initializer shall be a \grammarterm{braced-init-list} -containing only a single \grammarterm{assignment-expression} -and $E$ is the \grammarterm{assignment-expression}; +\tcode{T} is the declared type of the variable. +\begin{itemize} +\item +If the initializer of the variable is a \grammarterm{brace-or-equal-initializer} +of the form \tcode{= \grammarterm{initializer-clause}}, +$E$ is the \grammarterm{initializer-clause}. +\item +If the initializer is a \grammarterm{braced-init-list}, +it shall consist of a single brace-enclosed \grammarterm{assignment-expression} +and $E$ is the \grammarterm{assignment-expression}. +\item +If the initializer is a parenthesized \grammarterm{expression-list}, +the \grammarterm{expression-list} shall be +a single \grammarterm{assignment-expression} +and $E$ is the \grammarterm{assignment-expression}. +\end{itemize} \item -for a non-type template parameter declared with a type +For a non-type template parameter declared with a type that contains a placeholder type, \tcode{T} is the declared type of the non-type template parameter and $E$ is the corresponding template argument. \end{itemize} \tcode{T} shall not be an array type. -In the case of a \tcode{return} statement with no operand -or with an operand of type \keyword{void}, -\tcode{T} shall be either -\opt{\grammarterm{type-constraint}} \tcode{decltype(auto)} or -\cv{}~\opt{\grammarterm{type-constraint}} \keyword{auto}. - -\pnum -If the deduction is for a \tcode{return} statement -and $E$ is a \grammarterm{braced-init-list}\iref{dcl.init.list}, -the program is ill-formed. \pnum If the \grammarterm{placeholder-type-specifier} is of the form