]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix ICE in tsubst_copy with parenthesized expression [PR93299]
authorMarek Polacek <polacek@redhat.com>
Thu, 5 Mar 2020 00:04:31 +0000 (19:04 -0500)
committerMarek Polacek <polacek@redhat.com>
Thu, 5 Mar 2020 00:04:31 +0000 (19:04 -0500)
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/g++.dg/cpp1y/paren5.C [new file with mode: 0644]

index 26d9a08d9efd09941b9fdbf083b3a11913b45d6a..a9236063159ee6a699bd640792285cc94273d455 100644 (file)
@@ -1,3 +1,11 @@
+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
index 2de9036b6471fc7235e099fbf26363ae6637f80c..43d9660ebda74a9db954858d7e446e3e240663e3 100644 (file)
@@ -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 (file)
index 0000000..86a5135
--- /dev/null
@@ -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> { };