Commit 5e08432e by Mark Mitchell Committed by Mark Mitchell

re PR c++/7019 ([3.3 only] SFINAE does not work with explicitally specified template arguments)

	PR c++/7019
	* cp-tree.h (lookup_qualified_name): Adjust prototype.
	* decl.c (lookup_qualified_name): Add complain parameter.  Adjust
	call to is_aggr_type.
	* parser.c (cp_parser_lookup_name): Adjust call to
	lookup_qualified_name.
	* pt.c (tsubst_qualified_id): Likewise.
	(tsubst_copy_and_build): Likewise.
	* semantics.c (finish_qualified_id_expr): Deal with erroneous
	expressions.

	PR c++/7019
	* g++.dg/template/overload2.C: New test.

From-SVN: r69342
parent bda243ec
2003-07-14 Mark Mitchell <mark@codesourcery.com>
PR c++/7019
* cp-tree.h (lookup_qualified_name): Adjust prototype.
* decl.c (lookup_qualified_name): Add complain parameter. Adjust
call to is_aggr_type.
* parser.c (cp_parser_lookup_name): Adjust call to
lookup_qualified_name.
* pt.c (tsubst_qualified_id): Likewise.
(tsubst_copy_and_build): Likewise.
* semantics.c (finish_qualified_id_expr): Deal with erroneous
expressions.
2003-07-14 Gabriel Dos Reis <gdr@integrable-solutions.net> 2003-07-14 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/11510 PR c++/11510
......
...@@ -3679,7 +3679,7 @@ extern tree make_typename_type (tree, tree, tsubst_flags_t); ...@@ -3679,7 +3679,7 @@ extern tree make_typename_type (tree, tree, tsubst_flags_t);
extern tree make_unbound_class_template (tree, tree, tsubst_flags_t); extern tree make_unbound_class_template (tree, tree, tsubst_flags_t);
extern tree lookup_name_nonclass (tree); extern tree lookup_name_nonclass (tree);
extern tree lookup_function_nonclass (tree, tree); extern tree lookup_function_nonclass (tree, tree);
extern tree lookup_qualified_name (tree, tree, bool); extern tree lookup_qualified_name (tree, tree, bool, bool);
extern tree lookup_name (tree, int); extern tree lookup_name (tree, int);
extern tree lookup_name_current_level (tree); extern tree lookup_name_current_level (tree);
extern tree lookup_type_current_level (tree); extern tree lookup_type_current_level (tree);
......
...@@ -5761,10 +5761,12 @@ qualify_lookup (tree val, int flags) ...@@ -5761,10 +5761,12 @@ qualify_lookup (tree val, int flags)
bindings. bindings.
Returns a DECL (or OVERLOAD, or BASELINK) representing the Returns a DECL (or OVERLOAD, or BASELINK) representing the
declaration found. */ declaration found. If no suitable declaration can be found,
ERROR_MARK_NODE is returned. Iif COMPLAIN is true and SCOPE is
neither a class-type nor a namespace a diagnostic is issued. */
tree tree
lookup_qualified_name (tree scope, tree name, bool is_type_p) lookup_qualified_name (tree scope, tree name, bool is_type_p, bool complain)
{ {
int flags = 0; int flags = 0;
...@@ -5776,14 +5778,18 @@ lookup_qualified_name (tree scope, tree name, bool is_type_p) ...@@ -5776,14 +5778,18 @@ lookup_qualified_name (tree scope, tree name, bool is_type_p)
flags |= LOOKUP_COMPLAIN; flags |= LOOKUP_COMPLAIN;
if (is_type_p) if (is_type_p)
flags |= LOOKUP_PREFER_TYPES; flags |= LOOKUP_PREFER_TYPES;
if (!qualified_lookup_using_namespace (name, scope, &binding, if (qualified_lookup_using_namespace (name, scope, &binding,
flags)) flags))
return NULL_TREE;
return select_decl (&binding, flags); return select_decl (&binding, flags);
} }
else if (is_aggr_type (scope, /*or_else=*/1)) else if (is_aggr_type (scope, complain))
return lookup_member (scope, name, 0, is_type_p); {
else tree t;
t = lookup_member (scope, name, 0, is_type_p);
if (t)
return t;
}
return error_mark_node; return error_mark_node;
} }
......
...@@ -12825,7 +12825,8 @@ cp_parser_lookup_name (cp_parser *parser, tree name, ...@@ -12825,7 +12825,8 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
may be instantiated during name lookup. In that case, may be instantiated during name lookup. In that case,
errors may be issued. Even if we rollback the current errors may be issued. Even if we rollback the current
tentative parse, those errors are valid. */ tentative parse, those errors are valid. */
decl = lookup_qualified_name (parser->scope, name, is_type); decl = lookup_qualified_name (parser->scope, name, is_type,
/*complain=*/true);
if (dependent_p) if (dependent_p)
pop_scope (parser->scope); pop_scope (parser->scope);
} }
......
...@@ -7149,9 +7149,9 @@ tsubst_qualified_id (tree qualified_id, tree args, ...@@ -7149,9 +7149,9 @@ tsubst_qualified_id (tree qualified_id, tree args,
} }
else else
expr = name; expr = name;
if (!BASELINK_P (name) if (!BASELINK_P (name) && !DECL_P (expr))
&& !DECL_P (expr)) expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0,
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0); (complain & tf_error) != 0);
if (DECL_P (expr)) if (DECL_P (expr))
check_accessibility_of_qualified_id (expr, check_accessibility_of_qualified_id (expr,
/*object_type=*/NULL_TREE, /*object_type=*/NULL_TREE,
...@@ -7611,7 +7611,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -7611,7 +7611,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
scope = tsubst_expr (scope, args, complain, in_decl); scope = tsubst_expr (scope, args, complain, in_decl);
do_local_using_decl (lookup_qualified_name (scope, do_local_using_decl (lookup_qualified_name (scope,
name, name,
/*is_type_p=*/0)); /*is_type_p=*/0,
/*complain=*/true));
} }
else else
{ {
...@@ -8285,7 +8286,8 @@ tsubst_copy_and_build (tree t, ...@@ -8285,7 +8286,8 @@ tsubst_copy_and_build (tree t,
args = TREE_OPERAND (TREE_OPERAND (member, 1), 1); args = TREE_OPERAND (TREE_OPERAND (member, 1), 1);
member = lookup_qualified_name (TREE_OPERAND (member, 0), member = lookup_qualified_name (TREE_OPERAND (member, 0),
tmpl, tmpl,
/*is_type=*/0); /*is_type=*/0,
/*complain=*/true);
if (BASELINK_P (member)) if (BASELINK_P (member))
BASELINK_FUNCTIONS (member) BASELINK_FUNCTIONS (member)
= build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member), = build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member),
......
...@@ -1343,6 +1343,9 @@ tree ...@@ -1343,6 +1343,9 @@ tree
finish_qualified_id_expr (tree qualifying_class, tree expr, bool done, finish_qualified_id_expr (tree qualifying_class, tree expr, bool done,
bool address_p) bool address_p)
{ {
if (error_operand_p (expr))
return error_mark_node;
/* If EXPR occurs as the operand of '&', use special handling that /* If EXPR occurs as the operand of '&', use special handling that
permits a pointer-to-member. */ permits a pointer-to-member. */
if (address_p && done) if (address_p && done)
......
2003-07-14 Mark Mitchell <mark@codesourcery.com>
PR c++/7019
* g++.dg/template/overload2.C: New test.
2003-07-14 Franz Sirl <Franz.Sirl-kernel@lauterbach.com> 2003-07-14 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
PR optimization/11440 PR optimization/11440
......
template <class T, int (T::*)> struct foo;
template <class T>
int f(foo<T,&T::ob_type>*);
template <class T>
char* f(...);
struct X { int ob_type; };
struct Y { char* ob_type; };
int x = f<X>(0);
char* y = f<Y>(0);
char* z = f<int>(0);
int main() { return 0; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment