A member "using" declaration fails to override an inherited matching name. As a result, in the example below, the compiler reports a type error. The access-adjustment ("private:") adds a further wrinkle. According to the current standard, it should be ignored, and seems to be now, but if the using-declaration really becomes enough of a declaration to hide the inherited ``void i()'', it had better not become enough of a declaration to be private, too. Release: 3.1.1 20020515 (prerelease) Environment: System: Linux ipc 2.4.19-pre4 #3 SMP Fri Mar 29 02:57:10 EST 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc-3.1/configure --enable-languages=c,c++ --enable-threads=posix --prefix=/ncm/gnu-3.1 --enable-concept-checks How-To-Repeat: $ cat /tmp/a.cc struct Baser { enum { j, i }; }; struct Base : Baser { static void j() {} static void i() {} }; struct Derv : Base { using Baser::j; private: using Baser::i; }; int k = Derv::j; int l = Derv::i; $ g++ -v -c /tmp/a.cc Reading specs from /ncm/gnu-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/specs Configured with: ../gcc-3.1/configure --enable-languages=c,c++ --enable-threads=posix --prefix=/ncm/gnu-3.1 --enable-concept-checks Thread model: posix gcc version 3.1.1 20020515 (prerelease) /ncm/gnu-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ /tmp/a.cc -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase a.cc -version -o /tmp/ccIMt85B.s GNU CPP version 3.1.1 20020515 (prerelease) (cpplib) (i386 Linux/ELF) GNU C++ version 3.1.1 20020515 (prerelease) (i686-pc-linux-gnu) compiled by GNU C version 3.1 20020422 (prerelease). ignoring nonexistent directory "/ncm/gnu-3.1/i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /ncm/gnu-3.1/include/g++-v3 /ncm/gnu-3.1/include/g++-v3/i686-pc-linux-gnu /ncm/gnu-3.1/include/g++-v3/backward /usr/local/include /ncm/gnu-3.1/include /ncm/gnu-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/include /usr/include End of search list. /tmp/a.cc:8: invalid conversion from `void (*)()' to `int' /tmp/a.cc:9: invalid conversion from `void (*)()' to `int'
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed.
Still happens with gcc4.5.1. Note that it doesn't matter which of the variables are accessed since it's a name lookup problem and name lookup happens before access control checking.
(In reply to comment #2) > Still happens with gcc4.5.1. ... And on 4.6, 4.7 as well.
Author: jason Date: Mon Nov 14 17:55:57 2011 New Revision: 181359 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181359 Log: PR c++/6936 PR c++/25994 PR c++/26256 PR c++/30195 * search.c (lookup_field_1): Look through USING_DECL. (lookup_field_r): Call lookup_fnfields_slot instead of lookup_fnfields_1. * semantics.c (finish_member_declaration): Remove the check that prevents USING_DECLs from being verified by pushdecl_class_level. Call add_method for using declarations that designates functions if the using declaration is in a template class. Set DECL_IGNORED_P on class-scope using declarations. * typeck.c (build_class_member_access_expr): Handle USING_DECLs. * class.c (check_field_decls): Keep using declarations. (add_method): Remove two diagnostics about conflicting using declarations. * parser.c (cp_parser_nonclass_name): Handle USING_DECLs. * decl.c (start_enum): Call xref_tag whenever possible. * cp-tree.h (strip_using_decl): Declare, and reident the previous function. * name-lookup.c (strip_using_decl): New function. (supplement_binding_1): Call strip_using_decl on decl and bval. Perform most of the checks with USING_DECLs stripped. Also check that the target decl and the target bval does not refer to the same declaration. Allow pushing an enum multiple times in a template class. Adjustment to diagnose using redeclarations. Call diagnose_name_conflict. (push_class_level_binding): Call strip_using_decl on decl and bval. Perform most of the checks with USING_DECLs stripped. Return true if both decl and bval refer to USING_DECLs and are dependent. (diagnose_name_conflict): New function. Added: trunk/gcc/testsuite/g++.dg/cpp0x/forw_enum10.C trunk/gcc/testsuite/g++.dg/debug/using4.C trunk/gcc/testsuite/g++.dg/debug/using5.C trunk/gcc/testsuite/g++.dg/lookup/pr6936.C trunk/gcc/testsuite/g++.dg/lookup/using24.C trunk/gcc/testsuite/g++.dg/lookup/using25.C trunk/gcc/testsuite/g++.dg/lookup/using26.C trunk/gcc/testsuite/g++.dg/lookup/using27.C trunk/gcc/testsuite/g++.dg/lookup/using28.C trunk/gcc/testsuite/g++.dg/lookup/using29.C trunk/gcc/testsuite/g++.dg/lookup/using30.C trunk/gcc/testsuite/g++.dg/lookup/using31.C trunk/gcc/testsuite/g++.dg/lookup/using32.C trunk/gcc/testsuite/g++.dg/lookup/using33.C trunk/gcc/testsuite/g++.dg/lookup/using34.C trunk/gcc/testsuite/g++.dg/lookup/using35.C trunk/gcc/testsuite/g++.dg/lookup/using36.C trunk/gcc/testsuite/g++.dg/lookup/using37.C trunk/gcc/testsuite/g++.dg/lookup/using38.C trunk/gcc/testsuite/g++.dg/lookup/using39.C trunk/gcc/testsuite/g++.dg/lookup/using40.C trunk/gcc/testsuite/g++.dg/lookup/using41.C trunk/gcc/testsuite/g++.dg/lookup/using42.C trunk/gcc/testsuite/g++.dg/lookup/using44.C trunk/gcc/testsuite/g++.dg/lookup/using45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/name-lookup.c trunk/gcc/cp/parser.c trunk/gcc/cp/search.c trunk/gcc/cp/semantics.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/abi/mangle41.C trunk/gcc/testsuite/g++.dg/inherit/using4.C trunk/gcc/testsuite/g++.dg/lookup/name-clash9.C trunk/gcc/testsuite/g++.dg/parse/ctor5.C trunk/gcc/testsuite/g++.dg/template/static4.C trunk/gcc/testsuite/g++.dg/template/typedef1.C trunk/gcc/testsuite/g++.dg/template/using2.C trunk/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C trunk/gcc/testsuite/g++.old-deja/g++.bugs/900127_02.C trunk/gcc/testsuite/g++.old-deja/g++.jason/scoping16.C trunk/gcc/testsuite/g++.old-deja/g++.other/anon7.C trunk/gcc/testsuite/g++.old-deja/g++.other/redecl1.C trunk/gcc/testsuite/g++.old-deja/g++.other/typedef7.C trunk/gcc/testsuite/g++.old-deja/g++.other/using1.C
Fixed.