summaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authordberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-08 23:37:11 +0000
committerdberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-08 23:37:11 +0000
commit5ded8c6f262065518f04c441d1ea847fa38c5b38 (patch)
treee8e5667e9ce5aa5fc7514d5caa37a74c88e3f391 /gcc/c-decl.c
parent6c3c4d74d98659fda5994e5b843fa6b6842ce8aa (diff)
downloadgcc-5ded8c6f262065518f04c441d1ea847fa38c5b38.tar.gz
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* Makefile.in (TREE_H): Add treestruct.def. (c-decl.o): Add pointer-set.h * c-decl.c (diagnose_mismatched_decls): Don't attempt to look at visibility on regular DECL's. (merge_decls): Fix the copying of decl nodes of various types for the new structures. Don't update RTL, section name, weak status, etc, on DECL's without RTL. (grokdeclarator): DECL_ARG_TYPE_AS_WRITTEN is gone. Don't check volatile on non-variable types. (store_parm_decls_oldstyle): Use pointer_set instead of DECL_WEAK to check whether we have seen arguments. * c-objc-common.c (c_tree_printer): Reverse order of tests so that flag is checked before field (flag is common, field is not). * dwarf2out.c (decl_ultimate_origin): Only DECL's with TS_DECL_COMMON could have an origin. (add_location_or_const_value_attribute): Don't check section name on non-var/function decls. (dwarf2out_var_location): Reverse order of tests. * emit-rtl.c (set_reg_attrs_for_parm): DECL_CHECK is dead, replace with DECL_WRTL_CHECK. * expmed.c (make_tree): rtl is now in decl_with_rtl. * fold-const.c (fold_binary): Don't check weakness on non-var/function decls. (tree_expr_nonzero_p): Ditto. (fold_checksum_tree): Use tree_decl_extra as sizeof buffer. * ggc-page.c (extra_order_size_table): Add sizes for tree_decl_non_common, tree_parm_decl, tree_var_decl, and tree_field_decl. * gimplify.c (gimplify_bind_expr): Only set DECL_SEEN_IN_BIND_EXPR_P on VAR_DECL. * integrate.c (copy_decl_for_inlining): Don't set RTL on decl's without RTL. * langhooks-def.h (LANG_HOOK_INIT_TS): New. * langhooks.h (init_ts). New langhook. * passes.c (rest_of_decl_compilation): Reverse order of tests. * print-tree.c (print_node): Update to only print fields that exist in the structures the passed decl has. * toplev.c (wrapup_global_declarations): Don't reset DECL_DEFER_OUTPUT on DECL's that don't contain it. * tree-browser.c (browse_tree): DECL_ARG_TYPE_AS_WRITTEN removed. * tree-inline.c (remap_decl): Ditto. * tree-outof-ssa.c (create_temp): Reverse order of tests. * tree-pretty-print.c (print_declaration): Don't print DECL_REGISTER on things that don't contain it. * tree-vrp.c (expr_computes_nonzero): Don't check weakness on non-var/function decls. * tree.c (tree_contains_struct): New structure. (init_priority_for_decl): New hashtable. (tree_int_map): New structure. (tree_int_map_eq): New function. (tree_int_map_marked_p): Ditto. (tree_int_map_hash): Ditto. (tree_map): Move to tree.h. (tree_map_eq): Externalize. (tree_map_hash): Ditto. (tree_map_marked_p): Ditto. (init_ttree): Set up tree_contains_struct and call langhook. (decl_assembler_name): Use DECL_NON_COMMON_CHECK.. (tree_code_size): Update for new structures. (tree_node_structure): Update for new structures. (make_node_stat): Don't try to set DECL_IN_SYSTEM_HEADER on decls without the field. (copy_node_stat): Copy init priority. (build_decl_stat): Ditto for visibility. (ts_enum_names): New. (tree_contains_struct_check_failed): New function. (decl_init_priority_lookup): Ditto. (decl_init_priority_insert): Ditto. * treestruct.def: New file. * tree.h (CODE_CONTAINS_STRUCT): New macro. (CONTAINS_STRUCT_CHECK): Ditto. (tree_contains_struct_check_failed): New prototype. (DECL_CHECK): Removed. (DECL_MINIMAL_CHECK): New. (DECL_COMMON_CHECK): Ditto. (DECL_WRTL_CHECK): Ditto. (DECL_NON_COMMON_CHECK): Ditto. (DECL_WITH_VIS_CHECK): Ditto. (VAR_OR_FUNCTION_DECL_P): Ditto (struct tree_decl_minimal): New structure. (struct tree_decl_common): Ditto. (struct tree_decl_with_rtl): Ditto. (struct tree_decl_with_vis): Ditto. (struct tree_decl_non_common): Ditto. (struct tree_field_decl): Ditto. (struct tree_parm_decl): Ditto. (struct tree_var_decl): Ditto. (struct tree_function_decl): Ditto. (struct tree_const_decl): Ditto. (struct tree_result_decl): Ditto. (union tree_node): Add new structures. * var-tracking.c (track_expr_p): Reverse order of tests. * doc/c-tree.texi: Add documentation on DECL node internal structure. 2005-07-08 Daniel Berlin <dberlin@dberlin.org> * utils.c (create_param_decl): DECL_ARG_TYPE_AS_WRITTEN is removed. 2005-07-08 Daniel Berlin <dberlin@dberlin.org> * Make-lang.in: Add gt-cp-lang.h. (cp-lang.o): Ditto. * class.c (create_vtable_ptr): Stop setting DECL_ASSEMBLER_NAME on the field. * config-lang.in: Add cp-lang.c to gtfiles. * cp-lang.c: Include hashtab.h. (cp_init_ts): New function. (LANG_HOOK_INIT_TS): Use macro. (decl_shadowed_for_var_lookup): New function. (decl_shadowed_for_var_insert): Ditto. * cp-tree.h (THUNK_FUNCTION_CHECK): Use decl_common. (NON_THUNK_FUNCTION_CHECK): Ditto. (DECL_NAMESPACE_ASSOCIATIONS): Use decl_non_common. (DECL_INIT_PRIORITY): Ditto. (DECL_HAS_SHADOWED_FOR_VAR_P): Ditto. (DECL_SHADOWED_FOR_VAR): Use hashtable. (SET_DECL_SHADOWED_FOR_VAR): Ditto. * decl.c (duplicate_decls): Update for new/updated structures. (poplevel): Use SET_DECL_SHADOWED_FOR_VAR. * decl2.c (start_static_initialization_or_destruction): Deal with priority. * pt.c (tsubst_decl): Check TS_DECL_WRTL before doing SET_DECL_RTL. * tree.c (handle_init_priority_attribute): Handle priority. 2005-07-08 Daniel Berlin <dberlin@dberlin.org> * objc-act.c (objc_push_parm): DECL_ARG_TYPE_AS_WRITTEN is removed. * objc-act.h (KEYWORD_ARG_NAME): Use decl_non_common. (KEYWORD_KEY_NAME): Use decl_minimal. (METHOD_SEL_NAME): Ditto.. (METHOD_SEL_ARGS): Use decl_non_common. (METHOD_ADD_ARGS): Ditto. (METHOD_ADD_ARGS_ELLIPSIS_P): Use decl_common. (METHOD_DEFINITION): Ditto. (METHOD_ENCODING): Ditto. * objc-lang.c: (objc_init_ts): New function. 2005-07-08 Daniel Berlin <dberlin@dberlin.org> * trans-decl.c (create_function_arglist): DECL_ARG_TYPE_AS_WRITTEN is removed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101799 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c333
1 files changed, 177 insertions, 156 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 23ff373ed0d..67c72a58d8c 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -60,6 +60,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "libfuncs.h"
#include "except.h"
#include "langhooks-def.h"
+#include "pointer-set.h"
/* In grokdeclarator, distinguish syntactic contexts of declarators. */
enum decl_context
@@ -1471,7 +1472,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
/* warnings */
/* All decls must agree on a visibility. */
- if (DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (newdecl), TS_DECL_WITH_VIS)
+ && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
&& DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
{
warning (0, "redeclaration of %q+D with different visibility "
@@ -1638,8 +1640,6 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
}
}
- /* Keep the old rtl since we can safely use it. */
- COPY_DECL_RTL (olddecl, newdecl);
/* Merge the type qualifiers. */
if (TREE_READONLY (newdecl))
@@ -1674,153 +1674,178 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
if (DECL_INITIAL (newdecl) == 0)
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
- /* Merge the section attribute.
- We want to issue an error if the sections conflict but that must be
- done later in decl_attributes since we are called before attributes
- are assigned. */
- if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
- DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
-
- /* Copy the assembler name.
- Currently, it can only be defined in the prototype. */
- COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
-
- /* Use visibility of whichever declaration had it specified */
- if (DECL_VISIBILITY_SPECIFIED (olddecl))
- {
- DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
- DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
- }
-
- if (TREE_CODE (newdecl) == FUNCTION_DECL)
- {
- DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
- DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
- DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
- DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
- |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
- TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
- TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
- DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
- DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl);
- DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
- }
-
- /* Merge the storage class information. */
- merge_weak (newdecl, olddecl);
-
- /* For functions, static overrides non-static. */
- if (TREE_CODE (newdecl) == FUNCTION_DECL)
- {
- TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
- /* This is since we don't automatically
- copy the attributes of NEWDECL into OLDDECL. */
- TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
- /* If this clears `static', clear it in the identifier too. */
- if (!TREE_PUBLIC (olddecl))
- TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
- }
- if (DECL_EXTERNAL (newdecl))
- {
- TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
- DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
-
- /* An extern decl does not override previous storage class. */
- TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
- if (!DECL_EXTERNAL (newdecl))
- {
- DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
- DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
- }
- }
- else
- {
- TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
- TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
- }
-
- if (TREE_CODE (newdecl) == FUNCTION_DECL)
- {
- /* If we're redefining a function previously defined as extern
- inline, make sure we emit debug info for the inline before we
- throw it away, in case it was inlined into a function that hasn't
- been written out yet. */
- if (new_is_definition && DECL_INITIAL (olddecl))
- {
- if (TREE_USED (olddecl)
- /* In unit-at-a-time mode we never inline re-defined extern
- inline functions. */
- && !flag_unit_at_a_time
- && cgraph_function_possibly_inlined_p (olddecl))
- (*debug_hooks->outlining_inline_function) (olddecl);
-
- /* The new defn must not be inline. */
- DECL_INLINE (newdecl) = 0;
- DECL_UNINLINABLE (newdecl) = 1;
- }
- else
- {
- /* If either decl says `inline', this fn is inline,
- unless its definition was passed already. */
- if (DECL_DECLARED_INLINE_P (newdecl)
- || DECL_DECLARED_INLINE_P (olddecl))
- DECL_DECLARED_INLINE_P (newdecl) = 1;
-
- DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
- = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
- }
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS))
+ {
+ /* Merge the section attribute.
+ We want to issue an error if the sections conflict but that must be
+ done later in decl_attributes since we are called before attributes
+ are assigned. */
+ if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
+ DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
+
+ /* Copy the assembler name.
+ Currently, it can only be defined in the prototype. */
+ COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
+
+ /* Use visibility of whichever declaration had it specified */
+ if (DECL_VISIBILITY_SPECIFIED (olddecl))
+ {
+ DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
+ DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
+ }
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
+ DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
+ DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
+ DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
+ |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
+ TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
+ TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
+ DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
+ DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl);
+ DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
+ }
+
+ /* Merge the storage class information. */
+ merge_weak (newdecl, olddecl);
- if (DECL_BUILT_IN (olddecl))
- {
- /* If redeclaring a builtin function, it stays built in.
- But it gets tagged as having been declared. */
- DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
- DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
- C_DECL_DECLARED_BUILTIN (newdecl) = 1;
- if (new_is_prototype)
- C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
- else
- C_DECL_BUILTIN_PROTOTYPE (newdecl)
- = C_DECL_BUILTIN_PROTOTYPE (olddecl);
- }
+ /* For functions, static overrides non-static. */
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
+ /* This is since we don't automatically
+ copy the attributes of NEWDECL into OLDDECL. */
+ TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
+ /* If this clears `static', clear it in the identifier too. */
+ if (!TREE_PUBLIC (olddecl))
+ TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
+ }
+ }
+
+ if (DECL_EXTERNAL (newdecl))
+ {
+ TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
+ DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
+
+ /* An extern decl does not override previous storage class. */
+ TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
+ if (!DECL_EXTERNAL (newdecl))
+ {
+ DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
+ DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
+ }
+ }
+ else
+ {
+ TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
+ TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
+ }
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ /* If we're redefining a function previously defined as extern
+ inline, make sure we emit debug info for the inline before we
+ throw it away, in case it was inlined into a function that hasn't
+ been written out yet. */
+ if (new_is_definition && DECL_INITIAL (olddecl))
+ {
+ if (TREE_USED (olddecl)
+ /* In unit-at-a-time mode we never inline re-defined extern
+ inline functions. */
+ && !flag_unit_at_a_time
+ && cgraph_function_possibly_inlined_p (olddecl))
+ (*debug_hooks->outlining_inline_function) (olddecl);
+
+ /* The new defn must not be inline. */
+ DECL_INLINE (newdecl) = 0;
+ DECL_UNINLINABLE (newdecl) = 1;
+ }
+ else
+ {
+ /* If either decl says `inline', this fn is inline,
+ unless its definition was passed already. */
+ if (DECL_DECLARED_INLINE_P (newdecl)
+ || DECL_DECLARED_INLINE_P (olddecl))
+ DECL_DECLARED_INLINE_P (newdecl) = 1;
+
+ DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
+ = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
+ }
- /* Also preserve various other info from the definition. */
- if (!new_is_definition)
- {
- DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
- DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
- DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
- DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
- DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
-
- /* Set DECL_INLINE on the declaration if we've got a body
- from which to instantiate. */
- if (DECL_INLINE (olddecl) && !DECL_UNINLINABLE (newdecl))
- {
- DECL_INLINE (newdecl) = 1;
- DECL_ABSTRACT_ORIGIN (newdecl)
- = DECL_ABSTRACT_ORIGIN (olddecl);
- }
- }
- else
- {
- /* If a previous declaration said inline, mark the
- definition as inlinable. */
- if (DECL_DECLARED_INLINE_P (newdecl)
- && !DECL_UNINLINABLE (newdecl))
- DECL_INLINE (newdecl) = 1;
- }
- }
+ if (DECL_BUILT_IN (olddecl))
+ {
+ /* If redeclaring a builtin function, it stays built in.
+ But it gets tagged as having been declared. */
+ DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
+ DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
+ C_DECL_DECLARED_BUILTIN (newdecl) = 1;
+ if (new_is_prototype)
+ C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0;
+ else
+ C_DECL_BUILTIN_PROTOTYPE (newdecl)
+ = C_DECL_BUILTIN_PROTOTYPE (olddecl);
+ }
- /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
+ /* Also preserve various other info from the definition. */
+ if (!new_is_definition)
+ {
+ DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
+ DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
+ DECL_STRUCT_FUNCTION (newdecl) = DECL_STRUCT_FUNCTION (olddecl);
+ DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
+ DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
+
+ /* Set DECL_INLINE on the declaration if we've got a body
+ from which to instantiate. */
+ if (DECL_INLINE (olddecl) && !DECL_UNINLINABLE (newdecl))
+ {
+ DECL_INLINE (newdecl) = 1;
+ DECL_ABSTRACT_ORIGIN (newdecl)
+ = DECL_ABSTRACT_ORIGIN (olddecl);
+ }
+ }
+ else
+ {
+ /* If a previous declaration said inline, mark the
+ definition as inlinable. */
+ if (DECL_DECLARED_INLINE_P (newdecl)
+ && !DECL_UNINLINABLE (newdecl))
+ DECL_INLINE (newdecl) = 1;
+ }
+ }
+
+ /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
But preserve OLDDECL's DECL_UID and DECL_CONTEXT. */
{
unsigned olddecl_uid = DECL_UID (olddecl);
tree olddecl_context = DECL_CONTEXT (olddecl);
-
+
memcpy ((char *) olddecl + sizeof (struct tree_common),
(char *) newdecl + sizeof (struct tree_common),
- sizeof (struct tree_decl) - sizeof (struct tree_common));
+ sizeof (struct tree_decl_common) - sizeof (struct tree_common));
+ switch (TREE_CODE (olddecl))
+ {
+ case FIELD_DECL:
+ case VAR_DECL:
+ case PARM_DECL:
+ case LABEL_DECL:
+ case RESULT_DECL:
+ case CONST_DECL:
+ case TYPE_DECL:
+ case FUNCTION_DECL:
+ memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
+ (char *) newdecl + sizeof (struct tree_decl_common),
+ tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
+ break;
+
+ default:
+
+ memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
+ (char *) newdecl + sizeof (struct tree_decl_common),
+ sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common));
+ }
DECL_UID (olddecl) = olddecl_uid;
DECL_CONTEXT (olddecl) = olddecl_context;
}
@@ -4475,7 +4500,6 @@ grokdeclarator (const struct c_declarator *declarator,
promoted_type = c_type_promotes_to (type);
DECL_ARG_TYPE (decl) = promoted_type;
- DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written;
if (declspecs->inline_p)
pedwarn ("parameter %q+D declared %<inline%>", decl);
}
@@ -4680,8 +4704,11 @@ grokdeclarator (const struct c_declarator *declarator,
/* If a type has volatile components, it should be stored in memory.
Otherwise, the fact that those components are volatile
- will be ignored, and would even crash the compiler. */
- if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)))
+ will be ignored, and would even crash the compiler.
+ Of course, this only makes sense on VAR,PARM, and RESULT decl's. */
+ if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl))
+ && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == RESULT_DECL))
{
/* It is not an error for a structure with volatile fields to
be declared register, but reset DECL_REGISTER since it
@@ -6088,13 +6115,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
struct c_binding *b;
tree parm, decl, last;
tree parmids = arg_info->parms;
-
- /* We use DECL_WEAK as a flag to show which parameters have been
- seen already, since it is not used on PARM_DECL. */
-#ifdef ENABLE_CHECKING
- for (b = current_scope->bindings; b; b = b->prev)
- gcc_assert (TREE_CODE (b->decl) != PARM_DECL || !DECL_WEAK (b->decl));
-#endif
+ struct pointer_set_t *seen_args = pointer_set_create ();
if (!in_system_header)
warning (OPT_Wold_style_definition, "%Jold-style function definition",
@@ -6120,7 +6141,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
error ("%q+D declared as a non-parameter", decl);
/* If the declaration is already marked, we have a duplicate
name. Complain and ignore the duplicate. */
- else if (DECL_WEAK (decl))
+ else if (pointer_set_contains (seen_args, decl))
{
error ("multiple parameters named %q+D", decl);
TREE_PURPOSE (parm) = 0;
@@ -6151,7 +6172,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
}
TREE_PURPOSE (parm) = decl;
- DECL_WEAK (decl) = 1;
+ pointer_set_insert (seen_args, decl);
}
/* Now examine the parms chain for incomplete declarations
@@ -6170,7 +6191,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
TREE_TYPE (parm) = error_mark_node;
}
- if (!DECL_WEAK (parm))
+ if (!pointer_set_contains (seen_args, parm))
{
error ("declaration for parameter %q+D but no such parameter", parm);
@@ -6193,18 +6214,18 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
{
last = TREE_PURPOSE (parm);
DECL_ARGUMENTS (fndecl) = last;
- DECL_WEAK (last) = 0;
for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm))
if (TREE_PURPOSE (parm))
{
TREE_CHAIN (last) = TREE_PURPOSE (parm);
last = TREE_PURPOSE (parm);
- DECL_WEAK (last) = 0;
}
TREE_CHAIN (last) = 0;
}
+ pointer_set_destroy (seen_args);
+
/* If there was a previous prototype,
set the DECL_ARG_TYPE of each argument according to
the type previously specified, and report any mismatches. */