8sa1-gcc/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual10.C
Jakub Jelinek 69deaf149a re PR c++/87398 (g++ ICE on valid code: tree check: expected record_type or union_type or qual_union_type, have array_type in cxx_eval_constant_expression, at cp/constexpr.c:4820)
PR c++/87398
	* constexpr.c (cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Only
	look through COMPONENT_REFs with DECL_FIELD_IS_BASE FIELD_DECLs.

	* g++.dg/other/pr87398.C: New test.
	* g++.dg/cpp2a/constexpr-virtual10.C: New test.
	* g++.dg/cpp2a/constexpr-virtual11.C: New test.

From-SVN: r264580
2018-09-25 18:40:57 +02:00

19 lines
321 B
C

// P1064R0
// { dg-do compile }
// { dg-options "-std=c++2a" }
struct X
{
constexpr virtual int f() const { return 1; };
};
struct Y : public X
{
constexpr virtual int f() const { return 2; };
};
constexpr X a[2][1][3];
constexpr Y b[3][12];
static_assert (a[1][0][1].f() == 1);
static_assert (b[2][11].f() == 2);