* c-common.c (preprocessing_asm): New macro.
* c-lex.h (builtin_define, builtin_assert): Use pfile.
doc:
* tm.texi: Update.
config/alpha:
* alpha.h (CPLUSPLUS_CPP_SPEC): Remove.
(CPP_SPEC): Simplify.
(TARGET_CPU_CPP_BUILTINS): Update.
* freebsd.h (TARGET_OS_CPP_BUILTINS): New.
(CPP_SPEC): Simplify.
* linux.h (CPLUSPLUS_CPP_SPEC): Remove.
(TARGET_OS_CPP_BUILTINS): Update.
* osf.h (CPP_XFLOAT_SPEC): Kill.
(TARGET_OS_CPP_BUILTINS): Update.
(CPP_SUBTARGET_SPEC, SUBTARGET_EXTRA_SPECS): Simplify.
* osf5.h (CPP_XFLOAT_SPEC): Kill.
* vms.h (CPP_SUBTARGET_SPEC): Kill.
(TARGET_OS_CPP_BUILTINS): Update.
From-SVN: r53641
+2002-05-19 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * c-common.c (preprocessing_asm): New macro.
+ * c-lex.h (builtin_define, builtin_assert): Use pfile.
+doc:
+ * tm.texi: Update.
+config/alpha:
+ * alpha.h (CPLUSPLUS_CPP_SPEC): Remove.
+ (CPP_SPEC): Simplify.
+ (TARGET_CPU_CPP_BUILTINS): Update.
+ * freebsd.h (TARGET_OS_CPP_BUILTINS): New.
+ (CPP_SPEC): Simplify.
+ * linux.h (CPLUSPLUS_CPP_SPEC): Remove.
+ (TARGET_OS_CPP_BUILTINS): Update.
+ * osf.h (CPP_XFLOAT_SPEC): Kill.
+ (TARGET_OS_CPP_BUILTINS): Update.
+ (CPP_SUBTARGET_SPEC, SUBTARGET_EXTRA_SPECS): Simplify.
+ * osf5.h (CPP_XFLOAT_SPEC): Kill.
+ * vms.h (CPP_SUBTARGET_SPEC): Kill.
+ (TARGET_OS_CPP_BUILTINS): Update.
+
2002-05-19 Richard Henderson <rth@redhat.com>
* varasm.c (default_binds_local_p): Fix typo.
/* A straightforward target hook doesn't work, because of problems
linking that hook's body when part of non-C front ends. */
+ #define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
TARGET_CPU_CPP_BUILTINS ();
TARGET_OS_CPP_BUILTINS ();
}
/* If it was in user's namespace... */
if (p != buff + 2)
{
- /* Define the original macro if permitted. */
- if (!flag_iso)
- cpp_define (parse_in, macro);
-
/* Define the macro with leading and following __. */
if (q[-1] != '_')
*q++ = '_';
*q++ = '_';
*q = '\0';
cpp_define (parse_in, p);
+
+ /* Finally, define the original macro if permitted. */
+ if (!flag_iso)
+ cpp_define (parse_in, macro);
}
}
struct cpp_reader;
extern struct cpp_reader* parse_in;
-#define builtin_define(TXT) cpp_define (parse_in, TXT)
-#define builtin_assert(TXT) cpp_assert (parse_in, TXT)
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
/* Pass an object-like macro. If it doesn't lie in the user's
namespace, defines it unconditionally. Otherwise define a version
builtin_define ("__IEEE_FP"); \
if (TARGET_IEEE_WITH_INEXACT) \
builtin_define ("__IEEE_FP_INEXACT"); \
+ \
+ /* Macros dependent on the C dialect. */ \
+ if (preprocessing_asm_p ()) \
+ builtin_define_std ("LANGUAGE_ASSEMBLY"); \
+ else if (c_language == clk_c) \
+ builtin_define_std ("LANGUAGE_C"); \
+ else if (c_language == clk_cplusplus) \
+ { \
+ builtin_define ("__LANGUAGE_C_PLUS_PLUS"); \
+ builtin_define ("__LANGUAGE_C_PLUS_PLUS__");\
+ } \
+ else if (c_language == clk_objective_c) \
+ { \
+ builtin_define ("__LANGUAGE_OBJECTIVE_C"); \
+ builtin_define ("__LANGUAGE_OBJECTIVE_C__");\
+ } \
} while (0)
-/* For C++ we need to ensure that __LANGUAGE_C_PLUS_PLUS is defined independent
- of the source file extension. */
-#define CPLUSPLUS_CPP_SPEC "-D__LANGUAGE_C_PLUS_PLUS__\
- -D__LANGUAGE_C_PLUS_PLUS %(cpp)"
-
-/* Write out the correct language type definition for the header files.
- Unless we have assembler language, write out the symbols for C. */
-#define CPP_SPEC "\
-%{!undef:\
-%{.S:-D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY }}\
-%{.m:-D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C }\
-%{!.S:%{!.cc:%{!.cxx:%{!.cpp:%{!.cp:%{!.c++:%{!.C:%{!.m:-D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C }}}}}}}}}}\
-%(cpp_subtarget)"
+#define CPP_SPEC "%(cpp_subtarget)"
#ifndef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC ""
the GCC option `-posix', and PIC issues as on all FreeBSD platforms, we must
deal with the Alpha's FP issues. */
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ if (flag_pic) \
+ { \
+ builtin_define ("__PIC__"); \
+ builtin_define ("__pic__"); \
+ } \
+ }
+ while (0)
+
#undef CPP_SPEC
-#define CPP_SPEC "%(cpp_subtarget) \
- %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
- %{posix:-D_POSIX_SOURCE}"
+#define CPP_SPEC "%(cpp_subtarget) %{posix:-D_POSIX_SOURCE}"
#define LINK_SPEC "%{G*} %{relax:-relax} \
%{p:%e`-p' not supported; use `-pg' and gprof(1)} \
builtin_define_std ("linux"); \
builtin_define_std ("unix"); \
builtin_assert ("system=linux"); \
+ /* The GNU C++ standard library requires this. */ \
+ if (c_language == clk_cplusplus) \
+ builtin_define ("_GNU_SOURCE"); \
} while (0)
-/* The GNU C++ standard library requires that these macros be defined. */
-#undef CPLUSPLUS_CPP_SPEC
-#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
-
#undef LIB_SPEC
#define LIB_SPEC \
"%{shared: -lc} \
builtin_define ("_SYSTYPE_BSD"); \
builtin_define ("__osf__"); \
builtin_define ("_LONGLONG"); \
+ builtin_define ("__EXTERN_PREFIX"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=xpg4"); \
+ /* Tru64 UNIX V5 has a 16 byte long \
+ double type and requires __X_FLOAT \
+ to be defined for <math.h>. */ \
+ if (LONG_DOUBLE_TYPE_SIZE == 128) \
+ builtin_define ("__X_FLOAT"); \
} while (0)
-/* Tru64 UNIX V5 requires additional definitions for 16 byte long double
- support. Empty by default. */
-
-#define CPP_XFLOAT_SPEC ""
-
/* Accept DEC C flags for multithreaded programs. We use _PTHREAD_USE_D4
instead of PTHREAD_USE_D4 since both have the same effect and the former
doesn't invade the users' namespace. */
#undef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC \
-"%{pthread|threads:-D_REENTRANT} %{threads:-D_PTHREAD_USE_D4} %(cpp_xfloat) \
--D__EXTERN_PREFIX"
+"%{pthread|threads:-D_REENTRANT} %{threads:-D_PTHREAD_USE_D4}"
/* Under OSF4, -p and -pg require -lprof1, and -lprof1 requires -lpdf. */
#endif
#undef SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
- { "cpp_xfloat", CPP_XFLOAT_SPEC }, \
- { "asm_oldas", ASM_OLDAS_SPEC }
+#define SUBTARGET_EXTRA_SPECS { "asm_oldas", ASM_OLDAS_SPEC }
/* Indicate that we have a stamp.h to use. */
#ifndef CROSS_COMPILE
#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 128
-/* Tru64 UNIX V5 has a 16 byte long double type and requires __X_FLOAT to be
- defined to get the appropriate prototypes for the long double functions
- in <math.h>. */
-
-#undef CPP_XFLOAT_SPEC
-#define CPP_XFLOAT_SPEC "-D__X_FLOAT"
-
/* In Tru64 UNIX V5.1, Compaq introduced a new assembler
(/usr/lib/cmplrs/cc/adu) which currently (versions between 3.04.29 and
3.04.32) breaks mips-tfile. Passing the undocumented -oldas flag reverts
builtin_define_std ("VMS"); \
builtin_define ("__ALPHA"); \
builtin_assert ("system=vms"); \
+ if (TARGET_FLOAT_VAX) \
+ builtin_define ("__G_FLOAT"); \
+ else \
+ builtin_define ("__IEEE_FLOAT"); \
} while (0)
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{mfloat-ieee:-D__IEEE_FLOAT} \
-%{mfloat-vax:-D__G_FLOAT} \
-%{!mfloat-vax:-D__IEEE_FLOAT}"
-
/* By default, allow $ to be part of an identifier. */
#define DOLLARS_IN_IDENTIFIERS 2
@code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
defines only @code{_ABI64}.
+You can also test for the C dialect being compiled. The variable
+@code{c_language} is set to one of @code{clk_c}, @code{clk_cplusplus}
+or @code{clk_objective_c}. Note that if we are preprocessing
+assembler, this variable will be @code{clk_c} but the function-like
+macro @code{preprocessing_asm_p()} will return true, so you might want
+to check for that first.
+
With @code{TARGET_OS_CPP_BUILTINS} this macro obsoletes the
@code{CPP_PREDEFINES} target macro.