c++: Fix ICE in tsubst_copy with parenthesized expression [PR93299]
authorMarek Polacek <polacek@redhat.com>
Fri, 17 Jan 2020 20:17:42 +0000 (15:17 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 24 Jan 2020 20:44:01 +0000 (15:44 -0500)
commitd54a86cd92860e1108f43fae9329ccb0897f3e1d
tree481092d986b214da6742ca2a36a08c1323939c83
parent7c75a2a3bfdcc2fc792d730562c677d513347d1c
c++: Fix ICE in tsubst_copy with parenthesized expression [PR93299]

Since e4511ca2e9ecdb51d41b64452398f8e2df575668 force_paren_expr can create
a VIEW_CONVERT_EXPR so that we have something to set REF_PARENTHESIZED_P
on, while not making the expression dependent.  But tsubst_copy can't cope
with such a VIEW_CONVERT_EXPR, because it's not location_wrapper_p, or
a TEMPLATE_PARM_INDEX wrapped in a VIEW_CONVERT_EXPR.

I think we need to teach tsubst_copy how to handle it.  Setting
EXPR_LOCATION_WRAPPER_P in force_paren_expr would make the ICE go away
too, but tsubst_copy would lose the REF_PARENTHESIZED_P flag.

2020-01-24  Marek Polacek  <polacek@redhat.com>

PR c++/93299 - ICE in tsubst_copy with parenthesized expression.
* pt.c (tsubst_copy): Handle a REF_PARENTHESIZED_P VIEW_CONVERT_EXPR.

* g++.dg/cpp1y/paren5.C: New test.
gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/paren5.C [new file with mode: 0644]