From 2cadcaadf81b22f4a66f9554ef1e320d159117fa Mon Sep 17 00:00:00 2001 From: Alisdair Meredith Date: Sun, 27 Jul 2025 11:23:47 -0400 Subject: [PATCH] [dcl.inline] inline specifier is for ODR The key use of the inline specifier since C++11, if not before, has been to allow multiple declarations to satisfy the ODR rather than to provide a hint that compilers routinely ignore. This change moves but does not change wording, in order to move the comment making the connection with the ODR more prominent than the normative wording suggestings core transformation. It might be desirable to demote the normative coding hint to a note, but that goes beyond the remit of a simple editorial chsnge. --- source/declarations.tex | 58 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index 341c1bc1f3..f4e36d58b3 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -1090,21 +1090,32 @@ \indextext{specifier!\idxcode{inline}} \pnum +\indextext{specifier!\idxcode{inline}}% +\indextext{inline function}% +\indextext{inline variable}% The \keyword{inline} specifier shall be applied only to the declaration -of a variable or function. +of a function or variable. +The \keyword{inline} specifier shall not appear on a block scope declaration or +on the declaration of a function parameter. +If the \keyword{inline} specifier is used in a friend function declaration, that +declaration shall be a definition or the function shall have previously +been declared inline. \pnum -\indextext{specifier!\idxcode{inline}}% -\indextext{inline function}% A function declaration\iref{dcl.fct,class.mfct,class.friend} with an \keyword{inline} specifier declares an -\defnadj{inline}{function}. The inline specifier indicates to -the implementation that inline substitution of the function body at the -point of call is to be preferred to the usual function call mechanism. -An implementation is not required to perform this inline substitution at -the point of call; however, even if this inline substitution is omitted, -the other rules for inline functions specified in this subclause shall -still be respected. +\defnadj{inline}{function}. +A variable declaration with an \keyword{inline} specifier declares an +\defnadj{inline}{variable}. +\begin{note} +An inline function or variable +with external or module linkage +can be defined in multiple translation units\iref{basic.def.odr}, +but is one entity with one address. +A type or \keyword{static} variable +defined in the body of such a function +is therefore a single entity. +\end{note} \begin{note} The \keyword{inline} keyword has no effect on the linkage of a function. In certain cases, an inline function cannot use names with internal linkage; @@ -1112,15 +1123,13 @@ \end{note} \pnum -A variable declaration with an \keyword{inline} specifier declares an -\defnadj{inline}{variable}. - -\pnum -The \keyword{inline} specifier shall not appear on a block scope declaration or -on the declaration of a function parameter. -If the \keyword{inline} specifier is used in a friend function declaration, that -declaration shall be a definition or the function shall have previously -been declared inline. +The inline specifier indicates to +the implementation that inline substitution of the function body at the +point of call is to be preferred to the usual function call mechanism. +An implementation is not required to perform this inline substitution at +the point of call; however, even if this inline substitution is omitted, +the other rules for inline functions specified in this subclause shall +still be respected. \pnum If a definition of a function or variable is reachable @@ -1136,17 +1145,6 @@ before its definition becomes reachable in a translation unit. \end{note} -\pnum -\begin{note} -An inline function or variable -with external or module linkage -can be defined in multiple translation units\iref{basic.def.odr}, -but is one entity with one address. -A type or \keyword{static} variable -defined in the body of such a function -is therefore a single entity. -\end{note} - \pnum If an inline function or variable that is attached to a named module is declared in a definition domain,