diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1c9e2c6325..0ed260b5da1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2020-01-24 Marek Polacek + + 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 PR c++/92852 - ICE with generic lambda and reference var. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4520c995028..95719927249 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 7c6b4cdfa6c..d1213ccd44f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-24 Marek Polacek + + PR c++/93299 - ICE in tsubst_copy with parenthesized expression. + * g++.dg/cpp1y/paren5.C: New test. + 2020-01-24 Sandra Loosemore * 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 00000000000..86a51356465 --- /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 struct A { + enum { b = 8 }; +}; + +template struct __attribute__((aligned((A::b)))) D { }; +struct S : D<0> { }; + +template struct __attribute__((aligned((A::b) + N))) D2 { }; +struct S2 : D2<0> { };