[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    C++ PATCH for c++/49569 (ICE with implicitly-declared copy constructor)
From:       Jason Merrill <jason () redhat ! com>
Date:       2011-06-30 23:57:48
Message-ID: 4E0D0D7C.3050608 () redhat ! com
[Download RAW message or body]

If we aren't setting DECL_ARTIFICIAL on the rhs parm of an 
implicitly-declared copy constructor, we need to set DECL_PARM_INDEX for 
the sake of the constexpr expander.

Tested x86_64-pc-linux-gnu, applying to trunk.

["49569.patch" (text/x-patch)]

commit eae21fea450d9fa1b9fce0544db5cf7fdce8f022
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 30 18:35:25 2011 -0400

    	PR c++/49569
    	* method.c (implicitly_declare_fn): Set DECL_PARM_LEVEL and
    	DECL_PARM_INDEX on rhs parm.

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index f10e846..9b9eb9a 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C
new file mode 100644
index 0000000..c35d601
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/ctor1.C
@@ -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) { }
+};
+


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic