This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++0x Constructor Delegation take 2
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: "Pedro Lamarão" <pedro dot lamarao at mndfck dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Jun 2007 16:52:53 -0400
- Subject: Re: C++0x Constructor Delegation take 2
- References: <461DBB2D.4010309@mndfck.org> <24b520d20704240817ic999bb3xb39855b50e7f85ea@mail.gmail.com>
Hi Pedro,
With your patch, I'm starting to see a new failure in C++0x mode. I'm
not sure if this is a change from C++98 to C++0x, or whether it's
revealing a bug in the delegating constructors code:
The test case is gcc/testsuite/g++.dg/init/brace6.C in Subversion,
also shown below. In C++0x mode, we don't emit the error for the
second dg-error and we emit something different for the third
dg-error.
- Doug
/* PR c++/30759 */
/* { dg-do "compile" } */
struct A {
A(int) { }
};
struct B {
B(const B&);
int b;
};
struct C {};
struct D { int c; };
int main()
{
int i = { 1 };
int j = { 1, 2 }; /* { dg-error "requires one element" } */
A a = { 6 }; /* { dg-error "initializer for non" } */
B b = { 6 }; /* { dg-error "initializer for non" } */
C c = { 6 }; /* { dg-error "too many initializers" } */
D d = { 6 };
}
On 4/24/07, Doug Gregor <doug.gregor@gmail.com> wrote:
Hi Pedro,
I have a few small comments to make about this version of the patch.
Otherwise, it looks good to me. However, I don't have the ability to
approve it. Nathan, could you take a look?
Index: gcc/testsuite/g++.dg/cpp0x/dc_02.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/dc_02.C (revisão 0)
+++ gcc/testsuite/g++.dg/cpp0x/dc_02.C (revisão 0)
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options --std=gnu++0x }
I suggest using "-std=c++0x", since delegating constructors are in the
C++0x Working Paper (we're not relying on extensions at all).
+/* Initialize current class with INIT, a TREE_LIST of
+ arguments for a target constructor. If TREE_LIST is void_type_node,
+ an empty initializer list was given. */
+
+static void
+perform_target_ctor (tree init)
I suggest adding a comment stating that this routine implements the
delegating constructors feature of C++0x.
- Doug