Commit bdb05a7b by Neil Booth Committed by Neil Booth

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
parent e1085962
2000-11-26 Neil Booth <neilb@earthling.net>
* 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 <kenner@vlsi1.ultra.nyu.edu> Sun Nov 26 10:02:37 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* fold-const.c (fold, case CONVERT_EXPR): Always return tree of * fold-const.c (fold, case CONVERT_EXPR): Always return tree of
......
...@@ -205,9 +205,7 @@ parse_number (pfile, tok) ...@@ -205,9 +205,7 @@ parse_number (pfile, tok)
if (CPP_WTRADITIONAL (pfile) && sufftab[i].u) if (CPP_WTRADITIONAL (pfile) && sufftab[i].u)
cpp_warning (pfile, "traditional C rejects the `U' suffix"); cpp_warning (pfile, "traditional C rejects the `U' suffix");
if (CPP_OPTION (pfile, c89) if (sufftab[i].l == 2 && !CPP_OPTION (pfile, extended_numbers))
&& sufftab[i].l == 2
&& pfile->spec_nodes.n__STRICT_ANSI__->type == NT_MACRO)
SYNTAX_ERROR ("too many 'l' suffixes in integer constant"); SYNTAX_ERROR ("too many 'l' suffixes in integer constant");
} }
......
...@@ -26,7 +26,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -26,7 +26,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define VALID_SIGN(c, prevc) \ #define VALID_SIGN(c, prevc) \
(((c) == '+' || (c) == '-') && \ (((c) == '+' || (c) == '-') && \
((prevc) == 'e' || (prevc) == 'E' \ ((prevc) == 'e' || (prevc) == 'E' \
|| (((prevc) == 'p' || (prevc) == 'P') && !CPP_OPTION (pfile, c89)))) || (((prevc) == 'p' || (prevc) == 'P') \
&& CPP_OPTION (pfile, extended_numbers))))
/* Memory pools. */ /* Memory pools. */
#define ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1)) #define ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
......
...@@ -431,10 +431,11 @@ set_lang (pfile, lang) ...@@ -431,10 +431,11 @@ set_lang (pfile, lang)
{ {
struct cpp_pending *pend = CPP_OPTION (pfile, pending); struct cpp_pending *pend = CPP_OPTION (pfile, pending);
/* Default to zero. */ /* Defaults. */
CPP_OPTION (pfile, lang_asm) = 0; CPP_OPTION (pfile, lang) = lang;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, cplusplus) = 0; CPP_OPTION (pfile, cplusplus) = 0;
CPP_OPTION (pfile, extended_numbers) = 1; /* Allowed in GNU C and C99. */
switch (lang) switch (lang)
{ {
...@@ -444,7 +445,6 @@ set_lang (pfile, lang) ...@@ -444,7 +445,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1; CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 1; CPP_OPTION (pfile, c99) = 1;
new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define); new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
break; break;
...@@ -453,7 +453,6 @@ set_lang (pfile, lang) ...@@ -453,7 +453,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1; CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c89) = 1;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
break; break;
...@@ -465,8 +464,8 @@ set_lang (pfile, lang) ...@@ -465,8 +464,8 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 0; CPP_OPTION (pfile, dollars_in_ident) = 0;
CPP_OPTION (pfile, cplusplus_comments) = 0; CPP_OPTION (pfile, cplusplus_comments) = 0;
CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94; CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
CPP_OPTION (pfile, c89) = 1;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, extended_numbers) = 0;
new_pending_directive (pend, "__STRICT_ANSI__", cpp_define); new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
break; break;
case CLK_STDC99: case CLK_STDC99:
...@@ -474,7 +473,6 @@ set_lang (pfile, lang) ...@@ -474,7 +473,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 0; CPP_OPTION (pfile, dollars_in_ident) = 0;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1; CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 1; CPP_OPTION (pfile, c99) = 1;
new_pending_directive (pend, "__STRICT_ANSI__", cpp_define); new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define); new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
...@@ -489,7 +487,6 @@ set_lang (pfile, lang) ...@@ -489,7 +487,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1; CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 1; CPP_OPTION (pfile, objc) = 1;
new_pending_directive (pend, "__OBJC__", cpp_define); new_pending_directive (pend, "__OBJC__", cpp_define);
...@@ -503,7 +500,6 @@ set_lang (pfile, lang) ...@@ -503,7 +500,6 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX; CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1; CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
new_pending_directive (pend, "__cplusplus", cpp_define); new_pending_directive (pend, "__cplusplus", cpp_define);
break; break;
...@@ -514,9 +510,7 @@ set_lang (pfile, lang) ...@@ -514,9 +510,7 @@ set_lang (pfile, lang)
CPP_OPTION (pfile, dollars_in_ident) = 0; /* Maybe not? */ CPP_OPTION (pfile, dollars_in_ident) = 0; /* Maybe not? */
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 0; CPP_OPTION (pfile, digraphs) = 0;
CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, lang_asm) = 1;
new_pending_directive (pend, "__ASSEMBLER__", cpp_define); new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
break; break;
} }
...@@ -979,7 +973,7 @@ cpp_start_read (pfile, fname) ...@@ -979,7 +973,7 @@ cpp_start_read (pfile, fname)
CPP_OPTION (pfile, warn_traditional) = 0; CPP_OPTION (pfile, warn_traditional) = 0;
/* Do not warn about invalid token pasting if -lang-asm. */ /* 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; CPP_OPTION (pfile, warn_paste) = 0;
/* Set this if it hasn't been set already. */ /* Set this if it hasn't been set already. */
......
...@@ -673,7 +673,7 @@ parse_string (pfile, token, terminator) ...@@ -673,7 +673,7 @@ parse_string (pfile, token, terminator)
/* In assembly language, silently terminate string and /* In assembly language, silently terminate string and
character literals at end of line. This is a kludge character literals at end of line. This is a kludge
around not knowing where comments are. */ around not knowing where comments are. */
if (CPP_OPTION (pfile, lang_asm) && terminator != '>') if (CPP_OPTION (pfile, lang) == CLK_ASM && terminator != '>')
break; break;
/* Character constants and header names may not extend over /* Character constants and header names may not extend over
...@@ -1007,11 +1007,9 @@ _cpp_lex_token (pfile, result) ...@@ -1007,11 +1007,9 @@ _cpp_lex_token (pfile, result)
&& !CPP_IN_SYSTEM_HEADER (pfile)) && !CPP_IN_SYSTEM_HEADER (pfile))
break; break;
/* We silently allow C++ comments in system headers, /* Warn about comments only if pedantically GNUC89, and not
irrespective of conformance mode, because lots of in system headers. */
broken systems do that and trying to clean it up in if (CPP_OPTION (pfile, lang) == CLK_GNUC89 && CPP_PEDANTIC (pfile)
fixincludes is a nightmare. */
if (CPP_OPTION (pfile, c89) && CPP_PEDANTIC (pfile)
&& ! buffer->warned_cplusplus_comments) && ! buffer->warned_cplusplus_comments)
{ {
cpp_pedwarn (pfile, cpp_pedwarn (pfile,
......
...@@ -293,7 +293,7 @@ _cpp_handle_directive (pfile, indented) ...@@ -293,7 +293,7 @@ _cpp_handle_directive (pfile, indented)
skipped conditional groups. Complain about this form if skipped conditional groups. Complain about this form if
we're being pedantic, but not if this is regurgitated input we're being pedantic, but not if this is regurgitated input
(preprocessed or fed back in by the C++ frontend). */ (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]; dir = &dtable[T_LINE];
_cpp_push_token (pfile, &dname, &pfile->directive_pos); _cpp_push_token (pfile, &dname, &pfile->directive_pos);
...@@ -354,7 +354,7 @@ _cpp_handle_directive (pfile, indented) ...@@ -354,7 +354,7 @@ _cpp_handle_directive (pfile, indented)
source: we don't know where the comments are, and # may source: we don't know where the comments are, and # may
introduce assembler pseudo-ops. Don't complain about invalid introduce assembler pseudo-ops. Don't complain about invalid
directives in skipped conditional groups (6.10 p4). */ 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. */ /* Output the # and lookahead token for the assembler. */
_cpp_push_token (pfile, &dname, &pfile->directive_pos); _cpp_push_token (pfile, &dname, &pfile->directive_pos);
......
...@@ -351,6 +351,9 @@ struct cpp_options ...@@ -351,6 +351,9 @@ struct cpp_options
/* -fleading_underscore sets this to "_". */ /* -fleading_underscore sets this to "_". */
const char *user_label_prefix; 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. */ /* Non-0 means -v, so print the full set of include dirs. */
unsigned char verbose; unsigned char verbose;
...@@ -363,12 +366,6 @@ struct cpp_options ...@@ -363,12 +366,6 @@ struct cpp_options
/* Nonzero means handle #import, for objective C. */ /* Nonzero means handle #import, for objective C. */
unsigned char objc; 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. */ /* Nonzero means don't copy comments into the output file. */
unsigned char discard_comments; unsigned char discard_comments;
...@@ -378,6 +375,9 @@ struct cpp_options ...@@ -378,6 +375,9 @@ struct cpp_options
/* Nonzero means process the ISO digraph sequences. */ /* Nonzero means process the ISO digraph sequences. */
unsigned char digraphs; 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 /* Nonzero means print the names of included files rather than the
preprocessed output. 1 means just the #include "...", 2 means preprocessed output. 1 means just the #include "...", 2 means
#include <...> as well. */ #include <...> as well. */
...@@ -447,9 +447,6 @@ struct cpp_options ...@@ -447,9 +447,6 @@ struct cpp_options
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */ /* Nonzero means warn if undefined identifiers are evaluated in an #if. */
unsigned char warn_undef; 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. */ /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
unsigned char c99; unsigned char c99;
......
...@@ -564,7 +564,7 @@ parse_args (pfile, node) ...@@ -564,7 +564,7 @@ parse_args (pfile, node)
if (argc + 1 == macro->paramc && macro->var_args) 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"); cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used");
} }
else else
...@@ -1283,7 +1283,7 @@ parse_params (pfile, macro) ...@@ -1283,7 +1283,7 @@ parse_params (pfile, macro)
pfile->state.va_args_ok = 1; pfile->state.va_args_ok = 1;
if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic)) if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic))
cpp_pedwarn (pfile, cpp_pedwarn (pfile,
"C89 does not permit anonymous variable arguments"); "anonymous variable arguments were introduced in C99");
} }
else if (CPP_OPTION (pfile, pedantic)) else if (CPP_OPTION (pfile, pedantic))
cpp_pedwarn (pfile, cpp_pedwarn (pfile,
...@@ -1395,7 +1395,7 @@ _cpp_create_definition (pfile, node) ...@@ -1395,7 +1395,7 @@ _cpp_create_definition (pfile, node)
macro->count--; macro->count--;
} }
/* Let assembler get away with murder. */ /* Let assembler get away with murder. */
else if (!CPP_OPTION (pfile, lang_asm)) else if (CPP_OPTION (pfile, lang) != CLK_ASM)
{ {
ok = 0; ok = 0;
cpp_error (pfile, "'#' is not followed by a macro parameter"); cpp_error (pfile, "'#' is not followed by a macro parameter");
......
...@@ -199,7 +199,7 @@ scan_buffer (pfile) ...@@ -199,7 +199,7 @@ scan_buffer (pfile)
} }
else if (print.printed else if (print.printed
&& ! (token->flags & PREV_WHITE) && ! (token->flags & PREV_WHITE)
&& ! CPP_OPTION (pfile, lang_asm) && CPP_OPTION (pfile, lang) != CLK_ASM
&& cpp_avoid_paste (pfile, &tokens[1 - index], token)) && cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE; token->flags |= PREV_WHITE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment