Hi,
adjusting at the same time TREE_TYPE of the already built decl, avoids
ICEing during error recovery in merge_types for this kind of snippet.
Tested x86_64-linux.
Thanks,
Paolo.
////////////////////////////
/cp
2015-10-29 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/67845
* decl.c (grokfndecl): In case of erroneous cv-qualified non-member
functions consistently reset TREE_TYPE (decl) too.
/testsuite
2015-10-29 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/67845
* g++.dg/other/cv_func4.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 229518)
+++ cp/decl.c (working copy)
@@ -7998,6 +7998,11 @@ grokfndecl (tree ctype,
DECL_EXTERNAL (decl) = 1;
if (TREE_CODE (type) == FUNCTION_TYPE)
{
+ if (quals || rqual)
+ TREE_TYPE (decl) = apply_memfn_quals (TREE_TYPE (decl),
+ TYPE_UNQUALIFIED,
+ REF_QUAL_NONE);
+
if (quals)
{
error (ctype
Index: testsuite/g++.dg/other/cv_func4.C
===================================================================
--- testsuite/g++.dg/other/cv_func4.C (revision 0)
+++ testsuite/g++.dg/other/cv_func4.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/67845
+
+typedef void F () const;
+
+F foo; // { dg-error "cv-qualifier" }
+void foo ();