summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/c-decl.c
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2006-08-26 21:37:21 +0000
committerkan <kan@FreeBSD.org>2006-08-26 21:37:21 +0000
commitd2e7ac2a73d6bcff5e0c32bced4f407ce06175a0 (patch)
tree36bfe9866a842f09652778d17edc7168f0d238df /contrib/gcc/c-decl.c
parent76c8a9b91c6a52b70109327bfd45d4d3fa8e659f (diff)
downloadFreeBSD-src-d2e7ac2a73d6bcff5e0c32bced4f407ce06175a0.zip
FreeBSD-src-d2e7ac2a73d6bcff5e0c32bced4f407ce06175a0.tar.gz
Resolve conflicts after GCC 3.4.6 20060825 import.
Diffstat (limited to 'contrib/gcc/c-decl.c')
-rw-r--r--contrib/gcc/c-decl.c77
1 files changed, 45 insertions, 32 deletions
diff --git a/contrib/gcc/c-decl.c b/contrib/gcc/c-decl.c
index 26431d0..af6d668 100644
--- a/contrib/gcc/c-decl.c
+++ b/contrib/gcc/c-decl.c
@@ -957,6 +957,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
return false;
}
+ /* Enumerators have no linkage, so may only be declared once in a
+ given scope. */
+ if (TREE_CODE (olddecl) == CONST_DECL)
+ {
+ error ("%Jredeclaration of enumerator `%D'", newdecl, newdecl);
+ locate_old_decl (olddecl, error);
+ return false;
+ }
+
if (!comptypes (oldtype, newtype, COMPARE_STRICT))
{
if (TREE_CODE (olddecl) == FUNCTION_DECL
@@ -2956,12 +2965,21 @@ void
push_parm_decl (tree parm)
{
tree decl;
+ int old_dont_save_pending_sizes_p = 0;
/* Don't attempt to expand sizes while parsing this decl.
(We can get here with i_s_e 1 somehow from Objective-C.) */
int save_immediate_size_expand = immediate_size_expand;
immediate_size_expand = 0;
+ /* If this is a nested function, we do want to keep SAVE_EXPRs for
+ the argument sizes, regardless of the parent's setting. */
+ if (cfun)
+ {
+ old_dont_save_pending_sizes_p = cfun->x_dont_save_pending_sizes_p;
+ cfun->x_dont_save_pending_sizes_p = 0;
+ }
+
decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
TREE_PURPOSE (TREE_PURPOSE (parm)),
PARM, 0, NULL);
@@ -2971,6 +2989,8 @@ push_parm_decl (tree parm)
finish_decl (decl, NULL_TREE, NULL_TREE);
+ if (cfun)
+ cfun->x_dont_save_pending_sizes_p = old_dont_save_pending_sizes_p;
immediate_size_expand = save_immediate_size_expand;
}
@@ -4784,13 +4804,22 @@ start_struct (enum tree_code code, tree name)
ref = lookup_tag (code, name, 1);
if (ref && TREE_CODE (ref) == code)
{
- if (TYPE_FIELDS (ref))
+ if (TYPE_SIZE (ref))
{
if (code == UNION_TYPE)
error ("redefinition of `union %s'", IDENTIFIER_POINTER (name));
else
error ("redefinition of `struct %s'", IDENTIFIER_POINTER (name));
}
+ else if (C_TYPE_BEING_DEFINED (ref))
+ {
+ if (code == UNION_TYPE)
+ error ("nested redefinition of `union %s'",
+ IDENTIFIER_POINTER (name));
+ else
+ error ("nested redefinition of `struct %s'",
+ IDENTIFIER_POINTER (name));
+ }
}
else
{
@@ -5005,11 +5034,6 @@ finish_struct (tree t, tree fieldlist, tree attributes)
if (C_DECL_VARIABLE_SIZE (x))
C_TYPE_VARIABLE_SIZE (t) = 1;
- /* Detect invalid nested redefinition. */
- if (TREE_TYPE (x) == t)
- error ("nested redefinition of `%s'",
- IDENTIFIER_POINTER (TYPE_NAME (t)));
-
if (DECL_INITIAL (x))
{
unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1);
@@ -5131,6 +5155,9 @@ finish_struct (tree t, tree fieldlist, tree attributes)
TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
TYPE_ALIGN (x) = TYPE_ALIGN (t);
TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
+ C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
+ C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
+ C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
}
/* If this was supposed to be a transparent union, but we can't
@@ -5204,6 +5231,9 @@ start_enum (tree name)
pushtag (name, enumtype);
}
+ if (C_TYPE_BEING_DEFINED (enumtype))
+ error ("nested redefinition of `enum %s'", IDENTIFIER_POINTER (name));
+
C_TYPE_BEING_DEFINED (enumtype) = 1;
if (TYPE_VALUES (enumtype) != 0)
@@ -5976,9 +6006,6 @@ store_parm_decls (void)
{
tree fndecl = current_function_decl;
- /* The function containing FNDECL, if any. */
- tree context = decl_function_context (fndecl);
-
/* True if this definition is written with a prototype. */
bool prototype = (current_function_parms
&& TREE_CODE (current_function_parms) != TREE_LIST);
@@ -6003,20 +6030,9 @@ store_parm_decls (void)
/* Begin the statement tree for this function. */
begin_stmt_tree (&DECL_SAVED_TREE (fndecl));
- /* If this is a nested function, save away the sizes of any
- variable-size types so that we can expand them when generating
- RTL. */
- if (context)
- {
- tree t;
-
- DECL_LANG_SPECIFIC (fndecl)->pending_sizes
- = nreverse (get_pending_sizes ());
- for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes;
- t;
- t = TREE_CHAIN (t))
- SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context;
- }
+ /* Save away the sizes of any variable-size types so that we can
+ expand them when generating RTL. */
+ DECL_LANG_SPECIFIC (fndecl)->pending_sizes = get_pending_sizes ();
/* This function is being processed in whole-function mode. */
cfun->x_whole_function_mode_p = 1;
@@ -6167,15 +6183,12 @@ static void
c_expand_body_1 (tree fndecl, int nested_p)
{
if (nested_p)
- {
- /* Make sure that we will evaluate variable-sized types involved
- in our function's type. */
- expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
-
- /* Squirrel away our current state. */
- push_function_context ();
- }
+ /* Squirrel away our current state. */
+ push_function_context ();
+ /* Make sure that we will evaluate variable-sized types involved
+ in our function's type. */
+ put_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
tree_rest_of_compilation (fndecl, nested_p);
if (nested_p)
@@ -6396,7 +6409,7 @@ c_begin_compound_stmt (void)
tree stmt;
/* Create the COMPOUND_STMT. */
- stmt = add_stmt (build_stmt (COMPOUND_STMT, NULL_TREE));
+ stmt = add_stmt (build_stmt (COMPOUND_STMT, error_mark_node));
return stmt;
}
OpenPOWER on IntegriCloud