3907 – [3.3/3.4 Regression] nested template parm collides with member name (original) (raw)
| Description Franck Branjonneau 2001-07-31 17:46:01 UTC The following code: template< int zzzzzz > struct T { enum E { }; }; template< int s > struct U {}; template< int s > struct C { template< int t > class S: U< s >::S< t > {}; static T< s >::E t(); }; gives, from codesourcery: GCC Output These are the results of processing your source code with the following command: g++ [input] Exit code: 256 Messages: /usr/tmp/@13055.7.cc:15: declaration of `static typename T::E C::t()' /usr/tmp/@13055.7.cc:12: changes meaning of `t' from `int t' Note that in my environment, the message is slightly different: test.test.cc:26: declaration of `static typename T::E C::t()' test.test.cc:23: changes meaning of `t' from `int t' T::E !!! Are you confused ? ;-) Release: 3.0 (Debian) (Debian testing/unstable) Environment: System: Linux alpha.tchume.net 2.4.4 #2 mar mai 22 08:16:07 CEST 2001 i586 unknown Architecture: i586 host: i386-pc-linux-gnu build: i386-pc-linux-gnu target: i386-pc-linux-gnu configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux Comment 1 Nathan Sidwell 2001-08-01 03:02:07 UTC State-Changed-From-To: open->analyzed State-Changed-Why: confirmed as a regression Comment 2 Wolfgang Bangerth 2002-11-15 19:32:58 UTC From: Wolfgang Bangerth <bangerth@ticam.utexas.edu> To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org> Cc: Subject: Re: c++/3907: nested template parm collides with member name Date: Fri, 15 Nov 2002 19:32:58 -0600 (CST) The original testcase was a rejection of illegal code (because it accessed the nonexisting inner type U::S), but I can make this a rejects-legal this way: ----------------------------------------- template struct T { enum E { }; }; template struct U {}; template struct C { template struct S : U {}; typename T::E t; }; ----------------------------- tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ -c x.cc x.cc:6: error: declaration of `typename T::E C::t' x.cc:5: error: changes meaning of `t' from `int t' Of course, the scope of the template arg "t" should be limited to the end of the template class declaration. If someone is adventurous: the initial code accepted invalid code. I played with this further, and it is now PR 8596. Regards Wolfgang ------------------------------------------------------------------------- Wolfgang Bangerth email: bangerth@ticam.utexas.edu www: http://www.ticam.utexas.edu/~bangerth Comment 3 Drea Pinski 2003-06-19 18:37:22 UTC same error message on the mainline (20030618): pr3907.cc:7: error: declaration of `typename T::E C::t' pr3907.cc:6: error: changes meaning of `t' from `int t' Comment 4 Drea Pinski 2003-07-29 14:48:26 UTC Regression from 2.91.66. Comment 5 GCC Commits 2003-09-15 00:59:33 UTC Subject: Bug 3907 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-09-15 00:59:29 Modified files: gcc : ChangeLog coverage.c langhooks-def.h langhooks.c gcc/cp : ChangeLog call.c class.c cp-lang.c cp-tree.h decl.c semantics.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: template12.C Log message: * coverage.c (create_coverage): Do not call pushlevel/poplevel. * langhooks-def.h (lhd_do_nothing_iii_return_null_tree): New function. * langhooks.c (lhd_do_nothing_iii_return_null_tree): Define it. PR c++/3907 * class.c (maybe_note_name_used_in_class): Refine test for whether or not we are in a class scope. * cp-tree.h (language_function): Remove x_expanding_p. (expanding_p): Remove. (doing_semantic_analysis_p): Remove. (scope_kind): Add sk_function_parms, sk_class, sk_namespace. (innermost_scope_kind): New method. * call.c (cxx_type_promotes_to): Use type_decays_to. * cp-lang.c (LANG_HOOKS_PUSHLEVEL): Redefine. (LANG_HOOKS_POPLEVEL): Likewise. * decl.c (cp_binding_level): Remove parm_flag, template_parms_p, template_spec_p, namespace_p, is_for_scope, is_try_scope, and is_catch_scope. Add kind and explicit_spec_p. (cxx_scope_descriptor): Use a lookup table. (find_class_binding_level): Use "kind" field in binding_level, not the various flags. (pop_binding_level): Likewise. (innermost_nonclass_level): Likewise. (toplevel_bindings_p): Likewise. (namespace_bindings_p): Likewise. (template_parm_scope_p): Likewise. (innermost_scope_kind): New method. (current_tmpl_spec_kind): Use "kind" field in binding_level, not the various flags. (pushlevel): Remove check for doing_semantic_analysis_p. (begin_scope): Simplify. (add_decl_to_level): Use "kind" field in binding_level, not the various flags. (push_local_binding): Likewise. (pop_label): Remove check for doing_semantic_analysis_p. (poplevel): Use "kind" field in binding_level, not the various flags. (set_block): Remove check for doing_semantic_analysis_p. (pushlevel_class): Use "kind" field in binding_level, not the various flags. (poplevel_class): Likewise. (initial_push_namespace_scope): Likewise. (maybe_push_to_top_level): Likewise. (set_identifier_type_value_with_scope): Likewise. (pop_everything): Likewise. (maybe_process_template_type_declaration): Likewise. (pushtag): Likewise. (pushdecl): Likewise. (pushdecl_with_scope): Likewise. (check_previous_goto_1): Likewise. (define_label): Likewise. (finish_case_label): Likewise. (lookup_tag): Likewise. (unqualified_namespace_lookup): Likewise. (lookup_name_real): Likewise. (lookup_name_current_level): Likewise. (lookup_type_current_level): Likewise. (record_builtin_type): Likewise. (cp_make_fname_decl): Likewise. (maybe_inject_for_scope_var): Likewise. (cp_finish_decl): Remove check for doing_semantic_analysis_p. (start_function): Use begin_scope, not pushlevel. (finish_function): Use "kind" field in binding_level, not the various flags. (start_method): Use begin_scope, not pushlevel. (make_label_decl): Do not check expanding_p. (save_function-data): Do not set expanding_p. (cxx_push_function_context): Do not clear expanding_p. * semantics.c (cxx_expand_function_start): Do not set expanding_p. PR c++/3907 * g++.dg/parse/template12.C: New test. * g++.dg/abi/bitfield11.C: New test. * g++.dg/abi/bitfield12.C: Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1055&r2=2.1056 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/coverage.c.diff?cvsroot=gcc&r1=1.19&r2=1.20 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks-def.h.diff?cvsroot=gcc&r1=1.66&r2=1.67 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/langhooks.c.diff?cvsroot=gcc&r1=1.52&r2=1.53 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3678&r2=1.3679 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.432&r2=1.433 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.571&r2=1.572 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-lang.c.diff?cvsroot=gcc&r1=1.65&r2=1.66 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.915&r2=1.916 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1125&r2=1.1126 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.361&r2=1.362 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3053&r2=1.3054 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/template12.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 Comment 7 Mark Mitchell 2003-09-15 01:44:18 UTC Fixed in GCC 3.3.2, GCC 3.4. | |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |