re PR c++/49569 (-std=gnu++0x causes segmentation fault)
authorJason Merrill <jason@redhat.com>
Fri, 1 Jul 2011 00:03:58 +0000 (20:03 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Jul 2011 00:03:58 +0000 (20:03 -0400)
PR c++/49569
* method.c (implicitly_declare_fn): Set DECL_PARM_LEVEL and
DECL_PARM_INDEX on rhs parm.

From-SVN: r175738

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C [new file with mode: 0644]

index c2ebf9a38cbd36b8b86407617b5841389940d0d2..e3f98455c37c56977dcd06b7e5ff097d1bd181c3 100644 (file)
@@ -1,5 +1,9 @@
 2011-06-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49569
+       * method.c (implicitly_declare_fn): Set DECL_PARM_LEVEL and
+       DECL_PARM_INDEX on rhs parm.
+
        * pt.c (iterative_hash_template_arg): Use cp_tree_operand_length.
 
        PR c++/49355
index f10e846d0ea312df1b7a9d33e0df394487b9f53f..9b9eb9a9df9c7a3f8c076a3b5026fdfa4227d1b1 100644 (file)
@@ -1528,8 +1528,11 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
       /* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
         want its type to be included in the mangled function
         name.  */
-      DECL_ARGUMENTS (fn) = cp_build_parm_decl (NULL_TREE, rhs_parm_type);
-      TREE_READONLY (DECL_ARGUMENTS (fn)) = 1;
+      tree decl = cp_build_parm_decl (NULL_TREE, rhs_parm_type);
+      TREE_READONLY (decl) = 1;
+      retrofit_lang_decl (decl);
+      DECL_PARM_INDEX (decl) = DECL_PARM_LEVEL (decl) = 1;
+      DECL_ARGUMENTS (fn) = decl;
     }
   /* Add the "this" parameter.  */
   this_parm = build_this_parm (fn_type, TYPE_UNQUALIFIED);
index ed34b5f3c10e6e877118fb6c972df810e1c66d28..382e0981a707a83abba893a79f76035a8f52f97a 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49569
+       * g++.dg/cpp0x/regress/ctor1.C: New.
+
        PR c++/49355
        * g++.dg/cpp0x/initlist54.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C
new file mode 100644 (file)
index 0000000..c35d601
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/49569
+// { dg-options -std=c++0x }
+
+struct A
+{
+  virtual void f() = 0;
+};
+
+struct B: A
+{
+  int i;
+  virtual void f() { }
+};
+
+struct C
+{
+  B b;
+  C(): b() { }
+  C(const B& b): b(b) { }
+};
+