From e168a4d6cbb13c40be37eebe1499a25172088429 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 6 Nov 2022 21:19:47 -0600 Subject: [PATCH] Treat static followed by extern declarations as specifying internal linkage. See C17 section 6.2.2 p4-5. --- Symbol.pas | 3 +++ cc.notes | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Symbol.pas b/Symbol.pas index 60ac566..79cd3f2 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -2049,6 +2049,9 @@ if space <> fieldListSpace then begin {are we defining a function?} Error(42) else begin itype := MakeCompositeType(cs^.itype, itype); + if class = externsy then + if cs^.class = staticsy then + class := staticsy; p := cs; needSymbol := false; end; {else} diff --git a/cc.notes b/cc.notes index e849b32..42bad75 100644 --- a/cc.notes +++ b/cc.notes @@ -1966,6 +1966,8 @@ int foo(int[42]); 218. If a function declared within a block had the same name as a variable in an outer scope, the symbol table entry for that variable could be corrupted, leading to spurious errors or incorrect code generation. +219. If a function is first declared as "static" and then subsequently redeclared or defined as "extern" or with no storage-class specifier, it should be private to the source file, the same as if it was just declared "static". + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.