From d15f0fa7f9b7bc2eabb29429a7ca8556a3272625 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 1 Feb 2018 20:32:33 +0000 Subject: [PATCH] re PR c++/84125 (ICE in generic lambda when static_assert argument is implicitly converted to bool) PR c++/84125 * typeck.c (build_address): Relax the assert when processing_template_decl. * g++.dg/cpp1y/lambda-generic-84125.C:New test. From-SVN: r257311 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 897774e43f7..5b6c75a83f5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-01 Marek Polacek + + PR c++/84125 + * typeck.c (build_address): Relax the assert when + processing_template_decl. + 2018-02-01 Jason Merrill PR c++/84126 - ICE with variadic generic lambda diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1102f677f15..83e76782998 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5735,7 +5735,8 @@ build_address (tree t) { if (error_operand_p (t) || !cxx_mark_addressable (t)) return error_mark_node; - gcc_checking_assert (TREE_CODE (t) != CONSTRUCTOR); + gcc_checking_assert (TREE_CODE (t) != CONSTRUCTOR + || processing_template_decl); t = build_fold_addr_expr_loc (EXPR_LOCATION (t), t); if (TREE_CODE (t) != ADDR_EXPR) t = rvalue (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8ce7c29050c..64af7475985 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-01 Marek Polacek + + PR c++/84125 + * g++.dg/cpp1y/lambda-generic-84125.C:New test. + 2018-01-30 Jeff Law PR target/84128 diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C new file mode 100644 index 00000000000..8bf6a09652e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C @@ -0,0 +1,10 @@ +// PR c++/84125 +// { dg-do compile { target c++14 } } + +struct X { constexpr operator bool() const { return true; } }; + +int main(){ + [](auto) { + static_assert(X{}, ""); + }; +} -- 2.30.2