diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-06-17 20:26:13 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-06-17 20:26:13 +0100 |
commit | d392babbeb6cb531ab8b1ec68fde9ffd36373a6e (patch) | |
tree | 0fb1a2e97e30225aa4f459becebb527897e80e2b /gcc/cp | |
parent | 4a31a8add56d49867c187d90b3a89e97634543c2 (diff) | |
download | gcc-d392babbeb6cb531ab8b1ec68fde9ffd36373a6e.zip gcc-d392babbeb6cb531ab8b1ec68fde9ffd36373a6e.tar.gz gcc-d392babbeb6cb531ab8b1ec68fde9ffd36373a6e.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/parser.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 69839ba..815582c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -18953,7 +18953,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, here. */ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON) - && !is_friend && !processing_explicit_instantiation) + && !is_friend && is_declaration + && !processing_explicit_instantiation) warning (0, "declaration %qD does not declare anything", decl); type = TREE_TYPE (decl); |