When compiling with -Wshadow=global on GCC 7.3 and 8.2, the compiler warns that the following code snippet shadows.
constexpr int A = 0;
class Bar {
public:
enum Bars {
A = 0
};
};
enum class Foo {
A = 0 // warns this entry shadows global declaration of A
};
int main() {
return 0;
}
<source>:11:9: warning: declaration of 'A' shadows a global declaration [-Wshadow]
A = 0
^
<source>:1:15: note: shadowed declaration is here
constexpr int A = 0;
^
Because enum classes require the enum class name when referenced, my understanding is that all three declarations of A are separate: ::A, ::Bar::A, and ::Foo::A.
Clang 7 doesn't emit a warning with -Wshadow.
Is this a valid shadow warning, and if so, why?