From 79cd6c7b905ca9390bc1e7c87c259a5a18cefa81 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 21 Oct 2019 19:29:41 +0000 Subject: [PATCH] parser.c (cp_parser_class_head): Improve error recovery upon extra qualification error. /cp 2019-10-21 Paolo Carlini * parser.c (cp_parser_class_head): Improve error recovery upon extra qualification error. /testsuite 2019-10-21 Paolo Carlini * g++.dg/parse/qualified2.C: Tighten dg-error directive. * g++.old-deja/g++.other/decl5.C: Don't expect redundant error. From-SVN: r277268 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 8 ++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/qualified2.C | 2 +- gcc/testsuite/g++.old-deja/g++.other/decl5.C | 7 +++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 593510ffbf3..19a687a4b79 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-10-21 Paolo Carlini + + * parser.c (cp_parser_class_head): Improve error recovery upon + extra qualification error. + 2019-10-21 Jakub Jelinek PR c++/92015 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 450b1447cc1..6433f870b2e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24178,12 +24178,8 @@ cp_parser_class_head (cp_parser* parser, ... [or] the definition or explicit instantiation of a class member of a namespace outside of its namespace. */ if (scope == nested_name_specifier) - { - permerror (nested_name_specifier_token_start->location, - "extra qualification not allowed"); - nested_name_specifier = NULL_TREE; - num_templates = 0; - } + permerror (nested_name_specifier_token_start->location, + "extra qualification not allowed"); } /* An explicit-specialization must be preceded by "template <>". If it is not, try to recover gracefully. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f4e6c5c880..5aec5cd817a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-21 Paolo Carlini + + * g++.dg/parse/qualified2.C: Tighten dg-error directive. + * g++.old-deja/g++.other/decl5.C: Don't expect redundant error. + 2019-10-21 Jakub Jelinek PR c++/92015 diff --git a/gcc/testsuite/g++.dg/parse/qualified2.C b/gcc/testsuite/g++.dg/parse/qualified2.C index c582613c953..ef1bedb08ec 100644 --- a/gcc/testsuite/g++.dg/parse/qualified2.C +++ b/gcc/testsuite/g++.dg/parse/qualified2.C @@ -1,4 +1,4 @@ namespace Glib { template class Value {}; - template <> class Glib::Value {}; // { dg-error "" } + template <> class Glib::Value {}; // { dg-error "29:extra qualification" } } diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl5.C b/gcc/testsuite/g++.old-deja/g++.other/decl5.C index 6d229325187..26556aaa7ef 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/decl5.C +++ b/gcc/testsuite/g++.old-deja/g++.other/decl5.C @@ -8,11 +8,10 @@ struct A { - int A::fn(); // { dg-error "extra qualification" } - int A::m; // { dg-error "extra qualification" } + int A::fn(); // { dg-error "7:extra qualification" } + int A::m; // { dg-error "7:extra qualification" } struct e; - struct A::e {int i;}; // { dg-error "extra qualification" "qual" } - // { dg-error "anonymous struct" "anon" { target *-*-* } .-1 } + struct A::e {int i;}; // { dg-error "10:extra qualification" "qual" } struct A::expand { // { dg-error "qualified name" } int m; }; -- 2.30.2