Skip to content

Commit 8fbeb52

Browse files
committed
[basic.link] The notion of the linkage of a type is no longer used for
any purpose. Remove it and move its example next to the rule that justifies it, and simplify said example.
1 parent cafdbd8 commit 8fbeb52

File tree

2 files changed

+18
-53
lines changed

2 files changed

+18
-53
lines changed

source/basic.tex

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,21 @@
445445
\ref{class.dtor}, and \ref{class.copy.assign}).
446446
An inline function or variable shall be defined in every
447447
translation unit in which it is odr-used outside of a discarded statement.
448+
\begin{example}
449+
\begin{codeblock}
450+
auto f() {
451+
struct A {};
452+
return A{};
453+
}
454+
decltype(f()) g();
455+
auto x = g();
456+
\end{codeblock}
457+
A program containing this translation unit is ill-formed
458+
because \tcode{g} is odr-used but not defined,
459+
and cannot be defined in any other translation unit
460+
because the local class \tcode{A} cannot be named outside this
461+
translation unit.
462+
\end{example}
448463

449464
\pnum
450465
\indextext{type!incomplete}%
@@ -2456,56 +2471,6 @@
24562471
noted, a name declared at block scope\iref{basic.scope.block} has no
24572472
linkage.
24582473

2459-
\pnum
2460-
A type is said to have linkage if and only if:
2461-
\begin{itemize}
2462-
\item it is a class or enumeration type that is named (or has a name for
2463-
linkage purposes\iref{dcl.typedef}) and the name has linkage; or
2464-
2465-
\item it is an unnamed class or unnamed enumeration that is a member of a class
2466-
with linkage; or
2467-
2468-
\item it is a specialization of a class template\iref{temp}\footnote{A class
2469-
template has the linkage of the innermost enclosing class or namespace in which
2470-
it is declared.};
2471-
or
2472-
2473-
\item it is a fundamental type\iref{basic.fundamental}; or
2474-
2475-
\item it is a compound type\iref{basic.compound} other than a class or
2476-
enumeration, compounded exclusively from types that have linkage; or
2477-
2478-
\item it is a cv-qualified\iref{basic.type.qualifier} version of a
2479-
type that has linkage.
2480-
\end{itemize}
2481-
\begin{note}
2482-
In other words, a type without linkage contains a class or enumeration that
2483-
cannot be named outside its translation unit.
2484-
Classes with linkage may contain members
2485-
whose types do not have linkage.
2486-
Typedef names are ignored in the determination
2487-
of whether a type has linkage.
2488-
\end{note}
2489-
2490-
\begin{example}
2491-
\begin{codeblock}
2492-
template <class T> struct B {
2493-
void g(T) { }
2494-
void h(T);
2495-
friend void i(B, T) { }
2496-
};
2497-
2498-
void f() {
2499-
struct A { int x; }; // no linkage
2500-
A a = { 1 };
2501-
B<A> ba; // declares \tcode{B<A>::g(A)} and \tcode{B<A>::h(A)}
2502-
ba.g(a); // OK
2503-
ba.h(a); // error: \tcode{B<A>::h(A)} not defined; \tcode{A} cannot be named in another translation unit
2504-
i(ba, a); // OK
2505-
}
2506-
\end{codeblock}
2507-
\end{example}
2508-
25092474
\pnum
25102475
Two names that are the same\iref{basic} and that are declared
25112476
in different scopes shall denote the same variable, function,

source/classes.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@
854854
declaration in the class definition or its definition outside of the
855855
class definition declares the function as \tcode{inline} or \tcode{constexpr}.
856856
\begin{note}
857-
Member functions of a class in namespace scope have the linkage of that class.
858-
Member functions of a local class\iref{class.local} have no linkage.
857+
Member functions of a class have the linkage of the name of the class.
859858
See~\ref{basic.link}.
860859
\end{note}
861860

@@ -2846,7 +2845,8 @@
28462845

28472846
\pnum
28482847
\begin{note}
2849-
Static data members of a class in namespace scope have the linkage of that class\iref{basic.link}. A local class cannot have static data members\iref{class.local}.
2848+
Static data members of a class in namespace scope have the linkage of the name of the class\iref{basic.link}.
2849+
A local class cannot have static data members\iref{class.local}.
28502850
\end{note}
28512851

28522852
\pnum

0 commit comments

Comments
 (0)