On Thu, May 21, 2020 at 2:58 PM Martin Liška <mli...@suse.cz> wrote:
> On 5/21/20 8:52 PM, Jason Merrill wrote: > > Was there a decision somewhere to require ChangeLog entries for all > testcase changes now, as the hook is enforcing? They were optional before. > > Right now we ignore newly added test-case, these don't have to be > mentioned. > Can you please attach the patch (git format-patch)? > > Are you talking about modified or delete test-cases? If so, we can > definitely > relax the rules.. > Modified. Adjustments to expected errors in testcases don't seem to me worth documenting in a ChangeLog.
From c5a15303c57171b5b284b7a8ec0eb97f991779d6 Mon Sep 17 00:00:00 2001 From: Jason Merrill <ja...@redhat.com> Date: Thu, 21 May 2020 10:27:11 -0400 Subject: [PATCH 1/4] c++: Improve error-recovery for parms. To: gcc-patches@gcc.gnu.org If a parameter is erroneous, we currently drop it, leading to "too many arguments" errors later. Treating the function as (...) avoids those errors. gcc/cp/ChangeLog 2020-05-21 Jason Merrill <ja...@redhat.com> * decl.c (grokparms): Return NULL_TREE if any parms were erroneous. --- gcc/cp/decl.c | 18 +++++++++++++----- gcc/testsuite/g++.dg/parse/error33.C | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 024ddc88a4c..a389579ee52 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13961,7 +13961,10 @@ grokparms (tree parmlist, tree *parms) break; if (! decl || TREE_TYPE (decl) == error_mark_node) - continue; + { + any_error = 1; + continue; + } type = TREE_TYPE (decl); if (VOID_TYPE_P (type)) @@ -14014,7 +14017,8 @@ grokparms (tree parmlist, tree *parms) TREE_TYPE (decl) = type; } else if (abstract_virtuals_error (decl, type)) - any_error = 1; /* Seems like a good idea. */ + /* Ignore any default argument. */ + init = NULL_TREE; else if (cxx_dialect < cxx17 && INDIRECT_TYPE_P (type)) { /* Before C++17 DR 393: @@ -14043,9 +14047,7 @@ grokparms (tree parmlist, tree *parms) decl, t); } - if (any_error) - init = NULL_TREE; - else if (init && !processing_template_decl) + if (init && !processing_template_decl) init = check_default_argument (decl, init, tf_warning_or_error); } @@ -14058,6 +14060,12 @@ grokparms (tree parmlist, tree *parms) if (parm) result = chainon (result, void_list_node); *parms = decls; + if (any_error) + result = NULL_TREE; + + if (any_error) + /* We had parm errors, recover by giving the function (...) type. */ + result = NULL_TREE; return result; } diff --git a/gcc/testsuite/g++.dg/parse/error33.C b/gcc/testsuite/g++.dg/parse/error33.C index 0d25386a879..61b0cc3f2dc 100644 --- a/gcc/testsuite/g++.dg/parse/error33.C +++ b/gcc/testsuite/g++.dg/parse/error33.C @@ -8,9 +8,9 @@ struct A typedef void (A::T)(); /* { dg-error "15:typedef name may not be a nested" } */ -void bar(T); /* { dg-message "note: declared here" } */ +void bar(T); void baz() { - bar(&A::foo); /* { dg-error "too many arguments" } */ + bar(&A::foo); } -- 2.18.1