cppfiles.c (_cpp_find_include_file): Make sure ih->name is initialized.
* cppfiles.c (_cpp_find_include_file): Make sure ih->name is
initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also.
* cpperror.c (cpp_print_containing_files,
cpp_print_file_and_line, v_cpp_message): Rename to
print_containing_files, print_file_and_line, and v_message.
* cppexp.c (cpp_parse_expr, cpp_parse_escape, cpp_lex): Rename
to _cpp_parse_expr, parse_escape, and lex.
(parse_charconst): Remove broken multibyte support.
* cppfiles.c (include_hash): Make static.
(cpp_included): New function.
(merge_include_chains, find_include_file, finclude,
simplify_pathname): Rename to _cpp_merge_include_chains,
_cpp_find_include_file, _cpp_read_include_file, and
_cpp_simplify_pathname.
* cpphash.c (cpp_lookup, free_definition, delete_macro,
cpp_install, create_definition, macroexpand, compare_defs,
dump_definition): Rename to _cpp_lookup, _cpp_free_definition,
_cpp_delete_macro, _cpp_install, _cpp_create_definition,
_cpp_macroexpand, _cpp_compare_defs, and _cpp_dump_definition.
* cppinit.c (cpp_handle_option): Rename to handle_option, make
static.
* cpplib.c: Remove extern prototype of cpp_parse_expr.
* cpphash.h: Update prototypes.
* cpplib.h: Likewise. Prototype _cpp_parse_expr here.
From-SVN: r32390
2000-03-07 21:58:47 +01:00
|
|
|
|
/* Parse C expressions for cpplib.
|
2002-01-03 22:43:09 +01:00
|
|
|
|
Copyright (C) 1987, 1992, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
|
c-incpath.c, [...]: Update copyright.
gcc/
* c-incpath.c, c-incpath.h, c-pch.c, c.opt, cppexp.c,
et-forest.h, genattr.c, ggc-none.c, hosthooks-def.h,
hosthooks.h, params.h, ra-colorize.c, web.c,
config/darwin-c.c, config/alpha/freebsd.h, config/arm/pe.c,
config/avr/avr-protos.h, config/avr/avr.md,
config/fr30/fr30-protos.h, config/fr30/fr30.md,
config/h8300/fixunssfsi.c, config/i386/darwin.h,
config/i386/freebsd.h, config/i386/freebsd64.h,
config/ia64/hpux.h, config/ia64/unwind-ia64.c,
config/ip2k/libgcc.S, config/m32r/xm-m32r.h,
config/mmix/mmix-modes.def, config/ns32k/netbsd.h,
config/ns32k/ns32k.md, config/pa/pa64-hpux.h,
config/pa/pa64-regs.h, config/rs6000/aix41.h,
config/rs6000/aix43.h, config/rs6000/host-darwin.c,
config/sparc/aout.h, config/sparc/freebsd.h,
config/sparc/litecoff.h, config/vax/vax-protos.h,
doc/hostconfig.texi, doc/include/gcc-common.texi: Update
copyright.
gcc/cp/
* cp-lang.c, ptree.c: Update copyright.
From-SVN: r79506
2004-03-15 19:20:51 +01:00
|
|
|
|
2002, 2004 Free Software Foundation.
|
2000-04-18 22:42:00 +02:00
|
|
|
|
Contributed by Per Bothner, 1994.
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
|
|
|
|
This program 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.
|
|
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
2005-06-29 04:34:39 +02:00
|
|
|
|
Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
|
|
|
|
#include "config.h"
|
More cutover to system.h:
* Makefile.in (cppalloc.o, cpperror.o, cppexp.o, cpphash.o,
cpplib.o, cppmain.o, fix-header.o, gcov.o, gen-protos.o,
gengenrtl.o, halfpic.o, hash.o, scan-decls.o, scan.o): Depend on
system.h.
* cpphash.c: Include config.h.
* cppalloc.c: Include system.h. Add parameters to various
function prototypes.
* cpperror.c: Likewise.
* cppexp.c: Likewise.
* cpphash.c: Likewise.
* cpplib.c: Likewise.
* cppmain.c: Likewise.
* fix-header.c: Likewise.
* gcov.c: Likewise.
* gen-protos.c: Likewise.
* gengenrtl.c: Likewise.
* halfpic.c: Likewise.
* hash.c: Likewise.
* scan-decls.c: Likewise.
* scan.c: Likewise.
From-SVN: r18911
1998-03-30 14:05:54 +02:00
|
|
|
|
#include "system.h"
|
Warning Fixes:
* Makefile.in (print-rtl.o): Depend on bitmap.h.
(dbxout.o): Depend on toplev.h.
($(SCHED_PREFIX)sched.o): Likewise.
($(out_object_file)): Likewise for system.h and toplev.h.
(cppmain.o): Depend on gansidecl.h.
(cpplib.o): Likewise.
(cpperror.o): Likewise.
(cppexp.o): Likewise.
(cpphash.o): Likewise.
(cppalloc.o): Likewise.
(fix-header.o): Depend on cpplib.h and cpphash.h.
(scan-decls.o): Depend on gansidecl.h.
* basic-block.h (free_regset_vector): Add prototype.
* cccp.c (check_precompiled): Mark parameter `fname' with
ATTRIBUTE_UNUSED.
(do_assert): Likewise for `op' and `keyword'.
(do_unassert): Likewise.
(do_line): Likewise for `keyword'.
(do_error): Likewise for `op' and `keyword'.
(do_warning): Likewise.
(do_ident): Likewise for `keyword'.
(do_pragma): Likewise for `limit', `op' and `keyword'.
(do_sccs): Likewise.
(do_if): Likewise for `keyword'.
(do_elif): Likewise.
(do_else): Likewise.
(do_endif): Likewise.
* collect2.c (getenv): Remove redundant prototype.
(collect_exit, collect_execute, dump_file): Likewise.
(dump_list): Wrap prototype and definition in COLLECT_EXPORT_LIST.
(dump_prefix_list): Hide prototype and definition.
* sparc.c: Include toplev.h.
(intreg_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED.
(symbolic_memory_operand): Likewise.
(sp64_medium_pic_operand): Likewise.
(data_segment_operand): Likewise.
(text_segment_operand): Likewise.
(splittable_symbolic_memory_operand): Likewise.
(splittable_immediate_memory_operand): Likewise.
(eq_or_neq): Likewise.
(normal_comp_operator): Likewise.
(noov_compare_op): Likewise.
(v9_regcmp_op): Likewise.
(v8plus_regcmp_op): Likewise.
(extend_op): Likewise.
(cc_arithop): Likewise.
(cc_arithopn): Likewise.
(small_int): Likewise.
(uns_small_int): Likewise.
(clobbered_register): Likewise.
(legitimize_pic_address): Likewise.
(delay_operand): Likewise.
(sparc_builtin_saveregs): Remove unused variable `stdarg'.
* sparc.h (order_regs_for_local_alloc, eligible_for_return_delay,
sparc_issue_rate, v8plus_regcmp_p): Add prototypes.
* sparc.md (cmpdi_v8plus): Add abort for default case in switch.
* cppalloc.c: Include gansidecl.h.
* cpperror.c: Include stdarg.h/varargs.h and gansidecl.h.
(cpp_file_line_for_message): Mark parameter `pfile' with
ATTRIBUTE_UNUSED.
(v_cpp_message): New function.
(cpp_message): Use it. Also convert to variable arguments.
(cpp_fatal): Likewise.
(cpp_pfatal_with_name): Constify parameter `name'.
* cppexp.c: Move gansidecl.h before cpplib.h.
* cpphash.c: Likewise.
* cpphash.h (hashf, delete_macro): Add prototypes.
* cpplib.c: Include stdarg.h/varargs.h and move gansidecl.h before
cpplib.h. Don't include errno.h.
(update_path): Add arguments to prototype.
(cpp_fatal, cpp_file_line_for_message, cpp_message, delete_macro,
cpp_print_containing_files): Remove redundant prototypes.
(cpp_hash_cleanup, add_import, append_include_chain,
make_assertion, path_include, initialize_builtins,
initialize_char_syntax, finclude, validate_else, comp_def_part,
lookup_import, redundant_include_p, is_system_include,
read_name_map, read_filename_string, open_include_file,
check_macro_name, compare_defs, compare_token_lists,
eval_if_expression, change_newlines): Add prototype arguments.
(hashf): Remove redundant prototype.
(read_token_list, free_token_list, safe_read, xcalloc, savestring,
conditional_skip, skip_if_group): Add prototype arguments.
(fdopen): Remove redundant prototype.
(do_define, do_line, do_include, do_undef, do_error, do_pragma,
do_ident, do_if, do_xifdef, do_else, do_elif, do_endif, do_sccs,
do_once, do_assert, do_unassert, do_warning): Add prototype arguments.
(struct directive): Add prototype arguments to function pointer
member `func'.
(handle_directive): Add missing arguments to call to `do_line'.
(do_include): Mark parameters `unused1' and `unused2' with
ATTRIBUTE_UNUSED.
(do_line): Likewise for `keyword' and new parameters `unused1' and
`unused2'.
(do_error): Likewise for `keyword'.
(do_warning): Likewise. Also add missing argument `pfile' in call
to cpp_pedwarn.
(do_once): Mark parameter `keyword', `unused1' and `unused2' with
ATTRIBUTE_UNUSED.
(do_ident): Likewise for `keyword', `buf' and `limit'.
(do_pragma): Likewise. Also add missing arguments in call to do_once.
(do_sccs): Mark parameter `keyword', `buf' and `limit' with
ATTRIBUTE_UNUSED.
(do_if): Likewise for `keyword'.
(do_elif): Likewise.
(eval_if_expression): Likewise for `buf' and `length'.
(do_xifdef): Likewise for `unused1' and `unused2'.
(do_else): Likewise for `keyword', `buf' and `limit'.
(do_endif): Likewise.
(parse_name): Add missing argument `pfile' in call to cpp_pedwarn.
(cpp_handle_options): Remove superfluous NULL argument in call to
cpp_fatal.
(cpp_handle_options): Likewise.
(do_assert): Mark parameter `keyword', `buf' and `limit' with
ATTRIBUTE_UNUSED.
(do_unassert): Likewise.
(cpp_print_file_and_line): Add missing argument `pfile' in call to
cpp_file_line_for_message.
(v_cpp_error): New function.
(cpp_error): Use it. Also accept variable arguments.
(v_cpp_warning): New function.
(cpp_warning): Use it. Also accept variable arguments.
(cpp_pedwarn): Accept variable arguments.
(v_cpp_error_with_line): New function
(cpp_error_with_line): Use it. Accept variable arguments.
(v_cpp_warning_with_line): New function.
(cpp_warning_with_line): Use it. Accept variable arguments. Hide
definition.
(cpp_pedwarn_with_line): Accept variable arguments.
(cpp_pedwarn_with_file_and_line): Likewise.
(cpp_error_from_errno): Constify parameter `name'. Add missing
argument `pfile' in call to cpp_file_line_for_message.
(cpp_perror_with_name): Constify parameter `name'.
* cpplib.h: Define PARAMS() in terms of PROTO().
(fatal): Remove redundant prototype.
(cpp_error, cpp_warning, cpp_pedwarn, cpp_error_with_line,
cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line,
cpp_error_from_errno, cpp_perror_with_name, cpp_pfatal_with_name,
cpp_fatal, cpp_message, cpp_pfatal_with_name,
cpp_file_line_for_message, cpp_print_containing_files): Add
arguments to prototypes.
(scan_decls, cpp_finish): Add prototypes.
* cppmain.c: Include gansidecl.h.
(main): Remove unused variable `i'.
* dbxout.c: Include toplev.h.
* demangle.h (do_tlink, collect_execute, collect_exit,
collect_wait, dump_file, file_exists): Add prototype.
* dwarf2out.c (dwarf_type_encoding_name, decl_start_label): Hide
prototype and definition.
(gen_unspecified_parameters_die): Don't assign results of call to
function new_die() to unused variable `parm_die'.
(dwarf2out_line): Mark parameter `filename' with ATTRIBUTE_UNUSED.
(dwarf2out_define): Likewise for `lineno' and `buffer'.
* dwarfout.c (output_unsigned_leb128, output_signed_leb128): Hide
prototype and definition.
(output_die): Add prototype arguments to function pointer arg.
(output_unspecified_parameters_die): Mark parameter `arg' with
ATTRIBUTE_UNUSED.
* except.c (output_exception_table_entry): Remove unused variable
`eh_entry'.
* except.h (expand_fixup_region_start, expand_fixup_region_end):
Add prototypes.
* expr.c (do_jump_by_parts_equality_rtx): Remove prototype.
* expr.h (do_jump_by_parts_equality_rtx): Add prototype.
* fix-header.c: Include stdarg.h/varargs.h, move gansidecl.h
before cpplib.h, include cpphash.h, remove redundant prototype of
cpp_fatal, don't define `const', add a prototype for `fatal'.
(cpp_file_line_for_message): Add missing arguments `pfile'.
(v_cpp_message): New function.
(cpp_message): Use it.
(v_fatal): New function.
(fatal, cpp_fatal): Use it.
(cpp_pfatal_with_name): Constify parameter `name'.
* flow.c (free_regset_vector): Remove redundant prototype.
* function.c (round_down): Wrap prototype and definition with
macro ARGS_GROW_DOWNWARD.
(record_insns): Wrap prototype and definition with
defined (HAVE_prologue) || defined (HAVE_epilogue).
* gansidecl.h (ATTRIBUTE_PRINTF_4, ATTRIBUTE_PRINTF_5): New macros.
* gen-protos.c: Include gansidecl.h.
(hashf): Don't make it static, constify parameter `name'.
* genattrtab.c (check_attr_test): Change XEXP() to XSTR() to match
specifier %s in calls to function `fatal'.
* haifa-sched.c: Include toplev.h.
(find_rgns): Remove unused variable `j'.
* integrate.c (note_modified_parmregs): Mark parameter `x' with
ATTRIBUTE_UNUSED.
(mark_stores): Likewise.
* jump.c (mark_modified_reg): Likewise.
* output.h (insn_current_reference_address): Add prototype.
(eh_frame_section): Likewise.
* print-rtl.c: Include bitmap.h.
* reload1.c (reload): Wrap variables `note' and `next' in macro
PRESERVE_DEATH_INFO_REGNO_P.
(forget_old_reloads_1): Mark parameter `ignored' with
ATTRIBUTE_UNUSED.
(choose_reload_regs): Remove unused variable `in'.
(reload_cse_invalidate_mem): Mark parameter `ignore' with
ATTRIBUTE_UNUSED.
(reload_cse_check_clobber): Likewise.
* rtl.h (expand_null_return, reg_classes_intersect_p): Add prototype.
(mark_elimination): Fix typo in prototype.
* scan-decls.c: Include gansidecl.h.
* tree.h (using_eh_for_cleanups, supports_one_only): Add prototype.
From-SVN: r19867
1998-05-19 10:42:48 +02:00
|
|
|
|
#include "cpplib.h"
|
2004-05-24 12:50:45 +02:00
|
|
|
|
#include "internal.h"
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
#define PART_PRECISION (sizeof (cpp_num_part) * CHAR_BIT)
|
|
|
|
|
#define HALF_MASK (~(cpp_num_part) 0 >> (PART_PRECISION / 2))
|
|
|
|
|
#define LOW_PART(num_part) (num_part & HALF_MASK)
|
|
|
|
|
#define HIGH_PART(num_part) (num_part >> (PART_PRECISION / 2))
|
|
|
|
|
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
struct op
|
cppfiles.c (_cpp_find_include_file): Make sure ih->name is initialized.
* cppfiles.c (_cpp_find_include_file): Make sure ih->name is
initialized.
* cppinit.c (cpp_cleanup): Free imp->nshort also.
* cpperror.c (cpp_print_containing_files,
cpp_print_file_and_line, v_cpp_message): Rename to
print_containing_files, print_file_and_line, and v_message.
* cppexp.c (cpp_parse_expr, cpp_parse_escape, cpp_lex): Rename
to _cpp_parse_expr, parse_escape, and lex.
(parse_charconst): Remove broken multibyte support.
* cppfiles.c (include_hash): Make static.
(cpp_included): New function.
(merge_include_chains, find_include_file, finclude,
simplify_pathname): Rename to _cpp_merge_include_chains,
_cpp_find_include_file, _cpp_read_include_file, and
_cpp_simplify_pathname.
* cpphash.c (cpp_lookup, free_definition, delete_macro,
cpp_install, create_definition, macroexpand, compare_defs,
dump_definition): Rename to _cpp_lookup, _cpp_free_definition,
_cpp_delete_macro, _cpp_install, _cpp_create_definition,
_cpp_macroexpand, _cpp_compare_defs, and _cpp_dump_definition.
* cppinit.c (cpp_handle_option): Rename to handle_option, make
static.
* cpplib.c: Remove extern prototype of cpp_parse_expr.
* cpphash.h: Update prototypes.
* cpplib.h: Likewise. Prototype _cpp_parse_expr here.
From-SVN: r32390
2000-03-07 21:58:47 +01:00
|
|
|
|
{
|
2002-07-20 15:31:56 +02:00
|
|
|
|
const cpp_token *token; /* The token forming op (for diagnostics). */
|
2002-07-19 00:08:35 +02:00
|
|
|
|
cpp_num value; /* The value logically "right" of op. */
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
enum cpp_ttype op;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
};
|
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
/* Some simple utility routines on double integers. */
|
|
|
|
|
#define num_zerop(num) ((num.low | num.high) == 0)
|
|
|
|
|
#define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high)
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
static bool num_positive (cpp_num, size_t);
|
|
|
|
|
static bool num_greater_eq (cpp_num, cpp_num, size_t);
|
|
|
|
|
static cpp_num num_trim (cpp_num, size_t);
|
|
|
|
|
static cpp_num num_part_mul (cpp_num_part, cpp_num_part);
|
|
|
|
|
|
|
|
|
|
static cpp_num num_unary_op (cpp_reader *, cpp_num, enum cpp_ttype);
|
|
|
|
|
static cpp_num num_binary_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
|
|
|
|
|
static cpp_num num_negate (cpp_num, size_t);
|
|
|
|
|
static cpp_num num_bitwise_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
|
|
|
|
|
static cpp_num num_inequality_op (cpp_reader *, cpp_num, cpp_num,
|
|
|
|
|
enum cpp_ttype);
|
|
|
|
|
static cpp_num num_equality_op (cpp_reader *, cpp_num, cpp_num,
|
|
|
|
|
enum cpp_ttype);
|
|
|
|
|
static cpp_num num_mul (cpp_reader *, cpp_num, cpp_num);
|
|
|
|
|
static cpp_num num_div_op (cpp_reader *, cpp_num, cpp_num, enum cpp_ttype);
|
|
|
|
|
static cpp_num num_lshift (cpp_num, size_t, size_t);
|
|
|
|
|
static cpp_num num_rshift (cpp_num, size_t, size_t);
|
|
|
|
|
|
|
|
|
|
static cpp_num append_digit (cpp_num, int, int, size_t);
|
|
|
|
|
static cpp_num parse_defined (cpp_reader *);
|
|
|
|
|
static cpp_num eval_token (cpp_reader *, const cpp_token *);
|
|
|
|
|
static struct op *reduce (cpp_reader *, struct op *, enum cpp_ttype);
|
|
|
|
|
static unsigned int interpret_float_suffix (const uchar *, size_t);
|
|
|
|
|
static unsigned int interpret_int_suffix (const uchar *, size_t);
|
|
|
|
|
static void check_promotion (cpp_reader *, const struct op *);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
/* Token type abuse to create unary plus and minus operators. */
|
2005-05-28 17:52:48 +02:00
|
|
|
|
#define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
|
|
|
|
|
#define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2))
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
/* With -O2, gcc appears to produce nice code, moving the error
|
|
|
|
|
message load and subsequent jump completely out of the main path. */
|
|
|
|
|
#define SYNTAX_ERROR(msgid) \
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
do { cpp_error (pfile, CPP_DL_ERROR, msgid); goto syntax_error; } while(0)
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
#define SYNTAX_ERROR2(msgid, arg) \
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
do { cpp_error (pfile, CPP_DL_ERROR, msgid, arg); goto syntax_error; } \
|
|
|
|
|
while(0)
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
/* Subroutine of cpp_classify_number. S points to a float suffix of
|
|
|
|
|
length LEN, possibly zero. Returns 0 for an invalid suffix, or a
|
|
|
|
|
flag vector describing the suffix. */
|
|
|
|
|
static unsigned int
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
interpret_float_suffix (const uchar *s, size_t len)
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
{
|
2005-12-07 00:13:15 +01:00
|
|
|
|
size_t f = 0, l = 0, i = 0, d = 0;
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
while (len--)
|
|
|
|
|
switch (s[len])
|
|
|
|
|
{
|
|
|
|
|
case 'f': case 'F': f++; break;
|
|
|
|
|
case 'l': case 'L': l++; break;
|
|
|
|
|
case 'i': case 'I':
|
|
|
|
|
case 'j': case 'J': i++; break;
|
2005-12-07 00:13:15 +01:00
|
|
|
|
case 'd': case 'D':
|
|
|
|
|
/* Disallow fd, ld suffixes. */
|
|
|
|
|
if (d && (f || l))
|
|
|
|
|
return 0;
|
|
|
|
|
d++;
|
|
|
|
|
break;
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
if (f + l > 1 || i > 1)
|
|
|
|
|
return 0;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
2005-12-07 00:13:15 +01:00
|
|
|
|
/* Allow dd, df, dl suffixes for decimal float constants. */
|
|
|
|
|
if (d && ((d + f + l != 2) || i))
|
|
|
|
|
return 0;
|
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
return ((i ? CPP_N_IMAGINARY : 0)
|
|
|
|
|
| (f ? CPP_N_SMALL :
|
2005-12-07 00:13:15 +01:00
|
|
|
|
l ? CPP_N_LARGE : CPP_N_MEDIUM)
|
|
|
|
|
| (d ? CPP_N_DFLOAT : 0));
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Subroutine of cpp_classify_number. S points to an integer suffix
|
|
|
|
|
of length LEN, possibly zero. Returns 0 for an invalid suffix, or a
|
|
|
|
|
flag vector describing the suffix. */
|
|
|
|
|
static unsigned int
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
interpret_int_suffix (const uchar *s, size_t len)
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
{
|
|
|
|
|
size_t u, l, i;
|
|
|
|
|
|
|
|
|
|
u = l = i = 0;
|
|
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
|
switch (s[len])
|
|
|
|
|
{
|
|
|
|
|
case 'u': case 'U': u++; break;
|
|
|
|
|
case 'i': case 'I':
|
|
|
|
|
case 'j': case 'J': i++; break;
|
|
|
|
|
case 'l': case 'L': l++;
|
|
|
|
|
/* If there are two Ls, they must be adjacent and the same case. */
|
|
|
|
|
if (l == 2 && s[len] != s[len + 1])
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (l > 2 || u > 1 || i > 1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return ((i ? CPP_N_IMAGINARY : 0)
|
|
|
|
|
| (u ? CPP_N_UNSIGNED : 0)
|
|
|
|
|
| ((l == 0) ? CPP_N_SMALL
|
|
|
|
|
: (l == 1) ? CPP_N_MEDIUM : CPP_N_LARGE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Categorize numeric constants according to their field (integer,
|
|
|
|
|
floating point, or invalid), radix (decimal, octal, hexadecimal),
|
|
|
|
|
and type suffixes. */
|
|
|
|
|
unsigned int
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
{
|
|
|
|
|
const uchar *str = token->val.str.text;
|
|
|
|
|
const uchar *limit;
|
|
|
|
|
unsigned int max_digit, result, radix;
|
|
|
|
|
enum {NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON} float_flag;
|
|
|
|
|
|
|
|
|
|
/* If the lexer has done its job, length one can only be a single
|
|
|
|
|
digit. Fast-path this very common case. */
|
|
|
|
|
if (token->val.str.len == 1)
|
|
|
|
|
return CPP_N_INTEGER | CPP_N_SMALL | CPP_N_DECIMAL;
|
|
|
|
|
|
|
|
|
|
limit = str + token->val.str.len;
|
|
|
|
|
float_flag = NOT_FLOAT;
|
|
|
|
|
max_digit = 0;
|
|
|
|
|
radix = 10;
|
|
|
|
|
|
|
|
|
|
/* First, interpret the radix. */
|
|
|
|
|
if (*str == '0')
|
|
|
|
|
{
|
|
|
|
|
radix = 8;
|
|
|
|
|
str++;
|
|
|
|
|
|
|
|
|
|
/* Require at least one hex digit to classify it as hex. */
|
2003-03-31 17:50:53 +02:00
|
|
|
|
if ((*str == 'x' || *str == 'X')
|
|
|
|
|
&& (str[1] == '.' || ISXDIGIT (str[1])))
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
{
|
|
|
|
|
radix = 16;
|
|
|
|
|
str++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now scan for a well-formed integer or float. */
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
unsigned int c = *str++;
|
|
|
|
|
|
|
|
|
|
if (ISDIGIT (c) || (ISXDIGIT (c) && radix == 16))
|
|
|
|
|
{
|
|
|
|
|
c = hex_value (c);
|
|
|
|
|
if (c > max_digit)
|
|
|
|
|
max_digit = c;
|
|
|
|
|
}
|
|
|
|
|
else if (c == '.')
|
|
|
|
|
{
|
|
|
|
|
if (float_flag == NOT_FLOAT)
|
|
|
|
|
float_flag = AFTER_POINT;
|
|
|
|
|
else
|
|
|
|
|
SYNTAX_ERROR ("too many decimal points in number");
|
|
|
|
|
}
|
|
|
|
|
else if ((radix <= 10 && (c == 'e' || c == 'E'))
|
|
|
|
|
|| (radix == 16 && (c == 'p' || c == 'P')))
|
|
|
|
|
{
|
|
|
|
|
float_flag = AFTER_EXPON;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Start of suffix. */
|
|
|
|
|
str--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (float_flag != NOT_FLOAT && radix == 8)
|
|
|
|
|
radix = 10;
|
|
|
|
|
|
|
|
|
|
if (max_digit >= radix)
|
|
|
|
|
SYNTAX_ERROR2 ("invalid digit \"%c\" in octal constant", '0' + max_digit);
|
|
|
|
|
|
|
|
|
|
if (float_flag != NOT_FLOAT)
|
|
|
|
|
{
|
|
|
|
|
if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"use of C99 hexadecimal floating constant");
|
|
|
|
|
|
|
|
|
|
if (float_flag == AFTER_EXPON)
|
|
|
|
|
{
|
|
|
|
|
if (*str == '+' || *str == '-')
|
|
|
|
|
str++;
|
|
|
|
|
|
|
|
|
|
/* Exponent is decimal, even if string is a hex float. */
|
|
|
|
|
if (!ISDIGIT (*str))
|
|
|
|
|
SYNTAX_ERROR ("exponent has no digits");
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
str++;
|
|
|
|
|
while (ISDIGIT (*str));
|
|
|
|
|
}
|
|
|
|
|
else if (radix == 16)
|
|
|
|
|
SYNTAX_ERROR ("hexadecimal floating constants require an exponent");
|
|
|
|
|
|
|
|
|
|
result = interpret_float_suffix (str, limit - str);
|
|
|
|
|
if (result == 0)
|
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"invalid suffix \"%.*s\" on floating constant",
|
2002-06-01 16:11:45 +02:00
|
|
|
|
(int) (limit - str), str);
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
return CPP_N_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Traditional C didn't accept any floating suffixes. */
|
|
|
|
|
if (limit != str
|
|
|
|
|
&& CPP_WTRADITIONAL (pfile)
|
|
|
|
|
&& ! cpp_sys_macro_p (pfile))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"traditional C rejects the \"%.*s\" suffix",
|
2002-06-01 16:11:45 +02:00
|
|
|
|
(int) (limit - str), str);
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
|
2005-12-07 00:13:15 +01:00
|
|
|
|
/* Radix must be 10 for decimal floats. */
|
|
|
|
|
if ((result & CPP_N_DFLOAT) && radix != 10)
|
|
|
|
|
{
|
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
|
|
|
|
"invalid suffix \"%.*s\" with hexadecimal floating constant",
|
|
|
|
|
(int) (limit - str), str);
|
|
|
|
|
return CPP_N_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
result |= CPP_N_FLOATING;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = interpret_int_suffix (str, limit - str);
|
|
|
|
|
if (result == 0)
|
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"invalid suffix \"%.*s\" on integer constant",
|
2002-06-01 16:11:45 +02:00
|
|
|
|
(int) (limit - str), str);
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
return CPP_N_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 06:18:16 +02:00
|
|
|
|
/* Traditional C only accepted the 'L' suffix.
|
|
|
|
|
Suppress warning about 'LL' with -Wno-long-long. */
|
|
|
|
|
if (CPP_WTRADITIONAL (pfile) && ! cpp_sys_macro_p (pfile))
|
|
|
|
|
{
|
|
|
|
|
int u_or_i = (result & (CPP_N_UNSIGNED|CPP_N_IMAGINARY));
|
|
|
|
|
int large = (result & CPP_N_WIDTH) == CPP_N_LARGE;
|
|
|
|
|
|
|
|
|
|
if (u_or_i || (large && CPP_OPTION (pfile, warn_long_long)))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
2002-08-02 06:18:16 +02:00
|
|
|
|
"traditional C rejects the \"%.*s\" suffix",
|
|
|
|
|
(int) (limit - str), str);
|
|
|
|
|
}
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
|
|
|
|
|
if ((result & CPP_N_WIDTH) == CPP_N_LARGE
|
|
|
|
|
&& ! CPP_OPTION (pfile, c99)
|
|
|
|
|
&& CPP_OPTION (pfile, warn_long_long))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
|
|
|
|
"use of C99 long long integer constant");
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
|
|
|
|
|
result |= CPP_N_INTEGER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
|
|
|
|
"imaginary constants are a GCC extension");
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
|
|
|
|
|
if (radix == 10)
|
|
|
|
|
result |= CPP_N_DECIMAL;
|
|
|
|
|
else if (radix == 16)
|
|
|
|
|
result |= CPP_N_HEX;
|
|
|
|
|
else
|
|
|
|
|
result |= CPP_N_OCTAL;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
syntax_error:
|
|
|
|
|
return CPP_N_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cpp_interpret_integer converts an integer constant into a cpp_num,
|
|
|
|
|
of precision options->precision.
|
|
|
|
|
|
|
|
|
|
We do not provide any interface for decimal->float conversion,
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
because the preprocessor doesn't need it and we don't want to
|
|
|
|
|
drag in GCC's floating point emulator. */
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
cpp_interpret_integer (cpp_reader *pfile, const cpp_token *token,
|
|
|
|
|
unsigned int type)
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
{
|
|
|
|
|
const uchar *p, *end;
|
|
|
|
|
cpp_num result;
|
|
|
|
|
|
|
|
|
|
result.low = 0;
|
|
|
|
|
result.high = 0;
|
2002-07-17 19:27:14 +02:00
|
|
|
|
result.unsignedp = !!(type & CPP_N_UNSIGNED);
|
|
|
|
|
result.overflow = false;
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
|
|
|
|
|
p = token->val.str.text;
|
|
|
|
|
end = p + token->val.str.len;
|
|
|
|
|
|
|
|
|
|
/* Common case of a single digit. */
|
|
|
|
|
if (token->val.str.len == 1)
|
|
|
|
|
result.low = p[0] - '0';
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cpp_num_part max;
|
|
|
|
|
size_t precision = CPP_OPTION (pfile, precision);
|
|
|
|
|
unsigned int base = 10, c = 0;
|
|
|
|
|
bool overflow = false;
|
|
|
|
|
|
|
|
|
|
if ((type & CPP_N_RADIX) == CPP_N_OCTAL)
|
|
|
|
|
{
|
|
|
|
|
base = 8;
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
else if ((type & CPP_N_RADIX) == CPP_N_HEX)
|
|
|
|
|
{
|
|
|
|
|
base = 16;
|
|
|
|
|
p += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We can add a digit to numbers strictly less than this without
|
|
|
|
|
needing the precision and slowness of double integers. */
|
|
|
|
|
max = ~(cpp_num_part) 0;
|
|
|
|
|
if (precision < PART_PRECISION)
|
|
|
|
|
max >>= PART_PRECISION - precision;
|
|
|
|
|
max = (max - base + 1) / base + 1;
|
|
|
|
|
|
|
|
|
|
for (; p < end; p++)
|
|
|
|
|
{
|
|
|
|
|
c = *p;
|
|
|
|
|
|
|
|
|
|
if (ISDIGIT (c) || (base == 16 && ISXDIGIT (c)))
|
|
|
|
|
c = hex_value (c);
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Strict inequality for when max is set to zero. */
|
|
|
|
|
if (result.low < max)
|
|
|
|
|
result.low = result.low * base + c;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = append_digit (result, c, base, precision);
|
|
|
|
|
overflow |= result.overflow;
|
|
|
|
|
max = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (overflow)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"integer constant is too large for its type");
|
2002-06-20 22:34:19 +02:00
|
|
|
|
/* If too big to be signed, consider it unsigned. Only warn for
|
|
|
|
|
decimal numbers. Traditional numbers were always signed (but
|
2002-09-16 13:42:00 +02:00
|
|
|
|
we still honor an explicit U suffix); but we only have
|
2002-07-10 00:21:37 +02:00
|
|
|
|
traditional semantics in directives. */
|
2002-06-20 22:34:19 +02:00
|
|
|
|
else if (!result.unsignedp
|
2002-07-10 00:21:37 +02:00
|
|
|
|
&& !(CPP_OPTION (pfile, traditional)
|
|
|
|
|
&& pfile->state.in_directive)
|
2002-06-20 22:34:19 +02:00
|
|
|
|
&& !num_positive (result, precision))
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
{
|
|
|
|
|
if (base == 10)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"integer constant is so large that it is unsigned");
|
2002-07-17 19:27:14 +02:00
|
|
|
|
result.unsignedp = true;
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
/* Append DIGIT to NUM, a number of PRECISION bits being read in base BASE. */
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
append_digit (cpp_num num, int digit, int base, size_t precision)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num result;
|
|
|
|
|
unsigned int shift = 3 + (base == 16);
|
|
|
|
|
bool overflow;
|
|
|
|
|
cpp_num_part add_high, add_low;
|
|
|
|
|
|
|
|
|
|
/* Multiply by 8 or 16. Catching this overflow here means we don't
|
|
|
|
|
need to worry about add_high overflowing. */
|
2002-07-17 19:27:14 +02:00
|
|
|
|
overflow = !!(num.high >> (PART_PRECISION - shift));
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
result.high = num.high << shift;
|
|
|
|
|
result.low = num.low << shift;
|
|
|
|
|
result.high |= num.low >> (PART_PRECISION - shift);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.unsignedp = num.unsignedp;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
|
|
|
|
if (base == 10)
|
|
|
|
|
{
|
|
|
|
|
add_low = num.low << 1;
|
|
|
|
|
add_high = (num.high << 1) + (num.low >> (PART_PRECISION - 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
add_high = add_low = 0;
|
|
|
|
|
|
|
|
|
|
if (add_low + digit < add_low)
|
|
|
|
|
add_high++;
|
|
|
|
|
add_low += digit;
|
|
|
|
|
|
|
|
|
|
if (result.low + add_low < result.low)
|
|
|
|
|
add_high++;
|
|
|
|
|
if (result.high + add_high < result.high)
|
|
|
|
|
overflow = true;
|
|
|
|
|
|
|
|
|
|
result.low += add_low;
|
|
|
|
|
result.high += add_high;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.overflow = overflow;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
|
|
|
|
/* The above code catches overflow of a cpp_num type. This catches
|
|
|
|
|
overflow of the (possibly shorter) target precision. */
|
|
|
|
|
num.low = result.low;
|
|
|
|
|
num.high = result.high;
|
|
|
|
|
result = num_trim (result, precision);
|
|
|
|
|
if (!num_eq (result, num))
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.overflow = true;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-03 22:43:09 +01:00
|
|
|
|
/* Handle meeting "defined" in a preprocessor expression. */
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
parse_defined (cpp_reader *pfile)
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
{
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
cpp_num result;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
int paren = 0;
|
|
|
|
|
cpp_hashnode *node = 0;
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
const cpp_token *token;
|
2001-11-05 23:26:13 +01:00
|
|
|
|
cpp_context *initial_context = pfile->context;
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
/* Don't expand macros. */
|
|
|
|
|
pfile->state.prevent_expansion++;
|
|
|
|
|
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
token = cpp_get_token (pfile);
|
|
|
|
|
if (token->type == CPP_OPEN_PAREN)
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
{
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
paren = 1;
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
token = cpp_get_token (pfile);
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
if (token->type == CPP_NAME)
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
{
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
node = token->val.node;
|
|
|
|
|
if (paren && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR, "missing ')' after \"defined\"");
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
node = 0;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2001-02-06 21:07:07 +01:00
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
cpperror.c (print_location): Don't print include chain if line == 0.
* cpperror.c (print_location): Don't print include chain
if line == 0.
(cpp_begin_message): Update to use DL_ macros.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppexp.c (CPP_ICE): Remove.
(SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
lex, integer_overflow, _cpp_parse_expr): Update.
* cppfiles.c (read_include_file, find_include_file,
handle_missing_header, _cpp_read_file, remap_filename): Update.
* cpphash.h (enum error_type): Remove.
(_cpp_begin_message): Update.
* cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
cpp_handle_option, cpp_post_options): Update.
* cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
skip_whitespace, parse_identifier, parse_slow, parse_string,
_cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
cpp_interpret_charconst): Update.
* cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
lex_macro_node, do_undef, glue_header_name, parse_include,
do_include_common, read_flag, do_line, do_linemarker, do_ident,
cpp_register_pragma, do_pragma_once, do_pragma_system_header,
do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
do_elif, do_endif, parse_answer, parse_assertion, do_assert,
_cpp_pop_buffer, do_diagnostic): Update.
* cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
collect_args, enter_macro_context, save_parameter, parse_params,
_cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Update.
* cppmain.c (cpp_preprocess_file): Update.
* fix-header.c (read_scan_file): Update.
From-SVN: r52302
2002-04-14 20:42:47 +02:00
|
|
|
|
"operator \"defined\" requires an identifier");
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
if (token->flags & NAMED_OP)
|
2001-02-06 21:07:07 +01:00
|
|
|
|
{
|
|
|
|
|
cpp_token op;
|
|
|
|
|
|
|
|
|
|
op.flags = 0;
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
op.type = token->type;
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
2001-02-06 21:07:07 +01:00
|
|
|
|
"(\"%s\" is an alternative token for \"%s\" in C++)",
|
c-lex.c (cb_def_pragma): Update.
* c-lex.c (cb_def_pragma): Update.
(c_lex): Update, and skip padding.
* cppexp.c (lex, parse_defined): Update, remove unused variable.
* cpphash.h (struct toklist): Delete.
(union utoken): New.
(struct cpp_context): Update.
(struct cpp_reader): New members eof, avoid_paste.
(_cpp_temp_token): New.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (_cpp_temp_token): New.
(_cpp_lex_direct): Add PREV_WHITE when parsing args.
(cpp_output_token): Don't print leading whitespace.
(cpp_output_line): Update.
* cpplib.c (glue_header_name, parse_include, get__Pragma_string,
do_include_common, do_line, do_ident, do_pragma,
do_pragma_dependency, _cpp_do__Pragma, parse_answer,
parse_assertion): Update.
(get_token_no_padding): New.
* cpplib.h (CPP_PADDING): New.
(AVOID_LPASTE): Delete.
(struct cpp_token): New union member source.
(cpp_get_token): Update.
* cppmacro.c (macro_arg): Convert to use pointers to const tokens.
(builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p,
replace_args, quote_string, stringify_arg, parse_arg, next_context,
enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput,
_cpp_backup_tokens, _cpp_create_definition): Update.
(push_arg_context): Delete.
(padding_token, push_token_context, push_ptoken_context): New.
(make_string_token, make_number_token): Update, rename.
(cpp_get_token): Update to handle tokens as pointers to const,
and insert padding appropriately.
* cppmain.c (struct printer): New member prev.
(check_multiline_token): Constify.
(do_preprocessing, cb_line_change): Update.
(scan_translation_unit): Update to handle spacing.
* scan-decls.c (get_a_token): New.
(skip_to_closing_brace, scan_decls): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi: Update.
* gcc.dg/cpp/macro10.c: New test.
* gcc.dg/cpp/strify3.c: New test.
* gcc.dg/cpp/spacing1.c: Add tests.
* gcc.dg/cpp/19990703-1.c: Remove bogus test.
* gcc.dg/cpp/20000625-2.c: Fudge to pass.
From-SVN: r45793
2001-09-25 00:53:12 +02:00
|
|
|
|
cpp_token_as_text (pfile, token),
|
2001-02-06 21:07:07 +01:00
|
|
|
|
cpp_token_as_text (pfile, &op));
|
|
|
|
|
}
|
|
|
|
|
}
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (node)
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
{
|
2003-08-03 14:23:46 +02:00
|
|
|
|
if (pfile->context != initial_context && CPP_PEDANTIC (pfile))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
cpperror.c (print_location): Don't print include chain if line == 0.
* cpperror.c (print_location): Don't print include chain
if line == 0.
(cpp_begin_message): Update to use DL_ macros.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppexp.c (CPP_ICE): Remove.
(SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
lex, integer_overflow, _cpp_parse_expr): Update.
* cppfiles.c (read_include_file, find_include_file,
handle_missing_header, _cpp_read_file, remap_filename): Update.
* cpphash.h (enum error_type): Remove.
(_cpp_begin_message): Update.
* cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
cpp_handle_option, cpp_post_options): Update.
* cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
skip_whitespace, parse_identifier, parse_slow, parse_string,
_cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
cpp_interpret_charconst): Update.
* cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
lex_macro_node, do_undef, glue_header_name, parse_include,
do_include_common, read_flag, do_line, do_linemarker, do_ident,
cpp_register_pragma, do_pragma_once, do_pragma_system_header,
do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
do_elif, do_endif, parse_answer, parse_assertion, do_assert,
_cpp_pop_buffer, do_diagnostic): Update.
* cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
collect_args, enter_macro_context, save_parameter, parse_params,
_cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Update.
* cppmain.c (cpp_preprocess_file): Update.
* fix-header.c (read_scan_file): Update.
From-SVN: r52302
2002-04-14 20:42:47 +02:00
|
|
|
|
"this use of \"defined\" may not be portable");
|
2001-11-05 23:26:13 +01:00
|
|
|
|
|
2002-07-24 00:57:49 +02:00
|
|
|
|
_cpp_mark_macro_used (node);
|
|
|
|
|
|
2001-07-29 19:27:57 +02:00
|
|
|
|
/* A possible controlling macro of the form #if !defined ().
|
|
|
|
|
_cpp_parse_expr checks there was no other junk on the line. */
|
|
|
|
|
pfile->mi_ind_cmacro = node;
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
}
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
|
|
|
|
|
pfile->state.prevent_expansion--;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-17 19:27:14 +02:00
|
|
|
|
result.unsignedp = false;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
result.high = 0;
|
2002-07-17 19:27:14 +02:00
|
|
|
|
result.overflow = false;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
result.low = node && node->type == NT_MACRO;
|
|
|
|
|
return result;
|
cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
(lex): Call it for CPP_HASH. Remove CPP_ASSERTION case.
(_cpp_parse_expr): Remove case '#'. Don't set
parsing_if_directive.
* cpphash.c (collect_objlike_expansion,
collect_funlike_expansion, collect_params,
_cpp_create_definition): The list no longer has a trailing
VSPACE token.
* cpphash.h (enum node_type): Add T_ASSERTION.
(struct hashnode): Remove aschain, add pred.
(struct predicate): New.
Update prototypes.
* cpplex.c (expand_token_space): Handle both offset and
nonoffset lists.
(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
_cpp_equiv_toklists): New.
(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
stop at any single-character token, not just newline.
(_cpp_lex_token): Remove special cases for #define and #if.
(cpp_get_token): Expect # as a separate token type. Remove
DIRECTIVE case.
(_cpp_get_directive_token): Remove DIRECTIVE case.
(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.
* cpplib.c (_cpp_check_directive): Set dirno and
SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
(_cpp_handle_directive): Run # <number> through the same logic
as normal directives.
(do_define): Don't set parsing_define_directive. Use
_cpp_scan_until. The list does not have a VSPACE at the end.
(do_if): Save, clear, and restore only_seen_white around
_cpp_parse_expr.
(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
(do_assert, do_unassert): Rewrite.
* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
(LIST_OFFSET): New flag.
(struct cpp_toklist): Replace dir_handler and dir_flags with
dirno and flags.
(struct cpp_reader): Remove parsing_if_directive and
parsing_define_directive.
From-SVN: r33984
2000-05-18 17:55:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-29 01:14:56 +02:00
|
|
|
|
/* Convert a token into a CPP_NUMBER (an interpreted preprocessing
|
|
|
|
|
number or character constant, or the result of the "defined" or "#"
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
operators). */
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
eval_token (cpp_reader *pfile, const cpp_token *token)
|
1995-03-16 22:59:07 +01:00
|
|
|
|
{
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
cpp_num result;
|
2002-04-29 01:14:56 +02:00
|
|
|
|
unsigned int temp;
|
2002-05-04 09:30:32 +02:00
|
|
|
|
int unsignedp = 0;
|
top level:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* fix-header.c (struct partial_proto): Remove unnecessary fields.
(recognized_extern, recognized_function, read_scan_file):
Update for new scheme.
(check_protection): It's still a multiple include guard even
if it doesn't always trigger.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new scheme.
* scan.h: Declare struct cpp_token. Update prototypes.
2000-07-03 Neil Booth <neilb@earthling.net>
Zack Weinberg <zack@wolery.cumb.org>
Complete overhaul of the lexer and macro expander.
* cpphash.c (object_defn, funct_defn, push_macro_expansion,
arg, arglist, argdata, reflist, collect_objlike_expansion,
collect_funlike_expansion, collect_params,
warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat,
unsafe_chars, macarg, compare_defs, special_symbol,
scan_arguments, stringify, funlike_macroexpand,
_cpp_quote_string, monthnames): Delete.
(cpp_lookup, _cpp_free_definition, dump_funlike_macro,
_cpp_create_definition, _cpp_dump_definition,
dump_hash_helper): Adjust.
(find_param, count_params, parse_define, var_args_str,
check_macro_redefinition, save_expansion): New.
* cpplex.c (skip_block_comment, skip_line_comment, parse_name,
parse_string, output_line_command, trigraph_replace,
lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens,
cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist,
cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer,
_cpp_skip_rest_of_line): Modify.
(maybe_macroexpand, skip_comment, copy_comment, skip_string,
find_position, null_warning, bump_column, expand_name_space,
pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist,
_cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace,
_cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token,
_cpp_prescan): Delete.
(dump_param_spelling, process_directive, lex_next,
is_macro_disabled, stringify_arg, expand_context_stack,
output_token, make_string_token, alloc_number_token,
special_symbol, duplicate_token, maybe_paste_with_next,
can_paste, prevent_macro_expansion, restore_macro_expansion,
get_temp_token, release_temp_tokens, quote_string,
token_names, token_spellings, _cpp_expand_name_space,
_cpp_glue_header_name, _cpp_reserve_name_space,
digraph_spellings, trigraph_ok, skip_whitespace, save_comment,
placemarker_token, eof_token, cpp_context, macro_args,
get_raw_token, parse_arg, parse_args, save_token,
push_arg_context, push_macro_context, pop_context,
do_pop_context, free_macro_args, _cpp_get_line,
_cpp_run_directive): New.
* cpplib.c (validate_else, parse_include, push_conditional,
pass_thru_directive, read_line_number, parse_ifdef,
detect_if_not_defined, _cpp_check_directive, do_define,
do_undef, do_include, do_import, do_include_next, do_error,
do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas,
top_pragmas, do_pragma_gcc, do_pragma_implementation,
do_pragma_poison, do_pragma_system_header,
do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else,
dl_elif, do_endif, _cpp_unwind_if_stack, do_assert,
do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert,
cpp_defined): Update for new scheme.
(strtoul_for_line, get_define_node, dump_macro_name,
_cpp_check_linemarker, _cpp_parse_assertion): New.
(_cpp_handle_directive, do_pragma_default): Delete.
* cpphash.h (struct predicate): Now struct answer.
(enum spell_type, struct token_spelling, struct directive,
directive_handler): New.
Update prototypes. Remove unused macros.
* cpplib.h: Update prototypes. Remove unused macros,
structure definitions, and fields.
* cpperror.c (print_containing_files, v_message): Adjust.
* cppexp.c (parse_assertion, lex, parse_escape,
_cpp_parse_expr): Adjust.
* cppfiles.c (open_include_file, _cpp_execute_include,
_cpp_compare_file_date, cpp_read_file, read_include_file):
Adjust.
* cppinit.c (dump_special_to_buffer): Delete.
(append_include_chain, merge_include_chains, cpp_reader_init,
cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read,
cpp_finish, handle_option, print_help): Adjust.
* cppmain.c (main): Adjust.
testsuite:
2000-07-03 Zack Weinberg <zack@wolery.cumb.org>
* testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps.
* testsuite/gcc.dg/cpp/19990703-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-1.c: Likewise.
* testsuite/gcc.dg/cpp/20000625-2.c: Likewise.
* testsuite/gcc.dg/cpp/macro1.c,
testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c,
testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c,
testsuite/gcc.dg/cpp/strify1.c,
testsuite/gcc.dg/cpp/strify2.c: New tests.
From-SVN: r34859
2000-07-04 03:58:21 +02:00
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.unsignedp = false;
|
|
|
|
|
result.overflow = false;
|
|
|
|
|
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
switch (token->type)
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
{
|
1995-03-16 22:59:07 +01:00
|
|
|
|
case CPP_NUMBER:
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
temp = cpp_classify_number (pfile, token);
|
|
|
|
|
switch (temp & CPP_N_CATEGORY)
|
|
|
|
|
{
|
|
|
|
|
case CPP_N_FLOATING:
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"floating constant in preprocessor expression");
|
|
|
|
|
break;
|
|
|
|
|
case CPP_N_INTEGER:
|
|
|
|
|
if (!(temp & CPP_N_IMAGINARY))
|
|
|
|
|
return cpp_interpret_integer (pfile, token, temp);
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR,
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
"imaginary number in preprocessor expression");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CPP_N_INVALID:
|
|
|
|
|
/* Error already issued. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result.high = result.low = 0;
|
|
|
|
|
break;
|
2000-11-14 19:32:06 +01:00
|
|
|
|
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
case CPP_WCHAR:
|
2002-05-04 09:30:32 +02:00
|
|
|
|
case CPP_CHAR:
|
2002-05-07 00:53:10 +02:00
|
|
|
|
{
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
cppchar_t cc = cpp_interpret_charconst (pfile, token,
|
|
|
|
|
&temp, &unsignedp);
|
|
|
|
|
|
|
|
|
|
result.high = 0;
|
|
|
|
|
result.low = cc;
|
2002-05-07 00:53:10 +02:00
|
|
|
|
/* Sign-extend the result if necessary. */
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (!unsignedp && (cppchar_signed_t) cc < 0)
|
|
|
|
|
{
|
|
|
|
|
if (PART_PRECISION > BITS_PER_CPPCHAR_T)
|
|
|
|
|
result.low |= ~(~(cpp_num_part) 0
|
|
|
|
|
>> (PART_PRECISION - BITS_PER_CPPCHAR_T));
|
|
|
|
|
result.high = ~(cpp_num_part) 0;
|
|
|
|
|
result = num_trim (result, CPP_OPTION (pfile, precision));
|
|
|
|
|
}
|
2002-05-07 00:53:10 +02:00
|
|
|
|
}
|
2002-04-29 01:14:56 +02:00
|
|
|
|
break;
|
cpplib.h (CPP_ASSERTION, [...]): New token types.
* cpplib.h (CPP_ASSERTION, CPP_STRINGIZE, CPP_TOKPASTE): New
token types.
(struct cpp_reader): Add parsing_if_directive and
parsing_define_directive flags.
(struct cpp_options): Remove output_conditionals flag.
(check_macro_name): Delete prototype.
* cpphash.h (struct macrodef): Delete.
(struct reflist): Separate from struct definition.
(struct definition): Remove unused fields. Add column number.
(create_definition): Returns a DEFINITION *. Takes a
cpp_reader * and an int.
* cpphash.c (SKIP_WHITE_SPACE): Delete.
(PEEKC): Copy defn from cpplib.c.
(rest_extension, REST_EXTENSION_LENGTH): Delete.
(struct arg): New.
(struct arglist): Simplify.
(collect_expansion): Rewrite. Get tokens by calling
cpp_get_token. Add more error checking.
(collect_formal_parameters): New function, broken out of
create_definition and reworked to use get_directive_token.
(create_definition): All real work is now in collect_expansion
and collect_formal_parameters. do_define handles finding the
macro name. Return a DEFINITION, not a MACRODEF.
(macroexpand): Replace bcopy with memcpy throughout. Replace
character-at-a-time copy loop with memcpy and pointer increments.
(compare-defs): d1->argnames / d2->argnames might be null.
* cpplib.c (copy_rest_of_line): Delete function.
(skip_rest_of_line): Do all the work ourselves.
(skip_string): New function.
(parse_string): Use skip_string.
(get_macro_name): New function.
(check_macro_name): Delete.
(copy_comment): Use CPP_RESERVE and CPP_PUTC_Q.
(cpp_skip_hspace): Use CPP_BUMP_LINE.
(handle_directive): ICE if we're called on a macro buffer.
(do_define): Determine macro name and type (funlike/objlike)
here. Expunge all uses of MACRODEF.
(cpp_push_buffer): Set line_base to NULL.
(do_undef, read_line_number): Don't worry about getting a POP token.
(eval_if_expression): Set/reset parsing_if_directive around
cpp_parse_expr. Don't clear only_seen_white.
(skip_if_group): Remove output_conditionals logic. Use
skip_rest_of_line.
(cpp_get_token): Return ASSERTION, STRINGIZE, and TOKPASTE
tokens under appropriate conditions.
(cpp_unassert): Call do_unassert not do_assert. Oops.
* cppexp.c (parse_defined): New function, break out of
cpp_lex.
(cpp_lex): We now get CPP_ASSERTION tokens and can check them
ourselves, with cpp_defined.
* cppinit.c (cpp_handle_option, print_help): Delete -ifoutput.
* gcc.dg/20000209-2.c: Turn off -pedantic-errors.
* gcc.dg/strpaste-2.c: New.
From-SVN: r32274
2000-03-01 01:57:09 +01:00
|
|
|
|
|
2000-07-19 22:18:08 +02:00
|
|
|
|
case CPP_NAME:
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
if (token->val.node == pfile->spec_nodes.n_defined)
|
2001-11-05 23:26:13 +01:00
|
|
|
|
return parse_defined (pfile);
|
2001-02-07 19:32:42 +01:00
|
|
|
|
else if (CPP_OPTION (pfile, cplusplus)
|
|
|
|
|
&& (token->val.node == pfile->spec_nodes.n_true
|
|
|
|
|
|| token->val.node == pfile->spec_nodes.n_false))
|
|
|
|
|
{
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
result.high = 0;
|
|
|
|
|
result.low = (token->val.node == pfile->spec_nodes.n_true);
|
2001-02-07 19:32:42 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
result.high = 0;
|
|
|
|
|
result.low = 0;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
if (CPP_OPTION (pfile, warn_undef) && !pfile->state.skip_eval)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING, "\"%s\" is not defined",
|
cpperror.c (print_location): Don't print include chain if line == 0.
* cpperror.c (print_location): Don't print include chain
if line == 0.
(cpp_begin_message): Update to use DL_ macros.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppexp.c (CPP_ICE): Remove.
(SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
lex, integer_overflow, _cpp_parse_expr): Update.
* cppfiles.c (read_include_file, find_include_file,
handle_missing_header, _cpp_read_file, remap_filename): Update.
* cpphash.h (enum error_type): Remove.
(_cpp_begin_message): Update.
* cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
cpp_handle_option, cpp_post_options): Update.
* cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
skip_whitespace, parse_identifier, parse_slow, parse_string,
_cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
cpp_interpret_charconst): Update.
* cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
lex_macro_node, do_undef, glue_header_name, parse_include,
do_include_common, read_flag, do_line, do_linemarker, do_ident,
cpp_register_pragma, do_pragma_once, do_pragma_system_header,
do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
do_elif, do_endif, parse_answer, parse_assertion, do_assert,
_cpp_pop_buffer, do_diagnostic): Update.
* cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
collect_args, enter_macro_context, save_parameter, parse_params,
_cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Update.
* cppmain.c (cpp_preprocess_file): Update.
* fix-header.c (read_scan_file): Update.
From-SVN: r52302
2002-04-14 20:42:47 +02:00
|
|
|
|
NODE_NAME (token->val.node));
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
2002-04-29 01:14:56 +02:00
|
|
|
|
break;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
2002-04-29 01:14:56 +02:00
|
|
|
|
default: /* CPP_HASH */
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
_cpp_test_assertion (pfile, &temp);
|
|
|
|
|
result.high = 0;
|
|
|
|
|
result.low = temp;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
}
|
2000-04-03 00:12:14 +02:00
|
|
|
|
|
2002-07-17 19:27:14 +02:00
|
|
|
|
result.unsignedp = !!unsignedp;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
return result;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-02 10:27:23 +02:00
|
|
|
|
/* Operator precedence and flags table.
|
2000-04-01 09:48:59 +02:00
|
|
|
|
|
|
|
|
|
After an operator is returned from the lexer, if it has priority less
|
2002-04-28 21:42:54 +02:00
|
|
|
|
than the operator on the top of the stack, we reduce the stack by one
|
|
|
|
|
operator and repeat the test. Since equal priorities do not reduce,
|
|
|
|
|
this is naturally right-associative.
|
|
|
|
|
|
|
|
|
|
We handle left-associative operators by decrementing the priority of
|
|
|
|
|
just-lexed operators by one, but retaining the priority of operators
|
|
|
|
|
already on the stack.
|
2000-04-01 09:48:59 +02:00
|
|
|
|
|
|
|
|
|
The remaining cases are '(' and ')'. We handle '(' by skipping the
|
|
|
|
|
reduction phase completely. ')' is given lower priority than
|
|
|
|
|
everything else, including '(', effectively forcing a reduction of the
|
2002-12-19 06:18:13 +01:00
|
|
|
|
parenthesized expression. If there is a matching '(', the routine
|
2002-04-28 21:42:54 +02:00
|
|
|
|
reduce() exits immediately. If the normal exit route sees a ')', then
|
|
|
|
|
there cannot have been a matching '(' and an error message is output.
|
2000-04-02 10:27:23 +02:00
|
|
|
|
|
2002-04-26 08:32:50 +02:00
|
|
|
|
The parser assumes all shifted operators require a left operand unless
|
|
|
|
|
the flag NO_L_OPERAND is set. These semantics are automatic; any
|
|
|
|
|
extra semantics need to be handled with operator-specific code. */
|
2000-04-02 10:27:23 +02:00
|
|
|
|
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* Flags. If CHECK_PROMOTION, we warn if the effective sign of an
|
|
|
|
|
operand changes because of integer promotions. */
|
2002-04-28 21:42:54 +02:00
|
|
|
|
#define NO_L_OPERAND (1 << 0)
|
|
|
|
|
#define LEFT_ASSOC (1 << 1)
|
2002-07-20 15:31:56 +02:00
|
|
|
|
#define CHECK_PROMOTION (1 << 2)
|
2000-04-01 00:23:59 +02:00
|
|
|
|
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
/* Operator to priority map. Must be in the same order as the first
|
|
|
|
|
N entries of enum cpp_ttype. */
|
2005-05-28 17:52:48 +02:00
|
|
|
|
static const struct cpp_operator
|
2002-04-28 21:42:54 +02:00
|
|
|
|
{
|
2002-04-29 01:14:56 +02:00
|
|
|
|
uchar prio;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
uchar flags;
|
|
|
|
|
} optab[] =
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
{
|
2002-07-19 00:08:35 +02:00
|
|
|
|
/* EQ */ {0, 0}, /* Shouldn't happen. */
|
|
|
|
|
/* NOT */ {16, NO_L_OPERAND},
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* GREATER */ {12, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* LESS */ {12, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* PLUS */ {14, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* MINUS */ {14, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* MULT */ {15, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* DIV */ {15, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* MOD */ {15, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* AND */ {9, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* OR */ {7, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* XOR */ {8, LEFT_ASSOC | CHECK_PROMOTION},
|
2002-07-19 00:08:35 +02:00
|
|
|
|
/* RSHIFT */ {13, LEFT_ASSOC},
|
|
|
|
|
/* LSHIFT */ {13, LEFT_ASSOC},
|
|
|
|
|
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* MIN */ {10, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* MAX */ {10, LEFT_ASSOC | CHECK_PROMOTION},
|
2002-07-19 00:08:35 +02:00
|
|
|
|
|
|
|
|
|
/* COMPL */ {16, NO_L_OPERAND},
|
2002-07-19 21:24:43 +02:00
|
|
|
|
/* AND_AND */ {6, LEFT_ASSOC},
|
|
|
|
|
/* OR_OR */ {5, LEFT_ASSOC},
|
|
|
|
|
/* QUERY */ {3, 0},
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* COLON */ {4, LEFT_ASSOC | CHECK_PROMOTION},
|
2002-07-19 00:08:35 +02:00
|
|
|
|
/* COMMA */ {2, LEFT_ASSOC},
|
2002-07-19 21:24:43 +02:00
|
|
|
|
/* OPEN_PAREN */ {1, NO_L_OPERAND},
|
2002-07-19 00:08:35 +02:00
|
|
|
|
/* CLOSE_PAREN */ {0, 0},
|
|
|
|
|
/* EOF */ {0, 0},
|
|
|
|
|
/* EQ_EQ */ {11, LEFT_ASSOC},
|
|
|
|
|
/* NOT_EQ */ {11, LEFT_ASSOC},
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* GREATER_EQ */ {12, LEFT_ASSOC | CHECK_PROMOTION},
|
|
|
|
|
/* LESS_EQ */ {12, LEFT_ASSOC | CHECK_PROMOTION},
|
2002-07-19 00:08:35 +02:00
|
|
|
|
/* UPLUS */ {16, NO_L_OPERAND},
|
|
|
|
|
/* UMINUS */ {16, NO_L_OPERAND}
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
};
|
|
|
|
|
|
1995-03-16 22:59:07 +01:00
|
|
|
|
/* Parse and evaluate a C expression, reading from PFILE.
|
2002-05-23 00:02:16 +02:00
|
|
|
|
Returns the truth value of the expression.
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
|
|
|
|
The implementation is an operator precedence parser, i.e. a
|
|
|
|
|
bottom-up parser, using a stack for not-yet-reduced tokens.
|
|
|
|
|
|
|
|
|
|
The stack base is op_stack, and the current stack pointer is 'top'.
|
|
|
|
|
There is a stack element for each operator (only), and the most
|
|
|
|
|
recently pushed operator is 'top->op'. An operand (value) is
|
|
|
|
|
stored in the 'value' field of the stack element of the operator
|
|
|
|
|
that precedes it. */
|
|
|
|
|
bool
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
_cpp_parse_expr (cpp_reader *pfile)
|
1995-03-16 22:59:07 +01:00
|
|
|
|
{
|
2002-04-28 21:42:54 +02:00
|
|
|
|
struct op *top = pfile->op_stack;
|
|
|
|
|
unsigned int lex_count;
|
|
|
|
|
bool saw_leading_not, want_value = true;
|
|
|
|
|
|
|
|
|
|
pfile->state.skip_eval = 0;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
/* Set up detection of #if ! defined(). */
|
2001-07-29 19:27:57 +02:00
|
|
|
|
pfile->mi_ind_cmacro = 0;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
saw_leading_not = false;
|
2001-07-29 19:27:57 +02:00
|
|
|
|
lex_count = 0;
|
New macro expander.
2000-10-28 Neil Booth <neilb@earthling.net>
New macro expander.
* cpplib.c (struct answer): New.
(struct if_stack): Use cpp_lexer_pos rather than line and col.
Rename cmacro mi_cmacro.
(struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL,
IN_I): New directive and flags.
(skip_rest_of_line, check_eol, run_directive, glue_header_name,
parse_answer, parse_assertion, find_answer): New functions.
(parse_ifdef, detect_if_not_defined, validate_else): Remove.
(lex_macro_node): New function to replace parse_ifdef and
get_define_node.
(_cpp_handle_directive): New function, combines _cpp_check_directive
and _cpp_check_linemarker.
(do_define, do_undef, parse_include, do_include, do_import,
do_include_next, read_line_number, do_line, do_ident, do_pragma,
do_pragma_once, do_pragma_poison, do_pragma_dependency):
Update for new token getting interface.
(do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional)
: Update for new multiple-include optimisation technique.
(do_elif): Don't forget to invalidate controlling macros.
(unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update.
(parse_assertion, parse_answer, find_answer, _cpp_test_assertion):
Functions to handle assertions with the new token interface.
(do_assert, do_unassert): Use them.
(cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert):
Use run_directive.
(_cpp_init_stacks): Register directive names. Don't register special
nodes.
* cpperror.c (print_containing_files, _cpp_begin_message): Update to
new position recording regime.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes.
(cpp_type2name): Move to cpplex.c.
* cppexp.c (parse_charconst): spec_nodes is no longer a pointer.
(parse_defined): Update to handle new multiple include optimisation
method. Remove poisoned identifier warning.
(parse_assertion, TYPE_NAME): Delete.
(lex): Update for multiple include optimisation, removal of
CPP_DEFINED, to use _cpp_test_assertion for assertions and
cpp_token_as_text.
(_cpp_parse_expr): Update for MI optimisation, and to use op_as_text.
(op_as_text): New function, to wrap cpp_token_as_text.
* cppfiles.c (stack_include_file, _cpp_pop_file_buffer):
Update for MI optimisation.
(_cpp_execute_include): Take a token rather than 3 arguments. Fix
segfault on diagnostic.
(_cpp_compare_file_date): Take a token rather than 3 args.
(cpp_read_file): Work correctly for zero-length files.
* cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename
_cpp_init_hashtable and _cpp_cleanup_hashtable.
(cpp_lookup): Place identifiers at front of identifier pool
for _cpp_lookup_with_hash.
(_cpp_lookup_with_hash): Require identifiers to be at the front of
the identifier pool. Commit the memory if not already in the
hash table.
* cppinit.c (cpp_reader_init): Move cpp_init_completed test to top.
Initialise various members of cpp_reader, memory pools, and the
special nodes.
(cpp_printer_init): Delete.
(cpp_cleanup): Update.
(struct builtin, builtin_array, initialize_builtins): Update for new
hashnode definition and builtin handling.
(cpp_start_read, cpp_finish): Don't take or initialise a
printer. Update.
* cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL,
PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE,
T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL,
T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete.
(struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos,
struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind,
NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos,
struct toklist, struct cpp_context, struct specnodes,
TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED,
NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION,
enum builtin_type, cpp_can_paste): New.
(struct cpp_token): Delete line and col members.
(struct cpp_buffer): New member output_lineno.
(struct lexer_state): Delete indented, in_lex_line, seen_dot.
Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args.
(struct cpp_reader): New members lexer_pos, macro_pos, directive_pos,
ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool,
base_context, context, directive, mi_state, mi_if_not_defined,
mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused,
mlstring_pos, macro_buffer, macro_buffer_len.
Delete members mls_line, mls_column, token_list, potential_control_macro,
temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token,
context_cap, cur_context, no_expand_level, paste_level, contexts, args,
save_parameter_spellings, need_newline, .
Change type of date, time and spec_nodes members.
Change prototypes for include and ident callbacks.
(struct cpp_hashnode): Change type of name. Remove union members
expansion and code. Add members macro, operator and builtin.
(cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read,
cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line,
cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead,
cpp_stop_lookahead): New prototypes.
(cpp_printer_init, cpp_dump_definition): Delete prototypes.
(U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs):
Move from cpphash.h.
* cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr,
ufputs): Move to cpplib.h.
(enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL,
TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION,
COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler,
struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens,
_cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist,
_cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space,
_cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive,
_cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name,
_cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker,
_cpp_parse_assertion, _cpp_find_answer): Delete.
(VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE,
POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool,
_cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk,
_cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion,
_cpp_handle_directive, DSC): New.
(struct include_file): New member defined.
(DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include,
_cpp_compare_file_date): Update.
(_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New.
(_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable,
_cpp_cleanup_hashtable.
* Makefile.in: Remove cppoutput.c.
* cppoutput.c: Delete
* fixheader.c (read_scan_file): Update for new cpp_get_token
prototype.
(recognized_function): New argument LINE.
* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
new cpp_get_token prototype.
* scan.h (recognized_function): Update prototype.
* po/POTFILES.in: Remove cppoutput.c.
From-SVN: r37098
2000-10-28 19:59:06 +02:00
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
/* Lowest priority operator prevents further reductions. */
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
top->op = CPP_EOF;
|
2000-04-02 10:27:23 +02:00
|
|
|
|
|
1995-03-16 22:59:07 +01:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
struct op op;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
2001-07-29 19:27:57 +02:00
|
|
|
|
lex_count++;
|
2002-07-20 15:31:56 +02:00
|
|
|
|
op.token = cpp_get_token (pfile);
|
|
|
|
|
op.op = op.token->type;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
|
|
|
|
|
switch (op.op)
|
|
|
|
|
{
|
2002-04-29 01:14:56 +02:00
|
|
|
|
/* These tokens convert into values. */
|
c-lex.c (c_lex): Remove CPP_INT, CPP_FLOAT cases.
* c-lex.c (c_lex): Remove CPP_INT, CPP_FLOAT cases.
* c-parse.in (yyerror, _yylex): Similarly.
* cppexp.c (parse_number, parse_defined, lex, _cpp_parse_expr):
Don't use CPP_INT, CPP_FLOAT; CPP_NUMBER is enough.
Update comments.
* cpplib.h (CPP_INT, CPP_FLOAT): Remove.
* cp/spew.c (read_token, yyerror): Remove CPP_INT, CPP_FLOAT cases.
From-SVN: r44144
2001-07-19 08:12:50 +02:00
|
|
|
|
case CPP_NUMBER:
|
2002-04-29 01:14:56 +02:00
|
|
|
|
case CPP_CHAR:
|
|
|
|
|
case CPP_WCHAR:
|
|
|
|
|
case CPP_NAME:
|
|
|
|
|
case CPP_HASH:
|
2002-04-26 08:32:50 +02:00
|
|
|
|
if (!want_value)
|
2002-04-29 01:14:56 +02:00
|
|
|
|
SYNTAX_ERROR2 ("missing binary operator before token \"%s\"",
|
2002-07-20 15:31:56 +02:00
|
|
|
|
cpp_token_as_text (pfile, op.token));
|
2002-04-26 08:32:50 +02:00
|
|
|
|
want_value = false;
|
2002-07-20 15:31:56 +02:00
|
|
|
|
top->value = eval_token (pfile, op.token);
|
2000-04-01 09:42:37 +02:00
|
|
|
|
continue;
|
|
|
|
|
|
2001-07-29 19:27:57 +02:00
|
|
|
|
case CPP_NOT:
|
|
|
|
|
saw_leading_not = lex_count == 1;
|
|
|
|
|
break;
|
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface.
(op_t, operator codes, struct token, tokentab2, op_to_str): Remove.
(struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New.
* cpplex.c (token_names): Trim leading CPP_ from names; make
the strings unsigned.
(_cpp_spell_operator): New.
(is_macro_disabled): Disable all macros if rescanning
preprocessed text.
(_cpp_get_directive_token): Remove.
* cppinit.c: Don't set no_macro_expand.
* cpplib.c (read_line_number, do_line): Check only for EOF,
not VSPACE.
* cpphash.h: Update prototypes.
* cpplib.h (CPP_VSPACE): Remove.
(struct cpp_reader): Remove no_macro_expand.
testsuite:
* gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c,
gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps.
From-SVN: r34920
2000-07-08 04:33:00 +02:00
|
|
|
|
case CPP_PLUS:
|
2002-04-26 08:32:50 +02:00
|
|
|
|
if (want_value)
|
|
|
|
|
op.op = CPP_UPLUS;
|
|
|
|
|
break;
|
|
|
|
|
case CPP_MINUS:
|
|
|
|
|
if (want_value)
|
|
|
|
|
op.op = CPP_UMINUS;
|
|
|
|
|
break;
|
2002-04-29 01:14:56 +02:00
|
|
|
|
|
2002-04-26 08:32:50 +02:00
|
|
|
|
default:
|
2002-04-29 01:14:56 +02:00
|
|
|
|
if ((int) op.op <= (int) CPP_EQ || (int) op.op >= (int) CPP_PLUS_EQ)
|
cppexp.c (cpp_num): Move to cpplib.h.
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
testsuite:
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r54007
2002-05-29 19:15:42 +02:00
|
|
|
|
SYNTAX_ERROR2 ("token \"%s\" is not valid in preprocessor expressions",
|
2002-07-20 15:31:56 +02:00
|
|
|
|
cpp_token_as_text (pfile, op.token));
|
2002-04-26 08:32:50 +02:00
|
|
|
|
break;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
/* Check we have a value or operator as appropriate. */
|
|
|
|
|
if (optab[op.op].flags & NO_L_OPERAND)
|
1995-03-16 22:59:07 +01:00
|
|
|
|
{
|
2002-04-28 21:42:54 +02:00
|
|
|
|
if (!want_value)
|
2002-04-29 01:14:56 +02:00
|
|
|
|
SYNTAX_ERROR2 ("missing binary operator before token \"%s\"",
|
2002-07-20 15:31:56 +02:00
|
|
|
|
cpp_token_as_text (pfile, op.token));
|
2002-04-28 21:42:54 +02:00
|
|
|
|
}
|
|
|
|
|
else if (want_value)
|
|
|
|
|
{
|
2004-07-04 14:57:50 +02:00
|
|
|
|
/* We want a number (or expression) and haven't got one.
|
|
|
|
|
Try to emit a specific diagnostic. */
|
|
|
|
|
if (op.op == CPP_CLOSE_PAREN && top->op == CPP_OPEN_PAREN)
|
|
|
|
|
SYNTAX_ERROR ("missing expression between '(' and ')'");
|
|
|
|
|
|
|
|
|
|
if (op.op == CPP_EOF && top->op == CPP_EOF)
|
|
|
|
|
SYNTAX_ERROR ("#if with no expression");
|
|
|
|
|
|
|
|
|
|
if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN)
|
|
|
|
|
SYNTAX_ERROR2 ("operator '%s' has no right operand",
|
|
|
|
|
cpp_token_as_text (pfile, top->token));
|
|
|
|
|
else if (op.op == CPP_CLOSE_PAREN || op.op == CPP_EOF)
|
|
|
|
|
/* Complain about missing paren during reduction. */;
|
|
|
|
|
else
|
|
|
|
|
SYNTAX_ERROR2 ("operator '%s' has no left operand",
|
|
|
|
|
cpp_token_as_text (pfile, op.token));
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
2000-04-01 09:42:37 +02:00
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
top = reduce (pfile, top, op.op);
|
|
|
|
|
if (!top)
|
|
|
|
|
goto syntax_error;
|
2000-04-01 09:42:37 +02:00
|
|
|
|
|
2002-04-29 01:14:56 +02:00
|
|
|
|
if (op.op == CPP_EOF)
|
|
|
|
|
break;
|
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
switch (op.op)
|
2000-04-04 00:33:12 +02:00
|
|
|
|
{
|
2002-04-28 21:42:54 +02:00
|
|
|
|
case CPP_CLOSE_PAREN:
|
|
|
|
|
continue;
|
|
|
|
|
case CPP_OR_OR:
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (!num_zerop (top->value))
|
2002-04-28 21:42:54 +02:00
|
|
|
|
pfile->state.skip_eval++;
|
|
|
|
|
break;
|
|
|
|
|
case CPP_AND_AND:
|
|
|
|
|
case CPP_QUERY:
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (num_zerop (top->value))
|
2002-04-28 21:42:54 +02:00
|
|
|
|
pfile->state.skip_eval++;
|
|
|
|
|
break;
|
|
|
|
|
case CPP_COLON:
|
2002-04-29 01:14:56 +02:00
|
|
|
|
if (top->op != CPP_QUERY)
|
|
|
|
|
SYNTAX_ERROR (" ':' without preceding '?'");
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (!num_zerop (top[-1].value)) /* Was '?' condition true? */
|
2002-04-28 21:42:54 +02:00
|
|
|
|
pfile->state.skip_eval++;
|
|
|
|
|
else
|
|
|
|
|
pfile->state.skip_eval--;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2000-04-02 10:27:23 +02:00
|
|
|
|
}
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
2002-04-26 08:32:50 +02:00
|
|
|
|
want_value = true;
|
2000-04-02 10:27:23 +02:00
|
|
|
|
|
1996-07-04 00:07:53 +02:00
|
|
|
|
/* Check for and handle stack overflow. */
|
2002-04-28 21:42:54 +02:00
|
|
|
|
if (++top == pfile->op_limit)
|
|
|
|
|
top = _cpp_expand_op_stack (pfile);
|
2002-05-23 00:02:16 +02:00
|
|
|
|
|
1995-03-16 22:59:07 +01:00
|
|
|
|
top->op = op.op;
|
2002-07-20 15:31:56 +02:00
|
|
|
|
top->token = op.token;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
2000-04-01 09:42:37 +02:00
|
|
|
|
|
2001-07-29 19:27:57 +02:00
|
|
|
|
/* The controlling macro expression is only valid if we called lex 3
|
|
|
|
|
times: <!> <defined expression> and <EOF>. push_conditional ()
|
|
|
|
|
checks that we are at top-of-file. */
|
|
|
|
|
if (pfile->mi_ind_cmacro && !(saw_leading_not && lex_count == 3))
|
|
|
|
|
pfile->mi_ind_cmacro = 0;
|
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
if (top != pfile->op_stack)
|
cpperror.c (print_location): Don't print include chain if line == 0.
* cpperror.c (print_location): Don't print include chain
if line == 0.
(cpp_begin_message): Update to use DL_ macros.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppexp.c (CPP_ICE): Remove.
(SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined,
lex, integer_overflow, _cpp_parse_expr): Update.
* cppfiles.c (read_include_file, find_include_file,
handle_missing_header, _cpp_read_file, remap_filename): Update.
* cpphash.h (enum error_type): Remove.
(_cpp_begin_message): Update.
* cppinit.c (append_include_chain, remove_dup_dirs, output_deps,
cpp_handle_option, cpp_post_options): Update.
* cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment,
skip_whitespace, parse_identifier, parse_slow, parse_string,
_cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape,
cpp_interpret_charconst): Update.
* cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive,
lex_macro_node, do_undef, glue_header_name, parse_include,
do_include_common, read_flag, do_line, do_linemarker, do_ident,
cpp_register_pragma, do_pragma_once, do_pragma_system_header,
do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else,
do_elif, do_endif, parse_answer, parse_assertion, do_assert,
_cpp_pop_buffer, do_diagnostic): Update.
* cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR,
DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New.
(cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line,
cpp_notice, cpp_notice_from_errno): Remove.
(cpp_error, cpp_error_with_line): Update to take a diagnostic
level.
(cpp_errno): New.
* cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens,
collect_args, enter_macro_context, save_parameter, parse_params,
_cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Update.
* cppmain.c (cpp_preprocess_file): Update.
* fix-header.c (read_scan_file): Update.
From-SVN: r52302
2002-04-14 20:42:47 +02:00
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ICE, "unbalanced stack in #if");
|
2000-04-02 10:27:23 +02:00
|
|
|
|
syntax_error:
|
2002-04-28 21:42:54 +02:00
|
|
|
|
return false; /* Return false on syntax error. */
|
2000-04-02 10:27:23 +02:00
|
|
|
|
}
|
2000-04-01 09:42:37 +02:00
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
return !num_zerop (top->value);
|
2002-04-28 21:42:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reduce the operator / value stack if possible, in preparation for
|
|
|
|
|
pushing operator OP. Returns NULL on error, otherwise the top of
|
|
|
|
|
the stack. */
|
|
|
|
|
static struct op *
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op)
|
2002-04-28 21:42:54 +02:00
|
|
|
|
{
|
|
|
|
|
unsigned int prio;
|
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (top->op <= CPP_EQ || top->op > CPP_LAST_CPP_OP + 2)
|
|
|
|
|
{
|
|
|
|
|
bad_op:
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ICE, "impossible operator '%u'", top->op);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-28 21:42:54 +02:00
|
|
|
|
if (op == CPP_OPEN_PAREN)
|
|
|
|
|
return top;
|
|
|
|
|
|
|
|
|
|
/* Decrement the priority of left-associative operators to force a
|
|
|
|
|
reduction with operators of otherwise equal priority. */
|
|
|
|
|
prio = optab[op].prio - ((optab[op].flags & LEFT_ASSOC) != 0);
|
|
|
|
|
while (prio < optab[top->op].prio)
|
|
|
|
|
{
|
2002-07-20 15:31:56 +02:00
|
|
|
|
if (CPP_OPTION (pfile, warn_num_sign_change)
|
|
|
|
|
&& optab[top->op].flags & CHECK_PROMOTION)
|
|
|
|
|
check_promotion (pfile, top);
|
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
switch (top->op)
|
|
|
|
|
{
|
|
|
|
|
case CPP_UPLUS:
|
|
|
|
|
case CPP_UMINUS:
|
|
|
|
|
case CPP_NOT:
|
|
|
|
|
case CPP_COMPL:
|
|
|
|
|
top[-1].value = num_unary_op (pfile, top->value, top->op);
|
|
|
|
|
break;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_PLUS:
|
|
|
|
|
case CPP_MINUS:
|
|
|
|
|
case CPP_RSHIFT:
|
|
|
|
|
case CPP_LSHIFT:
|
|
|
|
|
case CPP_MIN:
|
|
|
|
|
case CPP_MAX:
|
|
|
|
|
case CPP_COMMA:
|
|
|
|
|
top[-1].value = num_binary_op (pfile, top[-1].value,
|
|
|
|
|
top->value, top->op);
|
|
|
|
|
break;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_GREATER:
|
|
|
|
|
case CPP_LESS:
|
|
|
|
|
case CPP_GREATER_EQ:
|
|
|
|
|
case CPP_LESS_EQ:
|
|
|
|
|
top[-1].value
|
|
|
|
|
= num_inequality_op (pfile, top[-1].value, top->value, top->op);
|
|
|
|
|
break;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_EQ_EQ:
|
|
|
|
|
case CPP_NOT_EQ:
|
|
|
|
|
top[-1].value
|
|
|
|
|
= num_equality_op (pfile, top[-1].value, top->value, top->op);
|
|
|
|
|
break;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_AND:
|
|
|
|
|
case CPP_OR:
|
|
|
|
|
case CPP_XOR:
|
|
|
|
|
top[-1].value
|
|
|
|
|
= num_bitwise_op (pfile, top[-1].value, top->value, top->op);
|
|
|
|
|
break;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_MULT:
|
|
|
|
|
top[-1].value = num_mul (pfile, top[-1].value, top->value);
|
|
|
|
|
break;
|
2002-07-19 00:08:35 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_DIV:
|
|
|
|
|
case CPP_MOD:
|
|
|
|
|
top[-1].value = num_div_op (pfile, top[-1].value,
|
|
|
|
|
top->value, top->op);
|
|
|
|
|
break;
|
2002-07-19 00:08:35 +02:00
|
|
|
|
|
2002-07-19 21:24:43 +02:00
|
|
|
|
case CPP_OR_OR:
|
|
|
|
|
top--;
|
|
|
|
|
if (!num_zerop (top->value))
|
|
|
|
|
pfile->state.skip_eval--;
|
|
|
|
|
top->value.low = (!num_zerop (top->value)
|
|
|
|
|
|| !num_zerop (top[1].value));
|
|
|
|
|
top->value.high = 0;
|
|
|
|
|
top->value.unsignedp = false;
|
|
|
|
|
top->value.overflow = false;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case CPP_AND_AND:
|
|
|
|
|
top--;
|
|
|
|
|
if (num_zerop (top->value))
|
|
|
|
|
pfile->state.skip_eval--;
|
|
|
|
|
top->value.low = (!num_zerop (top->value)
|
|
|
|
|
&& !num_zerop (top[1].value));
|
|
|
|
|
top->value.high = 0;
|
|
|
|
|
top->value.unsignedp = false;
|
|
|
|
|
top->value.overflow = false;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case CPP_OPEN_PAREN:
|
|
|
|
|
if (op != CPP_CLOSE_PAREN)
|
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR, "missing ')' in expression");
|
2002-07-19 21:24:43 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
top--;
|
|
|
|
|
top->value = top[1].value;
|
|
|
|
|
return top;
|
|
|
|
|
|
|
|
|
|
case CPP_COLON:
|
|
|
|
|
top -= 2;
|
|
|
|
|
if (!num_zerop (top->value))
|
|
|
|
|
{
|
2002-07-19 00:08:35 +02:00
|
|
|
|
pfile->state.skip_eval--;
|
2002-07-19 21:24:43 +02:00
|
|
|
|
top->value = top[1].value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
top->value = top[2].value;
|
|
|
|
|
top->value.unsignedp = (top[1].value.unsignedp
|
|
|
|
|
|| top[2].value.unsignedp);
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case CPP_QUERY:
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR, "'?' without following ':'");
|
2002-07-19 21:24:43 +02:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
goto bad_op;
|
|
|
|
|
}
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-19 00:08:35 +02:00
|
|
|
|
top--;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (top->value.overflow && !pfile->state.skip_eval)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
"integer overflow in preprocessor expression");
|
2002-04-28 21:42:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (op == CPP_CLOSE_PAREN)
|
|
|
|
|
{
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR, "missing '(' in expression");
|
2002-04-28 21:42:54 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return top;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the position of the old top of stack after expansion. */
|
|
|
|
|
struct op *
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
_cpp_expand_op_stack (cpp_reader *pfile)
|
2002-04-28 21:42:54 +02:00
|
|
|
|
{
|
2002-05-10 00:27:31 +02:00
|
|
|
|
size_t old_size = (size_t) (pfile->op_limit - pfile->op_stack);
|
|
|
|
|
size_t new_size = old_size * 2 + 20;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
2005-05-28 17:52:48 +02:00
|
|
|
|
pfile->op_stack = XRESIZEVEC (struct op, pfile->op_stack, new_size);
|
2002-05-10 00:27:31 +02:00
|
|
|
|
pfile->op_limit = pfile->op_stack + new_size;
|
2002-04-28 21:42:54 +02:00
|
|
|
|
|
2002-05-10 00:27:31 +02:00
|
|
|
|
return pfile->op_stack + old_size;
|
1995-03-16 22:59:07 +01:00
|
|
|
|
}
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2002-07-20 15:31:56 +02:00
|
|
|
|
/* Emits a warning if the effective sign of either operand of OP
|
|
|
|
|
changes because of integer promotions. */
|
|
|
|
|
static void
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
check_promotion (cpp_reader *pfile, const struct op *op)
|
2002-07-20 15:31:56 +02:00
|
|
|
|
{
|
|
|
|
|
if (op->value.unsignedp == op[-1].value.unsignedp)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (op->value.unsignedp)
|
|
|
|
|
{
|
|
|
|
|
if (!num_positive (op[-1].value, CPP_OPTION (pfile, precision)))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
2002-07-20 15:31:56 +02:00
|
|
|
|
"the left operand of \"%s\" changes sign when promoted",
|
|
|
|
|
cpp_token_as_text (pfile, op->token));
|
|
|
|
|
}
|
|
|
|
|
else if (!num_positive (op->value, CPP_OPTION (pfile, precision)))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
2002-07-20 15:31:56 +02:00
|
|
|
|
"the right operand of \"%s\" changes sign when promoted",
|
|
|
|
|
cpp_token_as_text (pfile, op->token));
|
|
|
|
|
}
|
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
/* Clears the unused high order bits of the number pointed to by PNUM. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_trim (cpp_num num, size_t precision)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
if (precision > PART_PRECISION)
|
|
|
|
|
{
|
|
|
|
|
precision -= PART_PRECISION;
|
|
|
|
|
if (precision < PART_PRECISION)
|
2002-05-28 07:44:06 +02:00
|
|
|
|
num.high &= ((cpp_num_part) 1 << precision) - 1;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (precision < PART_PRECISION)
|
2002-05-28 07:44:06 +02:00
|
|
|
|
num.low &= ((cpp_num_part) 1 << precision) - 1;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
num.high = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* True iff A (presumed signed) >= 0. */
|
|
|
|
|
static bool
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_positive (cpp_num num, size_t precision)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
if (precision > PART_PRECISION)
|
|
|
|
|
{
|
|
|
|
|
precision -= PART_PRECISION;
|
2002-05-28 07:44:06 +02:00
|
|
|
|
return (num.high & (cpp_num_part) 1 << (precision - 1)) == 0;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-28 07:44:06 +02:00
|
|
|
|
return (num.low & (cpp_num_part) 1 << (precision - 1)) == 0;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-02 21:37:34 +02:00
|
|
|
|
/* Sign extend a number, with PRECISION significant bits and all
|
|
|
|
|
others assumed clear, to fill out a cpp_num structure. */
|
|
|
|
|
cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
cpp_num_sign_extend (cpp_num num, size_t precision)
|
2002-06-02 21:37:34 +02:00
|
|
|
|
{
|
|
|
|
|
if (!num.unsignedp)
|
|
|
|
|
{
|
|
|
|
|
if (precision > PART_PRECISION)
|
|
|
|
|
{
|
|
|
|
|
precision -= PART_PRECISION;
|
|
|
|
|
if (precision < PART_PRECISION
|
|
|
|
|
&& (num.high & (cpp_num_part) 1 << (precision - 1)))
|
|
|
|
|
num.high |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
|
|
|
|
|
}
|
|
|
|
|
else if (num.low & (cpp_num_part) 1 << (precision - 1))
|
|
|
|
|
{
|
|
|
|
|
if (precision < PART_PRECISION)
|
|
|
|
|
num.low |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
|
|
|
|
|
num.high = ~(cpp_num_part) 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
/* Returns the negative of NUM. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_negate (cpp_num num, size_t precision)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num copy;
|
|
|
|
|
|
|
|
|
|
copy = num;
|
|
|
|
|
num.high = ~num.high;
|
|
|
|
|
num.low = ~num.low;
|
|
|
|
|
if (++num.low == 0)
|
|
|
|
|
num.high++;
|
|
|
|
|
num = num_trim (num, precision);
|
|
|
|
|
num.overflow = (!num.unsignedp && num_eq (num, copy) && !num_zerop (num));
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns true if A >= B. */
|
|
|
|
|
static bool
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_greater_eq (cpp_num pa, cpp_num pb, size_t precision)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
bool unsignedp;
|
|
|
|
|
|
|
|
|
|
unsignedp = pa.unsignedp || pb.unsignedp;
|
|
|
|
|
|
|
|
|
|
if (!unsignedp)
|
|
|
|
|
{
|
|
|
|
|
/* Both numbers have signed type. If they are of different
|
|
|
|
|
sign, the answer is the sign of A. */
|
|
|
|
|
unsignedp = num_positive (pa, precision);
|
|
|
|
|
|
|
|
|
|
if (unsignedp != num_positive (pb, precision))
|
|
|
|
|
return unsignedp;
|
|
|
|
|
|
|
|
|
|
/* Otherwise we can do an unsigned comparison. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (pa.high > pb.high) || (pa.high == pb.high && pa.low >= pb.low);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns LHS OP RHS, where OP is a bit-wise operation. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_bitwise_op (cpp_reader *pfile ATTRIBUTE_UNUSED,
|
|
|
|
|
cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
lhs.overflow = false;
|
|
|
|
|
lhs.unsignedp = lhs.unsignedp || rhs.unsignedp;
|
|
|
|
|
|
|
|
|
|
/* As excess precision is zeroed, there is no need to num_trim () as
|
|
|
|
|
these operations cannot introduce a set bit there. */
|
|
|
|
|
if (op == CPP_AND)
|
|
|
|
|
{
|
|
|
|
|
lhs.low &= rhs.low;
|
|
|
|
|
lhs.high &= rhs.high;
|
|
|
|
|
}
|
|
|
|
|
else if (op == CPP_OR)
|
|
|
|
|
{
|
|
|
|
|
lhs.low |= rhs.low;
|
|
|
|
|
lhs.high |= rhs.high;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lhs.low ^= rhs.low;
|
|
|
|
|
lhs.high ^= rhs.high;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lhs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns LHS OP RHS, where OP is an inequality. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_inequality_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs,
|
|
|
|
|
enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
bool gte = num_greater_eq (lhs, rhs, CPP_OPTION (pfile, precision));
|
|
|
|
|
|
|
|
|
|
if (op == CPP_GREATER_EQ)
|
|
|
|
|
lhs.low = gte;
|
|
|
|
|
else if (op == CPP_LESS)
|
|
|
|
|
lhs.low = !gte;
|
|
|
|
|
else if (op == CPP_GREATER)
|
|
|
|
|
lhs.low = gte && !num_eq (lhs, rhs);
|
|
|
|
|
else /* CPP_LESS_EQ. */
|
|
|
|
|
lhs.low = !gte || num_eq (lhs, rhs);
|
|
|
|
|
|
|
|
|
|
lhs.high = 0;
|
|
|
|
|
lhs.overflow = false;
|
|
|
|
|
lhs.unsignedp = false;
|
|
|
|
|
return lhs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns LHS OP RHS, where OP is == or !=. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_equality_op (cpp_reader *pfile ATTRIBUTE_UNUSED,
|
|
|
|
|
cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
2002-06-07 15:29:17 +02:00
|
|
|
|
/* Work around a 3.0.4 bug; see PR 6950. */
|
|
|
|
|
bool eq = num_eq (lhs, rhs);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
if (op == CPP_NOT_EQ)
|
2002-06-07 15:29:17 +02:00
|
|
|
|
eq = !eq;
|
|
|
|
|
lhs.low = eq;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
lhs.high = 0;
|
|
|
|
|
lhs.overflow = false;
|
|
|
|
|
lhs.unsignedp = false;
|
|
|
|
|
return lhs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shift NUM, of width PRECISION, right by N bits. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_rshift (cpp_num num, size_t precision, size_t n)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num_part sign_mask;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
bool x = num_positive (num, precision);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
|
if (num.unsignedp || x)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
sign_mask = 0;
|
|
|
|
|
else
|
|
|
|
|
sign_mask = ~(cpp_num_part) 0;
|
|
|
|
|
|
|
|
|
|
if (n >= precision)
|
|
|
|
|
num.high = num.low = sign_mask;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Sign-extend. */
|
|
|
|
|
if (precision < PART_PRECISION)
|
|
|
|
|
num.high = sign_mask, num.low |= sign_mask << precision;
|
|
|
|
|
else if (precision < 2 * PART_PRECISION)
|
|
|
|
|
num.high |= sign_mask << (precision - PART_PRECISION);
|
|
|
|
|
|
|
|
|
|
if (n >= PART_PRECISION)
|
|
|
|
|
{
|
|
|
|
|
n -= PART_PRECISION;
|
|
|
|
|
num.low = num.high;
|
|
|
|
|
num.high = sign_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n)
|
|
|
|
|
{
|
|
|
|
|
num.low = (num.low >> n) | (num.high << (PART_PRECISION - n));
|
|
|
|
|
num.high = (num.high >> n) | (sign_mask << (PART_PRECISION - n));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
num = num_trim (num, precision);
|
|
|
|
|
num.overflow = false;
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shift NUM, of width PRECISION, left by N bits. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_lshift (cpp_num num, size_t precision, size_t n)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
if (n >= precision)
|
|
|
|
|
{
|
|
|
|
|
num.overflow = !num.unsignedp && !num_zerop (num);
|
|
|
|
|
num.high = num.low = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cpp_num orig, maybe_orig;
|
|
|
|
|
size_t m = n;
|
|
|
|
|
|
|
|
|
|
orig = num;
|
|
|
|
|
if (m >= PART_PRECISION)
|
|
|
|
|
{
|
|
|
|
|
m -= PART_PRECISION;
|
|
|
|
|
num.high = num.low;
|
|
|
|
|
num.low = 0;
|
|
|
|
|
}
|
|
|
|
|
if (m)
|
|
|
|
|
{
|
|
|
|
|
num.high = (num.high << m) | (num.low >> (PART_PRECISION - m));
|
|
|
|
|
num.low <<= m;
|
|
|
|
|
}
|
|
|
|
|
num = num_trim (num, precision);
|
|
|
|
|
|
|
|
|
|
if (num.unsignedp)
|
|
|
|
|
num.overflow = false;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
maybe_orig = num_rshift (num, precision, n);
|
|
|
|
|
num.overflow = !num_eq (orig, maybe_orig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The four unary operators: +, -, ! and ~. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_unary_op (cpp_reader *pfile, cpp_num num, enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
switch (op)
|
|
|
|
|
{
|
|
|
|
|
case CPP_UPLUS:
|
2002-07-19 21:24:43 +02:00
|
|
|
|
if (CPP_WTRADITIONAL (pfile) && !pfile->state.skip_eval)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_WARNING,
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
"traditional C rejects the unary plus operator");
|
|
|
|
|
num.overflow = false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CPP_UMINUS:
|
|
|
|
|
num = num_negate (num, CPP_OPTION (pfile, precision));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CPP_COMPL:
|
|
|
|
|
num.high = ~num.high;
|
|
|
|
|
num.low = ~num.low;
|
|
|
|
|
num = num_trim (num, CPP_OPTION (pfile, precision));
|
|
|
|
|
num.overflow = false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: /* case CPP_NOT: */
|
|
|
|
|
num.low = num_zerop (num);
|
|
|
|
|
num.high = 0;
|
|
|
|
|
num.overflow = false;
|
|
|
|
|
num.unsignedp = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The various binary operators. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_binary_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num result;
|
|
|
|
|
size_t precision = CPP_OPTION (pfile, precision);
|
|
|
|
|
bool gte;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
switch (op)
|
|
|
|
|
{
|
|
|
|
|
/* Shifts. */
|
|
|
|
|
case CPP_LSHIFT:
|
|
|
|
|
case CPP_RSHIFT:
|
|
|
|
|
if (!rhs.unsignedp && !num_positive (rhs, precision))
|
|
|
|
|
{
|
|
|
|
|
/* A negative shift is a positive shift the other way. */
|
|
|
|
|
if (op == CPP_LSHIFT)
|
|
|
|
|
op = CPP_RSHIFT;
|
|
|
|
|
else
|
|
|
|
|
op = CPP_LSHIFT;
|
|
|
|
|
rhs = num_negate (rhs, precision);
|
|
|
|
|
}
|
|
|
|
|
if (rhs.high)
|
|
|
|
|
n = ~0; /* Maximal. */
|
|
|
|
|
else
|
|
|
|
|
n = rhs.low;
|
|
|
|
|
if (op == CPP_LSHIFT)
|
|
|
|
|
lhs = num_lshift (lhs, precision, n);
|
|
|
|
|
else
|
|
|
|
|
lhs = num_rshift (lhs, precision, n);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Min / Max. */
|
|
|
|
|
case CPP_MIN:
|
|
|
|
|
case CPP_MAX:
|
|
|
|
|
{
|
|
|
|
|
bool unsignedp = lhs.unsignedp || rhs.unsignedp;
|
|
|
|
|
|
|
|
|
|
gte = num_greater_eq (lhs, rhs, precision);
|
|
|
|
|
if (op == CPP_MIN)
|
|
|
|
|
gte = !gte;
|
|
|
|
|
if (!gte)
|
|
|
|
|
lhs = rhs;
|
|
|
|
|
lhs.unsignedp = unsignedp;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* Arithmetic. */
|
|
|
|
|
case CPP_MINUS:
|
|
|
|
|
rhs = num_negate (rhs, precision);
|
|
|
|
|
case CPP_PLUS:
|
|
|
|
|
result.low = lhs.low + rhs.low;
|
|
|
|
|
result.high = lhs.high + rhs.high;
|
|
|
|
|
if (result.low < lhs.low)
|
|
|
|
|
result.high++;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.unsignedp = lhs.unsignedp || rhs.unsignedp;
|
|
|
|
|
result.overflow = false;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
|
|
|
|
result = num_trim (result, precision);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
if (!result.unsignedp)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
bool lhsp = num_positive (lhs, precision);
|
|
|
|
|
result.overflow = (lhsp == num_positive (rhs, precision)
|
|
|
|
|
&& lhsp != num_positive (result, precision));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
/* Comma. */
|
|
|
|
|
default: /* case CPP_COMMA: */
|
2004-02-12 00:50:45 +01:00
|
|
|
|
if (CPP_PEDANTIC (pfile) && (!CPP_OPTION (pfile, c99)
|
|
|
|
|
|| !pfile->state.skip_eval))
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_PEDWARN,
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
"comma operator in operand of #if");
|
|
|
|
|
lhs = rhs;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lhs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Multiplies two unsigned cpp_num_parts to give a cpp_num. This
|
|
|
|
|
cannot overflow. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_part_mul (cpp_num_part lhs, cpp_num_part rhs)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num result;
|
|
|
|
|
cpp_num_part middle[2], temp;
|
|
|
|
|
|
|
|
|
|
result.low = LOW_PART (lhs) * LOW_PART (rhs);
|
|
|
|
|
result.high = HIGH_PART (lhs) * HIGH_PART (rhs);
|
|
|
|
|
|
|
|
|
|
middle[0] = LOW_PART (lhs) * HIGH_PART (rhs);
|
|
|
|
|
middle[1] = HIGH_PART (lhs) * LOW_PART (rhs);
|
|
|
|
|
|
|
|
|
|
temp = result.low;
|
|
|
|
|
result.low += LOW_PART (middle[0]) << (PART_PRECISION / 2);
|
|
|
|
|
if (result.low < temp)
|
|
|
|
|
result.high++;
|
|
|
|
|
|
|
|
|
|
temp = result.low;
|
|
|
|
|
result.low += LOW_PART (middle[1]) << (PART_PRECISION / 2);
|
|
|
|
|
if (result.low < temp)
|
|
|
|
|
result.high++;
|
|
|
|
|
|
|
|
|
|
result.high += HIGH_PART (middle[0]);
|
|
|
|
|
result.high += HIGH_PART (middle[1]);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.unsignedp = true;
|
|
|
|
|
result.overflow = false;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Multiply two preprocessing numbers. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_mul (cpp_reader *pfile, cpp_num lhs, cpp_num rhs)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num result, temp;
|
|
|
|
|
bool unsignedp = lhs.unsignedp || rhs.unsignedp;
|
|
|
|
|
bool overflow, negate = false;
|
|
|
|
|
size_t precision = CPP_OPTION (pfile, precision);
|
|
|
|
|
|
|
|
|
|
/* Prepare for unsigned multiplication. */
|
|
|
|
|
if (!unsignedp)
|
|
|
|
|
{
|
|
|
|
|
if (!num_positive (lhs, precision))
|
|
|
|
|
negate = !negate, lhs = num_negate (lhs, precision);
|
|
|
|
|
if (!num_positive (rhs, precision))
|
|
|
|
|
negate = !negate, rhs = num_negate (rhs, precision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overflow = lhs.high && rhs.high;
|
|
|
|
|
result = num_part_mul (lhs.low, rhs.low);
|
|
|
|
|
|
|
|
|
|
temp = num_part_mul (lhs.high, rhs.low);
|
|
|
|
|
result.high += temp.low;
|
|
|
|
|
if (temp.high)
|
|
|
|
|
overflow = true;
|
|
|
|
|
|
|
|
|
|
temp = num_part_mul (lhs.low, rhs.high);
|
|
|
|
|
result.high += temp.low;
|
|
|
|
|
if (temp.high)
|
|
|
|
|
overflow = true;
|
|
|
|
|
|
|
|
|
|
temp.low = result.low, temp.high = result.high;
|
|
|
|
|
result = num_trim (result, precision);
|
|
|
|
|
if (!num_eq (result, temp))
|
|
|
|
|
overflow = true;
|
|
|
|
|
|
|
|
|
|
if (negate)
|
|
|
|
|
result = num_negate (result, precision);
|
|
|
|
|
|
|
|
|
|
if (unsignedp)
|
|
|
|
|
result.overflow = false;
|
|
|
|
|
else
|
|
|
|
|
result.overflow = overflow || (num_positive (result, precision) ^ !negate
|
|
|
|
|
&& !num_zerop (result));
|
|
|
|
|
result.unsignedp = unsignedp;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Divide two preprocessing numbers, returning the answer or the
|
|
|
|
|
remainder depending upon OP. */
|
|
|
|
|
static cpp_num
|
* cpplib.h, cpphash.h, cppcharset.c, cpperror.c, cppexp.c
* cppfiles.c, cpphash.c, cppinit.c, cpplex.c, cpplib.c
* cppmacro.c, cpppch.c, cpptrad.c, cppspec.c: Convert to
ISO C: new-style function declarations, no need for PARAMS,
no special punctuation on indirect function calls, use string
constant concatenation where convenient.
From-SVN: r68070
2003-06-17 08:17:44 +02:00
|
|
|
|
num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
cpp_num result, sub;
|
|
|
|
|
cpp_num_part mask;
|
|
|
|
|
bool unsignedp = lhs.unsignedp || rhs.unsignedp;
|
|
|
|
|
bool negate = false, lhs_neg = false;
|
|
|
|
|
size_t i, precision = CPP_OPTION (pfile, precision);
|
|
|
|
|
|
|
|
|
|
/* Prepare for unsigned division. */
|
|
|
|
|
if (!unsignedp)
|
|
|
|
|
{
|
|
|
|
|
if (!num_positive (lhs, precision))
|
|
|
|
|
negate = !negate, lhs_neg = true, lhs = num_negate (lhs, precision);
|
|
|
|
|
if (!num_positive (rhs, precision))
|
|
|
|
|
negate = !negate, rhs = num_negate (rhs, precision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find the high bit. */
|
|
|
|
|
if (rhs.high)
|
|
|
|
|
{
|
|
|
|
|
i = precision - 1;
|
2002-05-28 07:44:06 +02:00
|
|
|
|
mask = (cpp_num_part) 1 << (i - PART_PRECISION);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
for (; ; i--, mask >>= 1)
|
|
|
|
|
if (rhs.high & mask)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (rhs.low)
|
|
|
|
|
{
|
|
|
|
|
if (precision > PART_PRECISION)
|
|
|
|
|
i = precision - PART_PRECISION - 1;
|
|
|
|
|
else
|
|
|
|
|
i = precision - 1;
|
2002-05-28 07:44:06 +02:00
|
|
|
|
mask = (cpp_num_part) 1 << i;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
for (; ; i--, mask >>= 1)
|
|
|
|
|
if (rhs.low & mask)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-07-19 21:24:43 +02:00
|
|
|
|
if (!pfile->state.skip_eval)
|
re PR preprocessor/12847 (xxx.c:1:20: xxxx.h: No such file or directory)
PR preprocessor/12847
* cppfiles.c, cppexp.c, cpperror.c, cpplib.h, cpplib.c, cpplex.c,
cppinit.c, cpptrad.c, cppmacro.c, fix-header.c, cpppch.c, c-pch.c,
c-incpath.c, cppcharset.c (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN,
DL_ERROR, DL_ICE, DL_EXTRACT, DL_WARNING_P): Prefix macro names with
"CPP_".
From-SVN: r73183
2003-11-01 23:56:54 +01:00
|
|
|
|
cpp_error (pfile, CPP_DL_ERROR, "division by zero in #if");
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
return lhs;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-22 04:03:17 +02:00
|
|
|
|
/* First nonzero bit of RHS is bit I. Do naive division by
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
shifting the RHS fully left, and subtracting from LHS if LHS is
|
|
|
|
|
at least as big, and then repeating but with one less shift.
|
|
|
|
|
This is not very efficient, but is easy to understand. */
|
|
|
|
|
|
|
|
|
|
rhs.unsignedp = true;
|
|
|
|
|
lhs.unsignedp = true;
|
|
|
|
|
i = precision - i - 1;
|
|
|
|
|
sub = num_lshift (rhs, precision, i);
|
|
|
|
|
|
|
|
|
|
result.high = result.low = 0;
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
if (num_greater_eq (lhs, sub, precision))
|
|
|
|
|
{
|
|
|
|
|
lhs = num_binary_op (pfile, lhs, sub, CPP_MINUS);
|
|
|
|
|
if (i >= PART_PRECISION)
|
2002-05-28 07:44:06 +02:00
|
|
|
|
result.high |= (cpp_num_part) 1 << (i - PART_PRECISION);
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
else
|
2002-05-28 07:44:06 +02:00
|
|
|
|
result.low |= (cpp_num_part) 1 << i;
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
}
|
|
|
|
|
if (i-- == 0)
|
|
|
|
|
break;
|
|
|
|
|
sub.low = (sub.low >> 1) | (sub.high << (PART_PRECISION - 1));
|
|
|
|
|
sub.high >>= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We divide so that the remainder has the sign of the LHS. */
|
|
|
|
|
if (op == CPP_DIV)
|
|
|
|
|
{
|
|
|
|
|
result.unsignedp = unsignedp;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
result.overflow = false;
|
|
|
|
|
if (!unsignedp)
|
cppexp.c (possible_sum_sign, [...]): Remove.
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
From-SVN: r53900
2002-05-26 20:42:21 +02:00
|
|
|
|
{
|
|
|
|
|
if (negate)
|
|
|
|
|
result = num_negate (result, precision);
|
|
|
|
|
result.overflow = num_positive (result, precision) ^ !negate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* CPP_MOD. */
|
|
|
|
|
lhs.unsignedp = unsignedp;
|
|
|
|
|
lhs.overflow = false;
|
|
|
|
|
if (lhs_neg)
|
|
|
|
|
lhs = num_negate (lhs, precision);
|
|
|
|
|
|
|
|
|
|
return lhs;
|
|
|
|
|
}
|