From ff8ba86f447546c57e26bfab2a3437f14d6f2595 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 7 Dec 2018 00:25:10 +0100 Subject: [PATCH] re PR c++/87506 (ICE with inherited constexpr constructor with const argument) PR c++/87506 * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR. * g++.dg/cpp0x/constexpr-87506.C: New test. From-SVN: r266877 --- gcc/cp/ChangeLog | 7 ++++++- gcc/cp/constexpr.c | 2 ++ gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 707058064e0..df8a9d09bd2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-12-07 Jakub Jelinek + + PR c++/87506 + * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR. + 2018-12-06 Paolo Carlini * class.c (check_bitfield_decl): In error message about non-integral @@ -6,7 +11,7 @@ friends; when calling build_decl for a FIELD_DECL possibly pass the declarator->id_loc. -2018-12-06 Alexandre Oliva +2018-12-06 Alexandre Oliva PR c++/86747 * pt.c (tsubst_friend_class): Enter tsubsted class context. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index a668d14e8bf..1c844a8c2ef 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1281,6 +1281,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 9f2b5cf66f8..571f2b55d40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-07 Jakub Jelinek + + PR c++/87506 + * g++.dg/cpp0x/constexpr-87506.C: New test. + 2018-12-06 Paolo Carlini * g++.dg/parse/bitfield7.C: New. @@ -5,7 +10,7 @@ * g++.dg/parse/bitfield1.C: Likewise. * g++.dg/parse/bitfield2.C: Likewise. -2018-12-06 Alexandre Oliva +2018-12-06 Alexandre Oliva PR c++/86747 * g++.dg/pr86747.C: New. 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 00000000000..62d2ddcdcf5 --- /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{}); +} -- 2.30.2