re PR c++/30221 (internal compiler error: in reshape_init_r, at cp/decl.c:4632)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Sun, 29 Apr 2007 06:22:14 +0000 (06:22 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 29 Apr 2007 06:22:14 +0000 (23:22 -0700)
2007-04-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/30221
        * decl.c (reshape_init_r): Don't reshape the first element if it
        is a pointer to member function.

2007-04-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/30221
        * g++.dg/init/ptrfn2.C: New test.
        * g++.dg/init/ptrfn3.C: New test.

From-SVN: r124271

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

index 11f1396b71f5f8b798354b57e57e1063527e6098..2a363c47923d3051173d78c4eb7b43f4a2496da7 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/30221
+       * decl.c (reshape_init_r): Don't reshape the first element if it
+       is a pointer to member function.
+
 2007-04-27  Simon Baldwin  <simonb@google.com>
 
        * decl.c (grokparms): Changed message format from %qD to %qE.
index e75f4fc9da00fd83128de822c14d6f922b019627..31bc8d2649e42215513cef1572b5be2166802b05 100644 (file)
@@ -4638,19 +4638,24 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p)
     {
       if (TREE_CODE (init) == CONSTRUCTOR)
        {
+         if (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))
+           /* There is no need to reshape pointer-to-member function
+              initializers, as they are always constructed correctly
+              by the front end.  */
+           ;
+         else if (COMPOUND_LITERAL_P (init))
          /* For a nested compound literal, there is no need to reshape since
             brace elision is not allowed. Even if we decided to allow it,
             we should add a call to reshape_init in finish_compound_literal,
             before calling digest_init, so changing this code would still
             not be necessary.  */
-         if (!COMPOUND_LITERAL_P (init))
+           gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (init));
+         else
            {
              ++d->cur;
              gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));
              return reshape_init (type, init);
            }
-         else
-           gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (init));
        }
 
       warning (OPT_Wmissing_braces, "missing braces around initializer for %qT",
index c064f174fc5b9cb8f0aba85ccdced392912ece98..3113b303265c09e9c03bc68b2569475591ca1fdc 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/30221
+       * g++.dg/init/ptrfn2.C: New test.
+       * g++.dg/init/ptrfn3.C: New test.
+
 2007-04-29  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/31711
diff --git a/gcc/testsuite/g++.dg/init/ptrfn2.C b/gcc/testsuite/g++.dg/init/ptrfn2.C
new file mode 100644 (file)
index 0000000..0ca922b
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-options "" }
+// { dg-do compile }
+// C++/30221
+// We would ICE while trying to reshape the pointer to
+// member function element which is not needed.
+
+
+class abstract {};
+typedef void (abstract::*fptr1) (short & s ) const;
+struct s {};
+s array[] =
+{
+ (fptr1)0 
+};// { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/init/ptrfn3.C b/gcc/testsuite/g++.dg/init/ptrfn3.C
new file mode 100644 (file)
index 0000000..9600850
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-options "" }
+// { dg-do compile }
+// C++/30221
+// We would ICE while trying to reshape the pointer to
+// member function element which is not needed.
+
+
+class abstract {};
+typedef void (abstract::*fptr1) (short & s ) const;
+struct s {fptr1 f;};
+s array[] =
+{
+ (fptr1)0
+};