aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-03-04 19:04:31 -0500
committerMarek Polacek <polacek@redhat.com>2020-03-04 19:04:31 -0500
commit2b5d109ba3af320f65cb0707e8733eeea3c96262 (patch)
treeac410059f7df7ec4ec11c36759d82ef9c99b6ac7
parentd8b65123ea2e7f169c3e3972d3942d73f9b3333c (diff)
downloadgcc-2b5d109ba3af320f65cb0707e8733eeea3c96262.zip
gcc-2b5d109ba3af320f65cb0707e8733eeea3c96262.tar.gz
gcc-2b5d109ba3af320f65cb0707e8733eeea3c96262.tar.bz2
c++: Fix ICE in tsubst_copy with parenthesized expression [PR93299]
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/ChangeLog8
-rw-r--r--gcc/cp/pt.c8
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/paren5.C12
3 files changed, 28 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 26d9a08..a923606 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,6 +1,14 @@
2020-03-04 Marek Polacek <polacek@redhat.com>
Backported from mainline
+ 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-03-04 Marek Polacek <polacek@redhat.com>
+
+ Backported from mainline
2020-02-26 Marek Polacek <polacek@redhat.com>
PR c++/93676 - value-init crash in template.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2de9036..43d9660 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15834,6 +15834,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/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> { };