Skip to content

Commit 7218980

Browse files
Dawn Perchikzygoloid
authored andcommitted
CWG2372 Incorrect matching rules for block-scope extern declarations
1 parent f6ff9bc commit 7218980

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/basic.tex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,8 +2440,12 @@
24402440
\pnum
24412441
The name of a function declared in block scope and the name of a variable declared by a
24422442
block scope \tcode{extern} declaration have linkage. If there is a visible declaration
2443-
of an entity with linkage having the same name and type, ignoring entities declared
2444-
outside the innermost enclosing namespace scope, the block scope declaration declares
2443+
of an entity with linkage, ignoring entities declared
2444+
outside the innermost enclosing namespace scope,
2445+
such that the block scope declaration would be
2446+
a (possibly ill-formed) redeclaration
2447+
if the two declarations appeared in the same declarative region,
2448+
the block scope declaration declares
24452449
that same entity and receives the linkage of the previous declaration. If there is more
24462450
than one such matching entity, the program is ill-formed. Otherwise, if no matching
24472451
entity is found, the block scope entity receives external linkage.
@@ -2450,9 +2454,11 @@
24502454
\begin{example}
24512455
\begin{codeblock}
24522456
static void f();
2457+
extern "C" void h();
24532458
static int i = 0; // \#1
24542459
void g() {
24552460
extern void f(); // internal linkage
2461+
extern void h(); // C language linkage
24562462
int i; // \#2: \tcode{i} has no linkage
24572463
{
24582464
extern void f(); // internal linkage

0 commit comments

Comments
 (0)