From f4a61754c984d722ab71a0d6a9c7dbce70c2f26e Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 25 Oct 2012 15:53:31 +0000 Subject: [PATCH] c-family/ * c.opt (Winherited-variadic-ctor): New. cp/ * class.c (one_inherited_ctor): Warn about variadic inherited ctor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192811 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 4 ++++ gcc/c-family/c.opt | 4 ++++ gcc/cp/ChangeLog | 4 ++++ gcc/cp/class.c | 6 ++++++ gcc/doc/invoke.texi | 7 +++++++ gcc/testsuite/g++.dg/cpp0x/inh-ctor11.C | 4 ++-- 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 82f1fa22083..cabd82c771b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2012-10-25 Jason Merrill + + * c.opt (Winherited-variadic-ctor): New. + 2012-10-25 Marc Glisse PR c++/54427 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index d2a97ab1019..60cb726b2c9 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -426,6 +426,10 @@ Warn when a declaration does not specify a type Wimport C ObjC C++ ObjC++ Undocumented Ignore +Winherited-variadic-ctor +C++ ObjC++ Var(warn_inh_var_ctor) Init(1) Warning +Warn about C++11 inheriting constructors when the base has a variadic constructor + Wint-to-pointer-cast C ObjC C++ ObjC++ Var(warn_int_to_pointer_cast) Init(1) Warning Warn when there is a cast to a pointer from an integer of a different size diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c7c67e29bbf..38e79f58e6e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2012-10-25 Jason Merrill + + * class.c (one_inherited_ctor): Warn about variadic inherited ctor. + 2012-10-25 Marc Glisse PR c++/54427 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a478de80563..3e1b44a4c1e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2807,6 +2807,12 @@ one_inherited_ctor (tree ctor, tree t) new_parms[i++] = TREE_VALUE (parms); } one_inheriting_sig (t, ctor, new_parms, i); + if (parms == NULL_TREE) + { + warning (OPT_Winherited_variadic_ctor, + "the ellipsis in %qD is not inherited", ctor); + inform (DECL_SOURCE_LOCATION (ctor), "%qD declared here", ctor); + } } /* Create default constructors, assignment operators, and so forth for diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6a90ff19c69..a6baee7cda1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4632,6 +4632,13 @@ cases where multiple declaration is valid and changes nothing. @opindex Wno-nested-externs Warn if an @code{extern} declaration is encountered within a function. +@item -Wno-inherited-variadic-ctor +@opindex Winherited-variadic-ctor +@opindex Wno-inherited-variadic-ctor +Suppress warnings about use of C++11 inheriting constructors when the +base class inherited from has a C variadic constructor; the warning is +on by default because the ellipsis is not inherited. + @item -Winline @opindex Winline @opindex Wno-inline diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor11.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor11.C index 8e8ff010ffe..282402ba22d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/inh-ctor11.C +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor11.C @@ -2,12 +2,12 @@ struct A { - A(int, ...); + A(int, ...); // { dg-message "declared here" } }; struct B: A { - using A::A; + using A::A; // { dg-warning "ellipsis" } }; B b1(42); -- 2.11.4.GIT