C++ PATCH: PR 29105
Mark Mitchell
mark@codesourcery.com
Mon Oct 2 04:15:00 GMT 2006
This patch fixes a bug that caused a crash when calling a base class
member template from a derived class template. The problem was that
we failed to create a baselink, which then confused the call
machinery, which was invoked because the function call in the test
case is non-dependent.
Tested on x86-64-unknown_linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2006-10-01 Mark Mitchell <mark@codesourcery.com>
PR c++/29105
* pt.c (tsubst_baselink): Substitute into the qualifying scope.
* semantics.c (baselink_for_fns): Build a baselink, even when
processing a template.
2006-10-01 Mark Mitchell <mark@codesourcery.com>
PR c++/29105
* g++.dg/template/member6.C: New test.
* g++.dg/parse/typename7.C: Adjust error markers.
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 117359)
+++ gcc/cp/pt.c (working copy)
@@ -7779,15 +7779,15 @@ tsubst_baselink (tree baselink, tree obj
tree template_args = 0;
bool template_id_p = false;
- /* A baselink indicates a function from a base class. The
- BASELINK_ACCESS_BINFO and BASELINK_BINFO are going to have
- non-dependent types; otherwise, the lookup could not have
- succeeded. However, they may indicate bases of the template
- class, rather than the instantiated class.
-
- In addition, lookups that were not ambiguous before may be
- ambiguous now. Therefore, we perform the lookup again. */
+ /* A baselink indicates a function from a base class. Both the
+ BASELINK_ACCESS_BINFO and the base class referenced may
+ indicate bases of the template class, rather than the
+ instantiated class. In addition, lookups that were not
+ ambiguous before may be ambiguous now. Therefore, we perform
+ the lookup again. */
qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink));
+ qualifying_scope = tsubst (qualifying_scope, args,
+ complain, in_decl);
fns = BASELINK_FUNCTIONS (baselink);
optype = BASELINK_OPTYPE (baselink);
if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c (revision 117359)
+++ gcc/cp/semantics.c (working copy)
@@ -2400,7 +2400,6 @@ baselink_for_fns (tree fns)
tree cl;
if (BASELINK_P (fns)
- || processing_template_decl
|| error_operand_p (fns))
return fns;
Index: gcc/testsuite/g++.dg/parse/typename7.C
===================================================================
--- gcc/testsuite/g++.dg/parse/typename7.C (revision 117359)
+++ gcc/testsuite/g++.dg/parse/typename7.C (working copy)
@@ -11,7 +11,7 @@ struct A
template<typename T> void bar(T t) {
this->foo<typename T>(t); } // { dg-error "expected|parse error|no matching" }
template<typename T> void bad(T t) {
- foo<typename T>(t); } // { dg-error "expected|parse error" }
+ foo<typename T>(t); } // { dg-error "expected|parse error|no matching" }
};
template <typename T>
Index: gcc/testsuite/g++.dg/template/member6.C
===================================================================
--- gcc/testsuite/g++.dg/template/member6.C (revision 0)
+++ gcc/testsuite/g++.dg/template/member6.C (revision 0)
@@ -0,0 +1,16 @@
+// PR c++/29105
+
+struct Observer
+{
+ template < typename T > void observeComponent ();
+};
+
+template < typename T >
+struct TagFilter : Observer
+{
+ TagFilter ()
+ {
+ observeComponent < int > ();
+ }
+};
+
More information about the Gcc-patches
mailing list