aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-20 23:23:12 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-20 23:23:12 +0100
commit6a3ebcc6620cc923b8e533d6c2381db8016f3b74 (patch)
treebe39030978dc66e49e9c6ef4d23b198f4d87df4b
parent260a993319bdf4ebc01298b7e802afbd3b35574a (diff)
downloadgcc-6a3ebcc6620cc923b8e533d6c2381db8016f3b74.zip
gcc-6a3ebcc6620cc923b8e533d6c2381db8016f3b74.tar.gz
gcc-6a3ebcc6620cc923b8e533d6c2381db8016f3b74.tar.bz2
re PR c++/88110 (ICE (segfault) with -std=C++2a in cxx_eval_constant_expression when trying to evaluate nonoverridden "virtual ... = 0" function of a base class)
PR c++/88110 * constexpr.c (cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Punt if get_base_address of ADDR_EXPR operand is not a DECL_P. * g++.dg/cpp2a/constexpr-virtual13.C: New test. From-SVN: r266329
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/constexpr.c3
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-virtual13.C20
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f43d9c4..a5ee86e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/88110
+ * constexpr.c (cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Punt
+ if get_base_address of ADDR_EXPR operand is not a DECL_P.
+
2018-11-19 Marek Polacek <polacek@redhat.com>
PR c++/87781 - detect invalid elaborated-type-specifier.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index c9e1e0c..92fd2b2 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4815,7 +4815,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
obj = cxx_eval_constant_expression (ctx, obj, lval, non_constant_p,
overflow_p);
/* We expect something in the form of &x.D.2103.D.2094; get x. */
- if (TREE_CODE (obj) != ADDR_EXPR)
+ if (TREE_CODE (obj) != ADDR_EXPR
+ || !DECL_P (get_base_address (TREE_OPERAND (obj, 0))))
{
if (!ctx->quiet)
error_at (cp_expr_loc_or_loc (t, input_location),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b810f93..9f1edce 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-11-20 Jakub Jelinek <jakub@redhat.com>
+ PR c++/88110
+ * g++.dg/cpp2a/constexpr-virtual13.C: New test.
+
PR tree-optimization/87895
* gcc.dg/gomp/pr87895-1.c: New test.
* gcc.dg/gomp/pr87895-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual13.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual13.C
new file mode 100644
index 0000000..921df9f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual13.C
@@ -0,0 +1,20 @@
+// PR c++/88110
+// { dg-do compile }
+
+struct A {
+ virtual int foo () const = 0;
+};
+struct B {
+ virtual int bar () const = 0;
+ virtual int baz () const = 0;
+};
+struct C : public A { };
+struct D : public C { };
+struct E : public D, public B { };
+
+void
+qux (const E *x)
+{
+ if (x->baz ())
+ ;
+}