c++: Fix bogus "does not declare anything" warning (PR 66159)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 17 Jun 2020 19:26:13 +0000 (20:26 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 17 Jun 2020 19:26:13 +0000 (20:26 +0100)
commitd392babbeb6cb531ab8b1ec68fde9ffd36373a6e
tree0fb1a2e97e30225aa4f459becebb527897e80e2b
parent4a31a8add56d49867c187d90b3a89e97634543c2
c++: Fix bogus "does not declare anything" warning (PR 66159)

G++ gives a bogus warning for 'struct A; using B = struct ::A;'
complaining that the elaborated-type-specifier doesn't declare anything.
That's true, but it's not trying to declare struct ::A, just refer to it
unambiguously. Do not emit the warning unless we're actually parsing a
declaration.

gcc/cp/ChangeLog:

PR c++/66159
* parser.c (cp_parser_elaborated_type_specifier): Do not warn
unless in a declaration.

gcc/testsuite/ChangeLog:

PR c++/66159
* g++.dg/warn/forward-inner.C: Check alias-declaration using
elaborated-type-specifier.
gcc/cp/parser.c
gcc/testsuite/g++.dg/warn/forward-inner.C