/* Process declarations and variables for C compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GCC.
#include "c-family/c-pragma.h"
#include "c-lang.h"
#include "langhooks.h"
-#include "tree-mudflap.h"
#include "tree-iterator.h"
#include "diagnostic-core.h"
#include "tree-dump.h"
complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
- layout_decl (decl, 0);
+ relayout_decl (decl);
}
}
}
DECL_CHAIN (p) = BLOCK_VARS (block);
BLOCK_VARS (block) = p;
}
- else if (VAR_OR_FUNCTION_DECL_P (p))
+ else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope)
{
/* For block local externs add a special
DECL_EXTERNAL decl for debug info generation. */
/* Redeclaration of a type is a constraint violation (6.7.2.3p1),
but silently ignore the redeclaration if either is in a system
header. (Conflicting redeclarations were handled above.) This
- is allowed for C1X if the types are the same, not just
+ is allowed for C11 if the types are the same, not just
compatible. */
if (TREE_CODE (newdecl) == TYPE_DECL)
{
newdecl);
locate_old_decl (olddecl);
}
- else if (pedantic && !flag_isoc1x)
+ else if (pedantic && !flag_isoc11)
{
pedwarn (input_location, OPT_pedantic,
"redefinition of typedef %q+D", newdecl);
memcpy ((char *) olddecl + sizeof (struct tree_common),
(char *) newdecl + sizeof (struct tree_common),
sizeof (struct tree_decl_common) - sizeof (struct tree_common));
+ DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
switch (TREE_CODE (olddecl))
{
case FUNCTION_DECL:
/* Is anything being shadowed? Invisible decls do not count. */
for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed)
- if (b->decl && b->decl != new_decl && !b->invisible)
+ if (b->decl && b->decl != new_decl && !b->invisible
+ && (b->decl == error_mark_node
+ || diagnostic_report_warnings_p (global_dc,
+ DECL_SOURCE_LOCATION (b->decl))))
{
tree old_decl = b->decl;
if (DECL_INITIAL (decl))
TREE_TYPE (DECL_INITIAL (decl)) = type;
- layout_decl (decl, 0);
+ relayout_decl (decl);
}
if (TREE_CODE (decl) == VAR_DECL)
DECL_DECLARED_INLINE_P (decl) = 1;
if (declspecs->noreturn_p)
{
- if (!flag_isoc1x)
+ if (!flag_isoc11)
{
if (flag_isoc99)
pedwarn (loc, OPT_pedantic,
If this is something of the form "foo;" and foo is a TYPE_DECL, then
If foo names a structure or union without a tag, then this
- is an anonymous struct (this is permitted by C1X).
+ is an anonymous struct (this is permitted by C11).
If MS or Plan 9 extensions are enabled and foo names a
structure, then again this is an anonymous struct.
Otherwise this is an error.
pedwarn (loc, 0, "declaration does not declare anything");
return NULL_TREE;
}
- if (!flag_isoc1x)
+ if (!flag_isoc11)
{
if (flag_isoc99)
pedwarn (loc, OPT_pedantic,
{
if (DECL_NAME (x) != 0)
break;
- if (flag_isoc1x
+ if (flag_isoc11
&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (x)) == UNION_TYPE))
break;
/* If the declarator is not suitable for a function definition,
cause a syntax error. */
- if (decl1 == 0)
+ if (decl1 == 0
+ || TREE_CODE (decl1) != FUNCTION_DECL)
return 0;
loc = DECL_SOURCE_LOCATION (decl1);
collect_source_ref (LOCATION_FILE (decl_sloc (decl, false)));
}
+/* Preserve the external declarations scope across a garbage collect. */
+static GTY(()) tree ext_block;
+
/* Collect all references relevant to SOURCE_FILE. */
static void
FOR_EACH_VEC_ELT (tree, all_translation_units, i, t)
collect_ada_nodes (BLOCK_VARS (DECL_INITIAL (t)), source_file);
+
+ collect_ada_nodes (BLOCK_VARS (ext_block), source_file);
}
/* Iterate over all global declarations and call CALLBACK. */
for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl))
callback (decl);
}
-}
-/* Preserve the external declarations scope across a garbage collect. */
-static GTY(()) tree ext_block;
+ for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl))
+ callback (decl);
+}
void
c_write_global_declarations (void)