[llvm-bugs] [Bug 36584] Regression(r313729): Invalid -Wunused-function warning

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 8 15:21:26 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36584

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |richard-llvm at metafoo.co.uk
             Status|NEW                         |RESOLVED

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
The warning is correct.

The typedef does not establish a "typedef name for linkage" for the type
"Type", because it is a typedef for "const struct {...}", not a typedef for
"struct {...}". So the type Type has no linkage.

As a consequence, the function Function has no linkage. An identical
declaration in a different source file would declare a different function.

So, this matches the criteria we currently use for the -Wunused-function
warning: the function is local to this file, is not used nor marked
__attribute__((unused)), and its declaration does not have side-effects.


We previously got the linkage for `Function` wrong:

https://godbolt.org/g/4XaEri

Note that GCC and Clang 6 onwards agree that Function has internal linkage.
Clang <= 5 and EDG incorrectly give it external linkage.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180308/d8857452/attachment.html>


More information about the llvm-bugs mailing list