Skip to content

P2533R0 Core Language Working Group "ready" #5287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 16, 2022
55 changes: 29 additions & 26 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,22 @@
\indextext{enumerator!definition}%
\indextext{one-definition rule|(}%

\pnum
Each of the following is termed a \defnadj{definable}{item}:
\begin{itemize}
\item a class type\iref{class},
\item an enumeration type\iref{dcl.enum},
\item a function\iref{dcl.fct},
\item a variable\iref{basic.pre},
\item a templated entity\iref{temp.pre},
\item a default argument for a parameter
(for a function in a given scope)\iref{dcl.fct.default}, or
\item a default template argument\iref{temp.param}.
\end{itemize}

\pnum
No translation unit shall contain more than one definition of any
variable, function, class type, enumeration type, template,
default argument for a parameter (for a function in a given scope), or
default template argument.
definable item.

\pnum
\indextext{expression!potentially evaluated}%
Expand Down Expand Up @@ -527,7 +538,7 @@
\end{example}

\pnum
Every program shall contain exactly one definition of every non-inline
Every program shall contain at least one definition of every
function or variable that is odr-used in that program
outside of a discarded statement\iref{stmt.if}; no diagnostic required.
The definition can appear explicitly in the program, it can be found in
Expand Down Expand Up @@ -611,20 +622,19 @@
\end{note}

\pnum
There can be more than one definition of a
For any definable item \tcode{D} with definitions in multiple translation units,
\begin{itemize}
\item class type\iref{class},
\item enumeration type\iref{dcl.enum},
\item inline function or variable\iref{dcl.inline},
\item templated entity\iref{temp.pre},
\item default argument for a parameter (for a function in a given scope)%
\iref{dcl.fct.default}, or
\item default template argument\iref{temp.param}
\item
if \tcode{D} is a non-inline non-templated function or variable, or
\item
if the definitions in different translation units
do not satisfy the following requirements,
\end{itemize}
in a program provided that
each definition appears in a different translation unit and
the definitions satisfy the following requirements.
Given such an entity \tcode{D} defined in more than one translation unit,
the program is ill-formed;
a diagnostic is required only
if the definable item is attached to a named module and
a prior definition is reachable at the point where a later definition occurs.
Given such an item,
for all definitions of \tcode{D}, or,
if \tcode{D} is an unnamed enumeration,
for all definitions of \tcode{D} that are reachable at any given program point,
Expand Down Expand Up @@ -745,13 +755,6 @@
might still denote different types in different translation units.
\end{note}

\pnum
If these definitions do not satisfy these requirements,
then the program is ill-formed;
a diagnostic is required only if
the entity is attached to a named module and
a prior definition is reachable at the point where a later definition occurs.

\pnum
\begin{example}
\begin{codeblock}
Expand Down Expand Up @@ -1222,7 +1225,8 @@
\grammarterm{compound-statement} of a \grammarterm{lambda-expression},
\grammarterm{function-body}, or \grammarterm{function-try-block},
\item
substatement of a selection or iteration statement, or
substatement of a selection or iteration statement
that is not itself a selection or iteration statement, or
\item
\grammarterm{handler} of a \grammarterm{function-try-block}
\end{itemize}
Expand Down Expand Up @@ -5179,8 +5183,7 @@
the other is a non-static data member of that object\iref{class.union}, or
\item
one is a standard-layout class object and
the other is the first non-static data member of that object, or,
if the object has no non-static data members,
the other is the first non-static data member of that object or
any base class subobject of that object\iref{class.mem}, or
\item
there exists an object \placeholder{c} such that
Expand Down
54 changes: 43 additions & 11 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2472,8 +2472,6 @@
\indextext{fundamental type conversion|see{conversion, user-defined}}%
\indextext{conversion!user-defined}%

\pnum
A member function of a class \tcode{X} with a name of the form
\begin{bnf}
\nontermdef{conversion-function-id}\br
\keyword{operator} conversion-type-id
Expand All @@ -2488,18 +2486,52 @@
\nontermdef{conversion-declarator}\br
ptr-operator \opt{conversion-declarator}
\end{bnf}
shall have no non-object parameters and
specifies a conversion from \tcode{X} to

\pnum
A declaration
whose \grammarterm{declarator-id} has
an \grammarterm{unqualified-id} that is a \grammarterm{conversion-function-id}
declares a \defnadj{conversion}{function};
its \grammarterm{declarator} shall be
a function declarator\iref{dcl.fct} of the form
\begin{ncsimplebnf}
ptr-declarator \terminal{(} parameter-declaration-clause \terminal{)} \opt{cv-qualifier-seq}\br
\bnfindent \opt{ref-qualifier-seq} \opt{noexcept-specifier} \opt{attribute-specifier-seq}
\end{ncsimplebnf}
where the \grammarterm{ptr-declarator} consists solely of
an \grammarterm{id-expression},
an optional \grammarterm{attribute-specifier-seq}, and
optional surrounding parentheses, and
the \grammarterm{id-expression} has one of the following forms:
\begin{itemize}
\item
in a \grammarterm{member-declaration} that belongs to
the \grammarterm{member-specification} of a class or class template
but is not a friend declaration\iref{class.friend},
the \grammarterm{id-expression} is a \grammarterm{conversion-function-id};
\item
otherwise, the \grammarterm{id-expression} is a \grammarterm{qualified-id}
whose \grammarterm{unqualified-id} is a \grammarterm{conversion-function-id}.
\end{itemize}

\pnum
A conversion function shall have no non-object parameters and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core issue doesn't include "non-object".

I suppose you added it to account for explicit object parameters.

Is that really enough? No need to restrict it to an explicit object parameter, but any amount of non-object parameters is OK? Is there wording elsewhere that make these cases ill-formed, and thus saying "non-object" is enough?

How about the function type specified below? Does it need a revision, too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the paper misrepresents the status quo? So tihs seems like a "plausible merge".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A conversion function with an explicit this parameter seems plausible, but there must not be other parameters. Further cleanup (if any) should be in a separate editorial or core issue.

shall be a non-static member function of a class or class template \tcode{X};
it specifies a conversion from \tcode{X} to
the type specified by the \grammarterm{conversion-type-id},
interpreted as a \grammarterm{type-id}\iref{dcl.name}.
Such functions are called \defnx{conversion functions}{conversion function}.
A \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
of a conversion function (if any) shall be neither
a \grammarterm{defining-type-specifier} nor \keyword{static}.
of a conversion function (if any) shall not be
a \grammarterm{defining-type-specifier}.

\pnum
\indextext{conversion!type of}%
The type of the conversion function\iref{dcl.fct} is
``function taking no parameter returning
\grammarterm{conversion-type-id}''.
The type of the conversion function is
``\opt{\tcode{noexcept}} function taking no parameter
\opt{\grammarterm{cv-qualifier-seq}} \opt{\grammarterm{ref-qualifier}}
returning \grammarterm{conversion-type-id}''.

\pnum
A conversion function is never used to convert a (possibly cv-qualified) object
to the (possibly cv-qualified) same object type (or a reference to it),
to a (possibly cv-qualified) base class of that type (or a reference to it),
Expand Down Expand Up @@ -2783,7 +2815,7 @@
to the entity being declared.
A bit-field shall not be a static member.
\indextext{bit-field!type of}%
A bit-field shall have integral or enumeration type;
A bit-field shall have integral or (possibly cv-qualified) enumeration type;
the bit-field semantic property is not part of the type of the class member.
The \grammarterm{constant-expression} shall be an integral constant expression
with a value greater than or equal to zero and
Expand Down
2 changes: 1 addition & 1 deletion source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6714,7 +6714,7 @@
see~\ref{depr.volatile.type}.
First, a variable with a unique name \exposid{e} is introduced. If the
\grammarterm{assignment-expression} in the \grammarterm{initializer}
has array type \tcode{A} and no \grammarterm{ref-qualifier} is present,
has array type \cvqual{cv1} \tcode{A} and no \grammarterm{ref-qualifier} is present,
\exposid{e} is defined by
\begin{ncbnf}
\opt{attribute-specifier-seq} \placeholder{S} \cv{} \terminal{A} \exposid{e} \terminal{;}
Expand Down
23 changes: 18 additions & 5 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,20 @@

\begin{bnf}
\nontermdef{lambda-specifiers}\br
\opt{decl-specifier-seq} \opt{noexcept-specifier} \opt{attribute-specifier-seq} \opt{trailing-return-type}
\opt{lambda-specifier-seq} \opt{noexcept-specifier} \opt{attribute-specifier-seq} \opt{trailing-return-type}
\end{bnf}

\begin{bnf}
\nontermdef{lambda-specifier}\br
\keyword{consteval}\br
\keyword{constexpr}\br
\keyword{mutable}
\end{bnf}

\begin{bnf}
\nontermdef{lambda-specifier-seq}\br
lambda-specifier\br
lambda-specifier lambda-specifier-seq
\end{bnf}

\pnum
Expand All @@ -1715,12 +1728,12 @@
\end{note}

\pnum
In the \grammarterm{decl-specifier-seq} of the \grammarterm{lambda-declarator},
each \grammarterm{decl-specifier}
shall be one of \keyword{mutable}, \keyword{constexpr}, or \keyword{consteval}.
A \grammarterm{lambda-specifier-seq}
shall contain at most one of each \grammarterm{lambda-specifier} and
shall not contain both \keyword{constexpr} and \keyword{consteval}.
If the \grammarterm{lambda-declarator} contains
an explicit object parameter\iref{dcl.fct},
then no \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
then no \grammarterm{lambda-specifier} in the \grammarterm{lambda-specifier-seq}
shall be \keyword{mutable}.
\begin{note}
The trailing \grammarterm{requires-clause} is described in \ref{dcl.decl}.
Expand Down