re PR c++/33969 (ICE with const and function pointer)
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Nov 2007 08:10:09 +0000 (09:10 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Nov 2007 08:10:09 +0000 (09:10 +0100)
PR c++/33969
* decl.c (grokdeclarator): Don't call build_memfn_type if type
is neither FUNCTION_TYPE nor METHOD_TYPE.

* g++.dg/other/ptrmem9.C: New test.

From-SVN: r129895

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/ptrmem9.C [new file with mode: 0644]

index 1acce719f7b829590689af6fa644f3def8b5c110..5eb1dcebedb771a997da507b3c35e63f91beeb03 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33969
+       * decl.c (grokdeclarator): Don't call build_memfn_type if type
+       is neither FUNCTION_TYPE nor METHOD_TYPE.
+
 2007-11-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/33516
index 9bab97b34a4a5e0bea4731e680841e0253bbd62c..990d943ecca69df810e99760723fa39ba49ebfac 100644 (file)
@@ -8153,7 +8153,8 @@ grokdeclarator (const cp_declarator *declarator,
          type_quals = TYPE_UNQUALIFIED;
 
          if (declarator->kind == cdk_ptrmem
-             && (TREE_CODE (type) == FUNCTION_TYPE || memfn_quals))
+             && (TREE_CODE (type) == FUNCTION_TYPE
+                 || (memfn_quals && TREE_CODE (type) == METHOD_TYPE)))
            {
              memfn_quals |= cp_type_quals (type);
              type = build_memfn_type (type,
index 3c20102a8c61ee1b70320c6a97729c2368421db5..3e6d7441a22066713a94869afff5387ce9861299 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33969
+       * g++.dg/other/ptrmem9.C: New test.
+
 2007-11-04  Andrew Pinski  <pinskia@gmail.com>
 
        PR middle-end/32931
diff --git a/gcc/testsuite/g++.dg/other/ptrmem9.C b/gcc/testsuite/g++.dg/other/ptrmem9.C
new file mode 100644 (file)
index 0000000..c4d3656
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/33969
+// { dg-do compile }
+
+struct A;
+void (*A::* fp)() const; // { dg-error "invalid in variable declaration" }