summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/c-common.c9
-rw-r--r--gcc/c-lex.h4
-rw-r--r--gcc/config/alpha/alpha.h30
-rw-r--r--gcc/config/alpha/freebsd.h15
-rw-r--r--gcc/config/alpha/linux.h7
-rw-r--r--gcc/config/alpha/osf.h18
-rw-r--r--gcc/config/alpha/osf5.h7
-rw-r--r--gcc/config/alpha/vms.h10
-rw-r--r--gcc/doc/tm.texi7
10 files changed, 79 insertions, 49 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8e6cf96b7fb..1f6f6f4fe58 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+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.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index d851c27637b..b9658da30e7 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -4374,6 +4374,7 @@ cb_register_builtins (pfile)
/* 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 ();
}
@@ -4407,10 +4408,6 @@ builtin_define_std (macro)
/* 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++ = '_';
@@ -4418,6 +4415,10 @@ builtin_define_std (macro)
*q++ = '_';
*q = '\0';
cpp_define (parse_in, p);
+
+ /* Finally, define the original macro if permitted. */
+ if (!flag_iso)
+ cpp_define (parse_in, macro);
}
}
diff --git a/gcc/c-lex.h b/gcc/c-lex.h
index b3e0a58a589..aa3d333f4f2 100644
--- a/gcc/c-lex.h
+++ b/gcc/c-lex.h
@@ -35,8 +35,8 @@ extern int indent_level;
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
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index 4b4f89b41b7..fc9ba92aaca 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -67,21 +67,25 @@ Boston, MA 02111-1307, USA. */
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 ""
diff --git a/gcc/config/alpha/freebsd.h b/gcc/config/alpha/freebsd.h
index bd74691c847..4fd4c696204 100644
--- a/gcc/config/alpha/freebsd.h
+++ b/gcc/config/alpha/freebsd.h
@@ -24,10 +24,19 @@ Boston, MA 02111-1307, USA. */
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)} \
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index d98a34d3d45..461bd0e764e 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -30,12 +30,11 @@ Boston, MA 02111-1307, USA. */
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} \
diff --git a/gcc/config/alpha/osf.h b/gcc/config/alpha/osf.h
index cb3b3447eee..6d5ea3bb882 100644
--- a/gcc/config/alpha/osf.h
+++ b/gcc/config/alpha/osf.h
@@ -39,23 +39,23 @@ Boston, MA 02111-1307, USA. */
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. */
@@ -143,9 +143,7 @@ Boston, MA 02111-1307, USA. */
#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
diff --git a/gcc/config/alpha/osf5.h b/gcc/config/alpha/osf5.h
index c832c574188..59b3ae11793 100644
--- a/gcc/config/alpha/osf5.h
+++ b/gcc/config/alpha/osf5.h
@@ -21,13 +21,6 @@
#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
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index 06d9c958576..03dd491c823 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -35,14 +35,12 @@ Boston, MA 02111-1307, USA. */
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
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 6f027b10788..3d321422a7f 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -609,6 +609,13 @@ and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
@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.