Bug 13950 - [DR176] lookup of dependent base name
Summary: [DR176] lookup of dependent base name
Status: RESOLVED DUPLICATE of bug 189
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.5.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on: 189
Blocks:
  Show dependency treegraph
 
Reported: 2004-01-31 20:14 UTC by Giovanni Bajo
Modified: 2009-11-17 04:04 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2009-11-13 20:08:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bajo 2004-01-31 20:14:04 UTC
-----------------------------------------------------
template <class T> struct Base {};
template <class T> struct Derived: public Base<T> {
  typename Derived::template Base<double>* p1;
};

template struct Derived<void>;
-----------------------------------------------------
test.cc:3: error: no class template named `Base' in `struct Derived<T>'
test.cc:3: internal compiler error: tree check: expected class 't', have 'x' 
(error_mark) in cp_parser_class_name, at cp/parser.c:11594

The problem appears to be that make_typename_type does perform a name lookup 
within the currently open class, while cp_parser_template_name does not. I 
think they both have to agree on what to do. 

Besides, the lookup should not fail (see DR176, and g++.dg/tc1/dr176.C which I 
will soon submit). So this is both a rejects-valid and an ice-on-valid.
Comment 1 Andrew Pinski 2004-01-31 20:20:39 UTC
Confirmed, the ICE is a regression from 3.3.3
Comment 2 GCC Commits 2004-02-03 20:00:52 UTC
Subject: Bug 13950

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-02-03 20:00:47

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c 
Added files:
	gcc/testsuite/g++.dg/template: lookup4.C 
	gcc/testsuite/g++.dg/parse: error14.C 

Log message:
	PR c++/13950
	* parser.c (cp_parser_class_name): Robustify.
	
	PR c++/13970
	* parser.c (cp_parser_cache_group): Do not consume the EOF token.
	
	PR c++/13950
	* g++.dg/template/lookup4.C: New test.
	
	PR c++/13970
	* g++.dg/parse/error14.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3459&r2=1.3460
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3927&r2=1.3928
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.166&r2=1.167
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/lookup4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error14.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 Mark Mitchell 2004-02-03 20:07:05 UTC
The ICE is fixed in GCC 3.4.  

Therefore, this is no longer a regression, and I have removed the target milestone.
Comment 5 Jason Merrill 2009-11-16 23:29:39 UTC
Subject: Bug 13950

Author: jason
Date: Mon Nov 16 23:29:25 2009
New Revision: 154223

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154223
Log:
	PR c++/13950, DR 176
	* search.c (lookup_field_r): Allow lookup to find the
	injected-class-name from a template base.
	(template_self_reference_p): Remove.
	* decl.c (make_typename_type): Diagnose ambiguity.  Use
	maybe_get_template_decl_from_type_decl.
	* parser.c (cp_parser_template_name): Pass true to is_template
	rather than use maybe_get_template_decl_from_type_decl.
	(cp_parser_lookup_name): Use maybe_get_template_decl_from_type_decl.
	* pt.c (maybe_get_template_decl_from_type_decl): Handle ambiguity.
	Use DECL_SELF_REFERENCE_P.

	* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
	Avoid duplicate ambiguity error.
	* error.c (dump_decl): Don't say "typedef" for injected-class-name.
	* pt.c (convert_template_argument): Tweak logic.

Added:
    trunk/gcc/testsuite/g++.dg/template/injected1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/error.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/inherit.C
    trunk/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/lookup8.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/ttp23.C

Comment 6 Jason Merrill 2009-11-17 01:34:44 UTC
Fixed for 4.5.
Comment 7 Jason Merrill 2009-11-17 04:04:09 UTC

*** This bug has been marked as a duplicate of 189 ***