[llvm-bugs] [Bug 41851] -Wstrict-prototypes doesn't seem to warn on definitions

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 16 10:20:04 PDT 2020


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

Aaron Puchert <aaronpuchert at alice-dsl.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Fixed By Commit(s)|                            |2f26bc5542705c390bf17af2fdf
                   |                            |c31e056147ea9
           Assignee|unassignedclangbugs at nondot. |aaronpuchert at alice-dsl.net
                   |org                         |
           Hardware|PC                          |All
         Resolution|INVALID                     |FIXED
                 CC|                            |aaronpuchert at alice-dsl.net
                 OS|Windows NT                  |All

--- Comment #2 from Aaron Puchert <aaronpuchert at alice-dsl.net> ---
(In reply to Richard Smith from comment #1)
> GCC is wrong. The definitions of g, h, and i are not unprototyped functions.
> [...]
> void f(); // unprototyped
> void g() {} // equivalent to 'void g(void) {}'
We discussed this in IRC afterwards, and it turns out the standard is not
terribly explicit, but GCC is probably right that g is not a prototype, and
that "void g() {}" is not equivalent to "void g(void) {}". In 6.9.1p7:

"If the declarator includes a parameter type list, the list also specifies the
types of all the parameters; such a declarator also serves as a function
prototype for later calls to the same function in the same translation unit."

This refers to 6.7.6.3p5: "If, in the declaration “T D1”, D1 has
the form

    D(parameter-type-list)

or

    D(identifier-list_opt)

[...]". Later in 6.11.7 it also refers only to the parameter-type-list
variant as prototype: "The use of function definitions with separate
parameter identifier and declaration lists (not prototype-format
parameter type and identifier declarators) is an obsolescent feature."

And if you look at the grammar you'll find that an empty list cannot be a
parameter-type-list:

parameter-type-list:
    parameter-list
    parameter-list , ...
parameter-list:
    parameter-declaration
    parameter-list , parameter-declaration
parameter-declaration:
    declaration-specifiers declarator
    declaration-specifiers abstract-declarator_opt

So I fixed this in https://reviews.llvm.org/D66919, which is going to be in
Clang 11.

-- 
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/20200816/c9f07c20/attachment.html>


More information about the llvm-bugs mailing list