Skip to content

Commit 4a9ad86

Browse files
committed
Merge 2018-11 CWG Motion 5
P1131R2 Core Issue 2292: simple-template-id is ambiguous between class-name and type-name Fixes #2398
2 parents e7c077e + f892418 commit 4a9ad86

File tree

9 files changed

+139
-145
lines changed

9 files changed

+139
-145
lines changed

source/basic.tex

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,19 +1776,13 @@
17761776
of that enumeration.
17771777

17781778
\pnum
1779-
If a \grammarterm{pseudo-destructor-name}\iref{expr.pseudo} contains a
1780-
\grammarterm{nested-name-specifier}, the \grammarterm{type-name}{s} are looked
1781-
up as types in the scope designated by the
1782-
\grammarterm{nested-name-specifier}. Similarly, in a
1783-
\grammarterm{qualified-id} of the form:
1779+
In a \grammarterm{qualified-id} of the form:
17841780

17851781
\begin{ncbnf}
1786-
\opt{nested-name-specifier} class-name \terminal{::} \terminal{\~} class-name
1782+
\opt{nested-name-specifier} type-name \terminal{::} \terminal{\~} type-name
17871783
\end{ncbnf}
1788-
1789-
the second \grammarterm{class-name} is looked up in the same scope as the
1790-
first. \begin{example}
1791-
1784+
the second \grammarterm{type-name} is looked up in the same scope as the first.
1785+
\begin{example}
17921786
\begin{codeblock}
17931787
struct C {
17941788
typedef int I;
@@ -1808,8 +1802,10 @@
18081802
p->AB::~AB(); // explicitly calls the destructor for \tcode{A}
18091803
}
18101804
\end{codeblock}
1811-
\end{example} \begin{note} \ref{basic.lookup.classref} describes how name
1812-
lookup proceeds after the \tcode{.} and \tcode{->} operators. \end{note}
1805+
\end{example}
1806+
\begin{note} \ref{basic.lookup.classref} describes how name
1807+
lookup proceeds after the \tcode{.} and \tcode{->} operators.
1808+
\end{note}
18131809

18141810
\rSec3[class.qual]{Class members}
18151811

@@ -2222,9 +2218,6 @@
22222218
access\iref{expr.ref} is an \grammarterm{unqualified-id}, and the type of
22232219
the object expression is of a class type \tcode{C}, the
22242220
\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}.
22282221

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

source/classes.tex

Lines changed: 11 additions & 16 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}.
@@ -2390,7 +2384,7 @@
23902384
\begin{note}
23912385
\indextext{fundamental type!destructor and}%
23922386
The notation for explicit call of a destructor can be used for any scalar type
2393-
name\iref{expr.pseudo}.
2387+
name\iref{expr.prim.id.dtor}.
23942388
Allowing this makes it possible to write code without having to know if a
23952389
destructor exists for a given type.
23962390
For example:
@@ -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.typedef}, \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)