Commit 830fcda8 by Jason Merrill Committed by Jason Merrill

decl.c (lookup_name_real): Also do implicit typename thing for artificial TYPE_DECLs.

	* decl.c (lookup_name_real): Also do implicit typename thing for
	artificial TYPE_DECLs.
	* search.c (lookup_field): Likewise.
	(lookup_fnfields, lookup_field): Adjust for implicit typename kludge.
	* semantics.c (begin_constructor_declarator): Use enter_scope_of.
	(enter_scope_of): Extract type from implicit typename.
	(begin_class_definition): Likewise.
	* lex.c (identifier_type): Handle implicit typename when checking
	for SELFNAME.
	* cp-tree.h: Declare flag_strict_prototype.
	* lex.c (do_scoped_id, do_identifier): Don't implicitly_declare if
	-fstrict-prototype.
	* decl.c (init_decl_processing): If -f{no,-}strict-prototype wasn't
	specified, set it to the value of pedantic.

From-SVN: r22158
parent 3d6ed3ef
1998-09-01 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (lookup_name_real): Also do implicit typename thing for
artificial TYPE_DECLs.
* search.c (lookup_field): Likewise.
(lookup_fnfields, lookup_field): Adjust for implicit typename kludge.
* semantics.c (begin_constructor_declarator): Use enter_scope_of.
(enter_scope_of): Extract type from implicit typename.
(begin_class_definition): Likewise.
* lex.c (identifier_type): Handle implicit typename when checking
for SELFNAME.
* cp-tree.h: Declare flag_strict_prototype.
* lex.c (do_scoped_id, do_identifier): Don't implicitly_declare if
-fstrict-prototype.
* decl.c (init_decl_processing): If -f{no,-}strict-prototype wasn't
specified, set it to the value of pedantic.
1998-09-01 Mark Mitchell <mark@markmitchell.com> 1998-09-01 Mark Mitchell <mark@markmitchell.com>
* decl2.c (arg_assoc): Handle template-id expressions as arguments. * decl2.c (arg_assoc): Handle template-id expressions as arguments.
......
...@@ -477,6 +477,11 @@ extern int flag_do_squangling; ...@@ -477,6 +477,11 @@ extern int flag_do_squangling;
required. */ required. */
extern int flag_optional_diags; extern int flag_optional_diags;
/* Nonzero means do not consider empty argument prototype to mean function
takes no arguments. */
extern int flag_strict_prototype;
/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */ /* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */
extern int flag_vtable_gc; extern int flag_vtable_gc;
......
...@@ -5091,8 +5091,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) ...@@ -5091,8 +5091,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
else if (processing_template_decl else if (processing_template_decl
&& classval && TREE_CODE (classval) == TYPE_DECL && classval && TREE_CODE (classval) == TYPE_DECL
&& ! currently_open_class (DECL_CONTEXT (classval)) && ! currently_open_class (DECL_CONTEXT (classval))
&& uses_template_parms (current_class_type) && uses_template_parms (current_class_type))
&& ! DECL_ARTIFICIAL (classval))
classval = lookup_field (current_class_type, name, 0, 1); classval = lookup_field (current_class_type, name, 0, 1);
/* yylex() calls this with -2, since we should never start digging for /* yylex() calls this with -2, since we should never start digging for
...@@ -5470,7 +5469,6 @@ init_decl_processing () ...@@ -5470,7 +5469,6 @@ init_decl_processing ()
int wchar_type_size; int wchar_type_size;
tree temp; tree temp;
tree array_domain_type; tree array_domain_type;
extern int flag_strict_prototype;
tree vb_off_identifier = NULL_TREE; tree vb_off_identifier = NULL_TREE;
/* Function type `char *(char *, char *)' and similar ones */ /* Function type `char *(char *, char *)' and similar ones */
tree string_ftype_ptr_ptr, int_ftype_string_string; tree string_ftype_ptr_ptr, int_ftype_string_string;
...@@ -5492,12 +5490,9 @@ init_decl_processing () ...@@ -5492,12 +5490,9 @@ init_decl_processing ()
current_lang_name = NULL_TREE; current_lang_name = NULL_TREE;
if (flag_strict_prototype == 2) if (flag_strict_prototype == 2)
{ flag_strict_prototype = pedantic;
if (pedantic)
strict_prototypes_lang_c = strict_prototypes_lang_cplusplus; strict_prototypes_lang_c = flag_strict_prototype;
}
else
strict_prototypes_lang_c = flag_strict_prototype;
/* Initially, C. */ /* Initially, C. */
current_lang_name = lang_name_c; current_lang_name = lang_name_c;
......
...@@ -826,7 +826,6 @@ process_start_catch_block (declspecs, declarator) ...@@ -826,7 +826,6 @@ process_start_catch_block (declspecs, declarator)
} }
/* Call this to end a catch block. Its responsible for emitting the /* Call this to end a catch block. Its responsible for emitting the
code to handle jumping back to the correct place, and for emitting code to handle jumping back to the correct place, and for emitting
the label to jump to if this catch block didn't match. */ the label to jump to if this catch block didn't match. */
......
/* Definitions for switches for C++. /* Definitions for switches for C++.
Copyright (C) 1995 Free Software Foundation, Inc. Copyright (C) 1995, 1998 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
......
...@@ -2754,6 +2754,7 @@ int ...@@ -2754,6 +2754,7 @@ int
identifier_type (decl) identifier_type (decl)
tree decl; tree decl;
{ {
tree t;
if (TREE_CODE (decl) == TEMPLATE_DECL) if (TREE_CODE (decl) == TEMPLATE_DECL)
{ {
if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL) if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
...@@ -2763,7 +2764,6 @@ identifier_type (decl) ...@@ -2763,7 +2764,6 @@ identifier_type (decl)
} }
if (looking_for_template && really_overloaded_fn (decl)) if (looking_for_template && really_overloaded_fn (decl))
{ {
tree t;
for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t)) for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t))) if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
return PFUNCNAME; return PFUNCNAME;
...@@ -2772,10 +2772,20 @@ identifier_type (decl) ...@@ -2772,10 +2772,20 @@ identifier_type (decl)
return NSNAME; return NSNAME;
if (TREE_CODE (decl) != TYPE_DECL) if (TREE_CODE (decl) != TYPE_DECL)
return IDENTIFIER; return IDENTIFIER;
if (((got_scope && TREE_TYPE (decl) == got_scope) if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
|| TREE_TYPE (decl) == current_class_type) return SELFNAME;
&& DECL_ARTIFICIAL (decl))
/* A constructor declarator for a template type will get here as an
implicit typename, a TYPENAME_TYPE with a type. */
t = got_scope;
if (t && TREE_CODE (t) == TYPENAME_TYPE)
t = TREE_TYPE (t);
decl = TREE_TYPE (decl);
if (TREE_CODE (decl) == TYPENAME_TYPE)
decl = TREE_TYPE (decl);
if (t && t == decl)
return SELFNAME; return SELFNAME;
return TYPENAME; return TYPENAME;
} }
...@@ -2902,7 +2912,7 @@ do_identifier (token, parsing, args) ...@@ -2902,7 +2912,7 @@ do_identifier (token, parsing, args)
cp_error ("`%D' not defined", token); cp_error ("`%D' not defined", token);
id = error_mark_node; id = error_mark_node;
} }
else if (in_call) else if (in_call && ! flag_strict_prototype)
{ {
id = implicitly_declare (token); id = implicitly_declare (token);
} }
...@@ -3054,7 +3064,8 @@ do_scoped_id (token, parsing) ...@@ -3054,7 +3064,8 @@ do_scoped_id (token, parsing)
LOOKUP_EXPR_GLOBAL (id) = 1; LOOKUP_EXPR_GLOBAL (id) = 1;
return id; return id;
} }
if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)) if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)
&& ! flag_strict_prototype)
id = implicitly_declare (token); id = implicitly_declare (token);
else else
{ {
......
...@@ -2598,7 +2598,6 @@ coerce_template_template_parms (parm_parms, arg_parms, in_decl, outer_args) ...@@ -2598,7 +2598,6 @@ coerce_template_template_parms (parm_parms, arg_parms, in_decl, outer_args)
return 1; return 1;
} }
/* Convert the indicated template ARG as necessary to match the /* Convert the indicated template ARG as necessary to match the
indicated template PARM. Returns the converted ARG, or indicated template PARM. Returns the converted ARG, or
error_mark_node if the conversion was unsuccessful. Error messages error_mark_node if the conversion was unsuccessful. Error messages
......
...@@ -1030,9 +1030,12 @@ lookup_field (xbasetype, name, protect, want_type) ...@@ -1030,9 +1030,12 @@ lookup_field (xbasetype, name, protect, want_type)
basetype_chain = TREE_CHAIN (basetype_chain); basetype_chain = TREE_CHAIN (basetype_chain);
basetype_path = TREE_VALUE (basetype_chain); basetype_path = TREE_VALUE (basetype_chain);
if (TREE_CHAIN (basetype_chain)) if (TREE_CHAIN (basetype_chain))
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path) my_friendly_assert
== TREE_VALUE (TREE_CHAIN (basetype_chain)), ((BINFO_INHERITANCE_CHAIN (basetype_path)
980827); == TREE_VALUE (TREE_CHAIN (basetype_chain)))
/* We only approximate base info for partial instantiations. */
|| current_template_parms,
980827);
else else
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path) my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
== NULL_TREE, 980827); == NULL_TREE, 980827);
...@@ -1187,7 +1190,6 @@ lookup_field (xbasetype, name, protect, want_type) ...@@ -1187,7 +1190,6 @@ lookup_field (xbasetype, name, protect, want_type)
/* Do implicit typename stuff. */ /* Do implicit typename stuff. */
if (rval && TREE_CODE (rval) == TYPE_DECL if (rval && TREE_CODE (rval) == TYPE_DECL
&& ! DECL_ARTIFICIAL (rval)
&& processing_template_decl && processing_template_decl
&& ! currently_open_class (BINFO_TYPE (rval_binfo)) && ! currently_open_class (BINFO_TYPE (rval_binfo))
&& uses_template_parms (type)) && uses_template_parms (type))
...@@ -1480,9 +1482,12 @@ lookup_fnfields (basetype_path, name, complain) ...@@ -1480,9 +1482,12 @@ lookup_fnfields (basetype_path, name, complain)
basetype_chain = TREE_CHAIN (basetype_chain); basetype_chain = TREE_CHAIN (basetype_chain);
basetype_path = TREE_VALUE (basetype_chain); basetype_path = TREE_VALUE (basetype_chain);
if (TREE_CHAIN (basetype_chain)) if (TREE_CHAIN (basetype_chain))
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path) my_friendly_assert
== TREE_VALUE (TREE_CHAIN (basetype_chain)), ((BINFO_INHERITANCE_CHAIN (basetype_path)
980827); == TREE_VALUE (TREE_CHAIN (basetype_chain)))
/* We only approximate base info for partial instantiations. */
|| current_template_parms,
980827);
else else
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path) my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
== NULL_TREE, 980827); == NULL_TREE, 980827);
......
...@@ -1114,13 +1114,7 @@ begin_constructor_declarator (scope, name) ...@@ -1114,13 +1114,7 @@ begin_constructor_declarator (scope, name)
tree name; tree name;
{ {
tree result = build_parse_node (SCOPE_REF, scope, name); tree result = build_parse_node (SCOPE_REF, scope, name);
enter_scope_of (result);
if (scope != current_class_type)
{
push_nested_class (scope, 3);
TREE_COMPLEXITY (result) = current_class_depth;
}
return result; return result;
} }
...@@ -1214,24 +1208,27 @@ tree ...@@ -1214,24 +1208,27 @@ tree
begin_class_definition (t) begin_class_definition (t)
tree t; tree t;
{ {
tree new_type = t;
push_obstacks_nochange (); push_obstacks_nochange ();
end_temporary_allocation (); end_temporary_allocation ();
if (t == error_mark_node if (t == error_mark_node
|| ! IS_AGGR_TYPE (t)) || ! IS_AGGR_TYPE (t))
{ {
t = new_type = make_lang_type (RECORD_TYPE); t = make_lang_type (RECORD_TYPE);
pushtag (make_anon_name (), t, 0); pushtag (make_anon_name (), t, 0);
} }
/* In a definition of a member class template, we will get here with an
implicit typename, a TYPENAME_TYPE with a type. */
if (TREE_CODE (t) == TYPENAME_TYPE)
t = TREE_TYPE (t);
if (TYPE_SIZE (t)) if (TYPE_SIZE (t))
duplicate_tag_error (t); duplicate_tag_error (t);
if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t)) if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
{ {
t = make_lang_type (TREE_CODE (t)); t = make_lang_type (TREE_CODE (t));
pushtag (TYPE_IDENTIFIER (t), t, 0); pushtag (TYPE_IDENTIFIER (t), t, 0);
new_type = t;
} }
if (processing_template_decl && TYPE_CONTEXT (t) if (processing_template_decl && TYPE_CONTEXT (t)
&& TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL && TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL
...@@ -1267,9 +1264,9 @@ begin_class_definition (t) ...@@ -1267,9 +1264,9 @@ begin_class_definition (t)
CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing; CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
} }
#if 0 #if 0
t = TYPE_IDENTIFIER ($<ttype>0); tmp = TYPE_IDENTIFIER ($<ttype>0);
if (t && IDENTIFIER_TEMPLATE (t)) if (tmp && IDENTIFIER_TEMPLATE (tmp))
overload_template_name (t, 1); overload_template_name (tmp, 1);
#endif #endif
reset_specialization(); reset_specialization();
...@@ -1278,7 +1275,7 @@ begin_class_definition (t) ...@@ -1278,7 +1275,7 @@ begin_class_definition (t)
that we can get it back later. */ that we can get it back later. */
begin_tree (); begin_tree ();
return new_type; return t;
} }
/* Finish a class definition T, with the indicated COMPONENTS, and /* Finish a class definition T, with the indicated COMPONENTS, and
...@@ -1432,6 +1429,13 @@ enter_scope_of (sr) ...@@ -1432,6 +1429,13 @@ enter_scope_of (sr)
} }
else if (scope != current_class_type) else if (scope != current_class_type)
{ {
if (TREE_CODE (scope) == TYPENAME_TYPE)
{
/* In a declarator for a template class member, the scope will
get here as an implicit typename, a TYPENAME_TYPE with a type. */
scope = TREE_TYPE (scope);
TREE_OPERAND (sr, 0) = scope;
}
push_nested_class (scope, 3); push_nested_class (scope, 3);
TREE_COMPLEXITY (sr) = current_class_depth; TREE_COMPLEXITY (sr) = current_class_depth;
} }
......
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