Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate -Wdeprecated-non-prototype warnings with K&R style function declarations #58181

Closed
gregbedwell opened this issue Oct 6, 2022 · 1 comment
Labels
c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party

Comments

@gregbedwell
Copy link
Collaborator

gregbedwell commented Oct 6, 2022

I was trying to find the source of some duplicate warnings coming out of some open-source test code that we run as part of our CI testing and narrowed it down to the following testcase:

https://godbolt.org/z/Y63Ten1Gn

clang version 16.0.0 (https://github.com/llvm/llvm-project.git c316332e1789221ec26875d1dc335382b6e68d83)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
Compiler returned: 0
static int foo(int x, int y);
static int foo(x, y)
    int x;
    int y;
{
    return x + y;
}

int baz(int a, int b);
int baz(a, b)
    int a;
    int b;
{
    return foo(a, b);
}
<source>:2:12: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
static int foo(x, y)
           ^
<source>:2:12: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
<source>:10:5: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
int baz(a, b)
    ^
3 warnings generated.
Compiler returned: 0

I'm not really very au-fait with pre-ANSI C (I was suprised to find it nestled inside one file in the codebase we were testing) so I'm not sure how correct or otherwise the above code is, but it seems odd to get the identical warning at 2:12 twice regardless. Similarly, I'm not even sure if any of the warnings emitted are actually valid. I could believe it either way.

CC: @AaronBallman as at a guess it may be related to 11da1b5

@gregbedwell gregbedwell added c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels Oct 6, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 6, 2022

@llvm/issue-subscribers-c

@AaronBallman AaronBallman added the confirmed Verified by a second party label Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

3 participants