From bdb05a7b49ee8569b9efa1b0e0401b3026e1034e Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 26 Nov 2000 17:31:13 +0000 Subject: [PATCH] cpplib.h (struct cpp_reader): Remove lang_asm. * cpplib.h (struct cpp_reader): Remove lang_asm. (struct cpp_options): Remove c89. New members lang, extended_numbers. * cppexp.c (parse_number): Use them. * cpphash.h (VALID_SIGN): Use them. * cppinit.c (set_lang, cpp_start_read): Update. * cpplex.c (parse_string, _cpp_lex_token): Update. * cpplib.c (_cpp_handle_directive): Update. * cppmacro.c (parse_args): Update. * cppmain.c (scan_buffer): Update. From-SVN: r37761 --- gcc/ChangeLog | 13 +++++++++++++ gcc/cppexp.c | 4 +--- gcc/cpphash.h | 3 ++- gcc/cppinit.c | 16 +++++----------- gcc/cpplex.c | 10 ++++------ gcc/cpplib.c | 4 ++-- gcc/cpplib.h | 15 ++++++--------- gcc/cppmacro.c | 6 +++--- gcc/cppmain.c | 2 +- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 61f696cf3ab..9871893eec3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2000-11-26 Neil Booth + + * cpplib.h (struct cpp_reader): Remove lang_asm. + (struct cpp_options): Remove c89. New members lang, + extended_numbers. + * cppexp.c (parse_number): Use them. + * cpphash.h (VALID_SIGN): Use them. + * cppinit.c (set_lang, cpp_start_read): Update. + * cpplex.c (parse_string, _cpp_lex_token): Update. + * cpplib.c (_cpp_handle_directive): Update. + * cppmacro.c (parse_args): Update. + * cppmain.c (scan_buffer): Update. + Sun Nov 26 10:02:37 2000 Richard Kenner * fold-const.c (fold, case CONVERT_EXPR): Always return tree of diff --git a/gcc/cppexp.c b/gcc/cppexp.c index 6665380c3a8..882908fda44 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -205,9 +205,7 @@ parse_number (pfile, tok) if (CPP_WTRADITIONAL (pfile) && sufftab[i].u) cpp_warning (pfile, "traditional C rejects the `U' suffix"); - if (CPP_OPTION (pfile, c89) - && sufftab[i].l == 2 - && pfile->spec_nodes.n__STRICT_ANSI__->type == NT_MACRO) + if (sufftab[i].l == 2 && !CPP_OPTION (pfile, extended_numbers)) SYNTAX_ERROR ("too many 'l' suffixes in integer constant"); } diff --git a/gcc/cpphash.h b/gcc/cpphash.h index ccbe1c7d58c..500c0c25747 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -26,7 +26,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define VALID_SIGN(c, prevc) \ (((c) == '+' || (c) == '-') && \ ((prevc) == 'e' || (prevc) == 'E' \ - || (((prevc) == 'p' || (prevc) == 'P') && !CPP_OPTION (pfile, c89)))) + || (((prevc) == 'p' || (prevc) == 'P') \ + && CPP_OPTION (pfile, extended_numbers)))) /* Memory pools. */ #define ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1)) diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 2f190cd1b90..e0b7c4e28ad 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -431,10 +431,11 @@ set_lang (pfile, lang) { struct cpp_pending *pend = CPP_OPTION (pfile, pending); - /* Default to zero. */ - CPP_OPTION (pfile, lang_asm) = 0; + /* Defaults. */ + CPP_OPTION (pfile, lang) = lang; CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, cplusplus) = 0; + CPP_OPTION (pfile, extended_numbers) = 1; /* Allowed in GNU C and C99. */ switch (lang) { @@ -444,7 +445,6 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c99) = 1; new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define); break; @@ -453,7 +453,6 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c89) = 1; CPP_OPTION (pfile, c99) = 0; break; @@ -465,8 +464,8 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 0; CPP_OPTION (pfile, cplusplus_comments) = 0; CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94; - CPP_OPTION (pfile, c89) = 1; CPP_OPTION (pfile, c99) = 0; + CPP_OPTION (pfile, extended_numbers) = 0; new_pending_directive (pend, "__STRICT_ANSI__", cpp_define); break; case CLK_STDC99: @@ -474,7 +473,6 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 0; CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c99) = 1; new_pending_directive (pend, "__STRICT_ANSI__", cpp_define); new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define); @@ -489,7 +487,6 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, objc) = 1; new_pending_directive (pend, "__OBJC__", cpp_define); @@ -503,7 +500,6 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX; CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 1; - CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c99) = 0; new_pending_directive (pend, "__cplusplus", cpp_define); break; @@ -514,9 +510,7 @@ set_lang (pfile, lang) CPP_OPTION (pfile, dollars_in_ident) = 0; /* Maybe not? */ CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, digraphs) = 0; - CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c99) = 0; - CPP_OPTION (pfile, lang_asm) = 1; new_pending_directive (pend, "__ASSEMBLER__", cpp_define); break; } @@ -979,7 +973,7 @@ cpp_start_read (pfile, fname) CPP_OPTION (pfile, warn_traditional) = 0; /* Do not warn about invalid token pasting if -lang-asm. */ - if (CPP_OPTION (pfile, lang_asm)) + if (CPP_OPTION (pfile, lang) == CLK_ASM) CPP_OPTION (pfile, warn_paste) = 0; /* Set this if it hasn't been set already. */ diff --git a/gcc/cpplex.c b/gcc/cpplex.c index bec14e76042..3cfd8e3e072 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -673,7 +673,7 @@ parse_string (pfile, token, terminator) /* In assembly language, silently terminate string and character literals at end of line. This is a kludge around not knowing where comments are. */ - if (CPP_OPTION (pfile, lang_asm) && terminator != '>') + if (CPP_OPTION (pfile, lang) == CLK_ASM && terminator != '>') break; /* Character constants and header names may not extend over @@ -1007,11 +1007,9 @@ _cpp_lex_token (pfile, result) && !CPP_IN_SYSTEM_HEADER (pfile)) break; - /* We silently allow C++ comments in system headers, - irrespective of conformance mode, because lots of - broken systems do that and trying to clean it up in - fixincludes is a nightmare. */ - if (CPP_OPTION (pfile, c89) && CPP_PEDANTIC (pfile) + /* Warn about comments only if pedantically GNUC89, and not + in system headers. */ + if (CPP_OPTION (pfile, lang) == CLK_GNUC89 && CPP_PEDANTIC (pfile) && ! buffer->warned_cplusplus_comments) { cpp_pedwarn (pfile, diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 3094385aabb..48a8bf6052b 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -293,7 +293,7 @@ _cpp_handle_directive (pfile, indented) skipped conditional groups. Complain about this form if we're being pedantic, but not if this is regurgitated input (preprocessed or fed back in by the C++ frontend). */ - if (! buffer->was_skipping && !CPP_OPTION (pfile, lang_asm)) + if (! buffer->was_skipping && CPP_OPTION (pfile, lang) != CLK_ASM) { dir = &dtable[T_LINE]; _cpp_push_token (pfile, &dname, &pfile->directive_pos); @@ -354,7 +354,7 @@ _cpp_handle_directive (pfile, indented) source: we don't know where the comments are, and # may introduce assembler pseudo-ops. Don't complain about invalid directives in skipped conditional groups (6.10 p4). */ - if (CPP_OPTION (pfile, lang_asm)) + if (CPP_OPTION (pfile, lang) == CLK_ASM) { /* Output the # and lookahead token for the assembler. */ _cpp_push_token (pfile, &dname, &pfile->directive_pos); diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 91cca900733..4ad00461be5 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -351,6 +351,9 @@ struct cpp_options /* -fleading_underscore sets this to "_". */ const char *user_label_prefix; + /* The language we're preprocessing. */ + enum c_lang lang; + /* Non-0 means -v, so print the full set of include dirs. */ unsigned char verbose; @@ -363,12 +366,6 @@ struct cpp_options /* Nonzero means handle #import, for objective C. */ unsigned char objc; - /* Nonzero means this is an assembly file, so ignore unrecognized - directives and the "# 33" form of #line, both of which are - probably comments. Also, permit unbalanced ' strings (again, - likely to be in comments). */ - unsigned char lang_asm; - /* Nonzero means don't copy comments into the output file. */ unsigned char discard_comments; @@ -378,6 +375,9 @@ struct cpp_options /* Nonzero means process the ISO digraph sequences. */ unsigned char digraphs; + /* Nonzero means to allow hexadecimal floats and LL suffixes. */ + unsigned char extended_numbers; + /* Nonzero means print the names of included files rather than the preprocessed output. 1 means just the #include "...", 2 means #include <...> as well. */ @@ -447,9 +447,6 @@ struct cpp_options /* Nonzero means warn if undefined identifiers are evaluated in an #if. */ unsigned char warn_undef; - /* Nonzero for the 1989 C Standard, including corrigenda and amendments. */ - unsigned char c89; - /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */ unsigned char c99; diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index c5ec6de49d9..4adf7f687ca 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -564,7 +564,7 @@ parse_args (pfile, node) if (argc + 1 == macro->paramc && macro->var_args) { - if (CPP_OPTION (pfile, c99) && CPP_PEDANTIC (pfile)) + if (CPP_PEDANTIC (pfile)) cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used"); } else @@ -1283,7 +1283,7 @@ parse_params (pfile, macro) pfile->state.va_args_ok = 1; if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic)) cpp_pedwarn (pfile, - "C89 does not permit anonymous variable arguments"); + "anonymous variable arguments were introduced in C99"); } else if (CPP_OPTION (pfile, pedantic)) cpp_pedwarn (pfile, @@ -1395,7 +1395,7 @@ _cpp_create_definition (pfile, node) macro->count--; } /* Let assembler get away with murder. */ - else if (!CPP_OPTION (pfile, lang_asm)) + else if (CPP_OPTION (pfile, lang) != CLK_ASM) { ok = 0; cpp_error (pfile, "'#' is not followed by a macro parameter"); diff --git a/gcc/cppmain.c b/gcc/cppmain.c index d530e7d8427..4e096c4abf9 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -199,7 +199,7 @@ scan_buffer (pfile) } else if (print.printed && ! (token->flags & PREV_WHITE) - && ! CPP_OPTION (pfile, lang_asm) + && CPP_OPTION (pfile, lang) != CLK_ASM && cpp_avoid_paste (pfile, &tokens[1 - index], token)) token->flags |= PREV_WHITE; -- 2.30.2