re PR c++/47957 (Type mismatch when a class derived a same name with template parameter)
PR c++/47957 gcc/cp/ * name-lookup.c (binding_to_template_parms_of_scope_p): Only consider scopes of primary template definitions. Adjust comments. gcc/testsuite/ * g++.dg/lookup/template3.C: New test. From-SVN: r170793
This commit is contained in:
parent
2d05576a4c
commit
5045ce4f3f
|
@ -1,3 +1,8 @@
|
|||
2011-03-08 Dodji Seketeli <dodji@redhat.com>
|
||||
|
||||
* name-lookup.c (binding_to_template_parms_of_scope_p): Only
|
||||
consider scopes of primary template definitions. Adjust comments.
|
||||
|
||||
2011-03-08 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/47488
|
||||
|
|
|
@ -3998,8 +3998,13 @@ qualified_lookup_using_namespace (tree name, tree scope,
|
|||
}
|
||||
|
||||
/* Subroutine of outer_binding.
|
||||
Returns TRUE if BINDING is a binding to a template parameter of SCOPE,
|
||||
FALSE otherwise. */
|
||||
|
||||
Returns TRUE if BINDING is a binding to a template parameter of
|
||||
SCOPE. In that case SCOPE is the scope of a primary template
|
||||
parameter -- in the sense of G++, i.e, a template that has its own
|
||||
template header.
|
||||
|
||||
Returns FALSE otherwise. */
|
||||
|
||||
static bool
|
||||
binding_to_template_parms_of_scope_p (cxx_binding *binding,
|
||||
|
@ -4015,6 +4020,8 @@ binding_to_template_parms_of_scope_p (cxx_binding *binding,
|
|||
return (scope
|
||||
&& scope->this_entity
|
||||
&& get_template_info (scope->this_entity)
|
||||
&& PRIMARY_TEMPLATE_P (TI_TEMPLATE
|
||||
(get_template_info (scope->this_entity)))
|
||||
&& parameter_of_template_p (binding_value,
|
||||
TI_TEMPLATE (get_template_info \
|
||||
(scope->this_entity))));
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2011-03-08 Dodji Seketeli <dodji@redhat.com>
|
||||
|
||||
* g++.dg/lookup/template3.C: New test.
|
||||
|
||||
2011-03-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||
|
||||
Backport from mainline
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Origin PR c++/47957
|
||||
// { dg-do compile }
|
||||
|
||||
struct S
|
||||
{
|
||||
int m;
|
||||
|
||||
S()
|
||||
: m(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Base
|
||||
{
|
||||
typedef S T;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct Derived : public Base
|
||||
{
|
||||
int
|
||||
foo()
|
||||
{
|
||||
T a; // This is Base::T, not the template parameter.
|
||||
return a.m;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
Derived<char> d;
|
||||
return d.foo();
|
||||
}
|
Loading…
Reference in New Issue