From: Jakub Jelinek Date: Fri, 30 Aug 2019 11:17:41 +0000 (+0200) Subject: backport: re PR c++/87506 (ICE with inherited constexpr constructor with const argument) X-Git-Tag: releases/gcc-7.5.0~286 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc1f52a2244f69819936b6b4dc77cd6cc67b5ea8;p=thirdparty%2Fgcc.git backport: re PR c++/87506 (ICE with inherited constexpr constructor with const argument) Backported from mainline 2018-12-07 Jakub Jelinek PR c++/87506 * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR. * g++.dg/cpp0x/constexpr-87506.C: New test. From-SVN: r275075 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1c416bcb0b68..64bf90ae6347 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek - + Backported from mainline + 2018-12-07 Jakub Jelinek + + PR c++/87506 + * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR. + 2018-12-04 Jakub Jelinek PR c++/88103 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index cfd6a3a0e6e1..010b75271db6 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1212,6 +1212,8 @@ adjust_temp_type (tree type, tree temp) /* Avoid wrapping an aggregate value in a NOP_EXPR. */ if (TREE_CODE (temp) == CONSTRUCTOR) return build_constructor (type, CONSTRUCTOR_ELTS (temp)); + if (TREE_CODE (temp) == EMPTY_CLASS_EXPR) + return build0 (EMPTY_CLASS_EXPR, type); gcc_assert (scalarish_type_p (type)); return cp_fold_convert (type, temp); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 079ea89feffa..56aa953bf140 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek - + Backported from mainline + 2018-12-07 Jakub Jelinek + + PR c++/87506 + * g++.dg/cpp0x/constexpr-87506.C: New test. + 2018-12-04 Jakub Jelinek PR c++/88103 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C new file mode 100644 index 000000000000..62d2ddcdcf5f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C @@ -0,0 +1,12 @@ +// PR c++/87506 +// { dg-do compile { target c++11 } } + +struct A {}; +struct B { constexpr B (const A) {} }; +struct C : B { using B::B; }; + +void +foo () +{ + C c (A{}); +}