aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2007-04-29 06:22:14 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2007-04-28 23:22:14 -0700
commit70ec16f7c29de16e0ec824de9a8979ff0a902488 (patch)
tree3840cef2f2e0b838d286f61d057440ec741bbf31 /gcc
parent4f06d65b44483f00dd2397321cf599e4066950c3 (diff)
downloadgcc-70ec16f7c29de16e0ec824de9a8979ff0a902488.zip
gcc-70ec16f7c29de16e0ec824de9a8979ff0a902488.tar.gz
gcc-70ec16f7c29de16e0ec824de9a8979ff0a902488.tar.bz2
re PR c++/30221 (internal compiler error: in reshape_init_r, at cp/decl.c:4632)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c11
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/init/ptrfn2.C14
-rw-r--r--gcc/testsuite/g++.dg/init/ptrfn3.C14
5 files changed, 48 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 11f1396..2a363c4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e75f4fc..31bc8d2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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",
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c064f17..3113b30 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..0ca922b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/ptrfn2.C
@@ -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
index 0000000..9600850
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/ptrfn3.C
@@ -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
+};