[PATCH] D147888: Update declaration message of extern linkage

Krishna Narayanan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 12:17:27 PDT 2023


Krishna-13-cyber added a comment.

In D147888#4274763 <https://reviews.llvm.org/D147888#4274763>, @cjdb wrote:

> I think we should fundamentally rethink this entire category of diagnostic. Rather than having a static diagnostic per offence stating //what// happened, we should instead have a single diagnostic that captures both what happened, why it's bad, and how to fix it. Something along the lines of
>
>   error: 'x' has been declared with incompatible linkage specifiers (static and extern); please pick exactly one
>     extern int x;
>     ^~~~~~
>   note: previous definition here
>     static int x;
>     ^~~~~~
>
> It'd also be more robust from an engineering perspective, since it means that we won't need to add new diagnostic permutations every time a new linkage specifier is added.



In D147888#4274763 <https://reviews.llvm.org/D147888#4274763>, @cjdb wrote:

> I think we should fundamentally rethink this entire category of diagnostic. Rather than having a static diagnostic per offence stating //what// happened, we should instead have a single diagnostic that captures both what happened, why it's bad, and how to fix it. Something along the lines of
>
>   error: 'x' has been declared with incompatible linkage specifiers (static and extern); please pick exactly one
>     extern int x;
>     ^~~~~~
>   note: previous definition here
>     static int x;
>     ^~~~~~
>
> It'd also be more robust from an engineering perspective, since it means that we won't need to add new diagnostic permutations every time a new linkage specifier is added.

I will try giving this a shot
Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147888/new/

https://reviews.llvm.org/D147888



More information about the cfe-commits mailing list