]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.c (preprocessing_asm): New macro.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 19 May 2002 21:53:53 +0000 (21:53 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 19 May 2002 21:53:53 +0000 (21:53 +0000)
* 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

gcc/ChangeLog
gcc/c-common.c
gcc/c-lex.h
gcc/config/alpha/alpha.h
gcc/config/alpha/freebsd.h
gcc/config/alpha/linux.h
gcc/config/alpha/osf.h
gcc/config/alpha/osf5.h
gcc/config/alpha/vms.h
gcc/doc/tm.texi

index 8e6cf96b7fbdff4165e27afa2ae861f14e126d3e..1f6f6f4fe58e56f12b2ed5eabe0ec131030535bf 100644 (file)
@@ -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.
index d851c27637be60f297f7f1c552b517207f0552bb..b9658da30e7fc0dde1504aaba0bcd8de1673f0bb 100644 (file)
@@ -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);
     }
 }
 
index b3e0a58a589d63c6672395f0cb0ffe76d69cc626..aa3d333f4f2dbabdee3744827152b113baa3e529 100644 (file)
@@ -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
index 4b4f89b41b7a714116e677151ca0ffb8aad73f84..fc9ba92aacadfe7dd6eb95d0ba39a32de1ae2442 100644 (file)
@@ -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 ""
index bd74691c847f5673dfe59095d4fcbd9a0fbd9bc7..4fd4c6962043340a7a3a0a50615b655cbb9c5da7 100644 (file)
@@ -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)}                    \
index d98a34d3d4596f4cb6c03ae0cf7d26d2322da5bf..461bd0e764eeb2a64325f9197555260f458a26c3 100644 (file)
@@ -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} \
index cb3b3447eeee10e4a56e4f15b42983f29ae0262e..6d5ea3bb882838f4882cb332edaf4c3d7df1ec09 100644 (file)
@@ -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
index c832c57418866d036e712a80279dab3568243439..59b3ae117934ff2a84f26354495015ef0dcd375e 100644 (file)
 #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
index 06d9c9585765c06a5a2960ea6de52a31ef9b7953..03dd491c823f1d0a10a55ac70a36cbb33687143e 100644 (file)
@@ -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
 
index 6f027b10788a05b58eb0565a409b9907d68893f7..3d321422a7f1185dc92e3722d137b405792a6d7a 100644 (file)
@@ -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.