Commit a7e8c268 by Mark Mitchell Committed by Mark Mitchell

re PR c++/3907 (nested template parm collides with member name)

	* coverage.c (create_coverage): Do not call pushlevel/poplevel.
	* langhooks-def.h (lhd_do_nothing_iii_return_null_tree): New
	function.
	* langhooks.c (lhd_do_nothing_iii_return_null_tree): Define it.

	PR c++/3907
	* class.c (maybe_note_name_used_in_class): Refine test for whether
	or not we are in a class scope.

	* cp-tree.h (language_function): Remove x_expanding_p.
	(expanding_p): Remove.
	(doing_semantic_analysis_p): Remove.
	(scope_kind): Add sk_function_parms, sk_class,
	sk_namespace.
	(innermost_scope_kind): New method.
	* call.c (cxx_type_promotes_to): Use type_decays_to.
	* cp-lang.c (LANG_HOOKS_PUSHLEVEL): Redefine.
	(LANG_HOOKS_POPLEVEL): Likewise.
	* decl.c (cp_binding_level): Remove parm_flag, template_parms_p,
	template_spec_p, namespace_p, is_for_scope, is_try_scope, and
	is_catch_scope.  Add kind and explicit_spec_p.
	(cxx_scope_descriptor): Use a lookup table.
	(find_class_binding_level): Use "kind" field in binding_level, not
	the various flags.
	(pop_binding_level): Likewise.
	(innermost_nonclass_level): Likewise.
	(toplevel_bindings_p): Likewise.
	(namespace_bindings_p): Likewise.
	(template_parm_scope_p): Likewise.
	(innermost_scope_kind): New method.
	(current_tmpl_spec_kind): Use "kind" field in binding_level, not
	the various flags.
	(pushlevel): Remove check for doing_semantic_analysis_p.
	(begin_scope): Simplify.
	(add_decl_to_level): Use "kind" field in binding_level, not
	the various flags.
	(push_local_binding): Likewise.
	(pop_label): Remove check for doing_semantic_analysis_p.
	(poplevel): Use "kind" field in binding_level, not
	the various flags.
	(set_block): Remove check for doing_semantic_analysis_p.
	(pushlevel_class): Use "kind" field in binding_level, not
	the various flags.
	(poplevel_class): Likewise.
	(initial_push_namespace_scope): Likewise.
	(maybe_push_to_top_level): Likewise.
	(set_identifier_type_value_with_scope): Likewise.
	(pop_everything): Likewise.
	(maybe_process_template_type_declaration): Likewise.
	(pushtag): Likewise.
	(pushdecl): Likewise.
	(pushdecl_with_scope): Likewise.
	(check_previous_goto_1): Likewise.
	(define_label): Likewise.
	(finish_case_label): Likewise.
	(lookup_tag): Likewise.
	(unqualified_namespace_lookup): Likewise.
	(lookup_name_real): Likewise.
	(lookup_name_current_level): Likewise.
	(lookup_type_current_level): Likewise.
	(record_builtin_type): Likewise.
	(cp_make_fname_decl): Likewise.
	(maybe_inject_for_scope_var): Likewise.
	(cp_finish_decl): Remove check for doing_semantic_analysis_p.
	(start_function): Use begin_scope, not pushlevel.
	(finish_function): Use "kind" field in binding_level, not
	the various flags.
	(start_method): Use begin_scope, not pushlevel.
	(make_label_decl): Do not check expanding_p.
	(save_function-data): Do not set expanding_p.
	(cxx_push_function_context): Do not clear expanding_p.
	* semantics.c (cxx_expand_function_start): Do not set expanding_p.

	PR c++/3907
	* g++.dg/parse/template12.C: New test.

	* g++.dg/abi/bitfield11.C: New test.
	* g++.dg/abi/bitfield12.C: Likewise.

From-SVN: r71393
parent 29edb15c
2003-09-12 Mark Mitchell <mark@codesourcery.com>
* coverage.c (create_coverage): Do not call pushlevel/poplevel.
* langhooks-def.h (lhd_do_nothing_iii_return_null_tree): New
function.
* langhooks.c (lhd_do_nothing_iii_return_null_tree): Define it.
2003-09-14 Kazu Hirata <kazu@cs.umass.edu> 2003-09-14 Kazu Hirata <kazu@cs.umass.edu>
* combine.c (simplify_comparison): Convert * combine.c (simplify_comparison): Convert
......
...@@ -854,19 +854,18 @@ create_coverage (void) ...@@ -854,19 +854,18 @@ create_coverage (void)
rest_of_decl_compilation (ctor, 0, 1, 0); rest_of_decl_compilation (ctor, 0, 1, 0);
announce_function (ctor); announce_function (ctor);
current_function_decl = ctor; current_function_decl = ctor;
DECL_INITIAL (ctor) = error_mark_node;
make_decl_rtl (ctor, NULL); make_decl_rtl (ctor, NULL);
init_function_start (ctor); init_function_start (ctor);
(*lang_hooks.decls.pushlevel) (0);
expand_function_start (ctor, 0); expand_function_start (ctor, 0);
/* Actually generate the code to call __gcov_init. */ /* Actually generate the code to call __gcov_init. */
gcov_info_address = force_reg (Pmode, XEXP (DECL_RTL (gcov_info), 0)); gcov_info_address = force_reg (Pmode, XEXP (DECL_RTL (gcov_info), 0));
emit_library_call (gcov_init_libfunc, LCT_NORMAL, VOIDmode, 1, emit_library_call (gcov_init_libfunc, LCT_NORMAL, VOIDmode, 1,
gcov_info_address, Pmode); gcov_info_address, Pmode);
expand_function_end (); expand_function_end ();
(*lang_hooks.decls.poplevel) (1, 0, 1); /* Create a dummy BLOCK. */
DECL_INITIAL (ctor) = make_node (BLOCK);
TREE_USED (DECL_INITIAL (ctor)) = 1;
rest_of_compilation (ctor); rest_of_compilation (ctor);
......
2003-09-12 Mark Mitchell <mark@codesourcery.com>
PR c++/3907
* class.c (maybe_note_name_used_in_class): Refine test for whether
or not we are in a class scope.
* cp-tree.h (language_function): Remove x_expanding_p.
(expanding_p): Remove.
(doing_semantic_analysis_p): Remove.
(scope_kind): Add sk_function_parms, sk_class,
sk_namespace.
(innermost_scope_kind): New method.
* call.c (cxx_type_promotes_to): Use type_decays_to.
* cp-lang.c (LANG_HOOKS_PUSHLEVEL): Redefine.
(LANG_HOOKS_POPLEVEL): Likewise.
* decl.c (cp_binding_level): Remove parm_flag, template_parms_p,
template_spec_p, namespace_p, is_for_scope, is_try_scope, and
is_catch_scope. Add kind and explicit_spec_p.
(cxx_scope_descriptor): Use a lookup table.
(find_class_binding_level): Use "kind" field in binding_level, not
the various flags.
(pop_binding_level): Likewise.
(innermost_nonclass_level): Likewise.
(toplevel_bindings_p): Likewise.
(namespace_bindings_p): Likewise.
(template_parm_scope_p): Likewise.
(innermost_scope_kind): New method.
(current_tmpl_spec_kind): Use "kind" field in binding_level, not
the various flags.
(pushlevel): Remove check for doing_semantic_analysis_p.
(begin_scope): Simplify.
(add_decl_to_level): Use "kind" field in binding_level, not
the various flags.
(push_local_binding): Likewise.
(pop_label): Remove check for doing_semantic_analysis_p.
(poplevel): Use "kind" field in binding_level, not
the various flags.
(set_block): Remove check for doing_semantic_analysis_p.
(pushlevel_class): Use "kind" field in binding_level, not
the various flags.
(poplevel_class): Likewise.
(initial_push_namespace_scope): Likewise.
(maybe_push_to_top_level): Likewise.
(set_identifier_type_value_with_scope): Likewise.
(pop_everything): Likewise.
(maybe_process_template_type_declaration): Likewise.
(pushtag): Likewise.
(pushdecl): Likewise.
(pushdecl_with_scope): Likewise.
(check_previous_goto_1): Likewise.
(define_label): Likewise.
(finish_case_label): Likewise.
(lookup_tag): Likewise.
(unqualified_namespace_lookup): Likewise.
(lookup_name_real): Likewise.
(lookup_name_current_level): Likewise.
(lookup_type_current_level): Likewise.
(record_builtin_type): Likewise.
(cp_make_fname_decl): Likewise.
(maybe_inject_for_scope_var): Likewise.
(cp_finish_decl): Remove check for doing_semantic_analysis_p.
(start_function): Use begin_scope, not pushlevel.
(finish_function): Use "kind" field in binding_level, not
the various flags.
(start_method): Use begin_scope, not pushlevel.
(make_label_decl): Do not check expanding_p.
(save_function-data): Do not set expanding_p.
(cxx_push_function_context): Do not clear expanding_p.
* semantics.c (cxx_expand_function_start): Do not set expanding_p.
2003-09-14 Mark Mitchell <mark@codesourcery.com> 2003-09-14 Mark Mitchell <mark@codesourcery.com>
* class.c (layout_class_type): Make DECL_MODE match TYPE_MODE for * class.c (layout_class_type): Make DECL_MODE match TYPE_MODE for
......
...@@ -4278,11 +4278,9 @@ cxx_type_promotes_to (tree type) ...@@ -4278,11 +4278,9 @@ cxx_type_promotes_to (tree type)
{ {
tree promote; tree promote;
if (TREE_CODE (type) == ARRAY_TYPE) /* Perform the array-to-pointer and function-to-pointer
return build_pointer_type (TREE_TYPE (type)); conversions. */
type = type_decays_to (type);
if (TREE_CODE (type) == FUNCTION_TYPE)
return build_pointer_type (type);
promote = type_promotes_to (type); promote = type_promotes_to (type);
if (same_type_p (type, promote)) if (same_type_p (type, promote))
......
...@@ -6358,7 +6358,7 @@ maybe_note_name_used_in_class (tree name, tree decl) ...@@ -6358,7 +6358,7 @@ maybe_note_name_used_in_class (tree name, tree decl)
splay_tree names_used; splay_tree names_used;
/* If we're not defining a class, there's nothing to do. */ /* If we're not defining a class, there's nothing to do. */
if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type)) if (innermost_scope_kind() != sk_class)
return; return;
/* If there's already a binding for this NAME, then we don't have /* If there's already a binding for this NAME, then we don't have
......
...@@ -102,6 +102,10 @@ static void cxx_initialize_diagnostics (diagnostic_context *); ...@@ -102,6 +102,10 @@ static void cxx_initialize_diagnostics (diagnostic_context *);
#define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name #define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name
#undef LANG_HOOKS_PRINT_ERROR_FUNCTION #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
#define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function #define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function
#undef LANG_HOOKS_PUSHLEVEL
#define LANG_HOOKS_PUSHLEVEL lhd_do_nothing_i
#undef LANG_HOOKS_POPLEVEL
#define LANG_HOOKS_POPLEVEL lhd_do_nothing_iii_return_null_tree
#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
#undef LANG_HOOKS_WRITE_GLOBALS #undef LANG_HOOKS_WRITE_GLOBALS
......
...@@ -798,7 +798,6 @@ struct language_function GTY(()) ...@@ -798,7 +798,6 @@ struct language_function GTY(())
int returns_abnormally; int returns_abnormally;
int in_function_try_handler; int in_function_try_handler;
int in_base_initializer; int in_base_initializer;
int x_expanding_p;
/* True if this function can throw an exception. */ /* True if this function can throw an exception. */
bool can_throw : 1; bool can_throw : 1;
...@@ -860,17 +859,6 @@ struct language_function GTY(()) ...@@ -860,17 +859,6 @@ struct language_function GTY(())
#define current_function_returns_abnormally \ #define current_function_returns_abnormally \
cp_function_chain->returns_abnormally cp_function_chain->returns_abnormally
/* Nonzero if we should generate RTL for functions that we process.
When this is zero, we just accumulate tree structure, without
interacting with the back end. */
#define expanding_p cp_function_chain->x_expanding_p
/* Nonzero if we are in the semantic analysis phase for the current
function. */
#define doing_semantic_analysis_p() (!expanding_p)
/* Nonzero if we are processing a base initializer. Zero elsewhere. */ /* Nonzero if we are processing a base initializer. Zero elsewhere. */
#define in_base_initializer cp_function_chain->in_base_initializer #define in_base_initializer cp_function_chain->in_base_initializer
...@@ -2942,15 +2930,24 @@ typedef enum cp_lvalue_kind { ...@@ -2942,15 +2930,24 @@ typedef enum cp_lvalue_kind {
/* The kinds of scopes we recognize. */ /* The kinds of scopes we recognize. */
typedef enum scope_kind { typedef enum scope_kind {
sk_block, /* An ordinary block scope. */ sk_block = 0, /* An ordinary block scope. This enumerator must
have the value zero because "cp_binding_level"
is initialized by using "memset" to set the
contents to zero, and the default scope kind
is "sk_block". */
sk_try, /* A try-block. */ sk_try, /* A try-block. */
sk_catch, /* A catch-block. */ sk_catch, /* A catch-block. */
sk_for, /* The scope of the variable declared in a sk_for, /* The scope of the variable declared in a
for-init-statement. */ for-init-statement. */
sk_function_parms, /* The scope containing function parameters. */
sk_class, /* The scope containing the members of a class. */
sk_namespace, /* The scope containing the members of a
namespace, including the global scope. */
sk_template_parms, /* A scope for template parameters. */ sk_template_parms, /* A scope for template parameters. */
sk_template_spec /* A scope corresponding to a template sk_template_spec /* Like sk_template_parms, but for an explicit
specialization. There is never anything in specialization. Since, by definition, an
this scope. */ explicit specialization is introduced by
"template <>", this scope is always empty. */
} scope_kind; } scope_kind;
/* Various kinds of template specialization, instantiation, etc. */ /* Various kinds of template specialization, instantiation, etc. */
...@@ -3622,6 +3619,7 @@ extern void cxx_mark_function_context (struct function *); ...@@ -3622,6 +3619,7 @@ extern void cxx_mark_function_context (struct function *);
extern int toplevel_bindings_p (void); extern int toplevel_bindings_p (void);
extern int namespace_bindings_p (void); extern int namespace_bindings_p (void);
extern void keep_next_level (int); extern void keep_next_level (int);
extern scope_kind innermost_scope_kind (void);
extern int template_parm_scope_p (void); extern int template_parm_scope_p (void);
extern void set_class_shadows (tree); extern void set_class_shadows (tree);
extern void maybe_push_cleanup_level (tree); extern void maybe_push_cleanup_level (tree);
......
...@@ -2971,10 +2971,6 @@ nullify_returns_r (tree* tp, int* walk_subtrees, void* data) ...@@ -2971,10 +2971,6 @@ nullify_returns_r (tree* tp, int* walk_subtrees, void* data)
void void
cxx_expand_function_start (void) cxx_expand_function_start (void)
{ {
/* Let everybody know that we're expanding this function, not doing
semantic analysis. */
expanding_p = 1;
/* Give our named return value the same RTL as our RESULT_DECL. */ /* Give our named return value the same RTL as our RESULT_DECL. */
if (current_function_return_value) if (current_function_return_value)
COPY_DECL_RTL (DECL_RESULT (cfun->decl), current_function_return_value); COPY_DECL_RTL (DECL_RESULT (cfun->decl), current_function_return_value);
......
...@@ -47,6 +47,7 @@ extern bool lhd_post_options (const char **); ...@@ -47,6 +47,7 @@ extern bool lhd_post_options (const char **);
extern HOST_WIDE_INT lhd_get_alias_set (tree); extern HOST_WIDE_INT lhd_get_alias_set (tree);
extern tree lhd_return_tree (tree); extern tree lhd_return_tree (tree);
extern tree lhd_return_null_tree (tree); extern tree lhd_return_null_tree (tree);
extern tree lhd_do_nothing_iii_return_null_tree (int, int, int);
extern int lhd_safe_from_p (rtx, tree); extern int lhd_safe_from_p (rtx, tree);
extern int lhd_staticp (tree); extern int lhd_staticp (tree);
extern int lhd_unsafe_for_reeval (tree); extern int lhd_unsafe_for_reeval (tree);
......
...@@ -56,6 +56,16 @@ lhd_do_nothing_i (int i ATTRIBUTE_UNUSED) ...@@ -56,6 +56,16 @@ lhd_do_nothing_i (int i ATTRIBUTE_UNUSED)
{ {
} }
/* Do nothing (int, int, int). Return NULL_TREE. */
tree
lhd_do_nothing_iii_return_null_tree (int i ATTRIBUTE_UNUSED,
int j ATTRIBUTE_UNUSED,
int k ATTRIBUTE_UNUSED)
{
return NULL_TREE;
}
/* Do nothing (function). */ /* Do nothing (function). */
void void
......
2003-09-14 Mark Mitchell <mark@codesourcery.com> 2003-09-14 Mark Mitchell <mark@codesourcery.com>
PR c++/3907
* g++.dg/parse/template12.C: New test.
* g++.dg/abi/bitfield11.C: New test. * g++.dg/abi/bitfield11.C: New test.
* g++.dg/abi/bitfield12.C: Likewise. * g++.dg/abi/bitfield12.C: Likewise.
......
template <int J>
struct A {
};
struct B {
template <int I>
struct C : public A<I> {};
typedef double I;
};
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