[PATCH] D33841: [clang-tidy] redundant keyword check
Daniel Kolozsvari via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 5 12:15:17 PDT 2019
koldaniel marked an inline comment as done.
koldaniel added inline comments.
================
Comment at: test/clang-tidy/readability-redundant-extern.cpp:37
+
+void another_file_scope(int _extern);
----------------
aaron.ballman wrote:
> More tests that I figured out:
> ```
> namespace {
> extern void f(); // 'extern' is not redundant
> }
>
> namespace a {
> namespace {
> namespace b {
> extern void f(); // 'extern' is not redundant
> }
> }
> }
>
> // Note, the above are consequences of http://eel.is/c++draft/basic.link#6
>
> #define FOO_EXTERN extern
> typedef int extern_int;
>
> extern_int FOO_EXTERN foo(); // 'extern' is redundant, but hopefully we don't try to fixit this to be '_int FOO_EXTERN foo();'
>
> // The above is a weird consequence of how specifiers are parsed in C and C++
> ```
In the first two examples extern is redundant:
"An unnamed namespace or a namespace declared directly or indirectly within an unnamed namespace has internal linkage. All other namespaces have external linkage."
Also, based on the examples in http://eel.is/c++draft/basic.link#8 , the extern keyword has no effect in case of unnamed namespaces. In case of 'C' linkage defined by an extern keyword the checker does not warn.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D33841/new/
https://reviews.llvm.org/D33841
More information about the llvm-commits
mailing list