From dc7650cc6d9e0db68a45b261cfa65a982588924c Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 5 Jan 2017 12:30:26 +0000 Subject: [PATCH] re PR c++/78765 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: in cp_build_addr_expr_1, at cp/typeck.c:5708)) cp/ PR c++/78765 * pt.c (convert_nontype_argument): Don't try and see if integral or enum expressions are constants prematurely. testsuite/ PR c++/78765 * g++.dg/cpp0x/pr78765.C: New. From-SVN: r244101 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/pr78765.C | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr78765.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e723be3eba..35f0a2222ac 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-01-05 Nathan Sidwell + + PR c++/78765 + * pt.c (convert_nontype_argument): Don't try and see if integral + or enum expressions are constants prematurely. + 2017-01-04 Marek Polacek PR c++/64767 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 51c3c57b009..366c59a2486 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6386,7 +6386,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) to leave it in that form rather than lower it to a CONSTRUCTOR. */; else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) - expr = maybe_constant_value (expr); + /* Constant value checking is done later with type conversion. */; else if (cxx_dialect >= cxx1z) { if (TREE_CODE (type) != REFERENCE_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 86dee20ddb8..aa6dc348cc3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-05 Nathan Sidwell + + PR c++/78765 + * g++.dg/cpp0x/pr78765.C: New. + 2017-01-05 Dominik Vogt * gcc.target/s390/memcpy-2.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr78765.C b/gcc/testsuite/g++.dg/cpp0x/pr78765.C new file mode 100644 index 00000000000..6b66d26e549 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr78765.C @@ -0,0 +1,15 @@ +// PR c++/78765 +// { dg-do compile { target c++11 } } + +// ICE with failed constexpr object and member fn call + +struct ValueType { + constexpr operator int() const {return field;} + int field; +}; + +static constexpr ValueType var = 0; // { dg-error "conversion" } + +template class ValueTypeInfo; + +ValueTypeInfo x; -- 2.30.2