aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-01-12 14:40:11 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-01-12 14:40:11 -0500
commitabdca01e866a9471d43a7b21980b71ba9657a1fe (patch)
treee198262c19309348f8b609a31d775b3d7ed78321 /gcc
parentb84619155e8f8537140aae55ab53125cafa8bc6c (diff)
downloadgcc-abdca01e866a9471d43a7b21980b71ba9657a1fe.zip
gcc-abdca01e866a9471d43a7b21980b71ba9657a1fe.tar.gz
gcc-abdca01e866a9471d43a7b21980b71ba9657a1fe.tar.bz2
PR c++/83186 - ICE with static_cast of list-initialized temporary.
* typeck.c (build_static_cast): Use build_non_dependent_expr. From-SVN: r256594
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-cast1.C12
3 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c155804..533e2d3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-12 Jason Merrill <jason@redhat.com>
+
+ PR c++/83186 - ICE with static_cast of list-initialized temporary.
+ * typeck.c (build_static_cast): Use build_non_dependent_expr.
+
2018-01-12 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (mark_rvalue_use): Add parm name.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 669a2b4..f0dc03d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7204,6 +7204,8 @@ build_static_cast (tree type, tree oexpr, tsubst_flags_t complain)
TREE_SIDE_EFFECTS (expr) = 1;
return convert_from_reference (expr);
}
+ else if (processing_template_decl)
+ expr = build_non_dependent_expr (expr);
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-cast1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-cast1.C
new file mode 100644
index 0000000..5446d85
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-cast1.C
@@ -0,0 +1,12 @@
+// PR c++/83186
+// { dg-do compile { target c++11 } }
+
+struct a {
+ operator unsigned();
+};
+template <class> void b() { static_cast<unsigned>(a{}); }
+
+int main()
+{
+ b<int>();
+}