OSDN Git Service

* varasm.c (output_constant_def_contents): Use
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Jul 2003 01:48:11 +0000 (01:48 +0000)
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Jul 2003 01:48:11 +0000 (01:48 +0000)
ASM_DECLARE_CONSTANT_NAME if defined.
* doc/tm.texi (Label Output): Document ASM_DECLARE_CONSTANT_NAME.
* config/darwin.h (ASM_DECLARE_OBJECT_NAME): Ensure zero-sized
objects get at least one byte to prevent assembler problems.
(ASM_DECLARE_CONSTANT_NAME): New.

Index: testsuite/ChangeLog
* gcc.c-torture/compile/zero-strct-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69842 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/darwin.h
gcc/doc/tm.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c [new file with mode: 0644]
gcc/varasm.c

index 6dcc99e..c0915fa 100644 (file)
 
 2003-07-26  Geoffrey Keating  <geoffk@apple.com>
 
+       * varasm.c (output_constant_def_contents): Use 
+       ASM_DECLARE_CONSTANT_NAME if defined.
+       * doc/tm.texi (Label Output): Document ASM_DECLARE_CONSTANT_NAME.
+       * config/darwin.h (ASM_DECLARE_OBJECT_NAME): Ensure zero-sized
+       objects get at least one byte to prevent assembler problems.
+       (ASM_DECLARE_CONSTANT_NAME): New.
+
        * Makefile.in (libbackend.o): Remove options_.h.
        (mostlyclean): Likewise.
 
index 4f9b487..64aab06 100644 (file)
@@ -356,18 +356,22 @@ do { text_section ();                                                     \
 #undef ASM_DECLARE_OBJECT_NAME
 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                      \
   do {                                                                 \
-    const char *xname = NAME;                                           \
-    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
-      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
-    if ((TREE_STATIC (DECL)                                             \
-        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
-        || DECL_INITIAL (DECL))                                         \
-      machopic_define_name (xname);                                     \
-    if ((TREE_STATIC (DECL)                                             \
-        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
-        || DECL_INITIAL (DECL))                                         \
+    const char *xname = NAME;                                          \
+    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)            \
+      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                   \
+    if ((TREE_STATIC (DECL)                                            \
+        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
+        || DECL_INITIAL (DECL))                                                \
+      machopic_define_name (xname);                                    \
+    if ((TREE_STATIC (DECL)                                            \
+        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
+        || DECL_INITIAL (DECL))                                                \
       (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);  \
-    ASM_OUTPUT_LABEL (FILE, xname);                                     \
+    ASM_OUTPUT_LABEL (FILE, xname);                                    \
+    /* Darwin doesn't support zero-size objects, so give them a        \
+       byte.  */                                                       \
+    if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0)                  \
+      assemble_zeros (1);                                              \
   } while (0)
 
 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
@@ -389,6 +393,15 @@ do { text_section ();                                                      \
     machopic_output_possible_stub_label (FILE, xname);                 \
   } while (0)
 
+#define ASM_DECLARE_CONSTANT_NAME(FILE, NAME, EXP, SIZE)       \
+  do {                                                         \
+    ASM_OUTPUT_LABEL (FILE, NAME);                             \
+    /* Darwin doesn't support zero-size objects, so give them a        \
+       byte.  */                                               \
+    if ((SIZE) == 0)                                           \
+      assemble_zeros (1);                                      \
+  } while (0)
+
 /* Wrap new method names in quotes so the assembler doesn't gag.
    Make Objective-C internal symbols local.  */
 
index e3f4afe..3f9dd15 100644 (file)
@@ -6634,6 +6634,22 @@ You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or
 @code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
 @end defmac
 
+@defmac ASM_DECLARE_CONSTANT_NAME (@var{stream}, @var{name}, @var{exp}, @var{size})
+A C statement (sans semicolon) to output to the stdio stream
+@var{stream} any text necessary for declaring the name @var{name} of a
+constant which is being defined.  This macro is responsible for
+outputting the label definition (perhaps using
+@code{ASM_OUTPUT_LABEL}).  The argument @var{exp} is the
+value of the constant, and @var{size} is the size of the constant
+in bytes.  @var{name} will be an internal label.
+
+If this macro is not defined, then the @var{name} is defined in the
+usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+
+You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
+of this macro.
+@end defmac
+
 @defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
 A C statement (sans semicolon) to output to the stdio stream
 @var{stream} any text necessary for claiming a register @var{regno}
index 2f0e153..c06df55 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-26  Geoffrey Keating  <geoffk@apple.com>
+
+       * gcc.c-torture/compile/zero-strct-2.c: New test.
+
 2003-07-25  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/intermod-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c b/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c
new file mode 100644 (file)
index 0000000..0f97f7d
--- /dev/null
@@ -0,0 +1,2 @@
+struct { } foo = { };
+void * bar(void) { return &foo; }
index a8ff36f..c9dae89 100644 (file)
@@ -2547,6 +2547,7 @@ output_constant_def_contents (rtx symbol)
 {
   tree exp = SYMBOL_REF_DECL (symbol);
   const char *label = XSTR (symbol, 0);
+  HOST_WIDE_INT size;
 
   /* Make sure any other constants whose addresses appear in EXP
      are assigned label numbers.  */
@@ -2571,17 +2572,20 @@ output_constant_def_contents (rtx symbol)
       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
     }
 
-  /* Output the label itself.  */
+  size = int_size_in_bytes (TREE_TYPE (exp));
+  if (TREE_CODE (exp) == STRING_CST)
+    size = MAX (TREE_STRING_LENGTH (exp), size);
+
+  /* Do any machine/system dependent processing of the constant.  */
+#ifdef ASM_DECLARE_CONSTANT_NAME
+  ASM_DECLARE_CONSTANT_NAME (asm_out_file, label, exp, size);
+#else
+  /* Standard thing is just output label for the constant.  */
   ASM_OUTPUT_LABEL (asm_out_file, label);
+#endif /* ASM_DECLARE_CONSTANT_NAME */
 
   /* Output the value of EXP.  */
-  output_constant (exp,
-                  (TREE_CODE (exp) == STRING_CST
-                   ? MAX (TREE_STRING_LENGTH (exp),
-                          int_size_in_bytes (TREE_TYPE (exp)))
-                   : int_size_in_bytes (TREE_TYPE (exp))),
-                  align);
-
+  output_constant (exp, size, align);
 }
 
 /* A constant which was deferred in its original location has been