Skip to content

[lex.separate][module.unit] move definitions of program and translation unit #7180

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 1 addition & 15 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2870,24 +2870,10 @@
\end{note}
\indextext{splice|)}

\rSec1[basic.link]{Program and linkage}%
\rSec1[basic.link]{Linkage}%
\indextext{linkage|(}

\pnum
\indextext{program}%
\indextext{linking}%
A \defn{program} consists of one or more translation units\iref{lex.separate}
linked together. A translation unit consists
of a sequence of declarations.

\begin{bnf}
\nontermdef{translation-unit}\br
\opt{declaration-seq}\br
\opt{global-module-fragment} module-declaration \opt{declaration-seq} \opt{private-module-fragment}
\end{bnf}

\pnum
\indextext{translation unit}%
A name has
\defnadj{external}{linkage},
\defnadj{module}{linkage},
Expand Down
2 changes: 1 addition & 1 deletion source/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
\begin{defnote}
Only one definition for such a function is in effect for the duration of the program's
execution, as the result of creating the program\iref{lex.phases} and resolving the
definitions of all translation units\iref{basic.link}.
definitions of all translation units.
\end{defnote}

\definition{required behavior}{defns.required.behavior}
Expand Down
13 changes: 9 additions & 4 deletions source/lex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
\pnum
\indextext{conventions!lexical|(}%
\indextext{compilation!separate|(}%
\indextext{program}%
A \defn{program} consists of one or more translation units\iref{lex.phases}
linked together.
The text of the program is kept in units called
\defnx{source files}{source file} in this document.

\pnum
A source file together with all the headers\iref{headers}
and source files included\iref{cpp.include} via the preprocessing
directive \tcode{\#include}, less any source lines skipped by any of the
Expand All @@ -40,7 +45,7 @@
\begin{note}
A \Cpp{} program need not all be translated at the same time.
Translation units can be separately translated and then later linked
to produce an executable program\iref{basic.link}.
to produce an executable program.
\end{note}
\indextext{compilation!separate|)}

Expand Down Expand Up @@ -174,7 +179,7 @@
Whitespace characters separating tokens are no longer significant.
The resulting tokens constitute a \defn{translation unit} and
are syntactically and
semantically analyzed as a \grammarterm{translation-unit}\iref{basic.link} and
semantically analyzed as a \grammarterm{translation-unit}\iref{module.unit} and
translated.
\begin{note}
The process of analyzing and translating the tokens can occasionally
Expand All @@ -200,8 +205,8 @@
\end{note}
\begin{note}
Previously translated translation 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 or module linkage,
The separate translation units of a program communicate by (for example)
calls to functions whose identifiers have external or module linkage\iref{basic.link},
manipulation of objects whose identifiers have external or module linkage, or
manipulation of data files.
\end{note}
Expand Down
4 changes: 4 additions & 0 deletions source/modules.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
\rSec1[module.unit]{Module units and purviews}

\begin{bnf}
\nontermdef{translation-unit}\br
\opt{declaration-seq}\br
\opt{global-module-fragment} module-declaration \opt{declaration-seq} \opt{private-module-fragment}

\nontermdef{module-declaration}\br
\opt{export-keyword} module-keyword module-name \opt{module-partition} \opt{attribute-specifier-seq} \terminal{;}
\end{bnf}
Expand Down