<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58181>58181</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Duplicate -Wdeprecated-non-prototype warnings with K&R style function declarations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          gregbedwell
      </td>
    </tr>
</table>

<pre>
    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 11da1b53d8cd3507959022cd790d5a7ad4573d94
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVsuu2zYQ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