This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Plane down the CPP builtins table a bit
On Fri, May 17, 2002 at 08:59:52PM +0100, Neil Booth wrote:
>
> So we don't cross over again, are you going to remove the remaining
> builtins to c-common.c? I think the following can go, as they are
> effectively properties of the front-end implementation, rather
> than mandated by the standard:
>
> __OBJC__ __CHAR_UNSIGNED__ __STRICT_ANSI__ and __ASSEMBLER__.
Sure... well, almost. __OBJC__ would be mandated by the relevant
standard if there was one, so I left it in cppinit, and c-common
doesn't have enough information to know when to define __ASSEMBLER__
(as far as I can tell). But apart from that, here's the patch. I'll
wait for your reactions before applying it.
I *think* we can uncomment the code setting CPP_OPTION (char_unsigned)
from flag_unsigned_char at this point (and therefore ditch the
-fsigned-char case in cpplib's parse_option), but I may be missing
something, so I didn't. (tradcpp should be unaffected.)
Should we be treating -std=cxx98 as __STRICT_ANSI__ ? We currently
don't.
zw
* c-common.c (cb_register_builtins): Define __STRICT_ANSI__
and __CHAR_UNSIGNED__ here...
* cppinit.c (init_builtins): Not here.
* cpphash.h (struct spec_nodes): Kill n__STRICT_ANSI__.
* cpphash.c (_cpp_init_hashtable): Don't set it.
* cppmacro.c (builtin_macro) [BT_STDC]: Use the language
setting directly. Clarify comment.
===================================================================
Index: c-common.c
--- c-common.c 19 May 2002 21:53:52 -0000 1.327
+++ c-common.c 21 May 2002 05:00:42 -0000
@@ -4372,6 +4372,12 @@ cb_register_builtins (pfile)
if (flag_no_inline)
cpp_define (pfile, "__NO_INLINE__");
+ if (flag_iso)
+ cpp_define (pfile, "__STRICT_ANSI__");
+
+ if (!flag_signed_char)
+ cpp_define (pfile, "__CHAR_UNSIGNED__");
+
/* 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)
===================================================================
Index: cpphash.c
--- cpphash.c 2 Feb 2002 18:56:34 -0000 1.118
+++ cpphash.c 21 May 2002 05:00:42 -0000
@@ -72,7 +72,6 @@ _cpp_init_hashtable (pfile, table)
s->n_defined = cpp_lookup (pfile, DSC("defined"));
s->n_true = cpp_lookup (pfile, DSC("true"));
s->n_false = cpp_lookup (pfile, DSC("false"));
- s->n__STRICT_ANSI__ = cpp_lookup (pfile, DSC("__STRICT_ANSI__"));
s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__"));
s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC;
}
===================================================================
Index: cpphash.h
--- cpphash.h 17 May 2002 20:16:46 -0000 1.150
+++ cpphash.h 21 May 2002 05:00:42 -0000
@@ -188,7 +188,6 @@ struct spec_nodes
cpp_hashnode *n_defined; /* defined operator */
cpp_hashnode *n_true; /* C++ keyword true */
cpp_hashnode *n_false; /* C++ keyword false */
- cpp_hashnode *n__STRICT_ANSI__; /* STDC_0_IN_SYSTEM_HEADERS */
cpp_hashnode *n__VA_ARGS__; /* C99 vararg macros */
};
===================================================================
Index: cppinit.c
--- cppinit.c 18 May 2002 08:23:19 -0000 1.228
+++ cppinit.c 21 May 2002 05:00:42 -0000
@@ -694,24 +694,15 @@ init_builtins (pfile)
if (CPP_OPTION (pfile, cplusplus))
_cpp_define_builtin (pfile, "__cplusplus 1");
-
- if (CPP_OPTION (pfile, objc))
+ else if (CPP_OPTION (pfile, objc))
_cpp_define_builtin (pfile, "__OBJC__ 1");
+ else if (CPP_OPTION (pfile, lang) == CLK_ASM)
+ _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
if (CPP_OPTION (pfile, lang) == CLK_STDC94)
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
else if (CPP_OPTION (pfile, c99))
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
-
- if (CPP_OPTION (pfile, unsigned_char))
- _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
-
- if (CPP_OPTION (pfile, lang) == CLK_STDC89
- || CPP_OPTION (pfile, lang) == CLK_STDC94
- || CPP_OPTION (pfile, lang) == CLK_STDC99)
- _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
- else if (CPP_OPTION (pfile, lang) == CLK_ASM)
- _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
if (pfile->cb.register_builtins)
(*pfile->cb.register_builtins) (pfile);
===================================================================
Index: cppmacro.c
--- cppmacro.c 16 May 2002 19:03:02 -0000 1.104
+++ cppmacro.c 21 May 2002 05:00:43 -0000
@@ -174,14 +174,17 @@ builtin_macro (pfile, node)
/* __STDC__ has the value 1 under normal circumstances.
However, if (a) we are in a system header, (b) the option
- stdc_0_in_system_headers is true, and (c) __STRICT_ANSI__ is
- not defined, then it has the value 0. */
+ stdc_0_in_system_headers is true (set by target config), and
+ (c) we are not in strictly conforming mode, then it has the
+ value 0. */
case BT_STDC:
{
int stdc;
+ enum c_lang lang = CPP_OPTION (pfile, lang);
if (CPP_IN_SYSTEM_HEADER (pfile)
&& CPP_OPTION (pfile, stdc_0_in_system_headers)
- && pfile->spec_nodes.n__STRICT_ANSI__->type == NT_VOID)
+ && !(lang == CLK_STDC89 || lang == CLK_STDC94
+ || lang == CLK_STDC99)) /* || lang == CLK_CXX98 ? */
stdc = 0;
else
stdc = 1;