From: Jason Merrill Date: Mon, 6 May 1996 18:36:48 +0000 (+0000) Subject: -fno-common change X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2786cbadc7943950874df60f65da3f6a081162d9;p=gcc.git -fno-common change From-SVN: r11940 --- diff --git a/gcc/c-common.c b/gcc/c-common.c index eb6ccafba84..3c9018ad268 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -37,7 +37,7 @@ Boston, MA 02111-1307, USA. */ 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_UNUSED, A_FORMAT, A_WEAK, A_ALIAS}; @@ -263,6 +263,7 @@ init_attributes () { add_attribute (A_PACKED, "packed", 0, 0, 0); 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, "volatile", 0, 0, 1); add_attribute (A_UNUSED, "unused", 0, 0, 1); @@ -358,6 +359,13 @@ decl_attributes (node, attributes, prefix_attributes) warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); 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: if (TREE_CODE (decl) == FUNCTION_DECL) TREE_THIS_VOLATILE (decl) = 1; diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 38c25eba6af..e031546960c 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3611,9 +3611,13 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) if (TREE_CODE (decl) == FUNCTION_DECL) 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 - possible. */ - DECL_COMMON (decl) = 1; + /* 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 (! flag_no_common) + DECL_COMMON (decl) = 1; /* Set attributes here so if duplicate decl, will have proper attributes. */ decl_attributes (decl, attributes, prefix_attributes); diff --git a/gcc/final.c b/gcc/final.c index 70aa819d058..4de4e121b01 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -405,7 +405,7 @@ end_final (filename) } /* Make space for the table of counts. */ - if (flag_no_common || size == 0) + if (size == 0) { /* Realign data section. */ ASM_OUTPUT_ALIGN (asm_out_file, align); diff --git a/gcc/flags.h b/gcc/flags.h index 60528ab3de1..5712f1943bd 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -315,7 +315,8 @@ extern int flag_pedantic_errors; 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; diff --git a/gcc/toplev.c b/gcc/toplev.c index 7fb0810fb20..c89069be89a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -482,7 +482,8 @@ int flag_short_temps; 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; diff --git a/gcc/varasm.c b/gcc/varasm.c index 15d749d72b5..468387c346b 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1229,18 +1229,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data) /* 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 the target can't output uninitialized but not common global data in .bss, then we have to use .data. */ #if ! defined (ASM_OUTPUT_BSS) && ! defined (ASM_OUTPUT_ALIGNED_BSS) - && (! flag_no_common || ! TREE_PUBLIC (decl)) - && DECL_COMMON (decl) + && (DECL_COMMON (decl) || ! TREE_PUBLIC (decl)) #endif && ! dont_output_data) { @@ -1286,7 +1279,6 @@ assemble_variable (decl, top_level, at_end, dont_output_data) if (TREE_PUBLIC (decl) #if defined (ASM_OUTPUT_BSS) || defined (ASM_OUTPUT_ALIGNED_BSS) && DECL_COMMON (decl) - && ! flag_no_common #endif ) {