re PR c++/79899 (ICE in ctor_omit_inherited_parms at gcc/cp/method.c:576 on ARM target)
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Mar 2017 15:33:04 +0000 (16:33 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Mar 2017 15:33:04 +0000 (16:33 +0100)
PR c++/79899
* optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL.
Use XALLOCAVEC macro.

* g++.dg/other/friend7.C: New test.

From-SVN: r246038

gcc/cp/ChangeLog
gcc/cp/optimize.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/friend7.C [new file with mode: 0644]

index a7acfa7..d3871aa 100644 (file)
@@ -1,5 +1,9 @@
 2017-03-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/79899
+       * optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL.
+       Use XALLOCAVEC macro.
+
        PR c++/79896
        * decl.c (finish_enum_value_list): If value is error_mark_node,
        don't copy it and change its type.
index 933612c..d646ef7 100644 (file)
@@ -262,7 +262,7 @@ maybe_thunk_body (tree fn, bool force)
   populate_clone_array (fn, fns);
 
   /* Don't use thunks if the base clone omits inherited parameters.  */
-  if (ctor_omit_inherited_parms (fns[0]))
+  if (fns[0] && ctor_omit_inherited_parms (fns[0]))
     return 0;
 
   DECL_ABSTRACT_P (fn) = false;
@@ -324,7 +324,7 @@ maybe_thunk_body (tree fn, bool force)
       if (length > max_parms)
         max_parms = length;
     }
-  args = (tree *) alloca (max_parms * sizeof (tree));
+  args = XALLOCAVEC (tree, max_parms);
 
   /* We know that any clones immediately follow FN in TYPE_METHODS.  */
   FOR_EACH_CLONE (clone, fn)
index 8b89d82..a7dae3d 100644 (file)
@@ -1,5 +1,8 @@
 2017-03-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/79899
+       * g++.dg/other/friend7.C: New test.
+
        PR c++/79896
        * g++.dg/ext/int128-5.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/other/friend7.C b/gcc/testsuite/g++.dg/other/friend7.C
new file mode 100644 (file)
index 0000000..4d22a87
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/79899
+
+// { dg-do compile }
+// { dg-options "-Os" }
+
+struct A
+{
+  friend A::~A() {} // { dg-error "implicitly friends of their class" }
+};