1992-03-14 00:07:15 -05:00
|
|
|
|
/* Lexical analyzer for C and Objective C.
|
1998-04-04 08:32:39 -05:00
|
|
|
|
Copyright (C) 1987, 88, 89, 92, 94-97, 1998 Free Software Foundation, Inc.
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
|
|
GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GNU CC is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GNU CC; see the file COPYING. If not, write to
|
1995-06-15 07:33:25 -04:00
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1997-11-02 16:19:36 -05:00
|
|
|
|
#include "config.h"
|
Major cutover to using system.h:
* Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o,
c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o,
caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o,
dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o,
expr.o, final.o, flow.o, function.o, getpwd.o, global.o,
integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o,
prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o,
reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o,
rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o,
tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend
on system.h.
* alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c,
c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c,
caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c,
integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c,
prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c,
reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c,
rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c,
stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c,
xcoffout.c: Include system.h. Organize include ordering so
that stdarg/varargs comes before other system headers. Remove
spurious casts of functions assured of a prototype in system.h.
From-SVN: r18726
1998-03-20 09:58:42 -05:00
|
|
|
|
#include "system.h"
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
#include "rtl.h"
|
|
|
|
|
#include "tree.h"
|
|
|
|
|
#include "input.h"
|
Warning fixes:
* Makefile.in (c-lang.o): Depend on c-tree.h, c-lex.h and toplev.h.
(c-lex.o): Depend on output.h.
(c-common.o): Likewise.
(stmt.o): Likewise.
(calls.o): Likewise.
(integrate.o): Depend on toplev.h.
(regclass.o): Depend on output.h.
(final.o): Depend on reload.h.
* c-common.c: Include output.h.
(check_format_info): Remove unused variable `integral_format'.
* c-decl.c (print_lang_decl): Mark parameters `file', `node' and
`indent' with ATTRIBUTE_UNUSED.
(print_lang_type): Likewise.
(maybe_build_cleanup): Likewise for parameter `decl'.
(copy_lang_decl): Likewise for parameter `node'.
* c-lang.c: Include c-tree.h, c-lex.h and toplev.h.
(lang_print_xnode): Mark parameters `file', `node' and `indent'
with ATTRIBUTE_UNUSED.
(lookup_interface): Likewise for parameter `arg'.
(is_class_name): Likewise.
(maybe_objc_check_decl): Likewise for parameter `decl'.
(maybe_objc_comptypes): Likewise for parameters `lhs', `rhs' and
`reflexive'.
(maybe_objc_method_name): Likewise for parameter `decl'.
(build_objc_string): Likewise for parameters `len' and `str'.
* c-lex.c: Include output.h.
* c-lex.h (position_after_white_space): Correct typo in prototype.
* c-tree.h (finish_file, c_expand_start_cond, c_expand_start_else,
c_expand_end_cond, init_iterators): Add prototypes.
* caller-save.c (set_reg_live): Mark parameters `reg' and `setter'
with ATTRIBUTE_UNUSED.
* calls.c: Include output.h.
* cccp.c (pipe_closed): Mark parameter `signo' with
ATTRIBUTE_UNUSED.
* combine.c: Move inclusion of expr.h to after insn-config.h.
* iris6.h (ASM_IDENTIFY_GCC, ASM_IDENTIFY_LANGUAGE): Don't define
as empty, rather define as ((void)0).
* sparc.c (sparc_check_64): Add braces around ambiguous `else'.
Add parentheses around assignment used as truth value.
* cplus-dem.c (squangle_mop_up): Change return type to void.
(internal_cplus_demangle): Remove unused parameter `options'.
All callers changed.
(cplus_demangle_opname): Remove function wide variable `int i' and
replace with `size_t i' at each location where it is used.
(cplus_demangle_opname): change type of `i' from int to size_t.
* cppexp.c (right_shift): Mark parameter `pfile' with
ATTRIBUTE_UNUSED.
* cpphash.c (cpp_lookup): Likewise.
(cpp_hash_cleanup): Likewise.
* cpplib.c (parse_name): Add a prototype and make it static.
(null_underflow): Mark parameter `pfile' with ATTRIBUTE_UNUSED.
(null_cleanup): Likewise for parameters `pbuf' and `pfile'.
(macro_cleanup): Likewise for parameter `pfile'.
(file_cleanup): Likewise.
* cpplib.h (cpp_reader_init, cpp_options_init, cpp_start_read,
cpp_read_check_assertion, skip_rest_of_line): Add prototypes.
* crtstuff.c (force_to_data, __CTOR_LIST__, force_to_data,
__DTOR_END__, __FRAME_END__): Mark with ATTRIBUTE_UNUSED.
* cse.c (cse_check_loop_start): Mark parameter `set' with
ATTRIBUTE_UNUSED.
* dbxout.c (flag_minimal_debug, have_used_extensions,
source_label_number): Move inside macro wrapper check against
defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO).
* dwarf2out.c (gen_entry_point_die): Hide prototype and definition.
* except.h (doing_eh): Provide prototype.
* expr.c: Move inclusion of expr.h to after insn-config.h.
* final.c: Include reload.h.
(shorten_branches): Cast the first argument of bzero to char *.
* fix-header.c (cpp_print_containing_files): Mark parameter
`pfile' with ATTRIBUTE_UNUSED.
(cpp_fatal): Likewise.
* flow.c (find_basic_blocks_1): Cast the first argument of bzero
to char *.
* genattrtab.c (make_length_attrs): Change the type of variable
`i' from int to size_t.
(zero_fn): Mark parameter `exp' with ATTRIBUTE_UNUSED.
(one_fn): Likewise.
* genextract.c (main): When generating insn-extract.c, mark
variable `junk' with ATTRIBUTE_UNUSED.
* gengenrtl.c (gencode): When generating genrtl.c, cast the first
argument of bzero to char*.
* integrate.c: Include toplev.h.
* libgcc2.c: Wrap `struct exception_table' and
`find_exception_handler' in macro DWARF2_UNWIND_INFO.
* objc/Make-lang.in (objc-act.o): Depend on toplev.h.
* objc/objc-act.c: Include toplev.h.
(lang_print_xnode): Mark parameters `file', `node' and `indent'
with ATTRIBUTE_UNUSED.
(finish_protocol): Likewise for parameter `protocol'.
* output.h (declare_weak): Add prototype.
(decode_reg_name): Don't wrap with TREE_CODE macro.
(assemble_alias): Add prototype.
* regclass.c: Include output.h.
* reload.h (reloads_conflict): Add prototype.
* rtl.h (print_rtl_single, mark_elimiation, reg_class_subset_p,
output_func_start_profiler): Add prototypes.
* rtlanal.c (reg_set_p_1): Mark parameters `x' and `pat' with
ATTRIBUTE_UNUSED.
* scan-decls.c: Include scan.h.
* scan.h (recognized_function, recognized_extern): Add prototypes.
* stmt.c: Include output.h.
* toplev.c (error_for_asm, warning_for_asm): Remove prototypes.
(output_lang_identify): Hide prototype and definition.
(float_signal): Mark parameter `signo' with ATTRIBUTE_UNUSED.
(pipe_closed): Likewise.
* toplev.h (count_error, strip_off_ending, error_for_asm,
warning_for_asm): Add prototypes.
From-SVN: r19712
1998-05-13 08:40:39 -04:00
|
|
|
|
#include "output.h"
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#include "c-lex.h"
|
|
|
|
|
#include "c-tree.h"
|
|
|
|
|
#include "flags.h"
|
|
|
|
|
#include "c-parse.h"
|
1995-04-18 14:16:51 -04:00
|
|
|
|
#include "c-pragma.h"
|
toplev.h: New file.
Wed May 6 06:35:38 1998 Robert Lipe <robertl@dgii.com>
* toplev.h: New file. Protypes for functions in toplev.c.
* tree.h, rtl.h: Deleted protos for functions in toplev.c.
* c-common.c, c-convert.c, c-decl.c, c-iterate.c, c-lex.c,
c-parse.in, c-parse.y, c-pragma.c, c-typeck.c, calls.c,
convert.c, dwarf2out.c, except.c, expr.c, final.c, fold-const.c,
function.c, hash.c, profile.c, real.c, reg-stack.c, regclass.c,
reload.c, reload1.c, stmt.c, stor-layout.c, tlink.c, tree.c,
varasm.c: include it.
From-SVN: r19563
1998-05-06 00:45:47 -04:00
|
|
|
|
#include "toplev.h"
|
1999-01-26 20:43:17 -05:00
|
|
|
|
#include "intl.h"
|
|
|
|
|
|
|
|
|
|
/* MULTIBYTE_CHARS support only works for native compilers.
|
|
|
|
|
??? Ideally what we want is to model widechar support after
|
|
|
|
|
the current floating point support. */
|
|
|
|
|
#ifdef CROSS_COMPILE
|
|
|
|
|
#undef MULTIBYTE_CHARS
|
|
|
|
|
#endif
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
1998-07-20 09:35:38 -04:00
|
|
|
|
#include "mbchar.h"
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#include <locale.h>
|
1998-07-20 09:35:38 -04:00
|
|
|
|
#endif /* MULTIBYTE_CHARS */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if USE_CPPLIB
|
|
|
|
|
#include "cpplib.h"
|
1998-05-21 04:54:04 -04:00
|
|
|
|
extern cpp_reader parse_in;
|
|
|
|
|
extern cpp_options parse_options;
|
1998-04-08 19:29:09 -04:00
|
|
|
|
#else
|
|
|
|
|
/* Stream for reading from the input file. */
|
|
|
|
|
FILE *finput;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-06-19 16:43:54 -04:00
|
|
|
|
extern void yyprint PROTO((FILE *, int, YYSTYPE));
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* The elements of `ridpointers' are identifier nodes
|
|
|
|
|
for the reserved type names and storage classes.
|
|
|
|
|
It is indexed by a RID_... value. */
|
|
|
|
|
tree ridpointers[(int) RID_MAX];
|
|
|
|
|
|
|
|
|
|
/* Cause the `yydebug' variable to be defined. */
|
|
|
|
|
#define YYDEBUG 1
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if USE_CPPLIB
|
1998-05-21 04:54:04 -04:00
|
|
|
|
extern unsigned char *yy_cur, *yy_lim;
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1998-05-21 04:54:04 -04:00
|
|
|
|
extern int yy_get_token ();
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#define GETC() (yy_cur < yy_lim ? *yy_cur++ : yy_get_token ())
|
1999-02-15 09:04:21 -05:00
|
|
|
|
#define UNGETC(c) ((c) == EOF ? 0 : yy_cur--)
|
1999-06-07 07:12:38 -04:00
|
|
|
|
|
|
|
|
|
#else /* ! USE_CPPLIB */
|
|
|
|
|
|
|
|
|
|
#define GETC() getch ()
|
|
|
|
|
#define UNGETC(c) put_back (c)
|
|
|
|
|
|
|
|
|
|
struct putback_buffer {
|
|
|
|
|
char *buffer;
|
|
|
|
|
int buffer_size;
|
|
|
|
|
int index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct putback_buffer putback = {NULL, 0, -1};
|
|
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
|
getch ()
|
|
|
|
|
{
|
|
|
|
|
if (putback.index != -1)
|
|
|
|
|
{
|
|
|
|
|
int ch = putback.buffer[putback.index];
|
|
|
|
|
--putback.index;
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
return getc (finput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
put_back (ch)
|
|
|
|
|
int ch;
|
|
|
|
|
{
|
|
|
|
|
if (ch != EOF)
|
|
|
|
|
{
|
|
|
|
|
if (putback.index == putback.buffer_size - 1)
|
|
|
|
|
{
|
|
|
|
|
putback.buffer_size += 16;
|
|
|
|
|
putback.buffer = xrealloc (putback.buffer, putback.buffer_size);
|
|
|
|
|
}
|
|
|
|
|
putback.buffer[++putback.index] = ch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* ! USE_CPPLIB */
|
1997-07-29 18:40:30 -04:00
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* the declaration found for the last IDENTIFIER token read in.
|
|
|
|
|
yylex must look this up to detect typedefs, which get token type TYPENAME,
|
|
|
|
|
so it is left around in case the identifier is not a typedef but is
|
|
|
|
|
used in a context which makes it a reference to a variable. */
|
|
|
|
|
tree lastiddecl;
|
|
|
|
|
|
|
|
|
|
/* Nonzero enables objc features. */
|
|
|
|
|
|
|
|
|
|
int doing_objc_thang;
|
|
|
|
|
|
|
|
|
|
extern int yydebug;
|
|
|
|
|
|
|
|
|
|
/* File used for outputting assembler code. */
|
|
|
|
|
extern FILE *asm_out_file;
|
|
|
|
|
|
|
|
|
|
#ifndef WCHAR_TYPE_SIZE
|
|
|
|
|
#ifdef INT_TYPE_SIZE
|
|
|
|
|
#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
|
|
|
|
|
#else
|
|
|
|
|
#define WCHAR_TYPE_SIZE BITS_PER_WORD
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Number of bytes in a wide character. */
|
|
|
|
|
#define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
|
|
|
|
|
|
|
|
|
|
static int maxtoken; /* Current nominal length of token buffer. */
|
|
|
|
|
char *token_buffer; /* Pointer to token buffer.
|
|
|
|
|
Actual allocated length is maxtoken + 2.
|
|
|
|
|
This is not static because objc-parse.y uses it. */
|
|
|
|
|
|
1997-11-02 16:19:36 -05:00
|
|
|
|
static int indent_level = 0; /* Number of { minus number of }. */
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Nonzero if end-of-file has been seen on input. */
|
|
|
|
|
static int end_of_file;
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if !USE_CPPLIB
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Buffered-back input character; faster than using ungetc. */
|
|
|
|
|
static int nextchar = -1;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_GENERIC_PRAGMAS
|
|
|
|
|
static int handle_generic_pragma PROTO((int));
|
|
|
|
|
#endif /* HANDLE_GENERIC_PRAGMAS */
|
c-lex.c (is_class_name): Delete declaration.
* c-lex.c (is_class_name): Delete declaration.
(whitespace_cr): Make static and add prototype.
* c-lex.h (make_pointer_declarator, reinit_parse_for_function,
yylex, get_directive_line): Turn declarations into prototypes.
(position_after_whitespace, check_newline, yyerror,, is_class_name,
forget_protocol_qualifiers, remember_protocol_qualifiers): Add
prototypes.
* genattr.c (extend_range, write_upcase, gen_attr, write_units): Add
prototypes.
* gencodes.c (gen_insn): Add prototype.
* genconfig.c (walk_insn, gen_insn, gen_expand, gen_split,
gen_peephole): Add prototypes.
* genflags.c (num_operands, gen_proto, gen_nonproto, gen_insn): Add
prototypes.
* gengenrtl.c (type_from_format, accessor_from_format, special_rtx,
special_format, find_formats, gendecl, genmacro, gendef, genlegend,
genheader, gencode): Add prototypes.
* genopinit.c (gen_insn): Add prototype.
* genoutput.c (output_prologue, output_epilogue, scan_operands,
process_template, validate_insn_alternatives, gen_insn, gen_peephole,
gen_expand, gen_split, n_occurrences): Add prototypes.
* genpeep.c (gen_peephole): Add prototype.
* loop.c (find_and_verify_loops, mark_loop_jump, prescan_loop,
reg_in_basic_block_p, consec_sets_invariant_p, libcall_other_reg,
labels_in_range_p, count_loop_regs_set, note_addr_stored,
loop_reg_used_before_p, scan_loop, replace_call_address,
skip_consec_insns, libcall_benefit, ignore_some_movables,
force_movables, combine_movables, rtx_equal_for_loop_p, move_movables,
strength_reduce, valid_initial_value_p, find_mem_givs, record_biv,
check_final_value, record_giv, update_giv_derive, basic_induction_var,
simplify_giv_expr, general_induction_var, consec_sets_giv,
check_dbra_loop, express_from, combine_givs_p, combine_givs,
product_cheap_p, maybe_eliminate_biv, maybe_eliminate_biv_1,
last_use_this_basic_block, record_initial, update_reg_last_use,
iteration_info, analyze_loop_iterations, insert_bct,
instrument_loop_bct, indirect_jump_in_function_p): Turn declarations
into prototypes.
From-SVN: r19038
1998-04-07 19:47:11 -04:00
|
|
|
|
static int whitespace_cr PROTO((int));
|
1997-12-20 06:31:54 -05:00
|
|
|
|
static int skip_white_space PROTO((int));
|
1998-04-16 18:22:43 -04:00
|
|
|
|
static int skip_white_space_on_line PROTO((void));
|
bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror, extend_token_buffer): Likewise. Don't include
limits.h or ctype.h. Remove unused variable `p'.
* c-lex.h (yyerror): Qualify a char* with the `const' keyword.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, warning_init, incomplete_type_error,
build_indirect_ref, lvalue_or_else, readonly_warning,
build_c_cast, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
From-SVN: r25296
1999-02-18 15:38:48 -05:00
|
|
|
|
static char *extend_token_buffer PROTO((const char *));
|
1997-12-06 19:31:01 -05:00
|
|
|
|
static int readescape PROTO((int *));
|
1999-03-17 01:34:46 -05:00
|
|
|
|
static void parse_float PROTO((PTR));
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1994-03-04 17:16:16 -05:00
|
|
|
|
/* Do not insert generated code into the source, instead, include it.
|
|
|
|
|
This allows us to build gcc automatically even for targets that
|
|
|
|
|
need to add or modify the reserved keyword lists. */
|
|
|
|
|
#include "c-gperf.h"
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* Return something to represent absolute declarators containing a *.
|
|
|
|
|
TARGET is the absolute declarator that the * contains.
|
|
|
|
|
TYPE_QUALS is a list of modifiers such as const or volatile
|
|
|
|
|
to apply to the pointer type, represented as identifiers.
|
|
|
|
|
|
|
|
|
|
We return an INDIRECT_REF whose "contents" are TARGET
|
|
|
|
|
and whose type is the modifier list. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
make_pointer_declarator (type_quals, target)
|
|
|
|
|
tree type_quals, target;
|
|
|
|
|
{
|
|
|
|
|
return build1 (INDIRECT_REF, type_quals, target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1993-04-09 19:12:37 -04:00
|
|
|
|
forget_protocol_qualifiers ()
|
|
|
|
|
{
|
|
|
|
|
int i, n = sizeof wordlist / sizeof (struct resword);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
1993-04-24 16:45:57 -04:00
|
|
|
|
if ((int) wordlist[i].rid >= (int) RID_IN
|
|
|
|
|
&& (int) wordlist[i].rid <= (int) RID_ONEWAY)
|
1993-04-09 19:12:37 -04:00
|
|
|
|
wordlist[i].name = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
remember_protocol_qualifiers ()
|
|
|
|
|
{
|
|
|
|
|
int i, n = sizeof wordlist / sizeof (struct resword);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
if (wordlist[i].rid == RID_IN)
|
|
|
|
|
wordlist[i].name = "in";
|
|
|
|
|
else if (wordlist[i].rid == RID_OUT)
|
|
|
|
|
wordlist[i].name = "out";
|
|
|
|
|
else if (wordlist[i].rid == RID_INOUT)
|
|
|
|
|
wordlist[i].name = "inout";
|
|
|
|
|
else if (wordlist[i].rid == RID_BYCOPY)
|
|
|
|
|
wordlist[i].name = "bycopy";
|
1998-10-08 07:28:08 -04:00
|
|
|
|
else if (wordlist[i].rid == RID_BYREF)
|
|
|
|
|
wordlist[i].name = "byref";
|
1993-04-09 19:12:37 -04:00
|
|
|
|
else if (wordlist[i].rid == RID_ONEWAY)
|
1998-12-02 05:36:07 -05:00
|
|
|
|
wordlist[i].name = "oneway";
|
1993-04-09 19:12:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
1998-04-15 08:31:38 -04:00
|
|
|
|
char *
|
1997-07-29 18:40:30 -04:00
|
|
|
|
init_parse (filename)
|
|
|
|
|
char *filename;
|
|
|
|
|
{
|
1998-04-08 19:29:09 -04:00
|
|
|
|
#if !USE_CPPLIB
|
|
|
|
|
/* Open input file. */
|
|
|
|
|
if (filename == 0 || !strcmp (filename, "-"))
|
|
|
|
|
{
|
|
|
|
|
finput = stdin;
|
|
|
|
|
filename = "stdin";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
finput = fopen (filename, "r");
|
|
|
|
|
if (finput == 0)
|
|
|
|
|
pfatal_with_name (filename);
|
|
|
|
|
|
|
|
|
|
#ifdef IO_BUFFER_SIZE
|
|
|
|
|
setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
|
|
|
|
|
#endif
|
1998-11-25 03:54:10 -05:00
|
|
|
|
#else /* !USE_CPPLIB */
|
1997-07-29 18:40:30 -04:00
|
|
|
|
parse_in.show_column = 1;
|
|
|
|
|
if (! cpp_start_read (&parse_in, filename))
|
|
|
|
|
abort ();
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 06:54:13 -05:00
|
|
|
|
|
1998-11-25 03:54:10 -05:00
|
|
|
|
if (filename == 0 || !strcmp (filename, "-"))
|
|
|
|
|
filename = "stdin";
|
|
|
|
|
|
[multiple changes]
1998-10-28 16:10 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* c-lang.c: Declare extern char *yy_cur if USE_CPPLIB.
(lang_init): Call check_newline always.
* c-lex.c (init_parse) [USE_CPPLIB=1]: After calling
cpp_start_read, set yy_cur and yy_lim to read from
parse_in.token_buffer, so that we'll see the first #line
directive.
* cpplib.c (cpp_start_read): finclude the main input file
before processing -include/-imacros. Process -imacros and
-include separately, and handle -include by stacking a
buffer for the file in question as if it'd been #included.
* toplev.c (documented_lang_options) Recognize -H when
USE_CPPLIB is on.
1998-10-28 16:09 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c: Merge do_once into do_pragma. Break file handling
code out of do_include.
Move append_include_chain, deps_output,
file_cleanup, redundant_include_p, import_hash,
lookup_import, add_import, read_filename_string, read_name_map,
open_include_file, finclude, safe_read to cppfiles.c.
Move prototypes for deps_output, append_include_chain,
finclude to cpplib.h. Move definition of struct
file_name_list there also.
* cppfiles.c: New file. Contains all the above functions
broken out of cpplib.c; also hack_vms_include_specification
from cccp.c and find_include_file, a new function broken out of
do_include.
* Makefile.in (cppmain): Depend on cppfiles.o.
(fix-header): Likewise.
(cppfiles.o): New target.
* configure.in (--enable-c-cpplib): Add cppfiles.o to
extra_c_objs. Add ../cppfiles.o to extra_cxx_objs.
From-SVN: r23424
1998-10-29 06:54:13 -05:00
|
|
|
|
/* cpp_start_read always puts at least one line directive into the
|
|
|
|
|
token buffer. We must arrange to read it out here. */
|
|
|
|
|
yy_cur = parse_in.token_buffer;
|
|
|
|
|
yy_lim = CPP_PWRITTEN (&parse_in);
|
1998-04-08 19:29:09 -04:00
|
|
|
|
#endif
|
1998-04-15 08:31:38 -04:00
|
|
|
|
|
1998-11-25 03:54:10 -05:00
|
|
|
|
init_lex ();
|
|
|
|
|
|
1998-04-15 08:31:38 -04:00
|
|
|
|
return filename;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
finish_parse ()
|
|
|
|
|
{
|
1998-04-08 19:29:09 -04:00
|
|
|
|
#if USE_CPPLIB
|
1997-07-29 18:40:30 -04:00
|
|
|
|
cpp_finish (&parse_in);
|
1998-04-08 19:29:09 -04:00
|
|
|
|
#else
|
|
|
|
|
fclose (finput);
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
1998-04-08 19:29:09 -04:00
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
|
1993-04-09 19:12:37 -04:00
|
|
|
|
void
|
1992-03-06 18:36:01 -05:00
|
|
|
|
init_lex ()
|
|
|
|
|
{
|
|
|
|
|
/* Make identifier nodes long enough for the language-specific slots. */
|
|
|
|
|
set_identifier_size (sizeof (struct lang_identifier));
|
|
|
|
|
|
|
|
|
|
/* Start it at 0, because check_newline is called at the very beginning
|
|
|
|
|
and will increment it to 1. */
|
|
|
|
|
lineno = 0;
|
|
|
|
|
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
|
|
|
|
/* Change to the native locale for multibyte conversions. */
|
|
|
|
|
setlocale (LC_CTYPE, "");
|
1998-09-20 20:56:50 -04:00
|
|
|
|
literal_codeset = getenv ("LANG");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
maxtoken = 40;
|
|
|
|
|
token_buffer = (char *) xmalloc (maxtoken + 2);
|
|
|
|
|
|
|
|
|
|
ridpointers[(int) RID_INT] = get_identifier ("int");
|
|
|
|
|
ridpointers[(int) RID_CHAR] = get_identifier ("char");
|
|
|
|
|
ridpointers[(int) RID_VOID] = get_identifier ("void");
|
|
|
|
|
ridpointers[(int) RID_FLOAT] = get_identifier ("float");
|
|
|
|
|
ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
|
|
|
|
|
ridpointers[(int) RID_SHORT] = get_identifier ("short");
|
|
|
|
|
ridpointers[(int) RID_LONG] = get_identifier ("long");
|
|
|
|
|
ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
|
|
|
|
|
ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
|
|
|
|
|
ridpointers[(int) RID_INLINE] = get_identifier ("inline");
|
|
|
|
|
ridpointers[(int) RID_CONST] = get_identifier ("const");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 05:53:40 -04:00
|
|
|
|
ridpointers[(int) RID_RESTRICT] = get_identifier ("restrict");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
|
|
|
|
|
ridpointers[(int) RID_AUTO] = get_identifier ("auto");
|
|
|
|
|
ridpointers[(int) RID_STATIC] = get_identifier ("static");
|
|
|
|
|
ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
|
|
|
|
|
ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
|
|
|
|
|
ridpointers[(int) RID_REGISTER] = get_identifier ("register");
|
1993-03-01 23:30:43 -05:00
|
|
|
|
ridpointers[(int) RID_ITERATOR] = get_identifier ("iterator");
|
1993-03-04 13:34:10 -05:00
|
|
|
|
ridpointers[(int) RID_COMPLEX] = get_identifier ("complex");
|
1993-04-09 19:12:37 -04:00
|
|
|
|
ridpointers[(int) RID_ID] = get_identifier ("id");
|
|
|
|
|
ridpointers[(int) RID_IN] = get_identifier ("in");
|
|
|
|
|
ridpointers[(int) RID_OUT] = get_identifier ("out");
|
|
|
|
|
ridpointers[(int) RID_INOUT] = get_identifier ("inout");
|
|
|
|
|
ridpointers[(int) RID_BYCOPY] = get_identifier ("bycopy");
|
1998-10-08 07:28:08 -04:00
|
|
|
|
ridpointers[(int) RID_BYREF] = get_identifier ("byref");
|
1993-04-09 19:12:37 -04:00
|
|
|
|
ridpointers[(int) RID_ONEWAY] = get_identifier ("oneway");
|
|
|
|
|
forget_protocol_qualifiers();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* Some options inhibit certain reserved words.
|
|
|
|
|
Clear those words out of the hash table so they won't be recognized. */
|
|
|
|
|
#define UNSET_RESERVED_WORD(STRING) \
|
|
|
|
|
do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
|
|
|
|
|
if (s) s->name = ""; } while (0)
|
|
|
|
|
|
1993-04-09 19:12:37 -04:00
|
|
|
|
if (! doing_objc_thang)
|
|
|
|
|
UNSET_RESERVED_WORD ("id");
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (flag_traditional)
|
|
|
|
|
{
|
|
|
|
|
UNSET_RESERVED_WORD ("const");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 05:53:40 -04:00
|
|
|
|
UNSET_RESERVED_WORD ("restrict");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
UNSET_RESERVED_WORD ("volatile");
|
|
|
|
|
UNSET_RESERVED_WORD ("typeof");
|
|
|
|
|
UNSET_RESERVED_WORD ("signed");
|
|
|
|
|
UNSET_RESERVED_WORD ("inline");
|
1993-03-01 21:12:44 -05:00
|
|
|
|
UNSET_RESERVED_WORD ("iterator");
|
1993-03-04 13:34:10 -05:00
|
|
|
|
UNSET_RESERVED_WORD ("complex");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 05:53:40 -04:00
|
|
|
|
else if (!flag_isoc9x)
|
|
|
|
|
UNSET_RESERVED_WORD ("restrict");
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (flag_no_asm)
|
|
|
|
|
{
|
|
|
|
|
UNSET_RESERVED_WORD ("asm");
|
|
|
|
|
UNSET_RESERVED_WORD ("typeof");
|
|
|
|
|
UNSET_RESERVED_WORD ("inline");
|
1993-03-01 21:12:44 -05:00
|
|
|
|
UNSET_RESERVED_WORD ("iterator");
|
1993-03-04 13:34:10 -05:00
|
|
|
|
UNSET_RESERVED_WORD ("complex");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
reinit_parse_for_function ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Function used when yydebug is set, to print a token in more detail. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
yyprint (file, yychar, yylval)
|
|
|
|
|
FILE *file;
|
|
|
|
|
int yychar;
|
|
|
|
|
YYSTYPE yylval;
|
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
switch (yychar)
|
|
|
|
|
{
|
|
|
|
|
case IDENTIFIER:
|
|
|
|
|
case TYPENAME:
|
1993-04-09 19:12:37 -04:00
|
|
|
|
case OBJECTNAME:
|
1992-03-06 18:36:01 -05:00
|
|
|
|
t = yylval.ttype;
|
|
|
|
|
if (IDENTIFIER_POINTER (t))
|
|
|
|
|
fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CONSTANT:
|
|
|
|
|
t = yylval.ttype;
|
|
|
|
|
if (TREE_CODE (t) == INTEGER_CST)
|
1992-07-06 18:35:53 -04:00
|
|
|
|
fprintf (file,
|
|
|
|
|
#if HOST_BITS_PER_WIDE_INT == 64
|
1998-01-28 18:25:15 -05:00
|
|
|
|
#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
|
|
|
|
|
" 0x%x%016x",
|
|
|
|
|
#else
|
|
|
|
|
#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
|
1992-07-06 18:35:53 -04:00
|
|
|
|
" 0x%lx%016lx",
|
|
|
|
|
#else
|
1998-01-28 18:25:15 -05:00
|
|
|
|
" 0x%llx%016llx",
|
|
|
|
|
#endif
|
1992-07-06 18:35:53 -04:00
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
|
|
|
|
|
" 0x%lx%08lx",
|
|
|
|
|
#else
|
|
|
|
|
" 0x%x%08x",
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-11 22:17:41 -05:00
|
|
|
|
/* Iff C is a carriage return, warn about it - if appropriate -
|
|
|
|
|
and return nonzero. */
|
c-lex.c (is_class_name): Delete declaration.
* c-lex.c (is_class_name): Delete declaration.
(whitespace_cr): Make static and add prototype.
* c-lex.h (make_pointer_declarator, reinit_parse_for_function,
yylex, get_directive_line): Turn declarations into prototypes.
(position_after_whitespace, check_newline, yyerror,, is_class_name,
forget_protocol_qualifiers, remember_protocol_qualifiers): Add
prototypes.
* genattr.c (extend_range, write_upcase, gen_attr, write_units): Add
prototypes.
* gencodes.c (gen_insn): Add prototype.
* genconfig.c (walk_insn, gen_insn, gen_expand, gen_split,
gen_peephole): Add prototypes.
* genflags.c (num_operands, gen_proto, gen_nonproto, gen_insn): Add
prototypes.
* gengenrtl.c (type_from_format, accessor_from_format, special_rtx,
special_format, find_formats, gendecl, genmacro, gendef, genlegend,
genheader, gencode): Add prototypes.
* genopinit.c (gen_insn): Add prototype.
* genoutput.c (output_prologue, output_epilogue, scan_operands,
process_template, validate_insn_alternatives, gen_insn, gen_peephole,
gen_expand, gen_split, n_occurrences): Add prototypes.
* genpeep.c (gen_peephole): Add prototype.
* loop.c (find_and_verify_loops, mark_loop_jump, prescan_loop,
reg_in_basic_block_p, consec_sets_invariant_p, libcall_other_reg,
labels_in_range_p, count_loop_regs_set, note_addr_stored,
loop_reg_used_before_p, scan_loop, replace_call_address,
skip_consec_insns, libcall_benefit, ignore_some_movables,
force_movables, combine_movables, rtx_equal_for_loop_p, move_movables,
strength_reduce, valid_initial_value_p, find_mem_givs, record_biv,
check_final_value, record_giv, update_giv_derive, basic_induction_var,
simplify_giv_expr, general_induction_var, consec_sets_giv,
check_dbra_loop, express_from, combine_givs_p, combine_givs,
product_cheap_p, maybe_eliminate_biv, maybe_eliminate_biv_1,
last_use_this_basic_block, record_initial, update_reg_last_use,
iteration_info, analyze_loop_iterations, insert_bct,
instrument_loop_bct, indirect_jump_in_function_p): Turn declarations
into prototypes.
From-SVN: r19038
1998-04-07 19:47:11 -04:00
|
|
|
|
static int
|
1997-11-11 22:17:41 -05:00
|
|
|
|
whitespace_cr (c)
|
|
|
|
|
int c;
|
|
|
|
|
{
|
|
|
|
|
static int newline_warning = 0;
|
|
|
|
|
|
|
|
|
|
if (c == '\r')
|
|
|
|
|
{
|
|
|
|
|
/* ANSI C says the effects of a carriage return in a source file
|
|
|
|
|
are undefined. */
|
|
|
|
|
if (pedantic && !newline_warning)
|
|
|
|
|
{
|
|
|
|
|
warning ("carriage return in source file");
|
|
|
|
|
warning ("(we only warn about the first carriage return)");
|
|
|
|
|
newline_warning = 1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* If C is not whitespace, return C.
|
|
|
|
|
Otherwise skip whitespace and return first nonwhite char read. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
skip_white_space (c)
|
|
|
|
|
register int c;
|
|
|
|
|
{
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
1992-04-18 17:22:25 -04:00
|
|
|
|
/* We don't recognize comments here, because
|
|
|
|
|
cpp output can include / and * consecutively as operators.
|
|
|
|
|
Also, there's no need, since cpp removes all comments. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
case '\n':
|
|
|
|
|
c = check_newline ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
|
case '\t':
|
|
|
|
|
case '\f':
|
|
|
|
|
case '\v':
|
|
|
|
|
case '\b':
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break;
|
|
|
|
|
|
1992-04-18 17:22:25 -04:00
|
|
|
|
case '\r':
|
1997-11-11 22:17:41 -05:00
|
|
|
|
whitespace_cr (c);
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-04-18 17:22:25 -04:00
|
|
|
|
break;
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
case '\\':
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\n')
|
|
|
|
|
lineno++;
|
|
|
|
|
else
|
|
|
|
|
error ("stray '\\' in program");
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skips all of the white space at the current location in the input file.
|
|
|
|
|
Must use and reset nextchar if it has the next character. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
position_after_white_space ()
|
|
|
|
|
{
|
|
|
|
|
register int c;
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if !USE_CPPLIB
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (nextchar != -1)
|
|
|
|
|
c = nextchar, nextchar = -1;
|
|
|
|
|
else
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (skip_white_space (c));
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-11 22:17:41 -05:00
|
|
|
|
/* Like skip_white_space, but don't advance beyond the end of line.
|
|
|
|
|
Moreover, we don't get passed a character to start with. */
|
|
|
|
|
static int
|
|
|
|
|
skip_white_space_on_line ()
|
|
|
|
|
{
|
|
|
|
|
register int c;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
c = GETC();
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '\n':
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
|
case '\t':
|
|
|
|
|
case '\f':
|
|
|
|
|
case '\v':
|
|
|
|
|
case '\b':
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '\r':
|
|
|
|
|
whitespace_cr (c);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Make the token buffer longer, preserving the data in it.
|
|
|
|
|
P should point to just beyond the last valid character in the old buffer.
|
|
|
|
|
The value we return is a pointer to the new buffer
|
|
|
|
|
at a place corresponding to P. */
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
extend_token_buffer (p)
|
bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror, extend_token_buffer): Likewise. Don't include
limits.h or ctype.h. Remove unused variable `p'.
* c-lex.h (yyerror): Qualify a char* with the `const' keyword.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, warning_init, incomplete_type_error,
build_indirect_ref, lvalue_or_else, readonly_warning,
build_c_cast, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
From-SVN: r25296
1999-02-18 15:38:48 -05:00
|
|
|
|
const char *p;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
int offset = p - token_buffer;
|
|
|
|
|
|
|
|
|
|
maxtoken = maxtoken * 2 + 10;
|
|
|
|
|
token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
|
|
|
|
|
|
|
|
|
|
return token_buffer + offset;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
|
1998-12-02 05:36:07 -05:00
|
|
|
|
#if defined HANDLE_PRAGMA
|
1998-09-02 05:59:57 -04:00
|
|
|
|
/* Local versions of these macros, that can be passed as function pointers. */
|
|
|
|
|
static int
|
|
|
|
|
pragma_getc ()
|
|
|
|
|
{
|
|
|
|
|
return GETC();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
pragma_ungetc (arg)
|
|
|
|
|
int arg;
|
|
|
|
|
{
|
|
|
|
|
UNGETC (arg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* At the beginning of a line, increment the line number
|
|
|
|
|
and process any #-directive on this line.
|
|
|
|
|
If the line is a #-directive, read the entire line and return a newline.
|
|
|
|
|
Otherwise, return the line's first non-whitespace character. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
check_newline ()
|
|
|
|
|
{
|
|
|
|
|
register int c;
|
|
|
|
|
register int token;
|
|
|
|
|
|
|
|
|
|
lineno++;
|
|
|
|
|
|
|
|
|
|
/* Read first nonwhite char on the line. */
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
while (c == ' ' || c == '\t')
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
if (c != '#')
|
|
|
|
|
{
|
|
|
|
|
/* If not #, return it so caller will use it. */
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read first nonwhite char after the `#'. */
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
while (c == ' ' || c == '\t')
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* If a letter follows, then if the word here is `line', skip
|
|
|
|
|
it and ignore it; otherwise, ignore the line, with an error
|
|
|
|
|
if the word isn't `pragma', `ident', `define', or `undef'. */
|
|
|
|
|
|
|
|
|
|
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
|
|
|
|
{
|
|
|
|
|
if (c == 'p')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
if (GETC() == 'r'
|
|
|
|
|
&& GETC() == 'a'
|
|
|
|
|
&& GETC() == 'g'
|
|
|
|
|
&& GETC() == 'm'
|
|
|
|
|
&& GETC() == 'a'
|
1997-11-11 22:17:41 -05:00
|
|
|
|
&& ((c = GETC()) == ' ' || c == '\t' || c == '\n'
|
|
|
|
|
|| whitespace_cr (c) ))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1997-11-11 22:17:41 -05:00
|
|
|
|
while (c == ' ' || c == '\t' || whitespace_cr (c))
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC ();
|
1996-04-17 14:54:58 -04:00
|
|
|
|
if (c == '\n')
|
|
|
|
|
return c;
|
1998-09-02 05:59:57 -04:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#if defined HANDLE_PRAGMA || defined HANDLE_GENERIC_PRAGMAS
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1996-04-17 14:54:58 -04:00
|
|
|
|
token = yylex ();
|
|
|
|
|
if (token != IDENTIFIER)
|
|
|
|
|
goto skipline;
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_PRAGMA || HANDLE_GENERIC_PRAGMAS */
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#ifdef HANDLE_PRAGMA
|
1998-10-01 06:50:15 -04:00
|
|
|
|
/* We invoke HANDLE_PRAGMA before HANDLE_GENERIC_PRAGMAS (if
|
|
|
|
|
both are defined), in order to give the back end a chance to
|
|
|
|
|
override the interpretation of generic style pragmas. */
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if !USE_CPPLIB
|
1998-06-29 17:40:49 -04:00
|
|
|
|
if (nextchar >= 0)
|
1996-04-17 14:54:58 -04:00
|
|
|
|
{
|
1998-09-02 05:59:57 -04:00
|
|
|
|
c = nextchar, nextchar = -1;
|
|
|
|
|
UNGETC (c);
|
1996-04-17 14:54:58 -04:00
|
|
|
|
}
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* !USE_CPPLIB */
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
if (TREE_CODE (yylval.ttype) != IDENTIFIER_NODE)
|
|
|
|
|
goto skipline;
|
|
|
|
|
|
1998-09-02 05:59:57 -04:00
|
|
|
|
if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc,
|
|
|
|
|
IDENTIFIER_POINTER (yylval.ttype)))
|
|
|
|
|
return GETC ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#endif /* HANDLE_PRAGMA */
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_GENERIC_PRAGMAS
|
|
|
|
|
if (handle_generic_pragma (token))
|
1998-09-02 05:59:57 -04:00
|
|
|
|
return GETC ();
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_GENERIC_PRAGMAS */
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1998-09-02 05:59:57 -04:00
|
|
|
|
/* Issue a warning message if we have been asked to do so.
|
|
|
|
|
Ignoring unknown pragmas in system header file unless
|
|
|
|
|
an explcit -Wunknown-pragmas has been given. */
|
|
|
|
|
if (warn_unknown_pragmas > 1
|
|
|
|
|
|| (warn_unknown_pragmas && ! in_system_header))
|
|
|
|
|
warning ("ignoring pragma: %s", token_buffer);
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1996-05-05 21:59:45 -04:00
|
|
|
|
goto skipline;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (c == 'd')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
if (GETC() == 'e'
|
|
|
|
|
&& GETC() == 'f'
|
|
|
|
|
&& GETC() == 'i'
|
|
|
|
|
&& GETC() == 'n'
|
|
|
|
|
&& GETC() == 'e'
|
|
|
|
|
&& ((c = GETC()) == ' ' || c == '\t' || c == '\n'))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1996-11-15 02:14:08 -05:00
|
|
|
|
if (c != '\n')
|
1997-07-29 18:40:30 -04:00
|
|
|
|
debug_define (lineno, GET_DIRECTIVE_LINE ());
|
1992-03-06 18:36:01 -05:00
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (c == 'u')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
if (GETC() == 'n'
|
|
|
|
|
&& GETC() == 'd'
|
|
|
|
|
&& GETC() == 'e'
|
|
|
|
|
&& GETC() == 'f'
|
|
|
|
|
&& ((c = GETC()) == ' ' || c == '\t' || c == '\n'))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1996-11-15 02:14:08 -05:00
|
|
|
|
if (c != '\n')
|
1997-07-29 18:40:30 -04:00
|
|
|
|
debug_undef (lineno, GET_DIRECTIVE_LINE ());
|
1992-03-06 18:36:01 -05:00
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (c == 'l')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
if (GETC() == 'i'
|
|
|
|
|
&& GETC() == 'n'
|
|
|
|
|
&& GETC() == 'e'
|
|
|
|
|
&& ((c = GETC()) == ' ' || c == '\t'))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
goto linenum;
|
|
|
|
|
}
|
|
|
|
|
else if (c == 'i')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
if (GETC() == 'd'
|
|
|
|
|
&& GETC() == 'e'
|
|
|
|
|
&& GETC() == 'n'
|
|
|
|
|
&& GETC() == 't'
|
|
|
|
|
&& ((c = GETC()) == ' ' || c == '\t'))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
/* #ident. The pedantic warning is now in cccp.c. */
|
|
|
|
|
|
|
|
|
|
/* Here we have just seen `#ident '.
|
|
|
|
|
A string constant should follow. */
|
|
|
|
|
|
1997-11-11 22:17:41 -05:00
|
|
|
|
c = skip_white_space_on_line ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* If no argument, ignore the line. */
|
|
|
|
|
if (c == '\n')
|
|
|
|
|
return c;
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token = yylex ();
|
|
|
|
|
if (token != STRING
|
|
|
|
|
|| TREE_CODE (yylval.ttype) != STRING_CST)
|
|
|
|
|
{
|
|
|
|
|
error ("invalid #ident");
|
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!flag_no_ident)
|
|
|
|
|
{
|
|
|
|
|
#ifdef ASM_OUTPUT_IDENT
|
|
|
|
|
ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip the rest of this line. */
|
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error ("undefined or invalid # directive");
|
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
linenum:
|
|
|
|
|
/* Here we have either `#line' or `# <nonletter>'.
|
|
|
|
|
In either case, it should be a line number; a digit should follow. */
|
|
|
|
|
|
1997-11-11 22:17:41 -05:00
|
|
|
|
/* Can't use skip_white_space here, but must handle all whitespace
|
|
|
|
|
that is not '\n', lest we get a recursion for '\r' '\n' when
|
|
|
|
|
calling yylex. */
|
|
|
|
|
UNGETC (c);
|
|
|
|
|
c = skip_white_space_on_line ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* If the # is the only nonwhite char on the line,
|
|
|
|
|
just ignore it. Check the new newline. */
|
|
|
|
|
if (c == '\n')
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
/* Something follows the #; read a token. */
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token = yylex ();
|
|
|
|
|
|
|
|
|
|
if (token == CONSTANT
|
|
|
|
|
&& TREE_CODE (yylval.ttype) == INTEGER_CST)
|
|
|
|
|
{
|
|
|
|
|
int old_lineno = lineno;
|
|
|
|
|
int used_up = 0;
|
|
|
|
|
/* subtract one, because it is the following line that
|
|
|
|
|
gets the specified number */
|
|
|
|
|
|
|
|
|
|
int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
|
|
|
|
|
|
|
|
|
|
/* Is this the last nonwhite stuff on the line? */
|
1997-11-11 22:17:41 -05:00
|
|
|
|
c = skip_white_space_on_line ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\n')
|
|
|
|
|
{
|
|
|
|
|
/* No more: store the line number and check following line. */
|
|
|
|
|
lineno = l;
|
|
|
|
|
return c;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* More follows: it must be a string constant (filename). */
|
|
|
|
|
|
1993-09-29 01:42:10 -04:00
|
|
|
|
/* Read the string constant. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token = yylex ();
|
|
|
|
|
|
|
|
|
|
if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
|
|
|
|
|
{
|
|
|
|
|
error ("invalid #line");
|
|
|
|
|
goto skipline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input_filename
|
|
|
|
|
= (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
|
|
|
|
|
strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
|
|
|
|
|
lineno = l;
|
|
|
|
|
|
|
|
|
|
/* Each change of file name
|
|
|
|
|
reinitializes whether we are now in a system header. */
|
|
|
|
|
in_system_header = 0;
|
|
|
|
|
|
|
|
|
|
if (main_input_filename == 0)
|
|
|
|
|
main_input_filename = input_filename;
|
|
|
|
|
|
|
|
|
|
/* Is this the last nonwhite stuff on the line? */
|
1997-11-11 22:17:41 -05:00
|
|
|
|
c = skip_white_space_on_line ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\n')
|
1993-02-27 14:09:40 -05:00
|
|
|
|
{
|
|
|
|
|
/* Update the name in the top element of input_file_stack. */
|
|
|
|
|
if (input_file_stack)
|
|
|
|
|
input_file_stack->name = input_filename;
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
token = yylex ();
|
|
|
|
|
used_up = 0;
|
|
|
|
|
|
|
|
|
|
/* `1' after file name means entering new file.
|
|
|
|
|
`2' after file name means just left a file. */
|
|
|
|
|
|
|
|
|
|
if (token == CONSTANT
|
|
|
|
|
&& TREE_CODE (yylval.ttype) == INTEGER_CST)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_INT_CST_LOW (yylval.ttype) == 1)
|
|
|
|
|
{
|
|
|
|
|
/* Pushing to a new file. */
|
|
|
|
|
struct file_stack *p
|
|
|
|
|
= (struct file_stack *) xmalloc (sizeof (struct file_stack));
|
|
|
|
|
input_file_stack->line = old_lineno;
|
|
|
|
|
p->next = input_file_stack;
|
|
|
|
|
p->name = input_filename;
|
1997-11-02 16:19:36 -05:00
|
|
|
|
p->indent_level = indent_level;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
input_file_stack = p;
|
|
|
|
|
input_file_stack_tick++;
|
1996-11-15 02:14:08 -05:00
|
|
|
|
debug_start_source_file (input_filename);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
used_up = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
|
|
|
|
|
{
|
|
|
|
|
/* Popping out of a file. */
|
|
|
|
|
if (input_file_stack->next)
|
|
|
|
|
{
|
|
|
|
|
struct file_stack *p = input_file_stack;
|
1997-11-02 16:19:36 -05:00
|
|
|
|
if (indent_level != p->indent_level)
|
|
|
|
|
{
|
1998-12-02 05:36:07 -05:00
|
|
|
|
warning_with_file_and_line
|
1997-11-02 16:19:36 -05:00
|
|
|
|
(p->name, old_lineno,
|
|
|
|
|
"This file contains more `%c's than `%c's.",
|
|
|
|
|
indent_level > p->indent_level ? '{' : '}',
|
|
|
|
|
indent_level > p->indent_level ? '}' : '{');
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
input_file_stack = p->next;
|
|
|
|
|
free (p);
|
|
|
|
|
input_file_stack_tick++;
|
1996-11-15 02:14:08 -05:00
|
|
|
|
debug_end_source_file (input_file_stack->line);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error ("#-lines for entering and leaving files don't match");
|
|
|
|
|
|
|
|
|
|
used_up = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1993-02-27 14:09:40 -05:00
|
|
|
|
/* Now that we've pushed or popped the input stack,
|
|
|
|
|
update the name in the top element. */
|
|
|
|
|
if (input_file_stack)
|
|
|
|
|
input_file_stack->name = input_filename;
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* If we have handled a `1' or a `2',
|
|
|
|
|
see if there is another number to read. */
|
|
|
|
|
if (used_up)
|
|
|
|
|
{
|
|
|
|
|
/* Is this the last nonwhite stuff on the line? */
|
1997-11-11 22:17:41 -05:00
|
|
|
|
c = skip_white_space_on_line ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\n')
|
|
|
|
|
return c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
token = yylex ();
|
|
|
|
|
used_up = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* `3' after file name means this is a system header file. */
|
|
|
|
|
|
|
|
|
|
if (token == CONSTANT
|
|
|
|
|
&& TREE_CODE (yylval.ttype) == INTEGER_CST
|
|
|
|
|
&& TREE_INT_CST_LOW (yylval.ttype) == 3)
|
1995-02-21 05:37:13 -05:00
|
|
|
|
in_system_header = 1, used_up = 1;
|
|
|
|
|
|
|
|
|
|
if (used_up)
|
|
|
|
|
{
|
|
|
|
|
/* Is this the last nonwhite stuff on the line? */
|
1997-11-11 22:17:41 -05:00
|
|
|
|
c = skip_white_space_on_line ();
|
1995-02-21 05:37:13 -05:00
|
|
|
|
if (c == '\n')
|
|
|
|
|
return c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1995-02-21 05:37:13 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
warning ("unrecognized text at end of #line");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error ("invalid #-line");
|
|
|
|
|
|
|
|
|
|
/* skip the rest of this line. */
|
|
|
|
|
skipline:
|
1997-11-02 16:19:36 -05:00
|
|
|
|
#if !USE_CPPLIB
|
|
|
|
|
if (c != '\n' && c != EOF && nextchar >= 0)
|
|
|
|
|
c = nextchar, nextchar = -1;
|
|
|
|
|
#endif
|
1996-01-15 17:25:24 -05:00
|
|
|
|
while (c != '\n' && c != EOF)
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#ifdef HANDLE_GENERIC_PRAGMAS
|
1992-06-30 22:34:39 -04:00
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
/* Handle a #pragma directive.
|
|
|
|
|
TOKEN is the token we read after `#pragma'. Processes the entire input
|
1998-10-01 06:50:15 -04:00
|
|
|
|
line and return non-zero iff the pragma has been successfully parsed. */
|
1992-06-30 22:34:39 -04:00
|
|
|
|
|
|
|
|
|
/* This function has to be in this file, in order to get at
|
|
|
|
|
the token types. */
|
|
|
|
|
|
c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>.
/
* c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>. Add
prototype for `handle_sysv_pragma', and make it static. Add
parentheses around assignment used as truth value.
* combine.c (combine_instructions): Protect variable `prev' with
macro HAVE_cc0.
(can_combine_p): Protect variable `link' with AUTO_INC_DEC.
(extract_left_shift): Add parentheses around operand of &.
(merge_outer_ops): Avoid an empty body in an else-statement.
(gen_rtx_combine): Remove unused variable `i'.
* sparc/gmon-sol2.c: Include <fcntl.h>. Make return type of
function monstartup `void'. Likewise for internal_mcount. Add
`static void' prototype for moncontrol. Reconcile sprintf format
vs. args.
* sparc/sparc.c: Include <stdlib.h> and <string.h>/<strings.h>.
Make return type of function_arg_slotno explicitly `int'.
(reg_unused_after): Add parentheses around assignment used as
truth value.
(save_regs): Add explicit braces to avoid ambiguous `else'.
(function_arg_slotno): Add parentheses around && within ||.
(function_arg_pass_by_reference): Likewise.
(sparc_flat_output_function_prologue): Reconcile fprintf format
vs. args.
* svr4.h (ASM_OUTPUT_LIMITED_STRING): Add parentheses around
assignment used as truth value.
* cplus-dem.c: Include <stdlib.h>.
(demangle_signature): Avoid an empty body in an else-statement.
(do_type): Remove unused variable `lvl'.
* cppexp.c: Don't have <stdlib.h> depend on MULTIBYTE_CHARS.
Include <string.h>/<strings.h>.
(cpp_lex): Remove unused variable `namelen'.
(cpp_lex): Explicitly declare `num_chars' as an int.
* cpplib.c: Avoid duplicate inclusion of <stdlib.h>, include
<unistd.h> instead. Explicitly declare is_system_include
returning int.
(make_assertion): Remove unused variable `kt'.
(cpp_expand_to_buffer): Hide variable `obuf'.
(output_line_command): Remove unused variables, `line_end',
`line_cmd_buf' and `len'.
(macarg): Remove unused variable `arg_start'.
(special_symbol): Remove unused variable `i'. Add parentheses
around assignment used as truth value.
(do_include): Remove unused variables `pcfname' and `retried',
hide `pcf' and `pcfbuflimit'.
(do_line): Remove unused variable `i'.
(finclude): Hide variable `missing_newline'.
(cpp_handle_options): Remove unused variable `j'.
(read_token_list): Remove unused variable `eofp'.
(cpp_error_with_line): Remove unused variable `i'.
(cpp_warning_with_line): Likewise.
(cpp_pedwarn_with_line): Explicitly declare `column' as int.
(cpp_error_from_errno): Remove unused variable `i'.
* cse.c (invalidate): Add parentheses around assignment used as
truth value.
(find_best_addr): Move declaration of variable `our_cost' inside
the conditional macro where its used.
(fold_rtx): Avoid an empty body in an if-statement.
(cse_insn): Wrap variables `this_insn_cc0_mode' and
`this_insn_cc0' in macro HAVE_cc0.
* dwarf2out.c: Include <stdlib.h> and <string.h>/<string.h>.
(ASM_OUTPUT_DWARF_DATA8): Reconcile format vs. args in fprintf's.
(output_uleb128): Likewise.
(output_sleb128): Likewise.
(output_cfi): Likewise.
(output_call_frame_info): Remove unused variables `j', `fde_size'
and `fde_pad'.
(comp_unit_has_inlines): Hide declaration as per rest of file.
(size_of_line_prolog): Correct typo in prototype.
(add_arange): Likewise.
(output_aranges): Likewise.
(add_name_and_src_coords_attributes): Likewise.
(gen_array_type_die): Likewise.
(gen_inlined_subroutine_die): Likewise.
(equate_decl_number_to_die): Remove unused variable `i'.
(print_die): Reconcile format vs. args in fprintf's.
(print_dwarf_line_table): Likewise.
(output_die): Likewise.
(output_line_info): Likewise.
(add_subscript_info): Avoid an empty body in an else-statement.
(gen_subprogram_die): Remove unused variable `fp_loc'.
* dwarfout.c: Explicitly declare `next_pubname_number' as int.
Protect `ordering_attribute' prototype with USE_ORDERING_ATTRIBUTE
macro. Protect `src_coords_attribute' prototype with
DWARF_DECL_COORDINATES macro. Hide `output_entry_point_die'
prototype as in the rest of the file. Likewise for
`output_pointer_type_die' and `output_reference_type_die'. Remove
prototype for `type_of_for_scope'.
(output_unsigned_leb128): Reconcile format vs. args in fprintf.
(type_attribute): Add explicit braces to avoid ambiguous `else'.
* final.c: Include <stdlib.h> and <string.h>/<strings.h>.
(shorten_branches): Protect declaration of tmp_length with
SHORTEN_WITH_ADJUST_INSN_LENGTH and ADJUST_INSN_LENGTH macros.
(profile_function): Protect declaration of `sval' and `cxt'
variables with appropriate macros.
(final_scan_insn): Likewise for `note' variable. Add explicit
braces to avoid empty body in an if-statement.
(output_asm_insn): Move variable `i' inside macro conditional
where it is used. Add parentheses around assignment used as truth
value.
(asm_fprintf) Likewise, likewise.
* fix-header.c (main): Remove unused variable `done'. Protect
declaration of `i' with FIXPROTO_IGNORE_LIST.
* pexecute.c: Include <unistd.h>. Prototype `my_strerror'.
* print-rtl.c (print_inline_rtx): Explicitly declare the parameter
`ind'.
* profile.c: Include <string.h>/<strings.h>.
(instrument_arcs): Remove unused variables `note', `inverted',
`zero' and `neg_one'.
(branch_prob): Avoid empty body in an if-statement.
* regclass.c: Include <stdlib.h>.
(reg_alternate_class): Explicitly declare parameter `regno'.
* regmove.c (regmove_optimize): Remove unused variable `p'. Add
parentheses around assignment used as truth value.
(find_matches): Remove unused variables `output_operand' and
`matching_operand'.
(fixup_match_1): Remove statement with no effect: "if (0) ;".
* scan.c (sstring_append): Explicitly declare `count' as int.
(scan_string): Explicitly declare parameter `init' as int.
* sched.c: Include <stdlib.h>.
(BLOCKAGE_RANGE): Add parentheses around arithmetic in operand of |.
(rank_for_schedule): Add parentheses around assignment used as
truth value.
(schedule_block): Likewise.
(regno_use_in): Likewise.
(schedule_insns): Remove unused variable `i'.
* toplev.c: Include <stdlib.h> and <string.h>/<strings.h>.
(v_message_with_decl): Remove unused variable `n'.
(botch): Explicitly declare parameter `s' as char *.
(main): Add parentheses around assignment used as truth value.
* tree.c (make_node): Protect the variable `kind' with the
GATHER_STATISTICS macro.
(real_value_from_int_cst): Move variable `e' inside conditional
macro area where it is used.
(tree_last): Add parentheses around assignment used as truth value.
(build1): Protect the variable `kind' with the GATHER_STATISTICS
macro.
(print_obstack_statistics): Reconcile format vs. args in fprintf.
Protect variables `i', `total_nodes', and `total_bytes' with the
GATHER_STATISTICS macro.
Lots more -W -Wall warnings disappear.
From-SVN: r17517
1998-01-27 17:11:54 -05:00
|
|
|
|
static int
|
1998-10-01 06:50:15 -04:00
|
|
|
|
handle_generic_pragma (token)
|
1996-04-17 14:54:58 -04:00
|
|
|
|
register int token;
|
1992-06-30 22:34:39 -04:00
|
|
|
|
{
|
1996-04-17 14:54:58 -04:00
|
|
|
|
register int c;
|
|
|
|
|
|
1992-07-01 08:58:09 -04:00
|
|
|
|
for (;;)
|
1992-06-30 22:34:39 -04:00
|
|
|
|
{
|
1996-04-17 14:54:58 -04:00
|
|
|
|
switch (token)
|
1992-07-01 08:58:09 -04:00
|
|
|
|
{
|
|
|
|
|
case IDENTIFIER:
|
|
|
|
|
case TYPENAME:
|
|
|
|
|
case STRING:
|
|
|
|
|
case CONSTANT:
|
|
|
|
|
handle_pragma_token (token_buffer, yylval.ttype);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
1998-09-02 05:59:57 -04:00
|
|
|
|
handle_pragma_token (token_buffer, NULL);
|
1992-07-01 08:58:09 -04:00
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if !USE_CPPLIB
|
1992-07-01 08:58:09 -04:00
|
|
|
|
if (nextchar >= 0)
|
|
|
|
|
c = nextchar, nextchar = -1;
|
|
|
|
|
else
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
|
|
|
|
c = GETC ();
|
1996-04-17 14:54:58 -04:00
|
|
|
|
|
|
|
|
|
while (c == ' ' || c == '\t')
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC ();
|
|
|
|
|
UNGETC (c);
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1998-09-02 05:59:57 -04:00
|
|
|
|
if (c == '\n' || c == EOF)
|
|
|
|
|
return handle_pragma_token (NULL, NULL);
|
|
|
|
|
|
1996-04-17 14:54:58 -04:00
|
|
|
|
token = yylex ();
|
1992-06-30 22:34:39 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-10-01 06:50:15 -04:00
|
|
|
|
#endif /* HANDLE_GENERIC_PRAGMAS */
|
1992-06-30 22:34:39 -04:00
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#define ENDFILE -1 /* token that represents end-of-file */
|
|
|
|
|
|
|
|
|
|
/* Read an escape sequence, returning its equivalent as a character,
|
1992-09-24 02:53:13 -04:00
|
|
|
|
or store 1 in *ignore_ptr if it is backslash-newline. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
static int
|
1992-09-24 02:53:13 -04:00
|
|
|
|
readescape (ignore_ptr)
|
|
|
|
|
int *ignore_ptr;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
register int c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
register int code;
|
|
|
|
|
register unsigned count;
|
1994-02-27 10:44:00 -05:00
|
|
|
|
unsigned firstdig = 0;
|
1992-08-27 01:55:33 -04:00
|
|
|
|
int nonnull;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case 'x':
|
|
|
|
|
if (warn_traditional)
|
|
|
|
|
warning ("the meaning of `\\x' varies with -traditional");
|
|
|
|
|
|
|
|
|
|
if (flag_traditional)
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
code = 0;
|
|
|
|
|
count = 0;
|
1992-08-27 01:55:33 -04:00
|
|
|
|
nonnull = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (!(c >= 'a' && c <= 'f')
|
|
|
|
|
&& !(c >= 'A' && c <= 'F')
|
|
|
|
|
&& !(c >= '0' && c <= '9'))
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
code *= 16;
|
|
|
|
|
if (c >= 'a' && c <= 'f')
|
|
|
|
|
code += c - 'a' + 10;
|
|
|
|
|
if (c >= 'A' && c <= 'F')
|
|
|
|
|
code += c - 'A' + 10;
|
|
|
|
|
if (c >= '0' && c <= '9')
|
|
|
|
|
code += c - '0';
|
1992-08-27 01:55:33 -04:00
|
|
|
|
if (code != 0 || count != 0)
|
|
|
|
|
{
|
|
|
|
|
if (count == 0)
|
|
|
|
|
firstdig = code;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
nonnull = 1;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
1992-08-27 01:55:33 -04:00
|
|
|
|
if (! nonnull)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
error ("\\x used with no following hex digits");
|
1992-10-04 00:58:30 -04:00
|
|
|
|
else if (count == 0)
|
|
|
|
|
/* Digits are all 0's. Ok. */
|
|
|
|
|
;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
|
|
|
|
|
|| (count > 1
|
1998-10-13 11:25:25 -04:00
|
|
|
|
&& (((unsigned)1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
<= firstdig)))
|
|
|
|
|
pedwarn ("hex escape out of range");
|
|
|
|
|
return code;
|
|
|
|
|
|
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
|
case '5': case '6': case '7':
|
|
|
|
|
code = 0;
|
|
|
|
|
count = 0;
|
|
|
|
|
while ((c <= '7') && (c >= '0') && (count++ < 3))
|
|
|
|
|
{
|
|
|
|
|
code = (code * 8) + (c - '0');
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
return code;
|
|
|
|
|
|
|
|
|
|
case '\\': case '\'': case '"':
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
case '\n':
|
|
|
|
|
lineno++;
|
1992-09-24 02:53:13 -04:00
|
|
|
|
*ignore_ptr = 1;
|
|
|
|
|
return 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
|
return TARGET_NEWLINE;
|
|
|
|
|
|
|
|
|
|
case 't':
|
|
|
|
|
return TARGET_TAB;
|
|
|
|
|
|
|
|
|
|
case 'r':
|
|
|
|
|
return TARGET_CR;
|
|
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
|
return TARGET_FF;
|
|
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
|
return TARGET_BS;
|
|
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
|
if (warn_traditional)
|
|
|
|
|
warning ("the meaning of `\\a' varies with -traditional");
|
|
|
|
|
|
|
|
|
|
if (flag_traditional)
|
|
|
|
|
return c;
|
|
|
|
|
return TARGET_BELL;
|
|
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
|
#if 0 /* Vertical tab is present in common usage compilers. */
|
|
|
|
|
if (flag_traditional)
|
|
|
|
|
return c;
|
|
|
|
|
#endif
|
|
|
|
|
return TARGET_VT;
|
|
|
|
|
|
1992-11-06 03:08:51 -05:00
|
|
|
|
case 'e':
|
1992-03-06 18:36:01 -05:00
|
|
|
|
case 'E':
|
1992-11-06 03:08:51 -05:00
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
return 033;
|
|
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
/* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
|
|
|
|
|
case '(':
|
|
|
|
|
case '{':
|
|
|
|
|
case '[':
|
1993-05-26 02:21:37 -04:00
|
|
|
|
/* `\%' is used to prevent SCCS from getting confused. */
|
|
|
|
|
case '%':
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("non-ANSI escape sequence `\\%c'", c);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
1992-08-27 01:45:47 -04:00
|
|
|
|
if (c >= 040 && c < 0177)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
pedwarn ("unknown escape sequence `\\%c'", c);
|
|
|
|
|
else
|
|
|
|
|
pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1999-01-26 20:43:17 -05:00
|
|
|
|
yyerror (msgid)
|
bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror, extend_token_buffer): Likewise. Don't include
limits.h or ctype.h. Remove unused variable `p'.
* c-lex.h (yyerror): Qualify a char* with the `const' keyword.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, warning_init, incomplete_type_error,
build_indirect_ref, lvalue_or_else, readonly_warning,
build_c_cast, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
From-SVN: r25296
1999-02-18 15:38:48 -05:00
|
|
|
|
const char *msgid;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.c (bitmap_print): Qualify a char* with the `const' keyword.
* bitmap.h (bitmap_print): Likewise.
* c-decl.c (builtin_function, grokdeclarator, grokfield): Likewise.
* c-lang.c (build_objc_string): Likewise.
* c-lex.c (yyerror, extend_token_buffer): Likewise. Don't include
limits.h or ctype.h. Remove unused variable `p'.
* c-lex.h (yyerror): Qualify a char* with the `const' keyword.
* c-pragma.c (handle_pragma_token): Likewise.
* c-pragma.h (handle_pragma_token): Likewise.
* c-tree.h (build_objc_string, builtin_function, grokfield,
build_indirect_ref, lvalue_or_else, readonly_warning, error_init,
pedwarn_init): Likewise.
* c-typeck.c (convert_for_assignment, warn_for_assignment,
push_string, warning_init, incomplete_type_error,
build_indirect_ref, lvalue_or_else, readonly_warning,
build_c_cast, spelling, push_member_name, print_spelling,
error_init, pedwarn_init, start_init): Likewise.
* objc/objc-act.c (build_objc_string): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* tree.h (lvalue_or_else, print_node, print_node_brief): Likewise.
From-SVN: r25296
1999-02-18 15:38:48 -05:00
|
|
|
|
const char *string = _(msgid);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* We can't print string and character constants well
|
|
|
|
|
because the token_buffer contains the result of processing escapes. */
|
|
|
|
|
if (end_of_file)
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s at end of input", string);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (token_buffer[0] == 0)
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s at null character", string);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (token_buffer[0] == '"')
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s before string constant", string);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (token_buffer[0] == '\'')
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s before character constant", string);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s before character 0%o", string, (unsigned char) token_buffer[0]);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else
|
1999-01-26 20:43:17 -05:00
|
|
|
|
error ("%s before `%s'", string, token_buffer);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
struct try_type
|
|
|
|
|
{
|
|
|
|
|
tree *node_var;
|
|
|
|
|
char unsigned_flag;
|
|
|
|
|
char long_flag;
|
|
|
|
|
char long_long_flag;
|
|
|
|
|
};
|
|
|
|
|
|
1998-12-02 05:36:07 -05:00
|
|
|
|
struct try_type type_sequence[] =
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
{ &integer_type_node, 0, 0, 0},
|
|
|
|
|
{ &unsigned_type_node, 1, 0, 0},
|
|
|
|
|
{ &long_integer_type_node, 0, 1, 0},
|
|
|
|
|
{ &long_unsigned_type_node, 1, 1, 0},
|
|
|
|
|
{ &long_long_integer_type_node, 0, 1, 1},
|
|
|
|
|
{ &long_long_unsigned_type_node, 1, 1, 1}
|
|
|
|
|
};
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
1999-03-17 01:34:46 -05:00
|
|
|
|
struct pf_args
|
|
|
|
|
{
|
|
|
|
|
/* Input */
|
|
|
|
|
int base;
|
|
|
|
|
char * p;
|
|
|
|
|
/* I/O */
|
|
|
|
|
int c;
|
|
|
|
|
int imag;
|
|
|
|
|
tree type;
|
|
|
|
|
int conversion_errno;
|
|
|
|
|
/* Output */
|
|
|
|
|
REAL_VALUE_TYPE value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
parse_float (data)
|
|
|
|
|
PTR data;
|
|
|
|
|
{
|
|
|
|
|
struct pf_args * args = (struct pf_args *) data;
|
|
|
|
|
int fflag = 0, lflag = 0;
|
|
|
|
|
/* Copy token_buffer now, while it has just the number
|
|
|
|
|
and not the suffixes; once we add `f' or `i',
|
|
|
|
|
REAL_VALUE_ATOF may not work any more. */
|
|
|
|
|
char *copy = (char *) alloca (args->p - token_buffer + 1);
|
|
|
|
|
bcopy (token_buffer, copy, args->p - token_buffer + 1);
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
int lose = 0;
|
|
|
|
|
|
|
|
|
|
/* Read the suffixes to choose a data type. */
|
|
|
|
|
switch (args->c)
|
|
|
|
|
{
|
|
|
|
|
case 'f': case 'F':
|
|
|
|
|
if (fflag)
|
|
|
|
|
error ("more than one `f' in numeric constant");
|
|
|
|
|
fflag = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'l': case 'L':
|
|
|
|
|
if (lflag)
|
|
|
|
|
error ("more than one `l' in numeric constant");
|
|
|
|
|
lflag = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'i': case 'I':
|
|
|
|
|
if (args->imag)
|
|
|
|
|
error ("more than one `i' or `j' in numeric constant");
|
|
|
|
|
else if (pedantic)
|
|
|
|
|
pedwarn ("ANSI C forbids imaginary numeric constants");
|
|
|
|
|
args->imag = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
lose = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lose)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (args->p >= token_buffer + maxtoken - 3)
|
|
|
|
|
args->p = extend_token_buffer (args->p);
|
|
|
|
|
*(args->p++) = args->c;
|
|
|
|
|
*(args->p) = 0;
|
|
|
|
|
args->c = GETC();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The second argument, machine_mode, of REAL_VALUE_ATOF
|
|
|
|
|
tells the desired precision of the binary result
|
|
|
|
|
of decimal-to-binary conversion. */
|
|
|
|
|
|
|
|
|
|
if (fflag)
|
|
|
|
|
{
|
|
|
|
|
if (lflag)
|
|
|
|
|
error ("both `f' and `l' in floating constant");
|
|
|
|
|
|
|
|
|
|
args->type = float_type_node;
|
|
|
|
|
errno = 0;
|
|
|
|
|
if (args->base == 16)
|
|
|
|
|
args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
else
|
|
|
|
|
args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
args->conversion_errno = errno;
|
|
|
|
|
/* A diagnostic is required here by some ANSI C testsuites.
|
|
|
|
|
This is not pedwarn, because some people don't want
|
|
|
|
|
an error for this. */
|
|
|
|
|
if (REAL_VALUE_ISINF (args->value) && pedantic)
|
|
|
|
|
warning ("floating point number exceeds range of `float'");
|
|
|
|
|
}
|
|
|
|
|
else if (lflag)
|
|
|
|
|
{
|
|
|
|
|
args->type = long_double_type_node;
|
|
|
|
|
errno = 0;
|
|
|
|
|
if (args->base == 16)
|
|
|
|
|
args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
else
|
|
|
|
|
args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
args->conversion_errno = errno;
|
|
|
|
|
if (REAL_VALUE_ISINF (args->value) && pedantic)
|
|
|
|
|
warning ("floating point number exceeds range of `long double'");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
errno = 0;
|
|
|
|
|
if (args->base == 16)
|
|
|
|
|
args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
else
|
|
|
|
|
args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
|
|
|
|
|
args->conversion_errno = errno;
|
|
|
|
|
if (REAL_VALUE_ISINF (args->value) && pedantic)
|
|
|
|
|
warning ("floating point number exceeds range of `double'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
int
|
|
|
|
|
yylex ()
|
|
|
|
|
{
|
|
|
|
|
register int c;
|
|
|
|
|
register char *p;
|
|
|
|
|
register int value;
|
|
|
|
|
int wide_flag = 0;
|
1993-04-09 19:12:37 -04:00
|
|
|
|
int objc_flag = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if !USE_CPPLIB
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (nextchar >= 0)
|
|
|
|
|
c = nextchar, nextchar = -1;
|
|
|
|
|
else
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* Effectively do c = skip_white_space (c)
|
|
|
|
|
but do it faster in the usual cases. */
|
|
|
|
|
while (1)
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case ' ':
|
|
|
|
|
case '\t':
|
|
|
|
|
case '\f':
|
|
|
|
|
case '\v':
|
|
|
|
|
case '\b':
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break;
|
|
|
|
|
|
1992-06-03 15:01:26 -04:00
|
|
|
|
case '\r':
|
|
|
|
|
/* Call skip_white_space so we can warn if appropriate. */
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
case '\n':
|
|
|
|
|
case '/':
|
|
|
|
|
case '\\':
|
|
|
|
|
c = skip_white_space (c);
|
|
|
|
|
default:
|
|
|
|
|
goto found_nonwhite;
|
|
|
|
|
}
|
|
|
|
|
found_nonwhite:
|
|
|
|
|
|
|
|
|
|
token_buffer[0] = c;
|
|
|
|
|
token_buffer[1] = 0;
|
|
|
|
|
|
|
|
|
|
/* yylloc.first_line = lineno; */
|
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case EOF:
|
|
|
|
|
end_of_file = 1;
|
|
|
|
|
token_buffer[0] = 0;
|
|
|
|
|
value = ENDFILE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'L':
|
|
|
|
|
/* Capital L may start a wide-string or wide-character constant. */
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
register int c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\'')
|
|
|
|
|
{
|
|
|
|
|
wide_flag = 1;
|
|
|
|
|
goto char_constant;
|
|
|
|
|
}
|
|
|
|
|
if (c == '"')
|
|
|
|
|
{
|
|
|
|
|
wide_flag = 1;
|
|
|
|
|
goto string_constant;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
goto letter;
|
|
|
|
|
|
|
|
|
|
case '@':
|
|
|
|
|
if (!doing_objc_thang)
|
|
|
|
|
{
|
|
|
|
|
value = c;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1993-04-09 19:12:37 -04:00
|
|
|
|
else
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1993-04-09 19:12:37 -04:00
|
|
|
|
/* '@' may start a constant string object. */
|
1997-07-29 18:40:30 -04:00
|
|
|
|
register int c = GETC ();
|
1993-04-09 19:12:37 -04:00
|
|
|
|
if (c == '"')
|
|
|
|
|
{
|
|
|
|
|
objc_flag = 1;
|
|
|
|
|
goto string_constant;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1995-05-16 08:14:26 -04:00
|
|
|
|
/* Fall through to treat '@' as the start of an identifier. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'A': case 'B': case 'C': case 'D': case 'E':
|
|
|
|
|
case 'F': case 'G': case 'H': case 'I': case 'J':
|
|
|
|
|
case 'K': case 'M': case 'N': case 'O':
|
|
|
|
|
case 'P': case 'Q': case 'R': case 'S': case 'T':
|
|
|
|
|
case 'U': case 'V': case 'W': case 'X': case 'Y':
|
|
|
|
|
case 'Z':
|
|
|
|
|
case 'a': case 'b': case 'c': case 'd': case 'e':
|
|
|
|
|
case 'f': case 'g': case 'h': case 'i': case 'j':
|
|
|
|
|
case 'k': case 'l': case 'm': case 'n': case 'o':
|
|
|
|
|
case 'p': case 'q': case 'r': case 's': case 't':
|
|
|
|
|
case 'u': case 'v': case 'w': case 'x': case 'y':
|
|
|
|
|
case 'z':
|
|
|
|
|
case '_':
|
1996-10-09 16:19:12 -04:00
|
|
|
|
case '$':
|
1992-03-06 18:36:01 -05:00
|
|
|
|
letter:
|
|
|
|
|
p = token_buffer;
|
1998-05-06 08:56:58 -04:00
|
|
|
|
while (ISALNUM (c) || c == '_' || c == '$' || c == '@')
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1993-01-08 21:56:59 -05:00
|
|
|
|
/* Make sure this char really belongs in an identifier. */
|
1996-10-09 16:19:12 -04:00
|
|
|
|
if (c == '$')
|
|
|
|
|
{
|
|
|
|
|
if (! dollars_in_ident)
|
|
|
|
|
error ("`$' in identifier");
|
|
|
|
|
else if (pedantic)
|
|
|
|
|
pedwarn ("`$' in identifier");
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1993-01-08 21:56:59 -05:00
|
|
|
|
if (p >= token_buffer + maxtoken)
|
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
*p++ = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*p = 0;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#if USE_CPPLIB
|
|
|
|
|
UNGETC (c);
|
|
|
|
|
#else
|
1992-03-06 18:36:01 -05:00
|
|
|
|
nextchar = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
#endif
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
value = IDENTIFIER;
|
|
|
|
|
yylval.itype = 0;
|
|
|
|
|
|
|
|
|
|
/* Try to recognize a keyword. Uses minimum-perfect hash function */
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
register struct resword *ptr;
|
|
|
|
|
|
c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>.
/
* c-lex.c: Include <stdlib.h> and <string.h>/<strings.h>. Add
prototype for `handle_sysv_pragma', and make it static. Add
parentheses around assignment used as truth value.
* combine.c (combine_instructions): Protect variable `prev' with
macro HAVE_cc0.
(can_combine_p): Protect variable `link' with AUTO_INC_DEC.
(extract_left_shift): Add parentheses around operand of &.
(merge_outer_ops): Avoid an empty body in an else-statement.
(gen_rtx_combine): Remove unused variable `i'.
* sparc/gmon-sol2.c: Include <fcntl.h>. Make return type of
function monstartup `void'. Likewise for internal_mcount. Add
`static void' prototype for moncontrol. Reconcile sprintf format
vs. args.
* sparc/sparc.c: Include <stdlib.h> and <string.h>/<strings.h>.
Make return type of function_arg_slotno explicitly `int'.
(reg_unused_after): Add parentheses around assignment used as
truth value.
(save_regs): Add explicit braces to avoid ambiguous `else'.
(function_arg_slotno): Add parentheses around && within ||.
(function_arg_pass_by_reference): Likewise.
(sparc_flat_output_function_prologue): Reconcile fprintf format
vs. args.
* svr4.h (ASM_OUTPUT_LIMITED_STRING): Add parentheses around
assignment used as truth value.
* cplus-dem.c: Include <stdlib.h>.
(demangle_signature): Avoid an empty body in an else-statement.
(do_type): Remove unused variable `lvl'.
* cppexp.c: Don't have <stdlib.h> depend on MULTIBYTE_CHARS.
Include <string.h>/<strings.h>.
(cpp_lex): Remove unused variable `namelen'.
(cpp_lex): Explicitly declare `num_chars' as an int.
* cpplib.c: Avoid duplicate inclusion of <stdlib.h>, include
<unistd.h> instead. Explicitly declare is_system_include
returning int.
(make_assertion): Remove unused variable `kt'.
(cpp_expand_to_buffer): Hide variable `obuf'.
(output_line_command): Remove unused variables, `line_end',
`line_cmd_buf' and `len'.
(macarg): Remove unused variable `arg_start'.
(special_symbol): Remove unused variable `i'. Add parentheses
around assignment used as truth value.
(do_include): Remove unused variables `pcfname' and `retried',
hide `pcf' and `pcfbuflimit'.
(do_line): Remove unused variable `i'.
(finclude): Hide variable `missing_newline'.
(cpp_handle_options): Remove unused variable `j'.
(read_token_list): Remove unused variable `eofp'.
(cpp_error_with_line): Remove unused variable `i'.
(cpp_warning_with_line): Likewise.
(cpp_pedwarn_with_line): Explicitly declare `column' as int.
(cpp_error_from_errno): Remove unused variable `i'.
* cse.c (invalidate): Add parentheses around assignment used as
truth value.
(find_best_addr): Move declaration of variable `our_cost' inside
the conditional macro where its used.
(fold_rtx): Avoid an empty body in an if-statement.
(cse_insn): Wrap variables `this_insn_cc0_mode' and
`this_insn_cc0' in macro HAVE_cc0.
* dwarf2out.c: Include <stdlib.h> and <string.h>/<string.h>.
(ASM_OUTPUT_DWARF_DATA8): Reconcile format vs. args in fprintf's.
(output_uleb128): Likewise.
(output_sleb128): Likewise.
(output_cfi): Likewise.
(output_call_frame_info): Remove unused variables `j', `fde_size'
and `fde_pad'.
(comp_unit_has_inlines): Hide declaration as per rest of file.
(size_of_line_prolog): Correct typo in prototype.
(add_arange): Likewise.
(output_aranges): Likewise.
(add_name_and_src_coords_attributes): Likewise.
(gen_array_type_die): Likewise.
(gen_inlined_subroutine_die): Likewise.
(equate_decl_number_to_die): Remove unused variable `i'.
(print_die): Reconcile format vs. args in fprintf's.
(print_dwarf_line_table): Likewise.
(output_die): Likewise.
(output_line_info): Likewise.
(add_subscript_info): Avoid an empty body in an else-statement.
(gen_subprogram_die): Remove unused variable `fp_loc'.
* dwarfout.c: Explicitly declare `next_pubname_number' as int.
Protect `ordering_attribute' prototype with USE_ORDERING_ATTRIBUTE
macro. Protect `src_coords_attribute' prototype with
DWARF_DECL_COORDINATES macro. Hide `output_entry_point_die'
prototype as in the rest of the file. Likewise for
`output_pointer_type_die' and `output_reference_type_die'. Remove
prototype for `type_of_for_scope'.
(output_unsigned_leb128): Reconcile format vs. args in fprintf.
(type_attribute): Add explicit braces to avoid ambiguous `else'.
* final.c: Include <stdlib.h> and <string.h>/<strings.h>.
(shorten_branches): Protect declaration of tmp_length with
SHORTEN_WITH_ADJUST_INSN_LENGTH and ADJUST_INSN_LENGTH macros.
(profile_function): Protect declaration of `sval' and `cxt'
variables with appropriate macros.
(final_scan_insn): Likewise for `note' variable. Add explicit
braces to avoid empty body in an if-statement.
(output_asm_insn): Move variable `i' inside macro conditional
where it is used. Add parentheses around assignment used as truth
value.
(asm_fprintf) Likewise, likewise.
* fix-header.c (main): Remove unused variable `done'. Protect
declaration of `i' with FIXPROTO_IGNORE_LIST.
* pexecute.c: Include <unistd.h>. Prototype `my_strerror'.
* print-rtl.c (print_inline_rtx): Explicitly declare the parameter
`ind'.
* profile.c: Include <string.h>/<strings.h>.
(instrument_arcs): Remove unused variables `note', `inverted',
`zero' and `neg_one'.
(branch_prob): Avoid empty body in an if-statement.
* regclass.c: Include <stdlib.h>.
(reg_alternate_class): Explicitly declare parameter `regno'.
* regmove.c (regmove_optimize): Remove unused variable `p'. Add
parentheses around assignment used as truth value.
(find_matches): Remove unused variables `output_operand' and
`matching_operand'.
(fixup_match_1): Remove statement with no effect: "if (0) ;".
* scan.c (sstring_append): Explicitly declare `count' as int.
(scan_string): Explicitly declare parameter `init' as int.
* sched.c: Include <stdlib.h>.
(BLOCKAGE_RANGE): Add parentheses around arithmetic in operand of |.
(rank_for_schedule): Add parentheses around assignment used as
truth value.
(schedule_block): Likewise.
(regno_use_in): Likewise.
(schedule_insns): Remove unused variable `i'.
* toplev.c: Include <stdlib.h> and <string.h>/<strings.h>.
(v_message_with_decl): Remove unused variable `n'.
(botch): Explicitly declare parameter `s' as char *.
(main): Add parentheses around assignment used as truth value.
* tree.c (make_node): Protect the variable `kind' with the
GATHER_STATISTICS macro.
(real_value_from_int_cst): Move variable `e' inside conditional
macro area where it is used.
(tree_last): Add parentheses around assignment used as truth value.
(build1): Protect the variable `kind' with the GATHER_STATISTICS
macro.
(print_obstack_statistics): Reconcile format vs. args in fprintf.
Protect variables `i', `total_nodes', and `total_bytes' with the
GATHER_STATISTICS macro.
Lots more -W -Wall warnings disappear.
From-SVN: r17517
1998-01-27 17:11:54 -05:00
|
|
|
|
if ((ptr = is_reserved_word (token_buffer, p - token_buffer)))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (ptr->rid)
|
|
|
|
|
yylval.ttype = ridpointers[(int) ptr->rid];
|
|
|
|
|
value = (int) ptr->token;
|
|
|
|
|
|
1993-04-09 19:12:37 -04:00
|
|
|
|
/* Only return OBJECTNAME if it is a typedef. */
|
|
|
|
|
if (doing_objc_thang && value == OBJECTNAME)
|
|
|
|
|
{
|
|
|
|
|
lastiddecl = lookup_name(yylval.ttype);
|
|
|
|
|
|
|
|
|
|
if (lastiddecl == NULL_TREE
|
|
|
|
|
|| TREE_CODE (lastiddecl) != TYPE_DECL)
|
|
|
|
|
value = IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Even if we decided to recognize asm, still perhaps warn. */
|
|
|
|
|
if (pedantic
|
1992-03-14 00:07:15 -05:00
|
|
|
|
&& (value == ASM_KEYWORD || value == TYPEOF
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|| ptr->rid == RID_INLINE)
|
|
|
|
|
&& token_buffer[0] != '_')
|
|
|
|
|
pedwarn ("ANSI does not permit the keyword `%s'",
|
|
|
|
|
token_buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we did not find a keyword, look for an identifier
|
|
|
|
|
(or a typename). */
|
|
|
|
|
|
|
|
|
|
if (value == IDENTIFIER)
|
|
|
|
|
{
|
1993-04-09 19:12:37 -04:00
|
|
|
|
if (token_buffer[0] == '@')
|
|
|
|
|
error("invalid identifier `%s'", token_buffer);
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
yylval.ttype = get_identifier (token_buffer);
|
|
|
|
|
lastiddecl = lookup_name (yylval.ttype);
|
|
|
|
|
|
|
|
|
|
if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
|
|
|
|
|
value = TYPENAME;
|
1992-05-17 16:16:20 -04:00
|
|
|
|
/* A user-invisible read-only initialized variable
|
|
|
|
|
should be replaced by its value.
|
|
|
|
|
We handle only strings since that's the only case used in C. */
|
|
|
|
|
else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL
|
|
|
|
|
&& DECL_IGNORED_P (lastiddecl)
|
|
|
|
|
&& TREE_READONLY (lastiddecl)
|
|
|
|
|
&& DECL_INITIAL (lastiddecl) != 0
|
|
|
|
|
&& TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST)
|
|
|
|
|
{
|
1993-03-20 04:05:49 -05:00
|
|
|
|
tree stringval = DECL_INITIAL (lastiddecl);
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1993-03-20 04:05:49 -05:00
|
|
|
|
/* Copy the string value so that we won't clobber anything
|
|
|
|
|
if we put something in the TREE_CHAIN of this one. */
|
|
|
|
|
yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
|
|
|
|
|
TREE_STRING_POINTER (stringval));
|
1992-05-17 16:16:20 -04:00
|
|
|
|
value = STRING;
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (doing_objc_thang)
|
|
|
|
|
{
|
1993-04-09 19:12:37 -04:00
|
|
|
|
tree objc_interface_decl = is_class_name (yylval.ttype);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
if (objc_interface_decl)
|
|
|
|
|
{
|
|
|
|
|
value = CLASSNAME;
|
|
|
|
|
yylval.ttype = objc_interface_decl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
1996-02-18 21:13:37 -05:00
|
|
|
|
case '0': case '1':
|
|
|
|
|
{
|
|
|
|
|
int next_c;
|
|
|
|
|
/* Check first for common special case: single-digit 0 or 1. */
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
next_c = GETC ();
|
|
|
|
|
UNGETC (next_c); /* Always undo this lookahead. */
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (!ISALNUM (next_c) && next_c != '.')
|
1996-02-18 21:13:37 -05:00
|
|
|
|
{
|
|
|
|
|
token_buffer[0] = (char)c, token_buffer[1] = '\0';
|
|
|
|
|
yylval.ttype = (c == '0') ? integer_zero_node : integer_one_node;
|
|
|
|
|
value = CONSTANT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/*FALLTHRU*/
|
|
|
|
|
}
|
|
|
|
|
case '2': case '3': case '4':
|
1992-03-06 18:36:01 -05:00
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
|
case '.':
|
|
|
|
|
{
|
|
|
|
|
int base = 10;
|
|
|
|
|
int count = 0;
|
|
|
|
|
int largest_digit = 0;
|
|
|
|
|
int numdigits = 0;
|
|
|
|
|
/* for multi-precision arithmetic,
|
1992-07-06 15:34:19 -04:00
|
|
|
|
we actually store only HOST_BITS_PER_CHAR bits in each part.
|
|
|
|
|
The number of parts is chosen so as to be sufficient to hold
|
1992-07-14 06:09:46 -04:00
|
|
|
|
the enough bits to fit into the two HOST_WIDE_INTs that contain
|
|
|
|
|
the integer value (this is always at least as many bits as are
|
|
|
|
|
in a target `long long' value, but may be wider). */
|
|
|
|
|
#define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
|
1992-07-06 15:34:19 -04:00
|
|
|
|
int parts[TOTAL_PARTS];
|
1992-03-06 18:36:01 -05:00
|
|
|
|
int overflow = 0;
|
|
|
|
|
|
1998-12-01 16:05:17 -05:00
|
|
|
|
enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS, AFTER_EXPON}
|
|
|
|
|
floatflag = NOT_FLOAT;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1992-07-06 15:34:19 -04:00
|
|
|
|
for (count = 0; count < TOTAL_PARTS; count++)
|
|
|
|
|
parts[count] = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
p = token_buffer;
|
|
|
|
|
*p++ = c;
|
|
|
|
|
|
|
|
|
|
if (c == '0')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
*p++ = (c = GETC());
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if ((c == 'x') || (c == 'X'))
|
|
|
|
|
{
|
|
|
|
|
base = 16;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
*p++ = (c = GETC());
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
/* Leading 0 forces octal unless the 0 is the only digit. */
|
|
|
|
|
else if (c >= '0' && c <= '9')
|
|
|
|
|
{
|
|
|
|
|
base = 8;
|
|
|
|
|
numdigits++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
numdigits++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read all the digits-and-decimal-points. */
|
|
|
|
|
|
|
|
|
|
while (c == '.'
|
1998-05-06 08:56:58 -04:00
|
|
|
|
|| (ISALNUM (c) && c != 'l' && c != 'L'
|
1993-03-04 13:34:10 -05:00
|
|
|
|
&& c != 'u' && c != 'U'
|
|
|
|
|
&& c != 'i' && c != 'I' && c != 'j' && c != 'J'
|
1992-03-06 18:36:01 -05:00
|
|
|
|
&& (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
|
|
|
|
|
{
|
|
|
|
|
if (c == '.')
|
|
|
|
|
{
|
1998-12-01 16:05:17 -05:00
|
|
|
|
if (base == 16 && pedantic)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
error ("floating constant may not be in radix 16");
|
1993-12-10 15:41:43 -05:00
|
|
|
|
if (floatflag == TOO_MANY_POINTS)
|
|
|
|
|
/* We have already emitted an error. Don't need another. */
|
|
|
|
|
;
|
1998-12-01 16:05:17 -05:00
|
|
|
|
else if (floatflag == AFTER_POINT || floatflag == AFTER_EXPON)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
error ("malformed floating constant");
|
|
|
|
|
floatflag = TOO_MANY_POINTS;
|
1993-12-10 15:41:43 -05:00
|
|
|
|
/* Avoid another error from atof by forcing all characters
|
|
|
|
|
from here on to be ignored. */
|
|
|
|
|
p[-1] = '\0';
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
floatflag = AFTER_POINT;
|
|
|
|
|
|
1998-12-01 16:05:17 -05:00
|
|
|
|
if (base == 8)
|
1998-12-02 05:36:07 -05:00
|
|
|
|
base = 10;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
*p++ = c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Accept '.' as the start of a floating-point number
|
|
|
|
|
only when it is followed by a digit.
|
|
|
|
|
Otherwise, unread the following non-digit
|
|
|
|
|
and use the '.' as a structural token. */
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (p == token_buffer + 2 && !ISDIGIT (c))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (c == '.')
|
|
|
|
|
{
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '.')
|
|
|
|
|
{
|
|
|
|
|
*p++ = c;
|
|
|
|
|
*p = 0;
|
|
|
|
|
return ELLIPSIS;
|
|
|
|
|
}
|
|
|
|
|
error ("parse error at `..'");
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token_buffer[1] = 0;
|
|
|
|
|
value = '.';
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* It is not a decimal point.
|
|
|
|
|
It should be a digit (perhaps a hex digit). */
|
|
|
|
|
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (ISDIGIT (c))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
c = c - '0';
|
|
|
|
|
}
|
|
|
|
|
else if (base <= 10)
|
|
|
|
|
{
|
1993-02-12 02:36:00 -05:00
|
|
|
|
if (c == 'e' || c == 'E')
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
base = 10;
|
1998-12-01 16:05:17 -05:00
|
|
|
|
floatflag = AFTER_EXPON;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
break; /* start of exponent */
|
|
|
|
|
}
|
|
|
|
|
error ("nondigits in number and not hexadecimal");
|
|
|
|
|
c = 0;
|
|
|
|
|
}
|
1998-12-01 16:05:17 -05:00
|
|
|
|
else if (base == 16 && (c == 'p' || c == 'P'))
|
|
|
|
|
{
|
|
|
|
|
floatflag = AFTER_EXPON;
|
|
|
|
|
break; /* start of exponent */
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else if (c >= 'a')
|
|
|
|
|
{
|
|
|
|
|
c = c - 'a' + 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
c = c - 'A' + 10;
|
|
|
|
|
}
|
|
|
|
|
if (c >= largest_digit)
|
|
|
|
|
largest_digit = c;
|
|
|
|
|
numdigits++;
|
|
|
|
|
|
1992-07-06 15:34:19 -04:00
|
|
|
|
for (count = 0; count < TOTAL_PARTS; count++)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1992-07-06 15:34:19 -04:00
|
|
|
|
parts[count] *= base;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (count)
|
|
|
|
|
{
|
1992-07-06 15:34:19 -04:00
|
|
|
|
parts[count]
|
|
|
|
|
+= (parts[count-1] >> HOST_BITS_PER_CHAR);
|
|
|
|
|
parts[count-1]
|
|
|
|
|
&= (1 << HOST_BITS_PER_CHAR) - 1;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
1992-07-06 15:34:19 -04:00
|
|
|
|
else
|
|
|
|
|
parts[0] += c;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1992-07-06 15:34:19 -04:00
|
|
|
|
/* If the extra highest-order part ever gets anything in it,
|
|
|
|
|
the number is certainly too big. */
|
|
|
|
|
if (parts[TOTAL_PARTS - 1] != 0)
|
|
|
|
|
overflow = 1;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
if (p >= token_buffer + maxtoken - 3)
|
|
|
|
|
p = extend_token_buffer (p);
|
1997-07-29 18:40:30 -04:00
|
|
|
|
*p++ = (c = GETC());
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (numdigits == 0)
|
|
|
|
|
error ("numeric constant with no digits");
|
|
|
|
|
|
|
|
|
|
if (largest_digit >= base)
|
|
|
|
|
error ("numeric constant contains digits beyond the radix");
|
|
|
|
|
|
|
|
|
|
/* Remove terminating char from the token buffer and delimit the string */
|
|
|
|
|
*--p = 0;
|
|
|
|
|
|
|
|
|
|
if (floatflag != NOT_FLOAT)
|
|
|
|
|
{
|
1995-03-02 18:08:54 -05:00
|
|
|
|
tree type = double_type_node;
|
1993-03-04 13:34:10 -05:00
|
|
|
|
int imag = 0;
|
1998-04-04 08:32:39 -05:00
|
|
|
|
int conversion_errno = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
REAL_VALUE_TYPE value;
|
1999-03-17 01:34:46 -05:00
|
|
|
|
struct pf_args args;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* Read explicit exponent if any, and put it in tokenbuf. */
|
|
|
|
|
|
1998-12-01 16:05:17 -05:00
|
|
|
|
if ((base == 10 && ((c == 'e') || (c == 'E')))
|
|
|
|
|
|| (base == 16 && (c == 'p' || c == 'P')))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (p >= token_buffer + maxtoken - 3)
|
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
*p++ = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if ((c == '+') || (c == '-'))
|
|
|
|
|
{
|
|
|
|
|
*p++ = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
1998-12-01 16:05:17 -05:00
|
|
|
|
/* Exponent is decimal, even if string is a hex float. */
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (! ISDIGIT (c))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
error ("floating constant exponent has no digits");
|
1998-12-02 05:36:07 -05:00
|
|
|
|
while (ISDIGIT (c))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (p >= token_buffer + maxtoken - 3)
|
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
*p++ = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-12-01 16:05:17 -05:00
|
|
|
|
if (base == 16 && floatflag != AFTER_EXPON)
|
|
|
|
|
error ("hexadecimal floating constant has no exponent");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
|
|
1999-03-17 01:34:46 -05:00
|
|
|
|
/* Setup input for parse_float() */
|
|
|
|
|
args.base = base;
|
|
|
|
|
args.p = p;
|
|
|
|
|
args.c = c;
|
|
|
|
|
args.imag = imag;
|
|
|
|
|
args.type = type;
|
|
|
|
|
args.conversion_errno = conversion_errno;
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Convert string to a double, checking for overflow. */
|
1999-03-17 01:34:46 -05:00
|
|
|
|
if (do_float_handler (parse_float, (PTR) &args))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1999-03-17 01:34:46 -05:00
|
|
|
|
/* Receive output from parse_float() */
|
|
|
|
|
value = args.value;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-03-17 01:34:46 -05:00
|
|
|
|
/* We got an exception from parse_float() */
|
|
|
|
|
error ("floating constant out of range");
|
|
|
|
|
value = dconst0;
|
|
|
|
|
}
|
1993-09-27 21:02:31 -04:00
|
|
|
|
|
1999-03-17 01:34:46 -05:00
|
|
|
|
/* Receive output from parse_float() */
|
|
|
|
|
c = args.c;
|
|
|
|
|
imag = args.imag;
|
|
|
|
|
type = args.type;
|
|
|
|
|
conversion_errno = args.conversion_errno;
|
|
|
|
|
|
1993-03-31 00:44:03 -05:00
|
|
|
|
#ifdef ERANGE
|
1998-04-04 08:32:39 -05:00
|
|
|
|
/* ERANGE is also reported for underflow,
|
|
|
|
|
so test the value to distinguish overflow from that. */
|
|
|
|
|
if (conversion_errno == ERANGE && !flag_traditional && pedantic
|
|
|
|
|
&& (REAL_VALUES_LESS (dconst1, value)
|
|
|
|
|
|| REAL_VALUES_LESS (value, dconstm1)))
|
|
|
|
|
warning ("floating point number exceeds range of `double'");
|
1993-03-31 00:44:03 -05:00
|
|
|
|
#endif
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1994-04-18 15:25:32 -04:00
|
|
|
|
/* If the result is not a number, assume it must have been
|
|
|
|
|
due to some error message above, so silently convert
|
|
|
|
|
it to a zero. */
|
|
|
|
|
if (REAL_VALUE_ISNAN (value))
|
|
|
|
|
value = dconst0;
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* Create a node with determined type and value. */
|
1993-03-04 13:34:10 -05:00
|
|
|
|
if (imag)
|
1996-09-29 19:02:58 -04:00
|
|
|
|
yylval.ttype = build_complex (NULL_TREE,
|
|
|
|
|
convert (type, integer_zero_node),
|
1993-03-04 13:34:10 -05:00
|
|
|
|
build_real (type, value));
|
|
|
|
|
else
|
|
|
|
|
yylval.ttype = build_real (type, value);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tree traditional_type, ansi_type, type;
|
1992-07-06 18:35:53 -04:00
|
|
|
|
HOST_WIDE_INT high, low;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
int spec_unsigned = 0;
|
|
|
|
|
int spec_long = 0;
|
|
|
|
|
int spec_long_long = 0;
|
1993-03-04 13:34:10 -05:00
|
|
|
|
int spec_imag = 0;
|
Warning fixes:
* c-lex.c (yylex): Remove unused variable `bytes'.
* flow.c (print_rtl_with_bb): Cast the return value of alloca.
* function.c (assign_parms): Wrap variable `varargs_setup' in
macro SETUP_INCOMING_VARARGS.
(thread_prologue_and_epilogue_insns): Mark parameter `f' with
ATTRIBUTE_UNUSED.
* local-alloc.c (no_equiv): Likewise for parameter `store'.
* sched.c (schedule_insns): Remove unused variables `insn' and `next'.
* tlink.c (symbol_hash_newfunc, symbol_hash_lookup,
file_hash_newfunc, file_hash_lookup, demangled_hash_newfunc,
demangled_hash_lookup, symbol_push, symbol_pop, file_push,
file_pop, tlink_init, tlink_execute, frob_extension,
obstack_fgets, tfgets, pfgets, freadsym, read_repo_file,
maybe_tweak, recompile_files, read_repo_files,
demangle_new_symbols, scan_linker_output): Add static prototype.
(symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc):
Make the third argument a `hash_table_key'.
* toplev.c (debug_start_source_file): Mark parameter `filename'
with ATTRIBUTE_UNUSED.
From-SVN: r25871
1999-03-20 14:21:31 -05:00
|
|
|
|
int warn, i;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1998-04-01 18:18:11 -05:00
|
|
|
|
traditional_type = ansi_type = type = NULL_TREE;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (c == 'u' || c == 'U')
|
|
|
|
|
{
|
|
|
|
|
if (spec_unsigned)
|
|
|
|
|
error ("two `u's in integer constant");
|
|
|
|
|
spec_unsigned = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (c == 'l' || c == 'L')
|
|
|
|
|
{
|
|
|
|
|
if (spec_long)
|
|
|
|
|
{
|
|
|
|
|
if (spec_long_long)
|
|
|
|
|
error ("three `l's in integer constant");
|
1998-09-09 18:02:02 -04:00
|
|
|
|
else if (pedantic && ! in_system_header && warn_long_long)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
pedwarn ("ANSI C forbids long long integer constants");
|
|
|
|
|
spec_long_long = 1;
|
|
|
|
|
}
|
|
|
|
|
spec_long = 1;
|
|
|
|
|
}
|
1993-03-04 13:34:10 -05:00
|
|
|
|
else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
|
|
|
|
|
{
|
|
|
|
|
if (spec_imag)
|
|
|
|
|
error ("more than one `i' or `j' in numeric constant");
|
1994-07-02 19:13:19 -04:00
|
|
|
|
else if (pedantic)
|
|
|
|
|
pedwarn ("ANSI C forbids imaginary numeric constants");
|
1993-03-04 13:34:10 -05:00
|
|
|
|
spec_imag = 1;
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
else
|
1995-12-28 07:21:45 -05:00
|
|
|
|
break;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (p >= token_buffer + maxtoken - 3)
|
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
*p++ = c;
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-16 03:33:24 -05:00
|
|
|
|
/* If it won't fit in the host's representation for integers,
|
|
|
|
|
then pedwarn. */
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1992-07-06 15:34:19 -04:00
|
|
|
|
warn = overflow;
|
|
|
|
|
if (warn)
|
|
|
|
|
pedwarn ("integer constant out of range");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* This is simplified by the fact that our constant
|
|
|
|
|
is always positive. */
|
1992-07-06 18:35:53 -04:00
|
|
|
|
|
|
|
|
|
high = low = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
|
|
|
|
|
{
|
|
|
|
|
high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
|
|
|
|
|
/ HOST_BITS_PER_CHAR)]
|
|
|
|
|
<< (i * HOST_BITS_PER_CHAR));
|
|
|
|
|
low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
|
|
|
|
|
}
|
1998-12-02 05:36:07 -05:00
|
|
|
|
|
1992-07-06 18:35:53 -04:00
|
|
|
|
yylval.ttype = build_int_2 (low, high);
|
1992-09-15 17:37:46 -04:00
|
|
|
|
TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* If warn_traditional, calculate both the ANSI type and the
|
|
|
|
|
traditional type, then see if they disagree.
|
|
|
|
|
Otherwise, calculate only the type for the dialect in use. */
|
|
|
|
|
if (warn_traditional || flag_traditional)
|
|
|
|
|
{
|
|
|
|
|
/* Calculate the traditional type. */
|
|
|
|
|
/* Traditionally, any constant is signed;
|
|
|
|
|
but if unsigned is specified explicitly, obey that.
|
|
|
|
|
Use the smallest size with the right number of bits,
|
|
|
|
|
except for one special case with decimal constants. */
|
|
|
|
|
if (! spec_long && base != 10
|
|
|
|
|
&& int_fits_type_p (yylval.ttype, unsigned_type_node))
|
|
|
|
|
traditional_type = (spec_unsigned ? unsigned_type_node
|
|
|
|
|
: integer_type_node);
|
|
|
|
|
/* A decimal constant must be long
|
|
|
|
|
if it does not fit in type int.
|
|
|
|
|
I think this is independent of whether
|
|
|
|
|
the constant is signed. */
|
|
|
|
|
else if (! spec_long && base == 10
|
|
|
|
|
&& int_fits_type_p (yylval.ttype, integer_type_node))
|
|
|
|
|
traditional_type = (spec_unsigned ? unsigned_type_node
|
|
|
|
|
: integer_type_node);
|
1992-07-06 15:34:19 -04:00
|
|
|
|
else if (! spec_long_long)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
traditional_type = (spec_unsigned ? long_unsigned_type_node
|
|
|
|
|
: long_integer_type_node);
|
|
|
|
|
else
|
|
|
|
|
traditional_type = (spec_unsigned
|
|
|
|
|
? long_long_unsigned_type_node
|
|
|
|
|
: long_long_integer_type_node);
|
|
|
|
|
}
|
|
|
|
|
if (warn_traditional || ! flag_traditional)
|
|
|
|
|
{
|
|
|
|
|
/* Calculate the ANSI type. */
|
|
|
|
|
if (! spec_long && ! spec_unsigned
|
|
|
|
|
&& int_fits_type_p (yylval.ttype, integer_type_node))
|
|
|
|
|
ansi_type = integer_type_node;
|
|
|
|
|
else if (! spec_long && (base != 10 || spec_unsigned)
|
|
|
|
|
&& int_fits_type_p (yylval.ttype, unsigned_type_node))
|
|
|
|
|
ansi_type = unsigned_type_node;
|
|
|
|
|
else if (! spec_unsigned && !spec_long_long
|
|
|
|
|
&& int_fits_type_p (yylval.ttype, long_integer_type_node))
|
|
|
|
|
ansi_type = long_integer_type_node;
|
1997-12-06 19:31:01 -05:00
|
|
|
|
else if (! spec_long_long
|
|
|
|
|
&& int_fits_type_p (yylval.ttype,
|
|
|
|
|
long_unsigned_type_node))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
ansi_type = long_unsigned_type_node;
|
|
|
|
|
else if (! spec_unsigned
|
|
|
|
|
&& int_fits_type_p (yylval.ttype,
|
|
|
|
|
long_long_integer_type_node))
|
|
|
|
|
ansi_type = long_long_integer_type_node;
|
|
|
|
|
else
|
|
|
|
|
ansi_type = long_long_unsigned_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = flag_traditional ? traditional_type : ansi_type;
|
|
|
|
|
|
|
|
|
|
if (warn_traditional && traditional_type != ansi_type)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_PRECISION (traditional_type)
|
|
|
|
|
!= TYPE_PRECISION (ansi_type))
|
|
|
|
|
warning ("width of integer constant changes with -traditional");
|
|
|
|
|
else if (TREE_UNSIGNED (traditional_type)
|
|
|
|
|
!= TREE_UNSIGNED (ansi_type))
|
|
|
|
|
warning ("integer constant is unsigned in ANSI C, signed with -traditional");
|
1992-04-14 13:46:57 -04:00
|
|
|
|
else
|
|
|
|
|
warning ("width of integer constant may change on other systems with -traditional");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1997-12-06 19:31:01 -05:00
|
|
|
|
if (pedantic && !flag_traditional && !spec_long_long && !warn
|
|
|
|
|
&& (TYPE_PRECISION (long_integer_type_node)
|
|
|
|
|
< TYPE_PRECISION (type)))
|
1999-03-16 03:33:24 -05:00
|
|
|
|
{
|
|
|
|
|
warn = 1;
|
|
|
|
|
pedwarn ("integer constant out of range");
|
|
|
|
|
}
|
1992-05-22 15:43:56 -04:00
|
|
|
|
|
1992-09-14 14:45:50 -04:00
|
|
|
|
if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
|
1993-01-09 04:25:56 -05:00
|
|
|
|
warning ("decimal constant is so large that it is unsigned");
|
1992-09-14 14:45:50 -04:00
|
|
|
|
|
1993-03-04 13:34:10 -05:00
|
|
|
|
if (spec_imag)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_PRECISION (type)
|
|
|
|
|
<= TYPE_PRECISION (integer_type_node))
|
|
|
|
|
yylval.ttype
|
1996-09-29 19:02:58 -04:00
|
|
|
|
= build_complex (NULL_TREE, integer_zero_node,
|
|
|
|
|
convert (integer_type_node,
|
|
|
|
|
yylval.ttype));
|
1993-03-04 13:34:10 -05:00
|
|
|
|
else
|
|
|
|
|
error ("complex integer constant is too wide for `complex int'");
|
|
|
|
|
}
|
|
|
|
|
else if (flag_traditional && !int_fits_type_p (yylval.ttype, type))
|
1992-08-01 14:07:21 -04:00
|
|
|
|
/* The traditional constant 0x80000000 is signed
|
|
|
|
|
but doesn't fit in the range of int.
|
|
|
|
|
This will change it to -0x80000000, which does fit. */
|
|
|
|
|
{
|
|
|
|
|
TREE_TYPE (yylval.ttype) = unsigned_type (type);
|
|
|
|
|
yylval.ttype = convert (type, yylval.ttype);
|
1994-04-16 17:04:03 -04:00
|
|
|
|
TREE_OVERFLOW (yylval.ttype)
|
|
|
|
|
= TREE_CONSTANT_OVERFLOW (yylval.ttype) = 0;
|
1992-08-01 14:07:21 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
TREE_TYPE (yylval.ttype) = type;
|
1999-03-16 03:33:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If it's still an integer (not a complex), and it doesn't
|
|
|
|
|
fit in the type we choose for it, then pedwarn. */
|
|
|
|
|
|
|
|
|
|
if (! warn
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (yylval.ttype)) == INTEGER_TYPE
|
|
|
|
|
&& ! int_fits_type_p (yylval.ttype, TREE_TYPE (yylval.ttype)))
|
|
|
|
|
pedwarn ("integer constant out of range");
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c);
|
1995-12-28 07:21:45 -05:00
|
|
|
|
*p = 0;
|
|
|
|
|
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (ISALNUM (c) || c == '.' || c == '_' || c == '$'
|
1995-12-28 07:21:45 -05:00
|
|
|
|
|| (!flag_traditional && (c == '-' || c == '+')
|
|
|
|
|
&& (p[-1] == 'e' || p[-1] == 'E')))
|
|
|
|
|
error ("missing white space after number `%s'", token_buffer);
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
value = CONSTANT; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case '\'':
|
|
|
|
|
char_constant:
|
|
|
|
|
{
|
|
|
|
|
register int result = 0;
|
1992-07-23 13:00:21 -04:00
|
|
|
|
register int num_chars = 0;
|
1998-07-20 09:35:38 -04:00
|
|
|
|
int chars_seen = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
unsigned width = TYPE_PRECISION (char_type_node);
|
|
|
|
|
int max_chars;
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
1998-07-20 09:35:38 -04:00
|
|
|
|
int longest_char = local_mb_cur_max ();
|
|
|
|
|
(void) local_mbtowc (NULL_PTR, NULL_PTR, 0);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
#endif
|
1998-07-20 09:35:38 -04:00
|
|
|
|
|
|
|
|
|
max_chars = TYPE_PRECISION (integer_type_node) / width;
|
|
|
|
|
if (wide_flag)
|
|
|
|
|
width = WCHAR_TYPE_SIZE;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
tryagain:
|
1997-07-29 18:40:30 -04:00
|
|
|
|
c = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
if (c == '\'' || c == EOF)
|
|
|
|
|
break;
|
|
|
|
|
|
1998-07-20 09:35:38 -04:00
|
|
|
|
++chars_seen;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (c == '\\')
|
|
|
|
|
{
|
1992-09-24 02:53:13 -04:00
|
|
|
|
int ignore = 0;
|
|
|
|
|
c = readescape (&ignore);
|
|
|
|
|
if (ignore)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
goto tryagain;
|
|
|
|
|
if (width < HOST_BITS_PER_INT
|
1998-10-13 11:25:25 -04:00
|
|
|
|
&& (unsigned) c >= ((unsigned)1 << width))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
pedwarn ("escape sequence out of range for character");
|
1993-04-09 17:47:48 -04:00
|
|
|
|
#ifdef MAP_CHARACTER
|
1998-05-06 08:56:58 -04:00
|
|
|
|
if (ISPRINT (c))
|
1993-04-09 17:47:48 -04:00
|
|
|
|
c = MAP_CHARACTER (c);
|
|
|
|
|
#endif
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (c == '\n')
|
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("ANSI C forbids newline in character constant");
|
|
|
|
|
lineno++;
|
|
|
|
|
}
|
1993-04-09 17:46:58 -04:00
|
|
|
|
else
|
1998-07-20 09:35:38 -04:00
|
|
|
|
{
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
|
|
|
|
wchar_t wc;
|
|
|
|
|
int i;
|
|
|
|
|
int char_len = -1;
|
|
|
|
|
for (i = 1; i <= longest_char; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (i > maxtoken - 4)
|
|
|
|
|
extend_token_buffer (token_buffer);
|
|
|
|
|
|
|
|
|
|
token_buffer[i] = c;
|
|
|
|
|
char_len = local_mbtowc (& wc,
|
|
|
|
|
token_buffer + 1,
|
|
|
|
|
i);
|
|
|
|
|
if (char_len != -1)
|
|
|
|
|
break;
|
|
|
|
|
c = GETC ();
|
|
|
|
|
}
|
|
|
|
|
if (char_len > 1)
|
|
|
|
|
{
|
|
|
|
|
/* mbtowc sometimes needs an extra char before accepting */
|
|
|
|
|
if (char_len < i)
|
|
|
|
|
UNGETC (c);
|
|
|
|
|
if (! wide_flag)
|
|
|
|
|
{
|
|
|
|
|
/* Merge character into result; ignore excess chars. */
|
|
|
|
|
for (i = 1; i <= char_len; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (i > max_chars)
|
|
|
|
|
break;
|
|
|
|
|
if (width < HOST_BITS_PER_INT)
|
|
|
|
|
result = (result << width)
|
|
|
|
|
| (token_buffer[i]
|
|
|
|
|
& ((1 << width) - 1));
|
|
|
|
|
else
|
|
|
|
|
result = token_buffer[i];
|
|
|
|
|
}
|
|
|
|
|
num_chars += char_len;
|
|
|
|
|
goto tryagain;
|
|
|
|
|
}
|
|
|
|
|
c = wc;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (char_len == -1)
|
1999-06-07 07:12:38 -04:00
|
|
|
|
{
|
|
|
|
|
warning ("Ignoring invalid multibyte character");
|
|
|
|
|
/* Replace all but the first byte. */
|
|
|
|
|
for (--i; i > 1; --i)
|
|
|
|
|
UNGETC (token_buffer[i]);
|
|
|
|
|
wc = token_buffer[1];
|
|
|
|
|
}
|
1998-07-20 09:35:38 -04:00
|
|
|
|
#ifdef MAP_CHARACTER
|
1999-06-07 07:12:38 -04:00
|
|
|
|
c = MAP_CHARACTER (wc);
|
|
|
|
|
#else
|
|
|
|
|
c = wc;
|
1993-04-09 17:46:58 -04:00
|
|
|
|
#endif
|
1998-07-20 09:35:38 -04:00
|
|
|
|
}
|
|
|
|
|
#else /* ! MULTIBYTE_CHARS */
|
|
|
|
|
#ifdef MAP_CHARACTER
|
|
|
|
|
c = MAP_CHARACTER (c);
|
|
|
|
|
#endif
|
|
|
|
|
#endif /* ! MULTIBYTE_CHARS */
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1998-07-20 09:35:38 -04:00
|
|
|
|
if (wide_flag)
|
|
|
|
|
{
|
|
|
|
|
if (chars_seen == 1) /* only keep the first one */
|
|
|
|
|
result = c;
|
|
|
|
|
goto tryagain;
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
/* Merge character into result; ignore excess chars. */
|
1998-07-20 09:35:38 -04:00
|
|
|
|
num_chars += (width / TYPE_PRECISION (char_type_node));
|
1992-03-06 18:36:01 -05:00
|
|
|
|
if (num_chars < max_chars + 1)
|
|
|
|
|
{
|
|
|
|
|
if (width < HOST_BITS_PER_INT)
|
|
|
|
|
result = (result << width) | (c & ((1 << width) - 1));
|
|
|
|
|
else
|
|
|
|
|
result = c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c != '\'')
|
|
|
|
|
error ("malformatted character constant");
|
1998-07-20 09:35:38 -04:00
|
|
|
|
else if (chars_seen == 0)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
error ("empty character constant");
|
|
|
|
|
else if (num_chars > max_chars)
|
|
|
|
|
{
|
|
|
|
|
num_chars = max_chars;
|
|
|
|
|
error ("character constant too long");
|
|
|
|
|
}
|
1998-07-20 09:35:38 -04:00
|
|
|
|
else if (chars_seen != 1 && ! flag_traditional && warn_multichar)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
warning ("multi-character character constant");
|
|
|
|
|
|
|
|
|
|
/* If char type is signed, sign-extend the constant. */
|
|
|
|
|
if (! wide_flag)
|
|
|
|
|
{
|
|
|
|
|
int num_bits = num_chars * width;
|
1993-04-30 22:59:52 -04:00
|
|
|
|
if (num_bits == 0)
|
|
|
|
|
/* We already got an error; avoid invalid shift. */
|
|
|
|
|
yylval.ttype = build_int_2 (0, 0);
|
|
|
|
|
else if (TREE_UNSIGNED (char_type_node)
|
|
|
|
|
|| ((result >> (num_bits - 1)) & 1) == 0)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
yylval.ttype
|
1998-01-28 18:25:15 -05:00
|
|
|
|
= build_int_2 (result & (~(unsigned HOST_WIDE_INT) 0
|
1992-07-06 18:35:53 -04:00
|
|
|
|
>> (HOST_BITS_PER_WIDE_INT - num_bits)),
|
1992-03-06 18:36:01 -05:00
|
|
|
|
0);
|
|
|
|
|
else
|
|
|
|
|
yylval.ttype
|
1998-01-28 18:25:15 -05:00
|
|
|
|
= build_int_2 (result | ~(~(unsigned HOST_WIDE_INT) 0
|
1992-07-06 18:35:53 -04:00
|
|
|
|
>> (HOST_BITS_PER_WIDE_INT - num_bits)),
|
1992-03-06 18:36:01 -05:00
|
|
|
|
-1);
|
1993-02-12 02:36:00 -05:00
|
|
|
|
TREE_TYPE (yylval.ttype) = integer_type_node;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yylval.ttype = build_int_2 (result, 0);
|
1993-02-12 02:36:00 -05:00
|
|
|
|
TREE_TYPE (yylval.ttype) = wchar_type_node;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = CONSTANT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case '"':
|
|
|
|
|
string_constant:
|
|
|
|
|
{
|
1998-07-20 09:35:38 -04:00
|
|
|
|
unsigned width = wide_flag ? WCHAR_TYPE_SIZE
|
|
|
|
|
: TYPE_PRECISION (char_type_node);
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
|
|
|
|
int longest_char = local_mb_cur_max ();
|
|
|
|
|
(void) local_mbtowc (NULL_PTR, NULL_PTR, 0);
|
|
|
|
|
#endif
|
|
|
|
|
c = GETC ();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
p = token_buffer + 1;
|
|
|
|
|
|
|
|
|
|
while (c != '"' && c >= 0)
|
|
|
|
|
{
|
1993-09-29 01:42:10 -04:00
|
|
|
|
if (c == '\\')
|
1992-03-06 18:36:01 -05:00
|
|
|
|
{
|
1992-09-24 15:23:56 -04:00
|
|
|
|
int ignore = 0;
|
1992-09-24 02:53:13 -04:00
|
|
|
|
c = readescape (&ignore);
|
|
|
|
|
if (ignore)
|
1992-03-06 18:36:01 -05:00
|
|
|
|
goto skipnewline;
|
1998-07-20 09:35:38 -04:00
|
|
|
|
if (width < HOST_BITS_PER_INT
|
1998-10-13 11:25:25 -04:00
|
|
|
|
&& (unsigned) c >= ((unsigned)1 << width))
|
1992-03-06 18:36:01 -05:00
|
|
|
|
pedwarn ("escape sequence out of range for character");
|
|
|
|
|
}
|
|
|
|
|
else if (c == '\n')
|
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("ANSI C forbids newline in string constant");
|
|
|
|
|
lineno++;
|
|
|
|
|
}
|
1998-07-20 09:35:38 -04:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef MULTIBYTE_CHARS
|
|
|
|
|
wchar_t wc;
|
|
|
|
|
int i;
|
|
|
|
|
int char_len = -1;
|
|
|
|
|
for (i = 0; i < longest_char; ++i)
|
|
|
|
|
{
|
1998-07-27 08:51:56 -04:00
|
|
|
|
if (p + i >= token_buffer + maxtoken)
|
1998-07-20 09:35:38 -04:00
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
p[i] = c;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
1998-07-20 09:35:38 -04:00
|
|
|
|
char_len = local_mbtowc (& wc, p, i + 1);
|
|
|
|
|
if (char_len != -1)
|
|
|
|
|
break;
|
|
|
|
|
c = GETC ();
|
|
|
|
|
}
|
|
|
|
|
if (char_len == -1)
|
|
|
|
|
{
|
1999-06-07 07:12:38 -04:00
|
|
|
|
warning ("Ignoring invalid multibyte character");
|
|
|
|
|
/* Replace all except the first byte. */
|
|
|
|
|
UNGETC (c);
|
|
|
|
|
for (--i; i > 0; --i)
|
|
|
|
|
UNGETC (p[i]);
|
|
|
|
|
char_len = 1;
|
|
|
|
|
}
|
|
|
|
|
/* mbtowc sometimes needs an extra char before accepting */
|
|
|
|
|
if (char_len <= i)
|
|
|
|
|
UNGETC (c);
|
|
|
|
|
if (! wide_flag)
|
|
|
|
|
{
|
|
|
|
|
p += (i + 1);
|
|
|
|
|
c = GETC ();
|
|
|
|
|
continue;
|
1998-07-20 09:35:38 -04:00
|
|
|
|
}
|
1999-06-07 07:12:38 -04:00
|
|
|
|
c = wc;
|
1998-07-20 09:35:38 -04:00
|
|
|
|
#endif /* MULTIBYTE_CHARS */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add this single character into the buffer either as a wchar_t
|
|
|
|
|
or as a single byte. */
|
|
|
|
|
if (wide_flag)
|
|
|
|
|
{
|
|
|
|
|
unsigned width = TYPE_PRECISION (char_type_node);
|
|
|
|
|
unsigned bytemask = (1 << width) - 1;
|
|
|
|
|
int byte;
|
|
|
|
|
|
1998-07-27 08:51:56 -04:00
|
|
|
|
if (p + WCHAR_BYTES > token_buffer + maxtoken)
|
1998-07-20 09:35:38 -04:00
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
|
|
|
|
|
for (byte = 0; byte < WCHAR_BYTES; ++byte)
|
|
|
|
|
{
|
|
|
|
|
int value;
|
1998-10-13 11:25:25 -04:00
|
|
|
|
if (byte >= (int) sizeof (c))
|
1998-07-20 09:35:38 -04:00
|
|
|
|
value = 0;
|
|
|
|
|
else
|
|
|
|
|
value = (c >> (byte * width)) & bytemask;
|
|
|
|
|
if (BYTES_BIG_ENDIAN)
|
|
|
|
|
p[WCHAR_BYTES - byte - 1] = value;
|
|
|
|
|
else
|
|
|
|
|
p[byte] = value;
|
|
|
|
|
}
|
|
|
|
|
p += WCHAR_BYTES;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1998-07-27 08:51:56 -04:00
|
|
|
|
if (p >= token_buffer + maxtoken)
|
1998-07-20 09:35:38 -04:00
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
*p++ = c;
|
|
|
|
|
}
|
1992-03-06 18:36:01 -05:00
|
|
|
|
|
|
|
|
|
skipnewline:
|
1998-07-20 09:35:38 -04:00
|
|
|
|
c = GETC ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Terminate the string value, either with a single byte zero
|
|
|
|
|
or with a wide zero. */
|
|
|
|
|
if (wide_flag)
|
|
|
|
|
{
|
1998-07-27 08:51:56 -04:00
|
|
|
|
if (p + WCHAR_BYTES > token_buffer + maxtoken)
|
1998-07-20 09:35:38 -04:00
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
bzero (p, WCHAR_BYTES);
|
|
|
|
|
p += WCHAR_BYTES;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1998-07-27 08:51:56 -04:00
|
|
|
|
if (p >= token_buffer + maxtoken)
|
1998-07-20 09:35:38 -04:00
|
|
|
|
p = extend_token_buffer (p);
|
|
|
|
|
*p++ = 0;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1995-02-21 05:37:13 -05:00
|
|
|
|
if (c < 0)
|
|
|
|
|
error ("Unterminated string constant");
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
/* We have read the entire constant.
|
|
|
|
|
Construct a STRING_CST for the result. */
|
|
|
|
|
|
|
|
|
|
if (wide_flag)
|
|
|
|
|
{
|
1998-07-20 09:35:38 -04:00
|
|
|
|
yylval.ttype = build_string (p - (token_buffer + 1),
|
|
|
|
|
token_buffer + 1);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
TREE_TYPE (yylval.ttype) = wchar_array_type_node;
|
1993-04-09 19:12:37 -04:00
|
|
|
|
value = STRING;
|
|
|
|
|
}
|
|
|
|
|
else if (objc_flag)
|
|
|
|
|
{
|
|
|
|
|
/* Return an Objective-C @"..." constant string object. */
|
1998-07-20 09:35:38 -04:00
|
|
|
|
yylval.ttype = build_objc_string (p - (token_buffer + 1),
|
1993-04-09 19:12:37 -04:00
|
|
|
|
token_buffer + 1);
|
|
|
|
|
TREE_TYPE (yylval.ttype) = char_array_type_node;
|
|
|
|
|
value = OBJC_STRING;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1998-07-20 09:35:38 -04:00
|
|
|
|
yylval.ttype = build_string (p - (token_buffer + 1),
|
|
|
|
|
token_buffer + 1);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
TREE_TYPE (yylval.ttype) = char_array_type_node;
|
1993-04-09 19:12:37 -04:00
|
|
|
|
value = STRING;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
1993-04-09 19:12:37 -04:00
|
|
|
|
break;
|
1992-03-06 18:36:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
|
case '-':
|
|
|
|
|
case '&':
|
|
|
|
|
case '|':
|
1995-02-21 06:41:31 -05:00
|
|
|
|
case ':':
|
1992-03-06 18:36:01 -05:00
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
case '*':
|
|
|
|
|
case '/':
|
|
|
|
|
case '%':
|
|
|
|
|
case '^':
|
|
|
|
|
case '!':
|
|
|
|
|
case '=':
|
|
|
|
|
{
|
|
|
|
|
register int c1;
|
|
|
|
|
|
|
|
|
|
combine:
|
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '+':
|
|
|
|
|
yylval.code = PLUS_EXPR; break;
|
|
|
|
|
case '-':
|
|
|
|
|
yylval.code = MINUS_EXPR; break;
|
|
|
|
|
case '&':
|
|
|
|
|
yylval.code = BIT_AND_EXPR; break;
|
|
|
|
|
case '|':
|
|
|
|
|
yylval.code = BIT_IOR_EXPR; break;
|
|
|
|
|
case '*':
|
|
|
|
|
yylval.code = MULT_EXPR; break;
|
|
|
|
|
case '/':
|
|
|
|
|
yylval.code = TRUNC_DIV_EXPR; break;
|
|
|
|
|
case '%':
|
|
|
|
|
yylval.code = TRUNC_MOD_EXPR; break;
|
|
|
|
|
case '^':
|
|
|
|
|
yylval.code = BIT_XOR_EXPR; break;
|
|
|
|
|
case LSHIFT:
|
|
|
|
|
yylval.code = LSHIFT_EXPR; break;
|
|
|
|
|
case RSHIFT:
|
|
|
|
|
yylval.code = RSHIFT_EXPR; break;
|
|
|
|
|
case '<':
|
|
|
|
|
yylval.code = LT_EXPR; break;
|
|
|
|
|
case '>':
|
|
|
|
|
yylval.code = GT_EXPR; break;
|
|
|
|
|
}
|
|
|
|
|
|
1997-07-29 18:40:30 -04:00
|
|
|
|
token_buffer[1] = c1 = GETC();
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token_buffer[2] = 0;
|
|
|
|
|
|
|
|
|
|
if (c1 == '=')
|
|
|
|
|
{
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '<':
|
|
|
|
|
value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
|
|
|
|
|
case '>':
|
|
|
|
|
value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
|
|
|
|
|
case '!':
|
|
|
|
|
value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
|
|
|
|
|
case '=':
|
|
|
|
|
value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
|
|
|
|
|
}
|
|
|
|
|
value = ASSIGN; goto done;
|
|
|
|
|
}
|
|
|
|
|
else if (c == c1)
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '+':
|
|
|
|
|
value = PLUSPLUS; goto done;
|
|
|
|
|
case '-':
|
|
|
|
|
value = MINUSMINUS; goto done;
|
|
|
|
|
case '&':
|
|
|
|
|
value = ANDAND; goto done;
|
|
|
|
|
case '|':
|
|
|
|
|
value = OROR; goto done;
|
|
|
|
|
case '<':
|
|
|
|
|
c = LSHIFT;
|
|
|
|
|
goto combine;
|
|
|
|
|
case '>':
|
|
|
|
|
c = RSHIFT;
|
|
|
|
|
goto combine;
|
|
|
|
|
}
|
1995-02-21 06:41:31 -05:00
|
|
|
|
else
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '-':
|
|
|
|
|
if (c1 == '>')
|
|
|
|
|
{ value = POINTSAT; goto done; }
|
|
|
|
|
break;
|
|
|
|
|
case ':':
|
|
|
|
|
if (c1 == '>')
|
|
|
|
|
{ value = ']'; goto done; }
|
|
|
|
|
break;
|
|
|
|
|
case '<':
|
|
|
|
|
if (c1 == '%')
|
1997-11-02 16:19:36 -05:00
|
|
|
|
{ value = '{'; indent_level++; goto done; }
|
1995-02-21 06:41:31 -05:00
|
|
|
|
if (c1 == ':')
|
|
|
|
|
{ value = '['; goto done; }
|
|
|
|
|
break;
|
|
|
|
|
case '%':
|
|
|
|
|
if (c1 == '>')
|
1997-11-02 16:19:36 -05:00
|
|
|
|
{ value = '}'; indent_level--; goto done; }
|
1995-02-21 06:41:31 -05:00
|
|
|
|
break;
|
|
|
|
|
}
|
1997-07-29 18:40:30 -04:00
|
|
|
|
UNGETC (c1);
|
1992-03-06 18:36:01 -05:00
|
|
|
|
token_buffer[1] = 0;
|
|
|
|
|
|
|
|
|
|
if ((c == '<') || (c == '>'))
|
|
|
|
|
value = ARITHCOMPARE;
|
|
|
|
|
else value = c;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
/* Don't make yyparse think this is eof. */
|
|
|
|
|
value = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
1997-11-02 16:19:36 -05:00
|
|
|
|
case '{':
|
|
|
|
|
indent_level++;
|
|
|
|
|
value = c;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '}':
|
|
|
|
|
indent_level--;
|
|
|
|
|
value = c;
|
|
|
|
|
break;
|
|
|
|
|
|
1992-03-06 18:36:01 -05:00
|
|
|
|
default:
|
|
|
|
|
value = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
/* yylloc.last_line = lineno; */
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
1992-03-14 00:07:15 -05:00
|
|
|
|
/* Sets the value of the 'yydebug' variable to VALUE.
|
1992-03-06 18:36:01 -05:00
|
|
|
|
This is a function so we don't have to have YYDEBUG defined
|
|
|
|
|
in order to build the compiler. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
set_yydebug (value)
|
|
|
|
|
int value;
|
|
|
|
|
{
|
|
|
|
|
#if YYDEBUG != 0
|
|
|
|
|
yydebug = value;
|
|
|
|
|
#else
|
|
|
|
|
warning ("YYDEBUG not defined.");
|
|
|
|
|
#endif
|
|
|
|
|
}
|