Skip to content

Commit

Permalink
CWG2141 Ambiguity in new-expression with elaborated-type-specifier
Browse files Browse the repository at this point in the history
Reorder added sentence on alias-declarations to avoid apparent
contradiction with the next sentence, and rephrase to avoid double
negative.
  • Loading branch information
Dawn Perchik authored and zygoloid committed Mar 9, 2016
1 parent 28c12a8 commit efdf8b5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
52 changes: 27 additions & 25 deletions source/declarations.tex
Expand Up @@ -50,7 +50,7 @@

\begin{bnf}
\nontermdef{alias-declaration}\br
\terminal{using} identifier attribute-specifier-seq\opt{} \terminal{=} type-id \terminal{;}
\terminal{using} identifier attribute-specifier-seq\opt{} \terminal{=} defining-type-id \terminal{;}
\end{bnf}

\begin{bnf}
Expand Down Expand Up @@ -184,7 +184,7 @@
contains exactly one \grammarterm{declarator-id}, which is the name
declared by that \grammarterm{init-declarator} and hence one of the names
declared by the declaration. The
\grammarterm{type-specifiers}~(\ref{dcl.type}) in the
\grammarterm{defining-type-specifiers}~(\ref{dcl.type}) in the
\grammarterm{decl-specifier-seq} and the recursive \grammarterm{declarator}
structure of the \grammarterm{init-declarator} describe a
type~(\ref{dcl.meaning}), which is then associated with the name being
Expand Down Expand Up @@ -234,7 +234,7 @@
\begin{bnf}
\nontermdef{decl-specifier}\br
storage-class-specifier\br
type-specifier\br
defining-type-specifier\br
function-specifier\br
\terminal{friend}\br
\terminal{typedef}\br
Expand Down Expand Up @@ -262,7 +262,7 @@
\indextext{ambiguity!declaration type}%
If a \grammarterm{type-name} is encountered while parsing a \grammarterm{decl-specifier-seq},
it is interpreted as part of the \grammarterm{decl-specifier-seq} if and only if there is no
previous \grammarterm{type-specifier} other than a \grammarterm{cv-qualifier} in the
previous \grammarterm{defining-type-specifier} other than a \grammarterm{cv-qualifier} in the
\grammarterm{decl-specifier-seq}.
The sequence shall be self-consistent as
described below.
Expand Down Expand Up @@ -555,7 +555,7 @@
fundamental~(\ref{basic.fundamental}) or compound~(\ref{basic.compound})
types. The \tcode{typedef} specifier shall not be
combined in a \grammarterm{decl-specifier-seq} with any other kind of
specifier except a \grammarterm{type-specifier,} and it shall not be used in the
specifier except a \grammarterm{defining-type-specifier}, and it shall not be used in the
\grammarterm{decl-specifier-seq} of a
\grammarterm{parameter-declaration}~(\ref{dcl.fct}) nor in the
\grammarterm{decl-specifier-seq} of a
Expand Down Expand Up @@ -604,7 +604,7 @@
\tcode{using} keyword becomes a \grammarterm{typedef-name}
and the optional \grammarterm{attribute-specifier-seq} following the
\grammarterm{identifier} appertains to that \grammarterm{typedef-name}.
It has the same
Such a \grammarterm{typedef-name} has the same
semantics as if it were introduced by the \tcode{typedef} specifier. In
particular, it does not define a new type.
\enterexample
Expand All @@ -617,6 +617,10 @@
\end{codeblock}

\exitexample
The \grammarterm{defining-type-specifier-seq}
of the \grammarterm{defining-type-id} shall not define
a class or enumeration if the \grammarterm{alias-declaration}
is the \grammarterm{declaration} of a \grammarterm{template-declaration}.

\pnum
\indextext{redefinition!\idxcode{typedef}}%
Expand Down Expand Up @@ -1011,13 +1015,6 @@
%
\begin{bnf}
\nontermdef{type-specifier}\br
trailing-type-specifier\br
class-specifier\br
enum-specifier
\end{bnf}

\begin{bnf}
\nontermdef{trailing-type-specifier}\br
simple-type-specifier\br
elaborated-type-specifier\br
typename-specifier\br
Expand All @@ -1031,22 +1028,31 @@
\end{bnf}

\begin{bnf}
\nontermdef{trailing-type-specifier-seq}\br
trailing-type-specifier attribute-specifier-seq\opt\br
trailing-type-specifier trailing-type-specifier-seq
\nontermdef{defining-type-specifier}\br
type-specifier\br
class-specifier\br
enum-specifier
\end{bnf}

\begin{bnf}
\nontermdef{defining-type-specifier-seq}\br
defining-type-specifier attribute-specifier-seq\opt\br
defining-type-specifier defining-type-specifier-seq
\end{bnf}

The optional \grammarterm{attribute-specifier-seq} in a \grammarterm{type-specifier-seq}
or a \grammarterm{trailing-type-specifier-seq}
or a \grammarterm{defining-type-specifier-seq}
appertains
to the type denoted by the preceding \grammarterm{type-specifier}{s}~(\ref{dcl.meaning}). The
to the type denoted by the preceding \grammarterm{type-specifier}{s}
or \grammarterm{defining-type-specifier}{s}~(\ref{dcl.meaning}). The
\grammarterm{attribute-specifier-seq} affects the type only for the declaration it appears in,
not other declarations involving the same type.

\pnum
As a general rule, at most one \grammarterm{type-specifier} is allowed in the complete
As a general rule, at most one \grammarterm{defining-type-specifier}
is allowed in the complete
\grammarterm{decl-specifier-seq} of a \grammarterm{declaration} or in a
\grammarterm{type-specifier-seq} or \grammarterm{trailing-type-specifier-seq}.
\grammarterm{type-specifier-seq} or \grammarterm{defining-type-specifier-seq}.
The only exceptions to this rule are the following:

\begin{itemize}
Expand All @@ -1066,18 +1072,14 @@

\pnum
Except in a declaration of a constructor, destructor, or conversion
function, at least one \grammarterm{type-specifier} that is not a
function, at least one \grammarterm{defining-type-specifier} that is not a
\grammarterm{cv-qualifier} shall appear in a complete
\grammarterm{type-specifier-seq} or a complete
\grammarterm{decl-specifier-seq}.\footnote{There is no special
provision for a \grammarterm{decl-specifier-seq} that
lacks a \grammarterm{type-specifier} or that has a
\grammarterm{type-specifier} that only specifies \grammarterm{cv-qualifier}{s}.
The ``implicit int'' rule of C is no longer supported.}
A \grammarterm{type-specifier-seq} shall not define a class or enumeration unless
it appears in the \grammarterm{type-id} of an
\grammarterm{alias-declaration}~(\ref{dcl.typedef}) that is not the \grammarterm{declaration}
of a \grammarterm{template-declaration}.

\pnum
\enternote
Expand Down
7 changes: 6 additions & 1 deletion source/declarators.tex
Expand Up @@ -133,7 +133,7 @@

\begin{bnf}
\nontermdef{trailing-return-type}\br
\terminal{->} trailing-type-specifier-seq abstract-declarator\opt
\terminal{->} type-id
\end{bnf}

\begin{bnf}
Expand Down Expand Up @@ -189,6 +189,11 @@
type-specifier-seq abstract-declarator\opt
\end{bnf}

\begin{bnf}
\nontermdef{defining-type-id}\br
defining-type-specifier-seq abstract-declarator\opt
\end{bnf}

\begin{bnf}
\nontermdef{abstract-declarator}\br
ptr-abstract-declarator\br
Expand Down
2 changes: 1 addition & 1 deletion source/special.tex
Expand Up @@ -791,7 +791,7 @@
Such functions are called \defn{conversion function}{s}.
A \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
of a conversion function (if any) shall be neither
a \grammarterm{type-specifier} nor \tcode{static}.
a \grammarterm{defining-type-specifier} nor \tcode{static}.
\indextext{conversion!type~of}%
Type of the conversion function~(\ref{dcl.fct}) is
``function taking no parameter returning
Expand Down

0 comments on commit efdf8b5

Please sign in to comment.