diff options
author | Marek Polacek <polacek@redhat.com> | 2020-01-17 15:17:42 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-01-24 15:44:01 -0500 |
commit | d54a86cd92860e1108f43fae9329ccb0897f3e1d (patch) | |
tree | 481092d986b214da6742ca2a36a08c1323939c83 | |
parent | 7c75a2a3bfdcc2fc792d730562c677d513347d1c (diff) | |
download | gcc-d54a86cd92860e1108f43fae9329ccb0897f3e1d.zip gcc-d54a86cd92860e1108f43fae9329ccb0897f3e1d.tar.gz gcc-d54a86cd92860e1108f43fae9329ccb0897f3e1d.tar.bz2 |
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.
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/paren5.C | 12 |
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1c9e2c..0ed260b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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. + 2020-01-24 Jason Merrill <jason@redhat.com> PR c++/92852 - ICE with generic lambda and reference var. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4520c99..9571992 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16423,6 +16423,14 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) return op; } } + /* force_paren_expr can also create a VIEW_CONVERT_EXPR. */ + else if (code == VIEW_CONVERT_EXPR && REF_PARENTHESIZED_P (t)) + { + op = tsubst_copy (op, args, complain, in_decl); + op = build1 (code, TREE_TYPE (op), op); + REF_PARENTHESIZED_P (op) = true; + return op; + } /* We shouldn't see any other uses of these in templates. */ gcc_unreachable (); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c6b4cd..d1213cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-24 Marek Polacek <polacek@redhat.com> + + PR c++/93299 - ICE in tsubst_copy with parenthesized expression. + * g++.dg/cpp1y/paren5.C: New test. + 2020-01-24 Sandra Loosemore <sandra@codesourcery.com> * g++.dg/cpp0x/constexpr-odr1.C: Add -fdelete-null-pointer-checks. diff --git a/gcc/testsuite/g++.dg/cpp1y/paren5.C b/gcc/testsuite/g++.dg/cpp1y/paren5.C new file mode 100644 index 0000000..86a5135 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/paren5.C @@ -0,0 +1,12 @@ +// PR c++/93299 - ICE in tsubst_copy with parenthesized expression. +// { dg-do compile { target c++14 } } + +template <typename> struct A { + enum { b = 8 }; +}; + +template <int> struct __attribute__((aligned((A<int>::b)))) D { }; +struct S : D<0> { }; + +template <int N> struct __attribute__((aligned((A<int>::b) + N))) D2 { }; +struct S2 : D2<0> { }; |