From 9cca4e3d1a29de999ebdab84ffa99aa11eedf64e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 27 Jan 2014 23:30:26 -0500 Subject: [PATCH] re PR c++/58837 ([c++11] ICE using invalid condition in static_assert) PR c++/58837 * typeck.c (cp_truthvalue_conversion): Use explicit comparison for FUNCTION_DECL. From-SVN: r207162 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/static_assert9.C | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/static_assert9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3c58b6bb74a..42adc480f18 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-01-27 Jason Merrill + PR c++/58837 + * typeck.c (cp_truthvalue_conversion): Use explicit comparison for + FUNCTION_DECL. + PR c++/59097 * decl.c (compute_array_index_type): Don't call maybe_constant_value for a non-integral expression. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 78090a735ce..b7ece1bf771 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5182,7 +5182,9 @@ tree cp_truthvalue_conversion (tree expr) { tree type = TREE_TYPE (expr); - if (TYPE_PTRDATAMEM_P (type)) + if (TYPE_PTRDATAMEM_P (type) + /* Avoid ICE on invalid use of non-static member function. */ + || TREE_CODE (expr) == FUNCTION_DECL) return build_binary_op (EXPR_LOCATION (expr), NE_EXPR, expr, nullptr_node, 1); else if (TYPE_PTR_P (type) || TYPE_PTRMEMFUNC_P (type)) diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert9.C b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C new file mode 100644 index 00000000000..fccaa449c17 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C @@ -0,0 +1,7 @@ +// PR c++/58837 +// { dg-require-effective-target c++11 } + +void f(); +static_assert(f, ""); +struct A {}; +static_assert(A::~A, ""); // { dg-error "non-static member function" } -- 2.30.2