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.
#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) \
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. */
@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}
+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.
--- /dev/null
+struct { } foo = { };
+void * bar(void) { return &foo; }
{
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. */
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