Skip to content

Commit

Permalink
-fno-common change
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@11940 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
merrill committed May 6, 1996
1 parent 37e76d7 commit 9493f14
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
10 changes: 9 additions & 1 deletion gcc/c-common.c
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions gcc/c-decl.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gcc/final.c
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion gcc/flags.h
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion gcc/toplev.c
Expand Up @@ -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;

Expand Down
10 changes: 1 addition & 9 deletions gcc/varasm.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
)
{
Expand Down

0 comments on commit 9493f14

Please sign in to comment.