Commit 3baa501d by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (make_typename_type): Change prototype.

	* cp-tree.h (make_typename_type): Change prototype.
	* decl.c (make_typename_type): Only complain if so requested.
	* parse.y (nested_name_specifier): Adjust calls.
	(typename_sub0): Likewise.
	(typename_sub1): Likewise.
	* parse.c: Regenerated.
	* pt.c (convert_template_argument): Pass complain to
	make_typename_type.
	(tsubst): Likewise.

From-SVN: r30254
parent aeaa5973
1999-10-29 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (make_typename_type): Change prototype.
* decl.c (make_typename_type): Only complain if so requested.
* parse.y (nested_name_specifier): Adjust calls.
(typename_sub0): Likewise.
(typename_sub1): Likewise.
* parse.c: Regenerated.
* pt.c (convert_template_argument): Pass complain to
make_typename_type.
(tsubst): Likewise.
1999-10-28 Mark Mitchell <mark@codesourcery.com> 1999-10-28 Mark Mitchell <mark@codesourcery.com>
* semantics.c (finish_handler): End the scope of the handler * semantics.c (finish_handler): End the scope of the handler
......
...@@ -3403,7 +3403,7 @@ extern tree namespace_binding PROTO((tree, tree)); ...@@ -3403,7 +3403,7 @@ extern tree namespace_binding PROTO((tree, tree));
extern void set_namespace_binding PROTO((tree, tree, tree)); extern void set_namespace_binding PROTO((tree, tree, tree));
extern tree lookup_namespace_name PROTO((tree, tree)); extern tree lookup_namespace_name PROTO((tree, tree));
extern tree build_typename_type PROTO((tree, tree, tree, tree)); extern tree build_typename_type PROTO((tree, tree, tree, tree));
extern tree make_typename_type PROTO((tree, tree)); extern tree make_typename_type PROTO((tree, tree, int));
extern tree lookup_name_nonclass PROTO((tree)); extern tree lookup_name_nonclass PROTO((tree));
extern tree lookup_function_nonclass PROTO((tree, tree)); extern tree lookup_function_nonclass PROTO((tree, tree));
extern tree lookup_name PROTO((tree, int)); extern tree lookup_name PROTO((tree, int));
......
...@@ -5277,9 +5277,14 @@ build_typename_type (context, name, fullname, base_type) ...@@ -5277,9 +5277,14 @@ build_typename_type (context, name, fullname, base_type)
return t; return t;
} }
/* Resolve `typename CONTEXT::NAME'. Returns an appropriate type,
unless an error occurs, in which case error_mark_node is returned.
If COMPLAIN zero, don't complain about any errors that occur. */
tree tree
make_typename_type (context, name) make_typename_type (context, name, complain)
tree context, name; tree context, name;
int complain;
{ {
tree fullname; tree fullname;
...@@ -5313,6 +5318,7 @@ make_typename_type (context, name) ...@@ -5313,6 +5318,7 @@ make_typename_type (context, name)
{ {
/* We can get here from typename_sub0 in the explicit_template_type /* We can get here from typename_sub0 in the explicit_template_type
expansion. Just fail. */ expansion. Just fail. */
if (complain)
cp_error ("no class template named `%#T' in `%#T'", cp_error ("no class template named `%#T' in `%#T'",
name, context); name, context);
return error_mark_node; return error_mark_node;
...@@ -5328,6 +5334,7 @@ make_typename_type (context, name) ...@@ -5328,6 +5334,7 @@ make_typename_type (context, name)
tmpl = lookup_field (context, name, 0, 0); tmpl = lookup_field (context, name, 0, 0);
if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl)) if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl))
{ {
if (complain)
cp_error ("no class template named `%#T' in `%#T'", cp_error ("no class template named `%#T' in `%#T'",
name, context); name, context);
return error_mark_node; return error_mark_node;
...@@ -5344,6 +5351,7 @@ make_typename_type (context, name) ...@@ -5344,6 +5351,7 @@ make_typename_type (context, name)
if (!IS_AGGR_TYPE (context)) if (!IS_AGGR_TYPE (context))
{ {
if (complain)
cp_error ("no type named `%#T' in `%#T'", name, context); cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node; return error_mark_node;
} }
...@@ -5358,6 +5366,7 @@ make_typename_type (context, name) ...@@ -5358,6 +5366,7 @@ make_typename_type (context, name)
there now or its never going to be. */ there now or its never going to be. */
if (!uses_template_parms (context)) if (!uses_template_parms (context))
{ {
if (complain)
cp_error ("no type named `%#T' in `%#T'", name, context); cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node; return error_mark_node;
} }
......
...@@ -2887,7 +2887,8 @@ nested_name_specifier: ...@@ -2887,7 +2887,8 @@ nested_name_specifier:
| nested_name_specifier nested_name_specifier_1 | nested_name_specifier nested_name_specifier_1
{ $$ = $2; } { $$ = $2; }
| nested_name_specifier TEMPLATE explicit_template_type SCOPE | nested_name_specifier TEMPLATE explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $3); } { got_scope = $$
= make_typename_type ($1, $3, /*complain=*/1); }
; ;
/* Why the @#$%^& do type_name and notype_identifier need to be expanded /* Why the @#$%^& do type_name and notype_identifier need to be expanded
...@@ -2939,7 +2940,7 @@ typename_sub0: ...@@ -2939,7 +2940,7 @@ typename_sub0:
typename_sub1 identifier %prec EMPTY typename_sub1 identifier %prec EMPTY
{ {
if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't') if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
$$ = make_typename_type ($1, $2); $$ = make_typename_type ($1, $2, /*complain=*/1);
else if (TREE_CODE ($2) == IDENTIFIER_NODE) else if (TREE_CODE ($2) == IDENTIFIER_NODE)
cp_error ("`%T' is not a class or namespace", $2); cp_error ("`%T' is not a class or namespace", $2);
else else
...@@ -2952,9 +2953,9 @@ typename_sub0: ...@@ -2952,9 +2953,9 @@ typename_sub0:
| typename_sub1 template_type %prec EMPTY | typename_sub1 template_type %prec EMPTY
{ $$ = TREE_TYPE ($2); } { $$ = TREE_TYPE ($2); }
| typename_sub1 explicit_template_type %prec EMPTY | typename_sub1 explicit_template_type %prec EMPTY
{ $$ = make_typename_type ($1, $2); } { $$ = make_typename_type ($1, $2, /*complain=*/1); }
| typename_sub1 TEMPLATE explicit_template_type %prec EMPTY | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
{ $$ = make_typename_type ($1, $3); } { $$ = make_typename_type ($1, $3, /*complain=*/1); }
; ;
typename_sub1: typename_sub1:
...@@ -2966,7 +2967,7 @@ typename_sub1: ...@@ -2966,7 +2967,7 @@ typename_sub1:
| typename_sub1 typename_sub2 | typename_sub1 typename_sub2
{ {
if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't') if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
$$ = make_typename_type ($1, $2); $$ = make_typename_type ($1, $2, /*complain=*/1);
else if (TREE_CODE ($2) == IDENTIFIER_NODE) else if (TREE_CODE ($2) == IDENTIFIER_NODE)
cp_error ("`%T' is not a class or namespace", $2); cp_error ("`%T' is not a class or namespace", $2);
else else
...@@ -2977,9 +2978,11 @@ typename_sub1: ...@@ -2977,9 +2978,11 @@ typename_sub1:
} }
} }
| typename_sub1 explicit_template_type SCOPE | typename_sub1 explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $2); } { got_scope = $$
= make_typename_type ($1, $2, /*complain=*/1); }
| typename_sub1 TEMPLATE explicit_template_type SCOPE | typename_sub1 TEMPLATE explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $3); } { got_scope = $$
= make_typename_type ($1, $3, /*complain=*/1); }
; ;
typename_sub2: typename_sub2:
......
...@@ -3156,7 +3156,8 @@ convert_template_argument (parm, arg, args, complain, i, in_decl) ...@@ -3156,7 +3156,8 @@ convert_template_argument (parm, arg, args, complain, i, in_decl)
cp_pedwarn (" use `typename %E'", arg); cp_pedwarn (" use `typename %E'", arg);
arg = make_typename_type (TREE_OPERAND (arg, 0), arg = make_typename_type (TREE_OPERAND (arg, 0),
TREE_OPERAND (arg, 1)); TREE_OPERAND (arg, 1),
complain);
is_type = 1; is_type = 1;
} }
if (is_type != requires_type) if (is_type != requires_type)
...@@ -6685,7 +6686,7 @@ tsubst (t, args, complain, in_decl) ...@@ -6685,7 +6686,7 @@ tsubst (t, args, complain, in_decl)
} }
} }
f = make_typename_type (ctx, f); f = make_typename_type (ctx, f, complain);
if (f == error_mark_node) if (f == error_mark_node)
return f; return f;
return cp_build_qualified_type_real (f, return cp_build_qualified_type_real (f,
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
class ostream;
extern ostream& cout;
class Foo { };
ostream &operator<<(ostream &os, const Foo &)
{
return os;
}
template<class T>
const typename T::fooz &operator<<(const Foo &, const T &t)
{
return t;
}
void main()
{
Foo foo;
cout << foo;
}
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