This was hard to find. Consider this snippet: ------------------ struct B { void f(); }; struct D : B { using B::f; B::f; }; ------------------ Note that D contains old- and new-style using declarations. In my case, they were several hundred lines apart in D, so it wasn't quite so obvious. What I get is this: g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c a.cc a.cc:2: error: ?void B::f()? and ?void B::f()? cannot be overloaded Note that it doesn't show where the attempt to overload happens, it only shows the original place. That's bad diagnostics. gcc2.95 didn't say anything about the code, so I rate this as a regression. W.
Comeau gives the following error: "ComeauTest.c", line 7: error: duplicate using-declaration of "B::f" ignored B::f; Confirmed.
I should add that it doesn't matter whether you use old- or new-style using declarations: B::f; B::f; and using B::f; using B::f; yield the same results. W.
Subject: Re: New: [3.3/3.4/4.0/4.1 regression] Confusing message with different using declarations "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes: | This was hard to find. Consider this snippet: | ------------------ | struct B { | void f(); | }; | | struct D : B { | using B::f; | B::f; | }; | ------------------ | Note that D contains old- and new-style using declarations. In my case, they | were several hundred lines apart in D, so it wasn't quite so obvious. What | I get is this: | | g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c a.cc | a.cc:2: error: ?void B::f()? and ?void B::f()? cannot be overloaded | | Note that it doesn't show where the attempt to overload happens, it only shows | the original place. That's bad diagnostics. Agreed. But, I don't think that will be fixed in 3.3.x -- Gaby
Subject: Bug 20637 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2005-06-06 14:18:22 Modified files: gcc/cp : ChangeLog class.c cp-tree.h decl2.c method.c semantics.c gcc/testsuite : ChangeLog gcc/testsuite/g++.dg/overload: error1.C gcc/testsuite/g++.old-deja/g++.benjamin: warn02.C gcc/testsuite/g++.old-deja/g++.brendan: arm2.C gcc/testsuite/g++.old-deja/g++.other: redecl2.C redecl4.C gcc/testsuite/g++.old-deja/g++.pt: memtemp78.C Added files: gcc/testsuite/g++.dg/inherit: using4.C Log message: cp: PR c++/20637 * cp-tree.h (add_method): Add using_decl parameter. * class.c (add_method): Add using_decl parameter. Adjust error messages. (handle_using_decl): Pass the using decl to add_method. (clone_function_decl): Adjust add_member calls. * decl2.c (check_classfn): Likewise. * method.c (lazily_declare_fn): Likewise. * semantics.c (finish_member_declaration): Likewise. * method.c (synthesize_method): Use inform, not warning. testsuite: PR c++/20637 * g++.dg/inherit/using4.C: New. * g++.dg/overload/error1.C: Adjust expected errors. * g++.old-deja/g++.benjamin/warn02.C: Likewise. * g++.old-deja/g++.brendan/arm2.C: Likewise. * g++.old-deja/g++.other/redecl2.C: Likewise. * g++.old-deja/g++.other/redecl4.C: Likewise. * g++.old-deja/g++.pt/memtemp78.C: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4776&r2=1.4777 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.718&r2=1.719 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1141&r2=1.1142 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.784&r2=1.785 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/method.c.diff?cvsroot=gcc&r1=1.332&r2=1.333 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.473&r2=1.474 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5601&r2=1.5602 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/using4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/error1.C.diff?cvsroot=gcc&r1=1.2&r2=1.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C.diff?cvsroot=gcc&r1=1.4&r2=1.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C.diff?cvsroot=gcc&r1=1.3&r2=1.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.other/redecl2.C.diff?cvsroot=gcc&r1=1.3&r2=1.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.other/redecl4.C.diff?cvsroot=gcc&r1=1.2&r2=1.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
Fixed on mainline, waiting for unfreeze on 4.0. I am disinclined to backport to 3.4, it is a usability issue only. The patch is larger than I am comfortable with.
fixed on 4.0 branch