Commit 2786cbad by Jason Merrill

-fno-common change

From-SVN: r11940
parent 7b8b9722
...@@ -37,7 +37,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -37,7 +37,7 @@ Boston, MA 02111-1307, USA. */
extern struct obstack permanent_obstack; extern struct obstack permanent_obstack;
enum attrs {A_PACKED, A_NOCOMMON, A_NORETURN, A_CONST, A_T_UNION, enum attrs {A_PACKED, A_NOCOMMON, A_COMMON, A_NORETURN, A_CONST, A_T_UNION,
A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED, A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED,
A_UNUSED, A_FORMAT, A_WEAK, A_ALIAS}; A_UNUSED, A_FORMAT, A_WEAK, A_ALIAS};
...@@ -263,6 +263,7 @@ init_attributes () ...@@ -263,6 +263,7 @@ init_attributes ()
{ {
add_attribute (A_PACKED, "packed", 0, 0, 0); add_attribute (A_PACKED, "packed", 0, 0, 0);
add_attribute (A_NOCOMMON, "nocommon", 0, 0, 1); add_attribute (A_NOCOMMON, "nocommon", 0, 0, 1);
add_attribute (A_COMMON, "common", 0, 0, 1);
add_attribute (A_NORETURN, "noreturn", 0, 0, 1); add_attribute (A_NORETURN, "noreturn", 0, 0, 1);
add_attribute (A_NORETURN, "volatile", 0, 0, 1); add_attribute (A_NORETURN, "volatile", 0, 0, 1);
add_attribute (A_UNUSED, "unused", 0, 0, 1); add_attribute (A_UNUSED, "unused", 0, 0, 1);
...@@ -358,6 +359,13 @@ decl_attributes (node, attributes, prefix_attributes) ...@@ -358,6 +359,13 @@ decl_attributes (node, attributes, prefix_attributes)
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
break; break;
case A_COMMON:
if (TREE_CODE (decl) == VAR_DECL)
DECL_COMMON (decl) = 1;
else
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
break;
case A_NORETURN: case A_NORETURN:
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
TREE_THIS_VOLATILE (decl) = 1; TREE_THIS_VOLATILE (decl) = 1;
......
...@@ -3611,8 +3611,12 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) ...@@ -3611,8 +3611,12 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0); gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
/* For C and Objective-C, we by default put things in .common when /* ANSI specifies that a tentative definition which is not merged with
possible. */ a non-tentative definition behaves exactly like a definition with an
initializer equal to zero. (Section 3.7.2)
-fno-common gives strict ANSI behavior. Usually you don't want it.
This matters only for variables with external linkage. */
if (! flag_no_common)
DECL_COMMON (decl) = 1; DECL_COMMON (decl) = 1;
/* Set attributes here so if duplicate decl, will have proper attributes. */ /* Set attributes here so if duplicate decl, will have proper attributes. */
......
...@@ -405,7 +405,7 @@ end_final (filename) ...@@ -405,7 +405,7 @@ end_final (filename)
} }
/* Make space for the table of counts. */ /* Make space for the table of counts. */
if (flag_no_common || size == 0) if (size == 0)
{ {
/* Realign data section. */ /* Realign data section. */
ASM_OUTPUT_ALIGN (asm_out_file, align); ASM_OUTPUT_ALIGN (asm_out_file, align);
......
...@@ -315,7 +315,8 @@ extern int flag_pedantic_errors; ...@@ -315,7 +315,8 @@ extern int flag_pedantic_errors;
extern int flag_pic; extern int flag_pic;
/* Nonzero means place uninitialized global data in the bss section. */ /* Nonzero means don't place uninitialized global data in common storage
by default. */
extern int flag_no_common; extern int flag_no_common;
......
...@@ -482,7 +482,8 @@ int flag_short_temps; ...@@ -482,7 +482,8 @@ int flag_short_temps;
int flag_pic; int flag_pic;
/* Nonzero means place uninitialized global data in the bss section. */ /* Nonzero means don't place uninitialized global data in common storage
by default. */
int flag_no_common; int flag_no_common;
......
...@@ -1229,18 +1229,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data) ...@@ -1229,18 +1229,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
/* Handle uninitialized definitions. */ /* Handle uninitialized definitions. */
/* ANSI specifies that a tentative definition which is not merged with
a non-tentative definition behaves exactly like a definition with an
initializer equal to zero. (Section 3.7.2)
-fno-common gives strict ANSI behavior. Usually you don't want it.
This matters only for variables with external linkage. */
if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node) if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
/* If the target can't output uninitialized but not common global data /* If the target can't output uninitialized but not common global data
in .bss, then we have to use .data. */ in .bss, then we have to use .data. */
#if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS) #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS)
&& (! flag_no_common || ! TREE_PUBLIC (decl)) && (DECL_COMMON (decl) || ! TREE_PUBLIC (decl))
&& DECL_COMMON (decl)
#endif #endif
&& ! dont_output_data) && ! dont_output_data)
{ {
...@@ -1286,7 +1279,6 @@ assemble_variable (decl, top_level, at_end, dont_output_data) ...@@ -1286,7 +1279,6 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
if (TREE_PUBLIC (decl) if (TREE_PUBLIC (decl)
#if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS) #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS)
&& DECL_COMMON (decl) && DECL_COMMON (decl)
&& ! flag_no_common
#endif #endif
) )
{ {
......
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