Skip to content

Commit 9784d05

Browse files
committed
P1131R2 Core Issue 2292: simple-template-id is ambiguous between class-name and type-name
1 parent 12935b8 commit 9784d05

File tree

6 files changed

+125
-121
lines changed

6 files changed

+125
-121
lines changed

source/basic.tex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,9 +2222,6 @@
22222222
access\iref{expr.ref} is an \grammarterm{unqualified-id}, and the type of
22232223
the object expression is of a class type \tcode{C}, the
22242224
\grammarterm{unqualified-id} is looked up in the scope of class \tcode{C}.
2225-
For a pseudo-destructor call\iref{expr.pseudo},
2226-
the \grammarterm{unqualified-id} is looked up in the context of the complete
2227-
\grammarterm{postfix-expression}.
22282225

22292226
\pnum
22302227
If the \grammarterm{unqualified-id} is \tcode{\~}\grammarterm{type-name}, the

source/classes.tex

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,8 @@
422422

423423
\pnum
424424
\indextext{class name!\idxcode{typedef}}%
425-
A \grammarterm{typedef-name}\iref{dcl.typedef} that names a class type,
426-
or a cv-qualified version thereof, is also a \grammarterm{class-name}. If a
427-
\grammarterm{typedef-name} that names a cv-qualified class type is used
428-
where a \grammarterm{class-name} is required, the cv-qualifiers are
429-
ignored. A \grammarterm{typedef-name} shall not be used as the
430-
\grammarterm{identifier} in a \grammarterm{class-head}.
425+
A \grammarterm{simple-template-id} is only a \grammarterm{class-name}
426+
if its \grammarterm{template-name} names a class template.
431427

432428
\rSec1[class.mem]{Class members}%
433429
\indextext{declaration!member}%
@@ -1233,8 +1229,7 @@
12331229
constructor\iref{class.qual}.
12341230
\end{itemize}
12351231

1236-
The \grammarterm{class-name} shall not be a \grammarterm{typedef-name}. In a constructor
1237-
declaration, each \grammarterm{decl-specifier} in the optional
1232+
In a constructor declaration, each \grammarterm{decl-specifier} in the optional
12381233
\grammarterm{decl-specifier-seq} shall be \tcode{friend}, \tcode{inline},
12391234
\tcode{constexpr}, or an \grammarterm{explicit-specifier}.
12401235
\begin{example}
@@ -2119,8 +2114,7 @@
21192114
same class as the \grammarterm{nested-name-specifier}.
21202115
\end{itemize}
21212116

2122-
The \grammarterm{class-name} shall not be a \grammarterm{typedef-name}. A
2123-
destructor shall take no arguments\iref{dcl.fct}.
2117+
A destructor shall take no arguments\iref{dcl.fct}.
21242118
Each \grammarterm{decl-specifier} of the \grammarterm{decl-specifier-seq}
21252119
of a destructor declaration (if any) shall be \tcode{friend}, \tcode{inline}, or
21262120
\tcode{virtual}.
@@ -3421,7 +3415,7 @@
34213415

34223416
\begin{bnf}
34233417
\nontermdef{class-or-decltype}\br
3424-
\opt{nested-name-specifier} class-name\br
3418+
\opt{nested-name-specifier} type-name\br
34253419
nested-name-specifier \terminal{template} simple-template-id\br
34263420
decltype-specifier
34273421
\end{bnf}
@@ -3440,17 +3434,18 @@
34403434
\pnum
34413435
\indextext{type!incomplete}%
34423436
A \grammarterm{class-or-decltype} shall denote
3443-
a class type that is not
3444-
an incompletely defined class\iref{class}.
3437+
a (possibly cv-qualified) class type that is not
3438+
an incompletely defined class\iref{class.mem};
3439+
any cv-qualifiers are ignored.
34453440
The class denoted by the \grammarterm{class-or-decltype} of
34463441
a \grammarterm{base-specifier} is called a
34473442
\defnadj{direct}{base class}
34483443
for the class being defined.
34493444
\indextext{base class}%
34503445
\indextext{derivation|see{inheritance}}%
34513446
During the lookup for a base class name, non-type names are
3452-
ignored\iref{basic.scope.hiding}. If the name found is not a
3453-
\grammarterm{class-name}, the program is ill-formed. A class \tcode{B} is a
3447+
ignored\iref{basic.scope.hiding}.
3448+
A class \tcode{B} is a
34543449
base class of a class \tcode{D} if it is a direct base class of
34553450
\tcode{D} or a direct base class of one of \tcode{D}'s base classes.
34563451
A class is an \defnadj{indirect}{base class} of another if it is a base

source/declarations.tex

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -550,20 +550,21 @@
550550

551551
\begin{bnf}
552552
\nontermdef{typedef-name}\br
553-
identifier
553+
identifier\br
554+
simple-template-id
554555
\end{bnf}
555556

556557
A name declared with the \tcode{typedef} specifier becomes a
557-
\grammarterm{typedef-name}. Within the scope of its declaration, a
558-
\grammarterm{typedef-name} is syntactically equivalent to a keyword and
559-
names the type associated with the identifier in the way described in
560-
\ref{dcl.decl}.
558+
\grammarterm{typedef-name}.
559+
A \grammarterm{typedef-name} names
560+
the type associated with the \grammarterm{identifier}\iref{dcl.decl}
561+
or \grammarterm{simple-template-id}\iref{temp};
561562
\indextext{declaration!typedef@\tcode{typedef} as type}%
562563
\indextext{equivalence!type}%
563564
\indextext{synonym!type name as}%
564-
A \grammarterm{typedef-name} is thus a synonym for another type. A
565+
a \grammarterm{typedef-name} is thus a synonym for another type. A
565566
\grammarterm{typedef-name} does not introduce a new type the way a class
566-
declaration\iref{class.name} or enum declaration does.
567+
declaration\iref{class.name} or enum declaration\iref{dcl.enum} does.
567568
\begin{example}
568569
After
569570

@@ -677,18 +678,20 @@
677678
\end{example}
678679

679680
\pnum
680-
\begin{note}
681681
\indextext{class name!\idxcode{typedef}}%
682-
A \grammarterm{typedef-name} that names a class type, or a cv-qualified
683-
version thereof, is also a \grammarterm{class-name}\iref{class.name}. If
684-
a \grammarterm{typedef-name} is used to identify the subject of an
682+
A \grammarterm{simple-template-id} is only a \grammarterm{typedef-name}
683+
if its \grammarterm{template-name} names
684+
an alias template or a template \grammarterm{template-parameter}.
685+
\begin{note}
686+
A \grammarterm{simple-template-id} that names a class template specialization
687+
is a \grammarterm{class-name}\iref{class.name}.
688+
If a \grammarterm{typedef-name} is used to identify the subject of an
685689
\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab}, a class
686690
definition\iref{class}, a constructor
687691
declaration\iref{class.ctor}, or a destructor
688692
declaration\iref{class.dtor}, the program is ill-formed.
689693
\end{note}
690694
\begin{example}
691-
692695
\begin{codeblock}
693696
struct S {
694697
S();
@@ -1270,7 +1273,6 @@
12701273
class-name\br
12711274
enum-name\br
12721275
typedef-name\br
1273-
simple-template-id
12741276
\end{bnf}
12751277

12761278
\begin{bnf}
@@ -1516,17 +1518,19 @@
15161518
the class whenever it is named.
15171519

15181520
\pnum
1521+
\begin{note}
15191522
\ref{basic.lookup.elab} describes how name lookup proceeds for the
1520-
\grammarterm{identifier} in an \grammarterm{elaborated-type-specifier}. If the
1521-
\grammarterm{identifier} resolves to a \grammarterm{class-name} or
1523+
\grammarterm{identifier} in an \grammarterm{elaborated-type-specifier}.
1524+
\end{note}
1525+
If the \grammarterm{identifier} or \grammarterm{simple-template-id}
1526+
resolves to a \grammarterm{class-name} or
15221527
\grammarterm{enum-name}, the \grammarterm{elaborated-type-specifier}
15231528
introduces it into the declaration the same way a
1524-
\grammarterm{simple-type-specifier} introduces its \grammarterm{type-name}. If
1525-
the \grammarterm{identifier} resolves to a
1526-
\grammarterm{typedef-name} or the \grammarterm{simple-template-id} resolves to
1527-
an alias template specialization,
1528-
the
1529-
\grammarterm{elaborated-type-specifier} is ill-formed.
1529+
\grammarterm{simple-type-specifier} introduces
1530+
its \grammarterm{type-name}\iref{dcl.type.simple}.
1531+
If the \grammarterm{identifier} or \grammarterm{simple-template-id} resolves to a
1532+
\grammarterm{typedef-name} (\ref{dcl.typename} \ref{temp.names}),
1533+
the \grammarterm{elaborated-type-specifier} is ill-formed.
15301534
\begin{note}
15311535
This implies that, within a class template with a template
15321536
\grammarterm{type-parameter} \tcode{T}, the declaration

0 commit comments

Comments
 (0)