Skip to content

P1103R3 Merging Modules #2721

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 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
376 changes: 307 additions & 69 deletions source/basic.tex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,7 @@
A bit-field shall not be a static member.
\indextext{bit-field!type of}%
A bit-field shall have integral or enumeration type;
the bit-field attribute is not part of the type of the class member.
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
is called the \defn{width} of the bit-field.
Expand Down
33 changes: 33 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,20 @@

\rSec2[diff.cpp17.lex]{\ref{lex}: lexical conventions}

\diffref{lex.header}
\change \grammarterm{header-name} tokens are formed in more contexts.
\rationale Required for new features.
\effect When the identifier \tcode{import}
is followed by a \tcode{<} character,
a \grammarterm{header-name} token may be formed.
\begin{example}
\begin{codeblock}
template<typename> class import {};
import<int> f(); // ill-formed; previously well-formed
::import<int> g(); // OK
\end{codeblock}
\end{example}

\diffref{lex.key}
\change New keywords.
\rationale Required for new features.
Expand Down Expand Up @@ -1862,6 +1876,25 @@

\rSec2[diff.cpp17.basic]{\ref{basic}: basics}

\diffref{basic.link,module.unit,module.import}
\change New identifiers with special meaning.
\rationale Required for new features.
\effect Top-level declarations beginning with
\tcode{module} or \tcode{import} may
be either ill-formed or interpreted differently
in this International Standard.
\begin{example}
\begin{codeblock}
class module;
module *m1; // ill-formed; previously well-formed
::module *m2; // OK

class import {};
import j1; // was variable declaration; now \grammarterm{import-declaration}
::import j2; // variable declaration
\end{codeblock}
\end{example}

\diffref{intro.races}
\change Except for the initial release operation,
a release sequence consists solely of atomic read-modify-write operations.
Expand Down
70 changes: 60 additions & 10 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
deduction-guide\br
explicit-instantiation\br
explicit-specialization\br
export-declaration\br
linkage-specification\br
namespace-definition\br
empty-declaration\br
Expand Down Expand Up @@ -1031,27 +1032,46 @@
been declared inline.

\pnum
An inline function or variable shall be defined in every translation unit in which
it is odr-used and shall have exactly the same definition in every
case\iref{basic.def.odr}.
If an inline function or variable
is odr-used in a translation unit,
a definition of it shall be reachable from the end of that translation unit,
and it shall have exactly the same definition
in every such translation unit\iref{basic.def.odr}.
\begin{note}
A call to the inline function or a use of the inline variable may be encountered before its definition
appears in the translation unit.
\end{note}
If the definition of a function or variable appears in a translation unit before its
If a definition of a function or variable is reachable
at the point of its
first declaration as inline, the program is ill-formed. If a function or variable
with external linkage is declared inline in one translation unit, it
shall be declared inline in all translation units in which it appears;
no diagnostic is required. An inline function or variable with external
linkage shall have the same address in all translation units.
with external or module linkage
is declared inline in one translation unit,
there shall be a reachable inline declaration
in all translation units in which it is declared;
no diagnostic is required.
An inline function or variable
with external or module linkage
shall have the same address in all translation units.
\begin{note}
A \tcode{static} local variable in an inline
function with external linkage always refers to the same object.
function with external or module linkage
always refers to the same object.
A type defined within the body of an inline
function with external linkage is the
function with external or module linkage is the
same type in every translation unit.
\end{note}

\pnum
An exported inline function or variable
shall be defined in the translation unit
containing its exported declaration,
outside the \grammarterm{private-module-fragment} (if any).
\begin{note}
There is no restriction on the linkage (or absence thereof)
of entities that the function body of an exported inline function
can reference. A constexpr function\iref{dcl.constexpr} is implicitly inline.
\end{note}

\rSec2[dcl.type]{Type specifiers}%
\indextext{specifier!type|see{type specifier}}

Expand Down Expand Up @@ -1709,6 +1729,17 @@
\end{codeblock}
\end{example}

\pnum
An exported function
with a declared return type that uses a placeholder type
shall be defined in the translation unit
containing its exported declaration,
outside the \grammarterm{private-module-fragment} (if any).
\begin{note}
There is no restriction on the linkage of
the deduced return type.
\end{note}

\pnum
If the name of an entity with an undeduced placeholder type appears in an
expression, the program is ill-formed. Once a
Expand Down Expand Up @@ -6642,6 +6673,25 @@
the definition of a namespace can be split over several parts of one or
more translation units.

\pnum
\begin{note}
A namespace name with external linkage is exported
if any of its \term{namespace-definition}{s} is exported,
or if it contains any
\grammarterm{export-declaration}{s}\iref{module.interface}.
A namespace is never attached to a module,
and never has module linkage
even if it is not exported.
\end{note}
\begin{example}
\begin{codeblock}
export module M;
namespace N1 {} // \tcode{N1} is not exported
export namespace N2 {} // \tcode{N2} is exported
namespace N3 { export int n; } // \tcode{N3} is exported
\end{codeblock}
\end{example}

\pnum
The outermost declarative region of a translation unit is a namespace;
see~\ref{basic.scope.namespace}.
Expand Down
54 changes: 41 additions & 13 deletions source/lex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
\begin{note} Previously translated translation units and instantiation
units can be preserved individually or in libraries. The separate
translation units of a program communicate\iref{basic.link} by (for
example) calls to functions whose identifiers have external linkage,
manipulation of objects whose identifiers have external linkage, or
example)
calls to functions whose identifiers have external or module linkage,
manipulation of objects whose identifiers have external or module linkage, or
manipulation of data files. Translation units can be separately
translated and then later linked to produce an executable
program\iref{basic.link}. \end{note}%
Expand Down Expand Up @@ -139,7 +140,18 @@
semantically analyzed and translated as a translation unit. \begin{note}
The process of analyzing and translating the tokens may occasionally
result in one token being replaced by a sequence of other
tokens\iref{temp.names}.\end{note} \begin{note} Source files, translation
tokens\iref{temp.names}.\end{note}
It is
\impldef{whether the sources for
module units and header units
on which the current translation unit has an interface
dependency are required to be available during translation}
whether the sources for
module units and header units
on which the current translation unit has an interface
dependency (\ref{module.unit}, \ref{module.import})
are required to be available.
\begin{note} Source files, translation
units and translated translation units need not necessarily be stored as
files, nor need there be any one-to-one correspondence between these
entities and any external representation. The description is conceptual
Expand Down Expand Up @@ -324,7 +336,20 @@
characters that could constitute a preprocessing token, even if that
would cause further lexical analysis to fail,
except that a \grammarterm{header-name}\iref{lex.header} is only formed
within a \tcode{\#include} directive\iref{cpp.include}.
\begin{itemize}
\item
within a \tcode{\#include} directive\iref{cpp.include},

\item
within a \grammarterm{has-include-expression}, or

\item
outside of any preprocessing directive,
if applying phase 4 of translation to the sequence
of preprocessing tokens produced thus far
is valid and
results in an \grammarterm{import-seq}\iref{cpp.module}.
\end{itemize}
\end{itemize}

\begin{example}
Expand Down Expand Up @@ -638,14 +663,17 @@
\grammarterm{identifier} has a special meaning is resolved to interpret the
token as a regular \grammarterm{identifier}.

\begin{floattable}{Identifiers with special meaning}{tab:identifiers.special}
{llll}
\topline
\tcode{audit} &
\tcode{axiom} &
\tcode{final} &
\begin{multicolfloattable}{Identifiers with special meaning}{tab:identifiers.special}
{lll}
\tcode{audit} \\
\tcode{axiom} \\
\columnbreak
\tcode{import} \\
\tcode{final} \\
\columnbreak
\tcode{module} \\
\tcode{override} \\
\end{floattable}
\end{multicolfloattable}

\pnum
\indextext{\idxcode{_}|see{character, underscore}}%
Expand Down Expand Up @@ -765,8 +793,8 @@
\tcode{while} \\
\end{multicolfloattable}

\begin{note} The \tcode{export} and \tcode{register} keywords are unused but
are reserved for future use.\end{note}
\begin{note} The \tcode{register} keyword is unused but
is reserved for future use.\end{note}

\pnum
Furthermore, the alternative representations shown in
Expand Down
20 changes: 20 additions & 0 deletions source/macros.tex
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,26 @@

\lstnewenvironment{codeblock}{\CodeBlockSetup}{}

% Left-align listings titles
\makeatletter
\def\lst@maketitle{\@makeleftcaption\lst@title@dropdelim}
\long\def\@makeleftcaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{%\hfil -- REMOVED
\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}%
\makeatother

\lstnewenvironment{codeblocktu}[1]{%
\lstset{title={%\parabullnum{Bullets1}{0pt}
#1:}}\CodeBlockSetup}{}

% An environment for command / program output that is not C++ code.
\lstnewenvironment{outputblock}{\lstset{language=}}{}

Expand Down
Loading