diff mbox

C++ PATCH for c++/48166 (ICE with invalid function-cv-quals)

Message ID 4D82303A.6010301@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 17, 2011, 4 p.m. UTC
I missed one case where we needed to change cp_type_quals to 
type_memfn_quals.  After that fix we gave the correct error, but still 
ICEd, so to avoid that I go ahead and strip the offending cv-quals.

Tested x86_64-pc-linux-gnu, applying to trunk, will apply to 4.6.1 after 
4.6.0 release.
commit 3ac9d1e0b60a71e6ff154d4c8996ebedb7ba9652
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 17 10:24:48 2011 -0400

    	PR c++/48166
    	* decl.c (revert_static_member_fn): Strip function-cv-quals.
diff mbox

Patch

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a7da574..0985749 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13344,10 +13344,14 @@  static_fn_type (tree memfntype)
 void
 revert_static_member_fn (tree decl)
 {
-  TREE_TYPE (decl) = static_fn_type (decl);
+  tree stype = static_fn_type (decl);
 
-  if (cp_type_quals (TREE_TYPE (decl)) != TYPE_UNQUALIFIED)
-    error ("static member function %q#D declared with type qualifiers", decl);
+  if (type_memfn_quals (stype) != TYPE_UNQUALIFIED)
+    {
+      error ("static member function %q#D declared with type qualifiers", decl);
+      stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED);
+    }
+  TREE_TYPE (decl) = stype;
 
   if (DECL_ARGUMENTS (decl))
     DECL_ARGUMENTS (decl) = DECL_CHAIN (DECL_ARGUMENTS (decl));
diff --git a/gcc/testsuite/g++.dg/parse/memfnquals1.C b/gcc/testsuite/g++.dg/parse/memfnquals1.C
new file mode 100644
index 0000000..ce8af7b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/memfnquals1.C
@@ -0,0 +1,6 @@ 
+// PR c++/48166
+
+struct foo {
+  static void func ();
+};
+void foo::func () const {}	// { dg-error "type qualifiers" }