aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-01-07 13:00:18 -0500
committerJason Merrill <jason@gcc.gnu.org>2013-01-07 13:00:18 -0500
commite4d7d8cb6990399ee4a83a9a6711374ef6202795 (patch)
tree4eab6b88d3becdcd887ac239524845fd3741e197
parent656e6f3761bb4bfe3efe8279710f5f4b980604fa (diff)
downloadgcc-e4d7d8cb6990399ee4a83a9a6711374ef6202795.zip
gcc-e4d7d8cb6990399ee4a83a9a6711374ef6202795.tar.gz
gcc-e4d7d8cb6990399ee4a83a9a6711374ef6202795.tar.bz2
re PR c++/55753 ([C++11][4.7/4.8 Regression] ICE constexpr ctor, tsubst_copy_and_build, at cp/pt.c:14336)
PR c++/55753 * tree.c (build_aggr_init_expr): Do nothing in a template. * pt.c (tsubst_copy_and_build) [CALL_EXPR]: Strip an ADDR_EXPR off a FUNCTION_DECL before tsubsting. From-SVN: r194986
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/cp/tree.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C15
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1a872ff..74ed223 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2013-01-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/55753
+ * tree.c (build_aggr_init_expr): Do nothing in a template.
+ * pt.c (tsubst_copy_and_build) [CALL_EXPR]: Strip an ADDR_EXPR off
+ a FUNCTION_DECL before tsubsting.
+
2013-01-04 Dodji Seketeli <dodji@redhat.com>
PR c++/52343
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 30bafa0..c55dabe 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13743,6 +13743,11 @@ tsubst_copy_and_build (tree t,
else
qualified_p = false;
+ if (TREE_CODE (function) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
+ /* Avoid error about taking the address of a constructor. */
+ function = TREE_OPERAND (function, 0);
+
function = tsubst_copy_and_build (function, args, complain,
in_decl,
!qualified_p,
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index fcab1a4..0824214 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -412,6 +412,10 @@ build_aggr_init_expr (tree type, tree init)
tree rval;
int is_ctor;
+ /* Don't build AGGR_INIT_EXPR in a template. */
+ if (processing_template_decl)
+ return init;
+
if (TREE_CODE (init) == CALL_EXPR)
fn = CALL_EXPR_FN (init);
else if (TREE_CODE (init) == AGGR_INIT_EXPR)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C
new file mode 100644
index 0000000..ed01a31
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor13.C
@@ -0,0 +1,15 @@
+// PR c++/55753
+// { dg-options -std=c++11 }
+
+struct A
+{
+ double r,i;
+ constexpr A(double r = 0.0, double i = 0.0): r(r), i(i) {}
+};
+
+template <typename Tp>
+struct B {
+ B() {
+ A((true ? 1.0 : A()));
+ }
+};