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

    <tr>
        <th>Summary</th>
        <td>
            clang's -Wdeprecated-non-prototype warning points at the wrong line
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    clang's `-Wdeprecated-non-prototype` warning can warn about a conflict between a function declaration and the definition of the same function. That's good.

When warning about a conflict, using the current style with "warning: ..." and "note: ...", one of the two lines must be mentioned in the "warning", and the other one in the "note".

Unfortunately, clang's choice to put the function declaration in the "warning" line and the function definition in the "note" line has a silly effect: The same header file, included by two different compilation units, shows a warning in one compilation unit but not in the other compilation unit.

How to reproduce (with clang 15.0.6):
Put this in foo.h:
```
void func3 ();
```
Put this in foo1.c:
```
#include "foo.h"
void func3 (int x, int y) {}
```
Put this in foo2.c:
```
#include "foo.h"
```
Compile foo1.c and foo2.c:
```
$ clang -S -Wdeprecated-non-prototype foo1.c
In file included from foo1.c:1:
./foo.h:1:6: warning: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C2x, conflicting with a subsequent definition [-Wdeprecated-non-prototype]
void func3 ();
     ^
foo1.c:2:6: note: conflicting prototype is here
void func3 (int x, int y) {}
     ^
1 warning generated.
$ clang -S -Wdeprecated-non-prototype foo2.c
```

Suggested fix:
```
$ clang -S -Wdeprecated-non-prototype foo1.c
foo1.c:2:6: warning: function definition conflicts with previous non-prototype declaration that will be treated like a zero-parameter prototype in C2x [-Wdeprecated-non-prototype]
void func3 (int x, int y) {}
     ^
In file included from foo1.c:1:
./foo.h:1:6: note: conflicting function declaration is here
void func3 ();
     ^
1 warning generated.
```

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