Skip to content

[DO NOT MERGE] Reorder core basics #7153

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

Closed
wants to merge 10 commits into from
Closed
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
103 changes: 38 additions & 65 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,22 @@
\indextext{storage class}%
\indextext{scope}%
\indextext{linkage}%
An \defn{entity} is a value, object, reference,
structured binding,
function, enumerator, type,
class member, bit-field, template, template specialization, namespace, or
pack.

\pnum
A \defn{name} is an \grammarterm{identifier}\iref{lex.name},
\grammarterm{operator-function-id}\iref{over.oper},
\grammarterm{literal-operator-id}\iref{over.literal}, or
\grammarterm{conversion-function-id}\iref{class.conv.fct}.

\pnum
Two names are \defnx{the same}{name!same} if
\begin{itemize}
\item they are \grammarterm{identifier}{s} composed of the same character sequence, or
\item they are \grammarterm{operator-function-id}{s} formed with the same operator, or
\item they are \grammarterm{literal-operator-id}{s} formed with the same
literal suffix identifier, or
\item they are \grammarterm{conversion-function-id}{s} formed with
equivalent\iref{temp.over.link} types.
\end{itemize}

\pnum
Every name is introduced by a \defn{declaration}, which is a
\begin{itemize}
Expand Down Expand Up @@ -85,42 +89,34 @@
The interpretation of a \grammarterm{for-range-declaration} produces
one or more of the above\iref{stmt.ranged}.
\end{note}
An entity $E$ is denoted by the name (if any)
that is introduced by a declaration of $E$ or
by a \grammarterm{typedef-name} introduced by a declaration specifying $E$.

\pnum
Some names denote types or templates. In general, whenever a name is
encountered it is necessary to determine whether that name denotes one of these
entities before continuing to parse the program that contains it. The process
that determines this is called
\defnx{name lookup}{lookup!name}\iref{basic.lookup}.

\pnum
A \defn{variable} is introduced by the
declaration of
a reference other than a non-static data member or of
an object. The variable's name, if any, denotes the reference or object.

\pnum
An \defn{entity} is a value, object, reference, structured binding, function,
enumerator, type, class member, bit-field, template, template specialization,
namespace, or pack. An entity $E$ is denoted by the name (if any) that is
introduced by a declaration of $E$ or by a \grammarterm{typedef-name}
introduced by a declaration specifying $E$.

\pnum
A \defnadj{local}{entity} is a variable with
automatic storage duration\iref{basic.stc.auto},
a structured binding\iref{dcl.struct.bind}
whose corresponding variable is such an entity,
or the \tcode{*\keyword{this}} object\iref{expr.prim.this}.

\pnum
Some names denote types or templates. In general,
whenever a name is encountered it is necessary to determine whether that name denotes
one of these entities before continuing to parse the program that contains it. The
process that determines this is called
\defnx{name lookup}{lookup!name}\iref{basic.lookup}.

\pnum
Two names are \defnx{the same}{name!same} if
\begin{itemize}
\item they are \grammarterm{identifier}{s} composed of the same character sequence, or
\item they are \grammarterm{operator-function-id}{s} formed with
the same operator, or
\item they are \grammarterm{conversion-function-id}{s} formed
with equivalent\iref{temp.over.link} types, or
\item they are \grammarterm{literal-operator-id}{s}\iref{over.literal} formed with
the same literal suffix identifier.
\end{itemize}

\pnum
\indextext{translation unit!name and}%
\indextext{linkage}%
Expand Down Expand Up @@ -2647,45 +2643,22 @@
only namespace names are considered.%
\indextext{lookup!name|)}%

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

\pnum
\indextext{program}%
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 is said to have \defn{linkage} when it can denote the same
object, reference, function, type, template, namespace or value as a
name introduced by a declaration in another scope:
\begin{itemize}
\item When a name has \defnadj{external}{linkage},
the entity it denotes
can be referred to by names from scopes of other translation units or
from other scopes of the same translation unit.

\item When a name has \defnx{module linkage}{linkage!module},
the entity it denotes
can be referred to by names from other scopes of the same module unit\iref{module.unit} or
from scopes of other module units of that same module.

\item When a name has \defnadj{internal}{linkage},
the entity it denotes
can be referred to by names from other scopes in the same translation
unit.

\item When a name has \indextext{linkage!no}\defn{no linkage}, the entity it denotes
cannot be referred to by names from other scopes.
\end{itemize}
A name can have
\defnadj{external}{linkage},
\defnadj{module}{linkage},
\defnadj{internal}{linkage}, or
\defnadj{no}{linkage},
as determined by the rules below.
\begin{note}
All declarations of an entity with a name with internal linkage
appear in the same translation unit.
All declarations of an entity with module linkage
are attached to the same module.
\end{note}

\pnum
\indextext{linkage!\idxcode{static} and}%
Expand Down
36 changes: 18 additions & 18 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,24 @@
Programs that have a legitimate reason to treat string literal objects
as potentially modifiable memory are probably rare.

\rSec2[diff.cpp]{\ref{cpp}: preprocessing directives}

\diffref{cpp.predefined}
\change
Whether \mname{STDC} is defined and if so, what its value is, are
\impldef{definition and meaning of \mname{STDC}}.
\rationale
\Cpp{} is not identical to C\@.
Mandating that \mname{STDC}
be defined would require that translators make an incorrect claim.
\effect
Change to semantics of well-defined feature.
\difficulty
Semantic transformation.
\howwide
Programs and headers that reference \mname{STDC} are
quite common.

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

\diffref{basic.def}
Expand Down Expand Up @@ -3370,24 +3388,6 @@
\howwide
Seldom.

\rSec2[diff.cpp]{\ref{cpp}: preprocessing directives}

\diffref{cpp.predefined}
\change
Whether \mname{STDC} is defined and if so, what its value is, are
\impldef{definition and meaning of \mname{STDC}}.
\rationale
\Cpp{} is not identical to C\@.
Mandating that \mname{STDC}
be defined would require that translators make an incorrect claim.
\effect
Change to semantics of well-defined feature.
\difficulty
Semantic transformation.
\howwide
Programs and headers that reference \mname{STDC} are
quite common.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\rSec1[diff.library]{C standard library}

Expand Down
4 changes: 4 additions & 0 deletions source/config.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
%% Release date
\newcommand{\reldate}{\today}

%% Core chapters
\newcommand{\firstcorechapter}{lex}
\newcommand{\lastcorechapter}{except}

%% Library chapters
\newcommand{\firstlibchapter}{support}
\newcommand{\lastlibchapter}{thread}
2 changes: 1 addition & 1 deletion source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7524,7 +7524,7 @@

\item
an operation that would have undefined or erroneous behavior
as specified in \ref{intro} through \ref{cpp},
as specified in \ref{intro} through \ref{\lastcorechapter},
excluding \ref{dcl.attr.assume} and \ref{dcl.attr.noreturn};
\begin{footnote}
This includes,
Expand Down
15 changes: 8 additions & 7 deletions source/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
Implementations are allowed, but not required,
to diagnose it\iref{intro.compliance.general}.
Evaluation of a constant expression\iref{expr.const}
never exhibits behavior specified as erroneous in \ref{intro} through \ref{cpp}.
never exhibits behavior specified as erroneous in \ref{intro} through \ref{\lastcorechapter}.
\end{defnote}

\definition{expression-equivalent}{defns.expression.equivalent}
Expand Down Expand Up @@ -644,7 +644,7 @@
issuance of a diagnostic message). Many incorrect program constructs do
not engender undefined behavior; they are required to be diagnosed.
Evaluation of a constant expression\iref{expr.const} never exhibits behavior explicitly
specified as undefined in \ref{intro} through \ref{cpp}.
specified as undefined in \ref{intro} through \ref{\lastcorechapter}.
\end{defnote}

\indexdefn{behavior!unspecified}%
Expand Down Expand Up @@ -722,7 +722,8 @@
\begin{itemize}
\item
If a program contains no violations of the rules in
\ref{lex} through \ref{\lastlibchapter} as well as those specified in \ref{depr},
\ref{\firstcorechapter} through \ref{\lastlibchapter} as well as those
specified in \ref{depr},
a conforming implementation shall,
in accordance with the resource limits specified in \ref{implimits},
accept and correctly execute
Expand Down Expand Up @@ -787,7 +788,7 @@
consistent with the descriptions in the library Clauses.

\pnum
A \Cpp{} translation unit\iref{lex.phases}
A \Cpp{} translation unit\iref{lex.phase.7,module.unit}
obtains access to the names defined in the library by
including the appropriate standard library header or importing
the appropriate standard library named header unit\iref{using.headers}.
Expand All @@ -796,7 +797,7 @@
The templates, classes, functions, and objects in the library have
external linkage\iref{basic.link}. The implementation provides
definitions for standard library entities, as necessary, while combining
translation units to form a complete \Cpp{} program\iref{lex.phases}.%
translation units to form a complete \Cpp{} program\iref{lex.phase.9}.%
\indextext{conformance requirements!library|)}

\pnum
Expand All @@ -809,7 +810,7 @@
supports all the facilities described in this document, while
a freestanding implementation
supports the entire \Cpp{} language
described in \ref{lex} through \ref{cpp} and
described in \ref{\firstcorechapter} through \ref{\lastcorechapter} and
the subset of the library facilities described in \ref{compliance}.

\pnum
Expand Down Expand Up @@ -952,7 +953,7 @@
\pnum
\indextext{standard!structure of|(}%
\indextext{standard!structure of}%
\ref{lex} through \ref{cpp} describe the \Cpp{} programming
\ref{\firstcorechapter} through \ref{\lastlibchapter} describe the \Cpp{} programming
language. That description includes detailed syntactic specifications in
a form described in~\ref{syntax}. For convenience, \ref{gram}
repeats all such syntactic specifications.
Expand Down
Loading