diff options
author | Zack Weinberg <zack@codesourcery.com> | 2002-05-16 19:03:02 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2002-05-16 19:03:02 +0000 |
commit | 5279d7394efe3e6d39e9c5f0bbb066e63f4cf398 (patch) | |
tree | 7ba2394a66b4c75f323247f002ba280c373fb85a /gcc | |
parent | 62e6ca55bd6a235d9feccd4ac48c2b89e0bc32e5 (diff) | |
download | gcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.zip gcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.tar.gz gcc-5279d7394efe3e6d39e9c5f0bbb066e63f4cf398.tar.bz2 |
c-common.c (STDC_0_IN_SYSTEM_HEADERS, [...]): Default-define here.
* c-common.c (STDC_0_IN_SYSTEM_HEADERS, REGISTER_PREFIX):
Default-define here.
(builtin_define_with_value): Can now wrap the expansion in
quotation marks if such is wanted.
(cb_register_builtins): Update calls to builtin_define_with_value.
Define __REGISTER_PREFIX__, __USER_LABEL_PREFIX__, and __VERSION__
here.
(c_common_init): Set options->stdc_0_in_system_headers.
* c-lex.h: Update prototype of builtin_define_with_value.
* cppdefault.h: Remove default definitions of USER_LABEL_PREFIX
and REGISTER_PREFIX.
* cppinit.c (VERS, ULP, C, X): Kill.
(builtin_array): Remove entries for __VERSION__,
__USER_LABEL_PREFIX__, __REGISTER_PREFIX__, and
__HAVE_BUILTIN_SETJMP__. Make __STDC__ always a builtin, not
a constant.
(init_builtins): Kill off a bunch of now-dead code.
(COMMAND_LINE_OPTIONS): Remove -fleading-underscore and
-fno-leading-underscore.
(cpp_handle_option): Remove code to set user_label_prefix.
(cpp_post_options): Likewise.
* cpplib.h (struct cpp_options): Remove user_label_prefix.
(stdc_0_in_system_headers): New.
* cppmacro.c (builtin_macro): Check CPP_OPTION (pfile,
stdc_0_in_system_headers) too to decide the value of __STDC__.
* tradcpp.c (user_label_prefix): Kill.
(main): Remove code handling -f(no-)leading-underscore.
(initialize_builtins): Don't define __REGISTER_PREFIX__
or __USER_LABEL_PREFIX__.
(install_value): Wrap compound statement in dummy loop so the
macro works properly in an if statement.
From-SVN: r53525
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 38 | ||||
-rw-r--r-- | gcc/c-common.c | 49 | ||||
-rw-r--r-- | gcc/c-lex.h | 7 | ||||
-rw-r--r-- | gcc/cppdefault.h | 18 | ||||
-rw-r--r-- | gcc/cppinit.c | 77 | ||||
-rw-r--r-- | gcc/cpplib.h | 6 | ||||
-rw-r--r-- | gcc/cppmacro.c | 14 | ||||
-rw-r--r-- | gcc/tradcpp.c | 21 |
8 files changed, 106 insertions, 124 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index acbf227..446367f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,41 @@ +2002-05-16 Zack Weinberg <zack@codesourcery.com> + + * c-common.c (STDC_0_IN_SYSTEM_HEADERS, REGISTER_PREFIX): + Default-define here. + (builtin_define_with_value): Can now wrap the expansion in + quotation marks if such is wanted. + (cb_register_builtins): Update calls to builtin_define_with_value. + Define __REGISTER_PREFIX__, __USER_LABEL_PREFIX__, and __VERSION__ + here. + (c_common_init): Set options->stdc_0_in_system_headers. + * c-lex.h: Update prototype of builtin_define_with_value. + * cppdefault.h: Remove default definitions of USER_LABEL_PREFIX + and REGISTER_PREFIX. + + * cppinit.c (VERS, ULP, C, X): Kill. + (builtin_array): Remove entries for __VERSION__, + __USER_LABEL_PREFIX__, __REGISTER_PREFIX__, and + __HAVE_BUILTIN_SETJMP__. Make __STDC__ always a builtin, not + a constant. + (init_builtins): Kill off a bunch of now-dead code. + (COMMAND_LINE_OPTIONS): Remove -fleading-underscore and + -fno-leading-underscore. + (cpp_handle_option): Remove code to set user_label_prefix. + (cpp_post_options): Likewise. + + * cpplib.h (struct cpp_options): Remove user_label_prefix. + (stdc_0_in_system_headers): New. + * cppmacro.c (builtin_macro): Check CPP_OPTION (pfile, + stdc_0_in_system_headers) too to decide the value of __STDC__. + + * tradcpp.c (user_label_prefix): Kill. + (main): Remove code handling -f(no-)leading-underscore. + (initialize_builtins): Don't define __REGISTER_PREFIX__ + or __USER_LABEL_PREFIX__. + (install_value): Wrap compound statement in dummy loop so the + macro works properly in an if statement. + + 2002-05-16 Janis Johnson <janis187@us.ibm.com> * loop.h (struct loop_info): Add member has_prefetch. diff --git a/gcc/c-common.c b/gcc/c-common.c index f60a27f..81810dd 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -83,6 +83,14 @@ cpp_reader *parse_in; /* Declared in c-lex.h. */ : "long long unsigned int")) #endif +#ifndef STDC_0_IN_SYSTEM_HEADERS +#define STDC_0_IN_SYSTEM_HEADERS 0 +#endif + +#ifndef REGISTER_PREFIX +#define REGISTER_PREFIX "" +#endif + /* The variant of the C language being processed. */ enum c_language_kind c_language; @@ -4331,10 +4339,17 @@ cb_register_builtins (pfile) cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__"); /* stddef.h needs to know these. */ - builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE); - builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE); - builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE); - builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE); + builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE, 0); + builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE, 0); + builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE, 0); + builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0); + + /* For use in assembly language. */ + builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); + builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); + + /* Misc. */ + builtin_define_with_value ("__VERSION__", version_string, 1); /* A straightforward target hook doesn't work, because of problems linking that hook's body when part of non-C front ends. */ @@ -4385,23 +4400,28 @@ builtin_define_std (macro) } } -/* Pass an object-like macro and a value to define it to. */ +/* Pass an object-like macro and a value to define it to. The third + parameter says whether or not to turn the value into a string + constant. */ void -builtin_define_with_value (macro, expansion) +builtin_define_with_value (macro, expansion, is_str) const char *macro; const char *expansion; + int is_str; { - char *buf, *q; + char *buf; size_t mlen = strlen (macro); size_t elen = strlen (expansion); + size_t extra = 2; /* space for an = and a NUL */ - q = buf = alloca (mlen + elen + 2); - memcpy (q, macro, mlen); - q += mlen; - *q++ = '='; - memcpy (q, expansion, elen); - q += elen; - *q = '\0'; + if (is_str) + extra += 2; /* space for two quote marks */ + + buf = alloca (mlen + elen + extra); + if (is_str) + sprintf (buf, "%s=\"%s\"", macro, expansion); + else + sprintf (buf, "%s=%s", macro, expansion); cpp_define (parse_in, buf); } @@ -4429,6 +4449,7 @@ c_common_init (filename) options->unsigned_char = !flag_signed_char; */ options->warn_multichar = warn_multichar; + options->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS; /* Register preprocessor built-ins before calls to cpp_main_file. */ diff --git a/gcc/c-lex.h b/gcc/c-lex.h index c9af009..b3e0a58 100644 --- a/gcc/c-lex.h +++ b/gcc/c-lex.h @@ -49,7 +49,10 @@ extern struct cpp_reader* parse_in; "_mips". */ extern void builtin_define_std PARAMS ((const char *)); -/* Pass an object-like macro and a value to define it to. */ -extern void builtin_define_with_value PARAMS ((const char *, const char *)); +/* Pass an object-like macro and a value to define it to. The third + parameter says whether or not to turn the value into a string + constant. */ +extern void builtin_define_with_value PARAMS ((const char *, const char *, + int)); #endif /* ! GCC_C_LEX_H */ diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h index 5d5d74a..40a8609 100644 --- a/gcc/cppdefault.h +++ b/gcc/cppdefault.h @@ -42,24 +42,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #undef CROSS_INCLUDE_DIR #endif -/* We let tm.h override the types used here, to handle trivial differences - such as the choice of unsigned int or long unsigned int for size_t. - When machines start needing nontrivial differences in the size type, - it would be best to do something here to figure out automatically - from other information what type to use. */ - -/* The string value for __USER_LABEL_PREFIX__ */ - -#ifndef USER_LABEL_PREFIX -#define USER_LABEL_PREFIX "" -#endif - -/* The string value for __REGISTER_PREFIX__ */ - -#ifndef REGISTER_PREFIX -#define REGISTER_PREFIX "" -#endif - /* This is the default list of directories to search for include files. It may be overridden by the various -I and -ixxx options. diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 57fa4c0..a03450c 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -623,11 +623,6 @@ cpp_destroy (pfile) known at build time should not be flagged BUILTIN, as then they do not appear in macro dumps with e.g. -dM or -dD. - Two values are not compile time constants, so we tag - them in the FLAGS field instead: - VERS value is the global version_string, quoted - ULP value is the global user_label_prefix - Also, macros with CPLUS set in the flags field are entered only for C++. */ struct builtin { @@ -638,15 +633,11 @@ struct builtin unsigned short flags; unsigned short len; }; -#define VERS 0x01 -#define ULP 0x02 #define CPLUS 0x04 #define BUILTIN 0x08 #define OPERATOR 0x10 #define B(n, t) { U n, 0, t, 0, BUILTIN, sizeof n - 1 } -#define C(n, v) { U n, v, 0, 0, 0, sizeof n - 1 } -#define X(n, f) { U n, 0, 0, 0, f, sizeof n - 1 } #define O(n, c, f) { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 } static const struct builtin builtin_array[] = { @@ -657,16 +648,7 @@ static const struct builtin builtin_array[] = B("__LINE__", BT_SPECLINE), B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL), B("_Pragma", BT_PRAGMA), - - X("__VERSION__", VERS), - X("__USER_LABEL_PREFIX__", ULP), - C("__REGISTER_PREFIX__", REGISTER_PREFIX), - C("__HAVE_BUILTIN_SETJMP__", "1"), -#ifdef STDC_0_IN_SYSTEM_HEADERS B("__STDC__", BT_STDC), -#else - C("__STDC__", "1"), -#endif /* Named operators known to the preprocessor. These cannot be #defined and always have their stated meaning. They are treated like normal @@ -685,8 +667,6 @@ static const struct builtin builtin_array[] = O("xor_eq", CPP_XOR_EQ, CPLUS) }; #undef B -#undef C -#undef X #undef O #define builtin_array_end (builtin_array + ARRAY_SIZE (builtin_array)) @@ -700,51 +680,24 @@ init_builtins (pfile) for(b = builtin_array; b < builtin_array_end; b++) { + cpp_hashnode *hp; if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus)) continue; if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names)) continue; - if (b->flags & (OPERATOR | BUILTIN)) + hp = cpp_lookup (pfile, b->name, b->len); + if (b->flags & OPERATOR) { - cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len); - if (b->flags & OPERATOR) - { - hp->flags |= NODE_OPERATOR; - hp->value.operator = b->operator; - } - else - { - hp->type = NT_MACRO; - hp->flags |= NODE_BUILTIN | NODE_WARN; - hp->value.builtin = b->builtin; - } + hp->flags |= NODE_OPERATOR; + hp->value.operator = b->operator; } - else /* A standard macro of some kind. */ + else { - const char *val; - char *str; - - if (b->flags & VERS) - { - /* Allocate enough space for 'name "value"\n\0'. */ - str = alloca (b->len + strlen (version_string) + 5); - sprintf (str, "%s \"%s\"\n", b->name, version_string); - } - else - { - if (b->flags & ULP) - val = CPP_OPTION (pfile, user_label_prefix); - else - val = b->value; - - /* Allocate enough space for "name value\n\0". */ - str = alloca (b->len + strlen (val) + 3); - sprintf(str, "%s %s\n", b->name, val); - } - - _cpp_define_builtin (pfile, str); + hp->type = NT_MACRO; + hp->flags |= NODE_BUILTIN | NODE_WARN; + hp->value.builtin = b->builtin; } } @@ -1209,8 +1162,6 @@ new_pending_directive (pend, text, handler) DEF_OPT("U", no_mac, OPT_U) \ DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \ DEF_OPT("d", no_arg, OPT_d) \ - DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore) \ - DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore) \ DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \ DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \ DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \ @@ -1408,12 +1359,6 @@ cpp_handle_option (pfile, argc, argv, ignore) { case N_OPTS: /* Shut GCC up. */ break; - case OPT_fleading_underscore: - CPP_OPTION (pfile, user_label_prefix) = "_"; - break; - case OPT_fno_leading_underscore: - CPP_OPTION (pfile, user_label_prefix) = ""; - break; case OPT_fno_operator_names: CPP_OPTION (pfile, operator_names) = 0; break; @@ -1843,10 +1788,6 @@ cpp_post_options (pfile) if (CPP_OPTION (pfile, cplusplus)) CPP_OPTION (pfile, warn_traditional) = 0; - /* Set this if it hasn't been set already. */ - if (CPP_OPTION (pfile, user_label_prefix) == NULL) - CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX; - /* Permanently disable macro expansion if we are rescanning preprocessed text. */ if (CPP_OPTION (pfile, preprocessed)) diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 1b7da37..9bccda3 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -248,9 +248,6 @@ struct cpp_options const char *include_prefix; unsigned int include_prefix_len; - /* -fleading_underscore sets this to "_". */ - const char *user_label_prefix; - /* The language we're preprocessing. */ enum c_lang lang; @@ -397,6 +394,9 @@ struct cpp_options /* Nonzero means chars (wide chars) are unsigned. */ unsigned char unsigned_char, unsigned_wchar; + + /* Nonzero means __STDC__ should have the value 0 in system headers. */ + unsigned char stdc_0_in_system_headers; }; /* Call backs. */ diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index f9c935f..c7a08f2 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -172,10 +172,20 @@ builtin_macro (pfile, node) pfile->cur_token[-1].line)); break; + /* __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. */ case BT_STDC: { - int stdc = (!CPP_IN_SYSTEM_HEADER (pfile) - || pfile->spec_nodes.n__STRICT_ANSI__->type != NT_VOID); + int stdc; + if (CPP_IN_SYSTEM_HEADER (pfile) + && CPP_OPTION (pfile, stdc_0_in_system_headers) + && pfile->spec_nodes.n__STRICT_ANSI__->type == NT_VOID) + stdc = 0; + else + stdc = 1; + result = new_number_token (pfile, stdc); } break; diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c index 9caf45e..b58bf9a 100644 --- a/gcc/tradcpp.c +++ b/gcc/tradcpp.c @@ -103,10 +103,6 @@ int warn_comments; int no_output; -/* Value of __USER_LABEL_PREFIX__. Target-dependent, also controlled - by -f(no-)leading-underscore. */ -static const char *user_label_prefix; - /* I/O buffer structure. The `fname' field is nonzero for source files and #include files and for the dummy text used for -D and -U. @@ -631,11 +627,7 @@ main (argc, argv) break; case 'f': - if (!strcmp (argv[i], "-fleading-underscore")) - user_label_prefix = "_"; - else if (!strcmp (argv[i], "-fno-leading-underscore")) - user_label_prefix = ""; - else if (!strcmp (argv[i], "-fsigned-char")) + if (!strcmp (argv[i], "-fsigned-char")) flag_signed_char = 1; else if (!strcmp (argv[i], "-funsigned-char")) flag_signed_char = 0; @@ -811,9 +803,6 @@ main (argc, argv) && (deps_missing_files || deps_file || print_deps_phony_targets)) fatal ("you must additionally specify either -M or -MM"); - if (user_label_prefix == 0) - user_label_prefix = USER_LABEL_PREFIX; - if (print_deps) { /* Set the default target (if there is none already), and @@ -5134,8 +5123,9 @@ dump_arg_n (defn, argnum) #define DSC(x) U x, sizeof x - 1 #define install_spec(name, type) \ install(DSC(name), type, -1); -#define install_value(name, val) \ - hp = install(DSC(name), T_CONST, -1); hp->value.cpval = val; +#define install_value(name, val) do { \ + hp = install(DSC(name), T_CONST, -1); hp->value.cpval = val; \ +} while (0) static void initialize_builtins () { @@ -5149,9 +5139,6 @@ initialize_builtins () install_spec ("__INCLUDE_LEVEL__", T_INCLUDE_LEVEL); install_spec ("__LINE__", T_SPECLINE); - install_value ("__REGISTER_PREFIX__", REGISTER_PREFIX); - install_value ("__USER_LABEL_PREFIX__", user_label_prefix); - if (flag_signed_char == 0) install_value ("__CHAR_UNSIGNED__", "1"); } |