aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-01-23 08:54:23 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-01-23 08:54:23 -0500
commit4d0c18c601bafe272e9c5093cfbb15a875710440 (patch)
treeb2c4f66e110254f441660524593bb55d883fddf0 /gcc
parent561fd08128381a5b37569b465f55cb4cac1f3b14 (diff)
downloadgcc-4d0c18c601bafe272e9c5093cfbb15a875710440.zip
gcc-4d0c18c601bafe272e9c5093cfbb15a875710440.tar.gz
gcc-4d0c18c601bafe272e9c5093cfbb15a875710440.tar.bz2
PR c++/87893 - constexpr ctor ICE on ARM.
PR c++/88293 - ICE with comma expression. * constexpr.c (initialized_type): Don't shortcut non-void type. Handle COMPOUND_EXPR. (cxx_eval_outermost_constant_expr): Return early for void type. From-SVN: r268185
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/constexpr.c8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-comma1.C9
3 files changed, 22 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 111782a..20a5471 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2019-01-21 Jason Merrill <jason@redhat.com>
+
+ PR c++/87893 - constexpr ctor ICE on ARM.
+ PR c++/88293 - ICE with comma expression.
+ * constexpr.c (initialized_type): Don't shortcut non-void type.
+ Handle COMPOUND_EXPR.
+ (cxx_eval_outermost_constant_expr): Return early for void type.
+
2019-01-21 Jakub Jelinek <jakub@redhat.com>
PR c++/88949
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ed4bbee..4268141 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2848,9 +2848,7 @@ initialized_type (tree t)
if (TYPE_P (t))
return t;
tree type = TREE_TYPE (t);
- if (!VOID_TYPE_P (type))
- /* No need to look deeper. */;
- else if (TREE_CODE (t) == CALL_EXPR)
+ if (TREE_CODE (t) == CALL_EXPR)
{
/* A constructor call has void type, so we need to look deeper. */
tree fn = get_function_named_in_call (t);
@@ -2858,6 +2856,8 @@ initialized_type (tree t)
&& DECL_CXX_CONSTRUCTOR_P (fn))
type = DECL_CONTEXT (fn);
}
+ else if (TREE_CODE (t) == COMPOUND_EXPR)
+ return initialized_type (TREE_OPERAND (t, 1));
else if (TREE_CODE (t) == AGGR_INIT_EXPR)
type = TREE_TYPE (AGGR_INIT_EXPR_SLOT (t));
return cv_unqualified (type);
@@ -5061,6 +5061,8 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
tree type = initialized_type (t);
tree r = t;
+ if (VOID_TYPE_P (type))
+ return t;
if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
{
/* In C++14 an NSDMI can participate in aggregate initialization,
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-comma1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-comma1.C
new file mode 100644
index 0000000..9dd1299
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-comma1.C
@@ -0,0 +1,9 @@
+// PR c++/88293
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ constexpr A () { }
+};
+
+const A &a = (A (), A ());