e53b6e564a
ChangeLog: * MAINTAINERS: Rename .c names to .cc. contrib/ChangeLog: * filter-clang-warnings.py: Rename .c names to .cc. * gcc_update: Likewise. * paranoia.cc: Likewise. contrib/header-tools/ChangeLog: * README: Rename .c names to .cc. gcc/ChangeLog: * Makefile.in: Rename .c names to .cc. * alias.h: Likewise. * asan.cc: Likewise. * auto-profile.h: Likewise. * basic-block.h (struct basic_block_d): Likewise. * btfout.cc: Likewise. * builtins.cc (expand_builtin_longjmp): Likewise. (validate_arg): Likewise. (access_ref::offset_bounded): Likewise. * caller-save.cc (reg_restore_code): Likewise. (setup_save_areas): Likewise. * calls.cc (initialize_argument_information): Likewise. (expand_call): Likewise. (emit_library_call_value_1): Likewise. * cfg-flags.def (RTL): Likewise. (SIBCALL): Likewise. (CAN_FALLTHRU): Likewise. * cfganal.cc (post_order_compute): Likewise. * cfgcleanup.cc (try_simplify_condjump): Likewise. (merge_blocks_move_predecessor_nojumps): Likewise. (merge_blocks_move_successor_nojumps): Likewise. (merge_blocks_move): Likewise. (old_insns_match_p): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.cc (expand_gimple_stmt): Likewise. * cfghooks.cc (split_block_before_cond_jump): Likewise. (profile_record_check_consistency): Likewise. * cfghooks.h: Likewise. * cfgrtl.cc (pass_free_cfg::execute): Likewise. (rtl_can_merge_blocks): Likewise. (try_redirect_by_replacing_jump): Likewise. (make_pass_outof_cfg_layout_mode): Likewise. (cfg_layout_can_merge_blocks_p): Likewise. * cgraph.cc (release_function_body): Likewise. (cgraph_node::get_fun): Likewise. * cgraph.h (struct cgraph_node): Likewise. (asmname_hasher::equal): Likewise. (cgraph_inline_failed_type): Likewise. (thunk_adjust): Likewise. (dump_callgraph_transformation): Likewise. (record_references_in_initializer): Likewise. (ipa_discover_variable_flags): Likewise. * cgraphclones.cc (GTY): Likewise. * cgraphunit.cc (symbol_table::finalize_compilation_unit): Likewise. * collect-utils.h (GCC_COLLECT_UTILS_H): Likewise. * collect2-aix.h (GCC_COLLECT2_AIX_H): Likewise. * collect2.cc (maybe_run_lto_and_relink): Likewise. * combine-stack-adj.cc: Likewise. * combine.cc (setup_incoming_promotions): Likewise. (combine_simplify_rtx): Likewise. (count_rtxs): Likewise. * common.opt: Likewise. * common/config/aarch64/aarch64-common.cc: Likewise. * common/config/arm/arm-common.cc (arm_asm_auto_mfpu): Likewise. * common/config/avr/avr-common.cc: Likewise. * common/config/i386/i386-isas.h (struct _isa_names_table): Likewise. * conditions.h: Likewise. * config.gcc: Likewise. * config/aarch64/aarch64-builtins.cc (aarch64_resolve_overloaded_memtag): Likewise. * config/aarch64/aarch64-protos.h (aarch64_classify_address): Likewise. (aarch64_get_extension_string_for_isa_flags): Likewise. * config/aarch64/aarch64-sve-builtins.cc (function_builder::add_function): Likewise. * config/aarch64/aarch64.cc (aarch64_regmode_natural_size): Likewise. (aarch64_sched_first_cycle_multipass_dfa_lookahead): Likewise. (aarch64_option_valid_attribute_p): Likewise. (aarch64_short_vector_p): Likewise. (aarch64_float_const_representable_p): Likewise. * config/aarch64/aarch64.h (DBX_REGISTER_NUMBER): Likewise. (ASM_OUTPUT_POOL_EPILOGUE): Likewise. (GTY): Likewise. * config/aarch64/cortex-a57-fma-steering.cc: Likewise. * config/aarch64/driver-aarch64.cc (contains_core_p): Likewise. * config/aarch64/t-aarch64: Likewise. * config/aarch64/x-aarch64: Likewise. * config/aarch64/x-darwin: Likewise. * config/alpha/alpha-protos.h: Likewise. * config/alpha/alpha.cc (alpha_scalar_mode_supported_p): Likewise. * config/alpha/alpha.h (LONG_DOUBLE_TYPE_SIZE): Likewise. (enum reg_class): Likewise. * config/alpha/alpha.md: Likewise. * config/alpha/driver-alpha.cc (AMASK_LOCKPFTCHOK): Likewise. * config/alpha/x-alpha: Likewise. * config/arc/arc-protos.h (arc_eh_uses): Likewise. * config/arc/arc.cc (ARC_OPT): Likewise. (arc_ccfsm_advance): Likewise. (arc_arg_partial_bytes): Likewise. (conditionalize_nonjump): Likewise. * config/arc/arc.md: Likewise. * config/arc/builtins.def: Likewise. * config/arc/t-arc: Likewise. * config/arm/arm-c.cc (arm_resolve_overloaded_builtin): Likewise. (arm_pragma_target_parse): Likewise. * config/arm/arm-protos.h (save_restore_target_globals): Likewise. (arm_cpu_cpp_builtins): Likewise. * config/arm/arm.cc (vfp3_const_double_index): Likewise. (shift_op): Likewise. (thumb2_final_prescan_insn): Likewise. (arm_final_prescan_insn): Likewise. (arm_asm_output_labelref): Likewise. (arm_small_register_classes_for_mode_p): Likewise. * config/arm/arm.h: Likewise. * config/arm/arm.md: Likewise. * config/arm/driver-arm.cc: Likewise. * config/arm/symbian.h: Likewise. * config/arm/t-arm: Likewise. * config/arm/thumb1.md: Likewise. * config/arm/x-arm: Likewise. * config/avr/avr-c.cc (avr_register_target_pragmas): Likewise. * config/avr/avr-fixed.md: Likewise. * config/avr/avr-log.cc (avr_log_vadump): Likewise. * config/avr/avr-mcus.def: Likewise. * config/avr/avr-modes.def (FRACTIONAL_INT_MODE): Likewise. * config/avr/avr-passes.def (INSERT_PASS_BEFORE): Likewise. * config/avr/avr-protos.h (make_avr_pass_casesi): Likewise. * config/avr/avr.cc (avr_option_override): Likewise. (avr_build_builtin_va_list): Likewise. (avr_mode_dependent_address_p): Likewise. (avr_function_arg_advance): Likewise. (avr_asm_output_aligned_decl_common): Likewise. * config/avr/avr.h (RETURN_ADDR_RTX): Likewise. (SUPPORTS_INIT_PRIORITY): Likewise. * config/avr/avr.md: Likewise. * config/avr/builtins.def: Likewise. * config/avr/gen-avr-mmcu-specs.cc (IN_GEN_AVR_MMCU_TEXI): Likewise. * config/avr/gen-avr-mmcu-texi.cc (IN_GEN_AVR_MMCU_TEXI): Likewise. (main): Likewise. * config/avr/t-avr: Likewise. * config/bfin/bfin.cc (frame_related_constant_load): Likewise. * config/bpf/bpf-protos.h (GCC_BPF_PROTOS_H): Likewise. * config/bpf/bpf.h (enum reg_class): Likewise. * config/bpf/t-bpf: Likewise. * config/c6x/c6x-protos.h (GCC_C6X_PROTOS_H): Likewise. * config/cr16/cr16-protos.h: Likewise. * config/cris/cris.cc (cris_address_cost): Likewise. (cris_side_effect_mode_ok): Likewise. (cris_init_machine_status): Likewise. (cris_emit_movem_store): Likewise. * config/cris/cris.h (INDEX_REG_CLASS): Likewise. (enum reg_class): Likewise. (struct cum_args): Likewise. * config/cris/cris.opt: Likewise. * config/cris/sync.md: Likewise. * config/csky/csky.cc (csky_expand_prologue): Likewise. * config/darwin-c.cc: Likewise. * config/darwin-f.cc: Likewise. * config/darwin-sections.def (zobj_const_section): Likewise. * config/darwin.cc (output_objc_section_asm_op): Likewise. (fprintf): Likewise. * config/darwin.h (GTY): Likewise. * config/elfos.h: Likewise. * config/epiphany/epiphany-sched.md: Likewise. * config/epiphany/epiphany.cc (epiphany_function_value): Likewise. * config/epiphany/epiphany.h (GTY): Likewise. (NO_FUNCTION_CSE): Likewise. * config/epiphany/mode-switch-use.cc: Likewise. * config/epiphany/predicates.md: Likewise. * config/epiphany/t-epiphany: Likewise. * config/fr30/fr30-protos.h: Likewise. * config/frv/frv-protos.h: Likewise. * config/frv/frv.cc (TLS_BIAS): Likewise. * config/frv/frv.h (ASM_OUTPUT_ALIGNED_LOCAL): Likewise. * config/ft32/ft32-protos.h: Likewise. * config/gcn/gcn-hsa.h (ASM_APP_OFF): Likewise. * config/gcn/gcn.cc (gcn_init_libfuncs): Likewise. * config/gcn/mkoffload.cc (copy_early_debug_info): Likewise. * config/gcn/t-gcn-hsa: Likewise. * config/gcn/t-omp-device: Likewise. * config/h8300/h8300-protos.h (GCC_H8300_PROTOS_H): Likewise. (same_cmp_following_p): Likewise. * config/h8300/h8300.cc (F): Likewise. * config/h8300/h8300.h (struct cum_arg): Likewise. (BRANCH_COST): Likewise. * config/i386/cygming.h (DEFAULT_PCC_STRUCT_RETURN): Likewise. * config/i386/djgpp.h (TARGET_ASM_LTO_END): Likewise. * config/i386/dragonfly.h (NO_PROFILE_COUNTERS): Likewise. * config/i386/driver-i386.cc (detect_caches_intel): Likewise. * config/i386/freebsd.h (NO_PROFILE_COUNTERS): Likewise. * config/i386/i386-c.cc (ix86_target_macros): Likewise. * config/i386/i386-expand.cc (get_mode_wider_vector): Likewise. * config/i386/i386-options.cc (ix86_set_func_type): Likewise. * config/i386/i386-protos.h (ix86_extract_perm_from_pool_constant): Likewise. (ix86_register_pragmas): Likewise. (ix86_d_has_stdcall_convention): Likewise. (i386_pe_seh_init_sections): Likewise. * config/i386/i386.cc (ix86_function_arg_regno_p): Likewise. (ix86_function_value_regno_p): Likewise. (ix86_compute_frame_layout): Likewise. (legitimize_pe_coff_symbol): Likewise. (output_pic_addr_const): Likewise. * config/i386/i386.h (defined): Likewise. (host_detect_local_cpu): Likewise. (CONSTANT_ADDRESS_P): Likewise. (DEFAULT_LARGE_SECTION_THRESHOLD): Likewise. (struct machine_frame_state): Likewise. * config/i386/i386.md: Likewise. * config/i386/lynx.h (ASM_OUTPUT_ALIGN): Likewise. * config/i386/mmx.md: Likewise. * config/i386/sse.md: Likewise. * config/i386/t-cygming: Likewise. * config/i386/t-djgpp: Likewise. * config/i386/t-gnu-property: Likewise. * config/i386/t-i386: Likewise. * config/i386/t-intelmic: Likewise. * config/i386/t-omp-device: Likewise. * config/i386/winnt-cxx.cc (i386_pe_type_dllimport_p): Likewise. (i386_pe_adjust_class_at_definition): Likewise. * config/i386/winnt.cc (gen_stdcall_or_fastcall_suffix): Likewise. (i386_pe_mangle_decl_assembler_name): Likewise. (i386_pe_encode_section_info): Likewise. * config/i386/x-cygwin: Likewise. * config/i386/x-darwin: Likewise. * config/i386/x-i386: Likewise. * config/i386/x-mingw32: Likewise. * config/i386/x86-tune-sched-core.cc: Likewise. * config/i386/x86-tune.def: Likewise. * config/i386/xm-djgpp.h (STANDARD_STARTFILE_PREFIX_1): Likewise. * config/ia64/freebsd.h: Likewise. * config/ia64/hpux.h (REGISTER_TARGET_PRAGMAS): Likewise. * config/ia64/ia64-protos.h (ia64_except_unwind_info): Likewise. * config/ia64/ia64.cc (ia64_function_value_regno_p): Likewise. (ia64_secondary_reload_class): Likewise. (bundling): Likewise. * config/ia64/ia64.h: Likewise. * config/ia64/ia64.md: Likewise. * config/ia64/predicates.md: Likewise. * config/ia64/sysv4.h: Likewise. * config/ia64/t-ia64: Likewise. * config/iq2000/iq2000.h (FUNCTION_MODE): Likewise. * config/iq2000/iq2000.md: Likewise. * config/linux.h (TARGET_HAS_BIONIC): Likewise. (if): Likewise. * config/m32c/m32c.cc (m32c_function_needs_enter): Likewise. * config/m32c/m32c.h (MAX_REGS_PER_ADDRESS): Likewise. * config/m32c/t-m32c: Likewise. * config/m32r/m32r-protos.h: Likewise. * config/m32r/m32r.cc (m32r_print_operand): Likewise. * config/m32r/m32r.h: Likewise. * config/m32r/m32r.md: Likewise. * config/m68k/m68k-isas.def: Likewise. * config/m68k/m68k-microarchs.def: Likewise. * config/m68k/m68k-protos.h (strict_low_part_peephole_ok): Likewise. (m68k_epilogue_uses): Likewise. * config/m68k/m68k.cc (m68k_call_tls_get_addr): Likewise. (m68k_sched_adjust_cost): Likewise. (m68k_sched_md_init): Likewise. * config/m68k/m68k.h (__transfer_from_trampoline): Likewise. (enum m68k_function_kind): Likewise. * config/m68k/m68k.md: Likewise. * config/m68k/m68kemb.h: Likewise. * config/m68k/uclinux.h (ENDFILE_SPEC): Likewise. * config/mcore/mcore-protos.h: Likewise. * config/mcore/mcore.cc (mcore_expand_insv): Likewise. (mcore_expand_prolog): Likewise. * config/mcore/mcore.h (TARGET_MCORE): Likewise. * config/mcore/mcore.md: Likewise. * config/microblaze/microblaze-protos.h: Likewise. * config/microblaze/microblaze.cc (microblaze_legitimate_pic_operand): Likewise. (microblaze_function_prologue): Likewise. (microblaze_function_epilogue): Likewise. (microblaze_select_section): Likewise. (microblaze_asm_output_mi_thunk): Likewise. (microblaze_eh_return): Likewise. * config/microblaze/microblaze.h: Likewise. * config/microblaze/microblaze.md: Likewise. * config/microblaze/t-microblaze: Likewise. * config/mips/driver-native.cc: Likewise. * config/mips/loongson2ef.md: Likewise. * config/mips/mips-protos.h (mips_expand_vec_cmp_expr): Likewise. * config/mips/mips.cc (mips_rtx_costs): Likewise. (mips_output_filename): Likewise. (mips_output_function_prologue): Likewise. (mips_output_function_epilogue): Likewise. (mips_output_mi_thunk): Likewise. * config/mips/mips.h: Likewise. * config/mips/mips.md: Likewise. * config/mips/t-mips: Likewise. * config/mips/x-native: Likewise. * config/mmix/mmix-protos.h: Likewise. * config/mmix/mmix.cc (mmix_option_override): Likewise. (mmix_dbx_register_number): Likewise. (mmix_expand_prologue): Likewise. * config/mmix/mmix.h: Likewise. * config/mmix/mmix.md: Likewise. * config/mmix/predicates.md: Likewise. * config/mn10300/mn10300.cc (mn10300_symbolic_operand): Likewise. (mn10300_legitimate_pic_operand_p): Likewise. * config/mn10300/mn10300.h (enum reg_class): Likewise. (NO_FUNCTION_CSE): Likewise. * config/moxie/moxie-protos.h: Likewise. * config/moxie/uclinux.h (TARGET_LIBC_HAS_FUNCTION): Likewise. * config/msp430/msp430-devices.cc (extract_devices_dir_from_exec_prefix): Likewise. * config/msp430/msp430.cc (msp430_gimplify_va_arg_expr): Likewise. (msp430_incoming_return_addr_rtx): Likewise. * config/msp430/msp430.h (msp430_get_linker_devices_include_path): Likewise. * config/msp430/t-msp430: Likewise. * config/nds32/nds32-cost.cc (nds32_rtx_costs_speed_prefer): Likewise. (nds32_rtx_costs_size_prefer): Likewise. (nds32_init_rtx_costs): Likewise. * config/nds32/nds32-doubleword.md: Likewise. * config/nds32/nds32.cc (nds32_memory_move_cost): Likewise. (nds32_builtin_decl): Likewise. * config/nds32/nds32.h (enum nds32_16bit_address_type): Likewise. (enum nds32_isr_nested_type): Likewise. (enum reg_class): Likewise. * config/nds32/predicates.md: Likewise. * config/nds32/t-nds32: Likewise. * config/nios2/nios2.cc (nios2_pragma_target_parse): Likewise. * config/nvptx/nvptx-protos.h: Likewise. * config/nvptx/nvptx.cc (nvptx_goacc_expand_var_decl): Likewise. * config/nvptx/nvptx.h (TARGET_CPU_CPP_BUILTINS): Likewise. * config/nvptx/t-nvptx: Likewise. * config/nvptx/t-omp-device: Likewise. * config/pa/elf.h: Likewise. * config/pa/pa-linux.h (GLOBAL_ASM_OP): Likewise. * config/pa/pa-netbsd.h (GLOBAL_ASM_OP): Likewise. * config/pa/pa-openbsd.h (TARGET_ASM_GLOBALIZE_LABEL): Likewise. * config/pa/pa-protos.h (pa_eh_return_handler_rtx): Likewise. (pa_legitimize_reload_address): Likewise. (pa_can_use_return_insn): Likewise. * config/pa/pa.cc (mem_shadd_or_shadd_rtx_p): Likewise. (som_output_text_section_asm_op): Likewise. * config/pa/pa.h (PROFILE_BEFORE_PROLOGUE): Likewise. * config/pa/pa.md: Likewise. * config/pa/som.h: Likewise. * config/pa/t-pa: Likewise. * config/pdp11/pdp11.cc (decode_pdp11_d): Likewise. * config/pdp11/pdp11.h: Likewise. * config/pdp11/pdp11.md: Likewise. * config/pdp11/t-pdp11: Likewise. * config/pru/pru.md: Likewise. * config/pru/t-pru: Likewise. * config/riscv/riscv-protos.h (NUM_SYMBOL_TYPES): Likewise. (riscv_gpr_save_operation_p): Likewise. (riscv_d_register_target_info): Likewise. (riscv_init_builtins): Likewise. * config/riscv/riscv.cc (riscv_output_mi_thunk): Likewise. * config/riscv/riscv.h (CSW_MAX_OFFSET): Likewise. * config/riscv/t-riscv: Likewise. * config/rl78/rl78.cc (rl78_asm_ctor_dtor): Likewise. * config/rl78/t-rl78: Likewise. * config/rs6000/aix.h: Likewise. * config/rs6000/aix71.h (ASM_SPEC_COMMON): Likewise. * config/rs6000/aix72.h (ASM_SPEC_COMMON): Likewise. * config/rs6000/aix73.h (ASM_SPEC_COMMON): Likewise. * config/rs6000/darwin.h (TARGET_ASM_GLOBALIZE_LABEL): Likewise. * config/rs6000/driver-rs6000.cc: Likewise. * config/rs6000/freebsd.h: Likewise. * config/rs6000/freebsd64.h: Likewise. * config/rs6000/lynx.h (ASM_OUTPUT_ALIGN): Likewise. * config/rs6000/rbtree.cc: Likewise. * config/rs6000/rbtree.h: Likewise. * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Likewise. * config/rs6000/rs6000-call.cc (rs6000_invalid_builtin): Likewise. (rs6000_expand_builtin): Likewise. (rs6000_init_builtins): Likewise. * config/rs6000/rs6000-cpus.def: Likewise. * config/rs6000/rs6000-gen-builtins.cc (write_init_ovld_table): Likewise. * config/rs6000/rs6000-internal.h (ALTIVEC_REG_BIT): Likewise. (quad_address_offset_p): Likewise. * config/rs6000/rs6000-logue.cc (interesting_frame_related_regno): Likewise. (rs6000_emit_epilogue): Likewise. * config/rs6000/rs6000-overload.def: Likewise. * config/rs6000/rs6000-p8swap.cc: Likewise. * config/rs6000/rs6000-protos.h (GCC_RS6000_PROTOS_H): Likewise. (rs6000_const_f32_to_i32): Likewise. * config/rs6000/rs6000.cc (legitimate_lo_sum_address_p): Likewise. (rs6000_debug_legitimize_address): Likewise. (rs6000_mode_dependent_address): Likewise. (rs6000_adjust_priority): Likewise. (rs6000_c_mode_for_suffix): Likewise. * config/rs6000/rs6000.h (defined): Likewise. (LONG_DOUBLE_TYPE_SIZE): Likewise. * config/rs6000/rs6000.md: Likewise. * config/rs6000/sysv4.h: Likewise. * config/rs6000/t-linux: Likewise. * config/rs6000/t-linux64: Likewise. * config/rs6000/t-rs6000: Likewise. * config/rs6000/x-darwin: Likewise. * config/rs6000/x-darwin64: Likewise. * config/rs6000/x-rs6000: Likewise. * config/rs6000/xcoff.h (ASM_OUTPUT_LABELREF): Likewise. * config/rx/rx.cc (rx_expand_builtin): Likewise. * config/s390/constraints.md: Likewise. * config/s390/driver-native.cc: Likewise. * config/s390/htmxlintrin.h: Likewise. * config/s390/s390-builtins.def (B_DEF): Likewise. (OB_DEF_VAR): Likewise. * config/s390/s390-builtins.h: Likewise. * config/s390/s390-c.cc: Likewise. * config/s390/s390-opts.h: Likewise. * config/s390/s390-protos.h (s390_check_symref_alignment): Likewise. (s390_register_target_pragmas): Likewise. * config/s390/s390.cc (s390_init_builtins): Likewise. (s390_expand_plus_operand): Likewise. (s390_expand_atomic): Likewise. (s390_valid_target_attribute_inner_p): Likewise. * config/s390/s390.h (LONG_DOUBLE_TYPE_SIZE): Likewise. * config/s390/s390.md: Likewise. * config/s390/t-s390: Likewise. * config/s390/vx-builtins.md: Likewise. * config/s390/x-native: Likewise. * config/sh/divtab-sh4-300.cc (main): Likewise. * config/sh/divtab-sh4.cc (main): Likewise. * config/sh/divtab.cc (main): Likewise. * config/sh/elf.h: Likewise. * config/sh/sh-protos.h (sh_fsca_int2sf): Likewise. * config/sh/sh.cc (SYMBOL_FLAG_FUNCVEC_FUNCTION): Likewise. (sh_struct_value_rtx): Likewise. (sh_remove_reg_dead_or_unused_notes): Likewise. * config/sh/sh.h (MIN_UNITS_PER_WORD): Likewise. * config/sh/t-sh: Likewise. * config/sol2-protos.h (solaris_override_options): Likewise. * config/sol2.h: Likewise. * config/sparc/driver-sparc.cc: Likewise. * config/sparc/freebsd.h: Likewise. * config/sparc/sparc-protos.h (make_pass_work_around_errata): Likewise. * config/sparc/sparc.cc (sparc_output_mi_thunk): Likewise. (sparc_asan_shadow_offset): Likewise. * config/sparc/sparc.h: Likewise. * config/sparc/sparc.md: Likewise. * config/sparc/t-sparc: Likewise. * config/sparc/x-sparc: Likewise. * config/stormy16/stormy16.cc (xstormy16_mode_dependent_address_p): Likewise. * config/t-darwin: Likewise. * config/t-dragonfly: Likewise. * config/t-freebsd: Likewise. * config/t-glibc: Likewise. * config/t-linux: Likewise. * config/t-netbsd: Likewise. * config/t-openbsd: Likewise. * config/t-pnt16-warn: Likewise. * config/t-sol2: Likewise. * config/t-vxworks: Likewise. * config/t-winnt: Likewise. * config/tilegx/t-tilegx: Likewise. * config/tilegx/tilegx-c.cc: Likewise. * config/tilegx/tilegx-protos.h (tilegx_function_profiler): Likewise. * config/tilegx/tilegx.md: Likewise. * config/tilepro/t-tilepro: Likewise. * config/tilepro/tilepro-c.cc: Likewise. * config/v850/t-v850: Likewise. * config/v850/v850-protos.h: Likewise. * config/v850/v850.cc (F): Likewise. * config/v850/v850.h (enum reg_class): Likewise. (SLOW_BYTE_ACCESS): Likewise. * config/vax/vax.cc (vax_mode_dependent_address_p): Likewise. * config/vax/vax.h (enum reg_class): Likewise. * config/vax/vax.md: Likewise. * config/visium/visium.cc (visium_legitimate_address_p): Likewise. * config/visium/visium.h: Likewise. * config/vms/t-vms: Likewise. * config/vms/vms-crtlmap.map: Likewise. * config/vms/vms-protos.h (vms_c_get_vms_ver): Likewise. * config/vx-common.h: Likewise. * config/x-darwin: Likewise. * config/x-hpux: Likewise. * config/x-linux: Likewise. * config/x-netbsd: Likewise. * config/x-openbsd: Likewise. * config/x-solaris: Likewise. * config/xtensa/xtensa-protos.h (xtensa_mem_offset): Likewise. * config/xtensa/xtensa.cc (xtensa_option_override): Likewise. * config/xtensa/xtensa.h: Likewise. * configure.ac: Likewise. * context.cc: Likewise. * convert.h: Likewise. * coretypes.h: Likewise. * coverage.cc: Likewise. * coverage.h: Likewise. * cppdefault.h (struct default_include): Likewise. * cprop.cc (local_cprop_pass): Likewise. (one_cprop_pass): Likewise. * cse.cc (hash_rtx_cb): Likewise. (fold_rtx): Likewise. * ctfc.h (ctfc_get_num_vlen_bytes): Likewise. * data-streamer.h (bp_unpack_var_len_int): Likewise. (streamer_write_widest_int): Likewise. * dbgcnt.def: Likewise. * dbxout.cc (dbxout_early_global_decl): Likewise. (dbxout_common_check): Likewise. * dbxout.h: Likewise. * debug.h (struct gcc_debug_hooks): Likewise. (dump_go_spec_init): Likewise. * df-core.cc: Likewise. * df-scan.cc (df_insn_info_delete): Likewise. (df_insn_delete): Likewise. * df.h (debug_df_chain): Likewise. (can_move_insns_across): Likewise. * dfp.cc (decimal_from_binary): Likewise. * diagnostic-color.cc: Likewise. * diagnostic-event-id.h: Likewise. * diagnostic-show-locus.cc (test_one_liner_labels): Likewise. * diagnostic.cc (bt_callback): Likewise. (num_digits): Likewise. * doc/avr-mmcu.texi: Likewise. * doc/cfg.texi: Likewise. * doc/contrib.texi: Likewise. * doc/cppinternals.texi: Likewise. * doc/extend.texi: Likewise. * doc/generic.texi: Likewise. * doc/gimple.texi: Likewise. * doc/gty.texi: Likewise. * doc/invoke.texi: Likewise. * doc/loop.texi: Likewise. * doc/lto.texi: Likewise. * doc/match-and-simplify.texi: Likewise. * doc/md.texi: Likewise. * doc/optinfo.texi: Likewise. * doc/options.texi: Likewise. * doc/passes.texi: Likewise. * doc/plugins.texi: Likewise. * doc/rtl.texi: Likewise. * doc/sourcebuild.texi: Likewise. * doc/tm.texi: Likewise. * doc/tm.texi.in: Likewise. * doc/tree-ssa.texi: Likewise. * dojump.cc (do_jump): Likewise. * dojump.h: Likewise. * dumpfile.cc (test_impl_location): Likewise. (test_capture_of_dump_calls): Likewise. * dumpfile.h (enum dump_kind): Likewise. (class dump_location_t): Likewise. (dump_enabled_p): Likewise. (enable_rtl_dump_file): Likewise. (dump_combine_total_stats): Likewise. * dwarf2asm.cc (dw2_asm_output_delta_uleb128): Likewise. * dwarf2ctf.h (ctf_debug_finish): Likewise. * dwarf2out.cc (dwarf2out_begin_prologue): Likewise. (struct loc_descr_context): Likewise. (rtl_for_decl_location): Likewise. (gen_subprogram_die): Likewise. (gen_label_die): Likewise. (is_trivial_indirect_ref): Likewise. (dwarf2out_late_global_decl): Likewise. (dwarf_file_hasher::hash): Likewise. (dwarf2out_end_source_file): Likewise. (dwarf2out_define): Likewise. (dwarf2out_early_finish): Likewise. * dwarf2out.h (struct dw_fde_node): Likewise. (struct dw_discr_list_node): Likewise. (output_loc_sequence_raw): Likewise. * emit-rtl.cc (gen_raw_REG): Likewise. (maybe_set_max_label_num): Likewise. * emit-rtl.h (struct rtl_data): Likewise. * errors.cc (internal_error): Likewise. (trim_filename): Likewise. * et-forest.cc: Likewise. * except.cc (init_eh_for_function): Likewise. * explow.cc (promote_ssa_mode): Likewise. (get_dynamic_stack_size): Likewise. * explow.h: Likewise. * expmed.h: Likewise. * expr.cc (safe_from_p): Likewise. (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. * file-prefix-map.cc (remap_filename): Likewise. * final.cc (app_enable): Likewise. (make_pass_compute_alignments): Likewise. (final_scan_insn_1): Likewise. (final_scan_insn): Likewise. * fixed-value.h (fixed_from_string): Likewise. * flag-types.h (NO_DEBUG): Likewise. (DWARF2_DEBUG): Likewise. (VMS_DEBUG): Likewise. (BTF_DEBUG): Likewise. (enum ctf_debug_info_levels): Likewise. * fold-const.cc (const_binop): Likewise. (fold_binary_loc): Likewise. (fold_checksum_tree): Likewise. * fp-test.cc: Likewise. * function.cc (expand_function_end): Likewise. * function.h (struct function): Likewise. * fwprop.cc (should_replace_address): Likewise. * gcc-main.cc: Likewise. * gcc-rich-location.h (class gcc_rich_location): Likewise. * gcc-symtab.h: Likewise. * gcc.cc (MIN_FATAL_STATUS): Likewise. (driver_handle_option): Likewise. (quote_spec_arg): Likewise. (driver::finalize): Likewise. * gcc.h (set_input): Likewise. * gcov-dump.cc: Likewise. * gcov.cc (solve_flow_graph): Likewise. * gcse-common.cc: Likewise. * gcse.cc (make_pass_rtl_hoist): Likewise. * genattr-common.cc: Likewise. * genattrtab.cc (min_fn): Likewise. (write_const_num_delay_slots): Likewise. * genautomata.cc: Likewise. * genconditions.cc (write_one_condition): Likewise. * genconstants.cc: Likewise. * genemit.cc (gen_exp): Likewise. * generic-match-head.cc: Likewise. * genextract.cc: Likewise. * gengenrtl.cc (always_void_p): Likewise. * gengtype-parse.cc (gtymarker_opt): Likewise. * gengtype-state.cc (state_writer::state_writer): Likewise. (write_state_trailer): Likewise. (equals_type_number): Likewise. (read_state): Likewise. * gengtype.cc (open_base_files): Likewise. (struct file_rule_st): Likewise. (header_dot_h_frul): Likewise. * gengtype.h: Likewise. * genmatch.cc (main): Likewise. * genmddeps.cc: Likewise. * genmodes.cc (emit_mode_inner): Likewise. (emit_mode_unit_size): Likewise. * genpeep.cc (gen_peephole): Likewise. * genpreds.cc (write_tm_preds_h): Likewise. * genrecog.cc (validate_pattern): Likewise. (write_header): Likewise. (main): Likewise. * gensupport.cc (change_subst_attribute): Likewise. (traverse_c_tests): Likewise. (add_predicate): Likewise. (init_predicate_table): Likewise. * gensupport.h (struct optab_pattern): Likewise. (get_num_insn_codes): Likewise. (maybe_eval_c_test): Likewise. (struct pred_data): Likewise. * ggc-internal.h: Likewise. * gimple-fold.cc (maybe_fold_reference): Likewise. (get_range_strlen_tree): Likewise. * gimple-fold.h (gimple_stmt_integer_valued_real_p): Likewise. * gimple-low.cc: Likewise. * gimple-match-head.cc (directly_supported_p): Likewise. * gimple-pretty-print.h: Likewise. * gimple-ssa-sprintf.cc (format_percent): Likewise. (adjust_range_for_overflow): Likewise. * gimple-streamer.h: Likewise. * gimple.h (struct GTY): Likewise. (is_gimple_resx): Likewise. * gimplify.cc (gimplify_expr): Likewise. (gimplify_init_constructor): Likewise. (omp_construct_selector_matches): Likewise. (gimplify_omp_target_update): Likewise. (gimplify_omp_ordered): Likewise. (gimplify_va_arg_expr): Likewise. * graphite-isl-ast-to-gimple.cc (should_copy_to_new_region): Likewise. * haifa-sched.cc (increase_insn_priority): Likewise. (try_ready): Likewise. (sched_create_recovery_edges): Likewise. * ifcvt.cc (find_if_case_1): Likewise. (find_if_case_2): Likewise. * inchash.h: Likewise. * incpath.cc (add_env_var_paths): Likewise. * input.cc (dump_location_info): Likewise. (assert_loceq): Likewise. (test_lexer_string_locations_concatenation_1): Likewise. (test_lexer_string_locations_concatenation_2): Likewise. (test_lexer_string_locations_concatenation_3): Likewise. * input.h (BUILTINS_LOCATION): Likewise. (class string_concat_db): Likewise. * internal-fn.cc (expand_MUL_OVERFLOW): Likewise. (expand_LOOP_VECTORIZED): Likewise. * ipa-cp.cc (make_pass_ipa_cp): Likewise. * ipa-fnsummary.cc (remap_freqcounting_preds_after_dup): Likewise. (ipa_fn_summary_t::duplicate): Likewise. (make_pass_ipa_fn_summary): Likewise. * ipa-fnsummary.h (enum ipa_hints_vals): Likewise. * ipa-free-lang-data.cc (fld_simplified_type): Likewise. (free_lang_data_in_decl): Likewise. * ipa-inline.cc (compute_inlined_call_time): Likewise. (inline_always_inline_functions): Likewise. * ipa-inline.h (free_growth_caches): Likewise. (inline_account_function_p): Likewise. * ipa-modref.cc (modref_access_analysis::analyze_stmt): Likewise. (modref_eaf_analysis::analyze_ssa_name): Likewise. * ipa-param-manipulation.cc (ipa_param_body_adjustments::mark_dead_statements): Likewise. (ipa_param_body_adjustments::remap_with_debug_expressions): Likewise. * ipa-prop.cc (ipa_set_node_agg_value_chain): Likewise. * ipa-prop.h (IPA_UNDESCRIBED_USE): Likewise. (unadjusted_ptr_and_unit_offset): Likewise. * ipa-reference.cc (make_pass_ipa_reference): Likewise. * ipa-reference.h (GCC_IPA_REFERENCE_H): Likewise. * ipa-split.cc (consider_split): Likewise. * ipa-sra.cc (isra_read_node_info): Likewise. * ipa-utils.h (struct ipa_dfs_info): Likewise. (recursive_call_p): Likewise. (ipa_make_function_pure): Likewise. * ira-build.cc (ira_create_allocno): Likewise. (ira_flattening): Likewise. * ira-color.cc (do_coloring): Likewise. (update_curr_costs): Likewise. * ira-conflicts.cc (process_regs_for_copy): Likewise. * ira-int.h (struct ira_emit_data): Likewise. (ira_prohibited_mode_move_regs): Likewise. (ira_get_dup_out_num): Likewise. (ira_destroy): Likewise. (ira_tune_allocno_costs): Likewise. (ira_implicitly_set_insn_hard_regs): Likewise. (ira_build_conflicts): Likewise. (ira_color): Likewise. * ira-lives.cc (process_bb_node_lives): Likewise. * ira.cc (class ira_spilled_reg_stack_slot): Likewise. (setup_uniform_class_p): Likewise. (def_dominates_uses): Likewise. * ira.h (ira_nullify_asm_goto): Likewise. * langhooks.cc (lhd_post_options): Likewise. * langhooks.h (class substring_loc): Likewise. (struct lang_hooks_for_tree_inlining): Likewise. (struct lang_hooks_for_types): Likewise. (struct lang_hooks): Likewise. * libfuncs.h (synchronize_libfunc): Likewise. * loop-doloop.cc (doloop_condition_get): Likewise. * loop-init.cc (fix_loop_structure): Likewise. * loop-invariant.cc: Likewise. * lower-subreg.h: Likewise. * lra-constraints.cc (curr_insn_transform): Likewise. * lra-int.h (struct lra_insn_reg): Likewise. (lra_undo_inheritance): Likewise. (lra_setup_reload_pseudo_preferenced_hard_reg): Likewise. (lra_split_hard_reg_for): Likewise. (lra_coalesce): Likewise. (lra_final_code_change): Likewise. * lra-spills.cc (lra_final_code_change): Likewise. * lra.cc (lra_process_new_insns): Likewise. * lto-compress.h (struct lto_compression_stream): Likewise. * lto-streamer-out.cc (DFS::DFS_write_tree_body): Likewise. (write_symbol): Likewise. * lto-streamer.h (enum LTO_tags): Likewise. (lto_value_range_error): Likewise. (lto_append_block): Likewise. (lto_streamer_hooks_init): Likewise. (stream_read_tree_ref): Likewise. (lto_prepare_function_for_streaming): Likewise. (select_what_to_stream): Likewise. (omp_lto_input_declare_variant_alt): Likewise. (cl_optimization_stream_in): Likewise. * lto-wrapper.cc (append_compiler_options): Likewise. * machmode.def: Likewise. * machmode.h (struct int_n_data_t): Likewise. * main.cc (main): Likewise. * match.pd: Likewise. * omp-builtins.def (BUILT_IN_GOMP_CRITICAL_NAME_END): Likewise. (BUILT_IN_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT): Likewise. * omp-expand.cc (expand_omp_atomic_fetch_op): Likewise. (make_pass_expand_omp_ssa): Likewise. * omp-low.cc (struct omp_context): Likewise. (struct omp_taskcopy_context): Likewise. (lower_omp): Likewise. * omp-oacc-neuter-broadcast.cc (omp_sese_active_worker_call): Likewise. (mask_name): Likewise. (omp_sese_dump_pars): Likewise. (worker_single_simple): Likewise. * omp-offload.cc (omp_finish_file): Likewise. (execute_oacc_loop_designation): Likewise. * optabs-query.cc (lshift_cheap_p): Likewise. * optc-gen.awk: Likewise. * optc-save-gen.awk: Likewise. * optinfo-emit-json.cc (optrecord_json_writer::optrecord_json_writer): Likewise. * opts-common.cc: Likewise. * output.h (app_enable): Likewise. (output_operand_lossage): Likewise. (insn_current_reference_address): Likewise. (get_insn_template): Likewise. (output_quoted_string): Likewise. * pass_manager.h (struct register_pass_info): Likewise. * plugin.cc: Likewise. * plugin.def (PLUGIN_ANALYZER_INIT): Likewise. * plugin.h (invoke_plugin_callbacks): Likewise. * pointer-query.cc (handle_mem_ref): Likewise. * postreload-gcse.cc (alloc_mem): Likewise. * predict.h (enum prediction): Likewise. (add_reg_br_prob_note): Likewise. * prefix.h: Likewise. * profile.h (get_working_sets): Likewise. * read-md.cc: Likewise. * read-md.h (struct mapping): Likewise. (class md_reader): Likewise. (class noop_reader): Likewise. * read-rtl-function.cc (function_reader::create_function): Likewise. (function_reader::extra_parsing_for_operand_code_0): Likewise. * read-rtl.cc (initialize_iterators): Likewise. * real.cc: Likewise. * real.h (struct real_value): Likewise. (format_helper::format_helper): Likewise. (real_hash): Likewise. (real_can_shorten_arithmetic): Likewise. * recog.cc (struct target_recog): Likewise. (offsettable_nonstrict_memref_p): Likewise. (constrain_operands): Likewise. * recog.h (MAX_RECOG_ALTERNATIVES): Likewise. (which_op_alt): Likewise. (struct insn_gen_fn): Likewise. * reg-notes.def (REG_NOTE): Likewise. * reg-stack.cc: Likewise. * regs.h (reg_is_parm_p): Likewise. * regset.h: Likewise. * reload.cc (push_reload): Likewise. (find_reloads): Likewise. (find_reloads_address_1): Likewise. (find_replacement): Likewise. (refers_to_regno_for_reload_p): Likewise. (refers_to_mem_for_reload_p): Likewise. * reload.h (push_reload): Likewise. (deallocate_reload_reg): Likewise. * reload1.cc (emit_input_reload_insns): Likewise. * reorg.cc (relax_delay_slots): Likewise. * rtl.def (UNKNOWN): Likewise. (SEQUENCE): Likewise. (BARRIER): Likewise. (ASM_OPERANDS): Likewise. (EQ_ATTR_ALT): Likewise. * rtl.h (struct GTY): Likewise. (LABEL_NAME): Likewise. (LABEL_ALT_ENTRY_P): Likewise. (SUBREG_BYTE): Likewise. (get_stack_check_protect): Likewise. (dump_rtx_statistics): Likewise. (unwrap_const_vec_duplicate): Likewise. (subreg_promoted_mode): Likewise. (gen_lowpart_common): Likewise. (operand_subword): Likewise. (immed_wide_int_const): Likewise. (decide_function_section): Likewise. (active_insn_p): Likewise. (delete_related_insns): Likewise. (try_split): Likewise. (val_signbit_known_clear_p): Likewise. (simplifiable_subregs): Likewise. (set_insn_deleted): Likewise. (subreg_get_info): Likewise. (remove_free_EXPR_LIST_node): Likewise. (finish_subregs_of_mode): Likewise. (get_mem_attrs): Likewise. (lookup_constant_def): Likewise. (rtx_to_tree_code): Likewise. (hash_rtx): Likewise. (condjump_in_parallel_p): Likewise. (validate_subreg): Likewise. (make_compound_operation): Likewise. (schedule_ebbs): Likewise. (print_inline_rtx): Likewise. (fixup_args_size_notes): Likewise. (expand_dec): Likewise. (prepare_copy_insn): Likewise. (mark_elimination): Likewise. (valid_mode_changes_for_regno): Likewise. (make_debug_expr_from_rtl): Likewise. (delete_vta_debug_insns): Likewise. (simplify_using_condition): Likewise. (set_insn_locations): Likewise. (fatal_insn_not_found): Likewise. (word_register_operation_p): Likewise. * rtlanal.cc (get_call_fndecl): Likewise. (side_effects_p): Likewise. (subreg_nregs): Likewise. (rtx_cost): Likewise. (canonicalize_condition): Likewise. * rtlanal.h (rtx_properties::try_to_add_note): Likewise. * run-rtl-passes.cc (run_rtl_passes): Likewise. * sanitizer.def (BUILT_IN_ASAN_VERSION_MISMATCH_CHECK): Likewise. * sched-deps.cc (add_dependence_1): Likewise. * sched-ebb.cc (begin_move_insn): Likewise. (add_deps_for_risky_insns): Likewise. (advance_target_bb): Likewise. * sched-int.h (reemit_notes): Likewise. (struct _haifa_insn_data): Likewise. (HID): Likewise. (DEP_CANCELLED): Likewise. (debug_ds): Likewise. (number_in_ready): Likewise. (schedule_ebbs_finish): Likewise. (find_modifiable_mems): Likewise. * sched-rgn.cc (debug_rgn_dependencies): Likewise. * sel-sched-dump.cc (dump_lv_set): Likewise. * sel-sched-dump.h: Likewise. * sel-sched-ir.cc (sel_insn_rtx_cost): Likewise. (setup_id_reg_sets): Likewise. (has_dependence_p): Likewise. (sel_num_cfg_preds_gt_1): Likewise. (bb_ends_ebb_p): Likewise. * sel-sched-ir.h (struct _list_node): Likewise. (struct idata_def): Likewise. (bb_next_bb): Likewise. * sel-sched.cc (vinsn_writes_one_of_regs_p): Likewise. (choose_best_pseudo_reg): Likewise. (verify_target_availability): Likewise. (can_speculate_dep_p): Likewise. (sel_rank_for_schedule): Likewise. * selftest-run-tests.cc (selftest::run_tests): Likewise. * selftest.h (class auto_fix_quotes): Likewise. * shrink-wrap.cc (handle_simple_exit): Likewise. * shrink-wrap.h: Likewise. * simplify-rtx.cc (simplify_context::simplify_associative_operation): Likewise. (simplify_context::simplify_gen_vec_select): Likewise. * spellcheck-tree.h: Likewise. * spellcheck.h: Likewise. * statistics.h (struct function): Likewise. * stmt.cc (conditional_probability): Likewise. * stmt.h: Likewise. * stor-layout.h: Likewise. * streamer-hooks.h: Likewise. * stringpool.h: Likewise. * symtab.cc (symbol_table::change_decl_assembler_name): Likewise. * target.def (HOOK_VECTOR_END): Likewise. (type.): Likewise. * target.h (union cumulative_args_t): Likewise. (by_pieces_ninsns): Likewise. (class predefined_function_abi): Likewise. * targhooks.cc (default_translate_mode_attribute): Likewise. * timevar.def: Likewise. * timevar.h (class timer): Likewise. * toplev.h (enable_rtl_dump_file): Likewise. * trans-mem.cc (collect_bb2reg): Likewise. * tree-call-cdce.cc (gen_conditions_for_pow): Likewise. * tree-cfg.cc (remove_bb): Likewise. (verify_gimple_debug): Likewise. (remove_edge_and_dominated_blocks): Likewise. (push_fndecl): Likewise. * tree-cfgcleanup.h (GCC_TREE_CFGCLEANUP_H): Likewise. * tree-complex.cc (expand_complex_multiplication): Likewise. (expand_complex_div_straight): Likewise. * tree-core.h (enum tree_index): Likewise. (enum operand_equal_flag): Likewise. * tree-eh.cc (honor_protect_cleanup_actions): Likewise. * tree-if-conv.cc (if_convertible_gimple_assign_stmt_p): Likewise. * tree-inline.cc (initialize_inlined_parameters): Likewise. * tree-inline.h (force_value_to_type): Likewise. * tree-nested.cc (get_chain_decl): Likewise. (walk_all_functions): Likewise. * tree-object-size.h: Likewise. * tree-outof-ssa.cc: Likewise. * tree-parloops.cc (create_parallel_loop): Likewise. * tree-pretty-print.cc (print_generic_expr_to_str): Likewise. (dump_generic_node): Likewise. * tree-profile.cc (tree_profiling): Likewise. * tree-sra.cc (maybe_add_sra_candidate): Likewise. * tree-ssa-address.cc: Likewise. * tree-ssa-alias.cc: Likewise. * tree-ssa-alias.h (ao_ref::max_size_known_p): Likewise. (dump_alias_stats): Likewise. * tree-ssa-ccp.cc: Likewise. * tree-ssa-coalesce.h: Likewise. * tree-ssa-live.cc (remove_unused_scope_block_p): Likewise. * tree-ssa-loop-manip.cc (copy_phi_node_args): Likewise. * tree-ssa-loop-unswitch.cc: Likewise. * tree-ssa-math-opts.cc: Likewise. * tree-ssa-operands.cc (class operands_scanner): Likewise. * tree-ssa-pre.cc: Likewise. * tree-ssa-reassoc.cc (optimize_ops_list): Likewise. (debug_range_entry): Likewise. * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): Likewise. * tree-ssa-sccvn.h (TREE_SSA_SCCVN_H): Likewise. * tree-ssa-scopedtables.cc (add_expr_commutative): Likewise. (equal_mem_array_ref_p): Likewise. * tree-ssa-strlen.cc (is_strlen_related_p): Likewise. * tree-ssa-strlen.h (get_range_strlen_dynamic): Likewise. * tree-ssa-tail-merge.cc (stmt_local_def): Likewise. * tree-ssa-ter.h: Likewise. * tree-ssa-threadupdate.h (enum bb_dom_status): Likewise. * tree-streamer-in.cc (lto_input_ts_block_tree_pointers): Likewise. * tree-streamer-out.cc (pack_ts_block_value_fields): Likewise. (write_ts_block_tree_pointers): Likewise. * tree-streamer.h (struct streamer_tree_cache_d): Likewise. (streamer_read_tree_bitfields): Likewise. (streamer_write_integer_cst): Likewise. * tree-vect-patterns.cc (apply_binop_and_append_stmt): Likewise. (vect_synth_mult_by_constant): Likewise. * tree-vect-stmts.cc (vectorizable_operation): Likewise. * tree-vectorizer.cc: Likewise. * tree-vectorizer.h (class auto_purge_vect_location): Likewise. (vect_update_inits_of_drs): Likewise. (vect_get_mask_type_for_stmt): Likewise. (vect_rgroup_iv_might_wrap_p): Likewise. (cse_and_gimplify_to_preheader): Likewise. (vect_free_slp_tree): Likewise. (vect_pattern_recog): Likewise. (vect_stmt_dominates_stmt_p): Likewise. * tree.cc (initialize_tree_contains_struct): Likewise. (need_assembler_name_p): Likewise. (type_with_interoperable_signedness): Likewise. * tree.def (SWITCH_EXPR): Likewise. * tree.h (TYPE_SYMTAB_ADDRESS): Likewise. (poly_int_tree_p): Likewise. (inlined_function_outer_scope_p): Likewise. (tree_code_for_canonical_type_merging): Likewise. * value-prof.cc: Likewise. * value-prof.h (get_nth_most_common_value): Likewise. (find_func_by_profile_id): Likewise. * value-range.cc (vrp_operand_equal_p): Likewise. * value-range.h: Likewise. * var-tracking.cc: Likewise. * varasm.cc (default_function_section): Likewise. (function_section_1): Likewise. (assemble_variable): Likewise. (handle_vtv_comdat_section): Likewise. * vec.h (struct vec_prefix): Likewise. * vmsdbgout.cc (full_name): Likewise. * vtable-verify.cc: Likewise. * vtable-verify.h (struct vtv_graph_node): Likewise. * xcoffout.cc: Likewise. * xcoffout.h (DEBUG_SYMS_TEXT): Likewise. gcc/ada/ChangeLog: * Make-generated.in: Rename .c names to .cc. * adaint.c: Likewise. * ctrl_c.c (dummy_handler): Likewise. * gcc-interface/Makefile.in: Likewise. * gcc-interface/config-lang.in: Likewise. * gcc-interface/decl.cc (concat_name): Likewise. (init_gnat_decl): Likewise. * gcc-interface/gigi.h (concat_name): Likewise. (init_gnat_utils): Likewise. (build_call_raise_range): Likewise. (gnat_mark_addressable): Likewise. (gnat_protect_expr): Likewise. (gnat_rewrite_reference): Likewise. * gcc-interface/lang-specs.h (ADA_DUMPS_OPTIONS): Likewise. * gcc-interface/utils.cc (GTY): Likewise. (add_deferred_type_context): Likewise. (init_gnat_utils): Likewise. * gcc-interface/utils2.cc (gnat_stable_expr_p): Likewise. (gnat_protect_expr): Likewise. (gnat_stabilize_reference_1): Likewise. (gnat_rewrite_reference): Likewise. * gsocket.h: Likewise. * init.cc (__gnat_error_handler): Likewise. * libgnarl/s-intman.ads: Likewise. * libgnarl/s-osinte__android.ads: Likewise. * libgnarl/s-osinte__darwin.ads: Likewise. * libgnarl/s-osinte__hpux.ads: Likewise. * libgnarl/s-osinte__linux.ads: Likewise. * libgnarl/s-osinte__qnx.ads: Likewise. * libgnarl/s-taskin.ads: Likewise. * rtfinal.cc: Likewise. * s-oscons-tmplt.c (CND): Likewise. * set_targ.ads: Likewise. gcc/analyzer/ChangeLog: * analyzer.cc (is_special_named_call_p): Rename .c names to .cc. (is_named_call_p): Likewise. * region-model-asm.cc (deterministic_p): Likewise. * region.cc (field_region::get_relative_concrete_offset): Likewise. * sm-malloc.cc (method_p): Likewise. * supergraph.cc (superedge::dump_dot): Likewise. gcc/c-family/ChangeLog: * c-ada-spec.cc: Rename .c names to .cc. * c-ada-spec.h: Likewise. * c-common.cc (c_build_vec_convert): Likewise. (warning_candidate_p): Likewise. * c-common.h (enum rid): Likewise. (build_real_imag_expr): Likewise. (finish_label_address_expr): Likewise. (c_get_substring_location): Likewise. (c_build_bind_expr): Likewise. (conflict_marker_get_final_tok_kind): Likewise. (c_parse_error): Likewise. (check_missing_format_attribute): Likewise. (invalid_array_size_error): Likewise. (warn_for_multistatement_macros): Likewise. (build_attr_access_from_parms): Likewise. * c-cppbuiltin.cc (c_cpp_builtins): Likewise. * c-format.cc: Likewise. * c-gimplify.cc (c_gimplify_expr): Likewise. * c-indentation.h: Likewise. * c-objc.h (objc_prop_attr_kind_for_rid): Likewise. * c-omp.cc (c_omp_predetermined_mapping): Likewise. * c-opts.cc (c_common_post_options): Likewise. (set_std_cxx23): Likewise. * c-pragma.cc (handle_pragma_redefine_extname): Likewise. * c-pretty-print.h: Likewise. gcc/c/ChangeLog: * Make-lang.in: Rename .c names to .cc. * c-convert.cc: Likewise. * c-decl.cc (struct lang_identifier): Likewise. (pop_scope): Likewise. (finish_decl): Likewise. * c-objc-common.h (GCC_C_OBJC_COMMON): Likewise. * c-parser.cc (c_parser_skip_to_end_of_block_or_statement): Likewise. * c-parser.h (GCC_C_PARSER_H): Likewise. * c-tree.h (c_keyword_starts_typename): Likewise. (finish_declspecs): Likewise. (c_get_alias_set): Likewise. (enum c_oracle_request): Likewise. (tag_exists_p): Likewise. (set_c_expr_source_range): Likewise. * c-typeck.cc (c_common_type): Likewise. (c_finish_omp_clauses): Likewise. * config-lang.in: Likewise. gcc/cp/ChangeLog: * Make-lang.in: Rename .c names to .cc. * config-lang.in: Likewise. * constexpr.cc (cxx_eval_constant_expression): Likewise. * coroutines.cc (morph_fn_to_coro): Likewise. * cp-gimplify.cc (cp_gimplify_expr): Likewise. * cp-lang.cc (struct lang_hooks): Likewise. (get_template_argument_pack_elems_folded): Likewise. * cp-objcp-common.cc (cp_tree_size): Likewise. (cp_unit_size_without_reusable_padding): Likewise. (pop_file_scope): Likewise. (cp_pushdecl): Likewise. * cp-objcp-common.h (GCC_CP_OBJCP_COMMON): Likewise. (cxx_simulate_record_decl): Likewise. * cp-tree.h (struct named_label_entry): Likewise. (current_function_return_value): Likewise. (more_aggr_init_expr_args_p): Likewise. (get_function_version_dispatcher): Likewise. (common_enclosing_class): Likewise. (strip_fnptr_conv): Likewise. (current_decl_namespace): Likewise. (do_aggregate_paren_init): Likewise. (cp_check_const_attributes): Likewise. (qualified_name_lookup_error): Likewise. (generic_targs_for): Likewise. (mark_exp_read): Likewise. (is_global_friend): Likewise. (maybe_reject_flexarray_init): Likewise. (module_token_lang): Likewise. (handle_module_option): Likewise. (literal_integer_zerop): Likewise. (build_extra_args): Likewise. (build_if_nonnull): Likewise. (maybe_check_overriding_exception_spec): Likewise. (finish_omp_target_clauses): Likewise. (maybe_warn_zero_as_null_pointer_constant): Likewise. (cxx_print_error_function): Likewise. (decl_in_std_namespace_p): Likewise. (merge_exception_specifiers): Likewise. (mangle_module_global_init): Likewise. (cxx_block_may_fallthru): Likewise. (fold_builtin_source_location): Likewise. (enum cp_oracle_request): Likewise. (subsumes): Likewise. (cp_finish_injected_record_type): Likewise. (vtv_build_vtable_verify_fndecl): Likewise. (cp_tree_c_finish_parsing): Likewise. * cvt.cc (diagnose_ref_binding): Likewise. (convert_to_void): Likewise. (convert_force): Likewise. (type_promotes_to): Likewise. * decl.cc (make_unbound_class_template_raw): Likewise. (cxx_init_decl_processing): Likewise. (check_class_member_definition_namespace): Likewise. (cxx_maybe_build_cleanup): Likewise. * decl2.cc (maybe_emit_vtables): Likewise. * error.cc (dump_function_name): Likewise. * init.cc (is_class_type): Likewise. (build_new_1): Likewise. * lang-specs.h: Likewise. * method.cc (make_alias_for_thunk): Likewise. * module.cc (specialization_add): Likewise. (module_state::read_cluster): Likewise. * name-lookup.cc (check_extern_c_conflict): Likewise. * name-lookup.h (struct cxx_binding): Likewise. * parser.cc (cp_parser_identifier): Likewise. * parser.h (struct cp_parser): Likewise. * pt.cc (has_value_dependent_address): Likewise. (push_tinst_level_loc): Likewise. * semantics.cc (finish_omp_clauses): Likewise. (finish_omp_atomic): Likewise. * tree.cc (cp_save_expr): Likewise. (cp_free_lang_data): Likewise. * typeck.cc (cp_common_type): Likewise. (strip_array_domain): Likewise. (rationalize_conditional_expr): Likewise. (check_return_expr): Likewise. * vtable-class-hierarchy.cc: Likewise. gcc/d/ChangeLog: * d-gimplify.cc: Rename .c names to .cc. * d-incpath.cc: Likewise. * lang-specs.h: Likewise. gcc/fortran/ChangeLog: * check.cc (gfc_check_all_any): Rename .c names to .cc. * class.cc (find_intrinsic_vtab): Likewise. * config-lang.in: Likewise. * cpp.cc (cpp_define_builtins): Likewise. * data.cc (get_array_index): Likewise. * decl.cc (match_clist_expr): Likewise. (get_proc_name): Likewise. (gfc_verify_c_interop_param): Likewise. (gfc_get_pdt_instance): Likewise. (gfc_match_formal_arglist): Likewise. (gfc_get_type_attr_spec): Likewise. * dependency.cc: Likewise. * error.cc (gfc_format_decoder): Likewise. * expr.cc (check_restricted): Likewise. (gfc_build_default_init_expr): Likewise. * f95-lang.cc: Likewise. * gfc-internals.texi: Likewise. * gfortran.h (enum match): Likewise. (enum procedure_type): Likewise. (enum oacc_routine_lop): Likewise. (gfc_get_pdt_instance): Likewise. (gfc_end_source_files): Likewise. (gfc_mpz_set_hwi): Likewise. (gfc_get_option_string): Likewise. (gfc_find_sym_in_expr): Likewise. (gfc_errors_to_warnings): Likewise. (gfc_real_4_kind): Likewise. (gfc_free_finalizer): Likewise. (gfc_sym_get_dummy_args): Likewise. (gfc_check_intrinsic_standard): Likewise. (gfc_free_case_list): Likewise. (gfc_resolve_oacc_routines): Likewise. (gfc_check_vardef_context): Likewise. (gfc_free_association_list): Likewise. (gfc_implicit_pure_function): Likewise. (gfc_ref_dimen_size): Likewise. (gfc_compare_actual_formal): Likewise. (gfc_resolve_wait): Likewise. (gfc_dt_upper_string): Likewise. (gfc_generate_module_code): Likewise. (gfc_delete_bbt): Likewise. (debug): Likewise. (gfc_build_block_ns): Likewise. (gfc_dep_difference): Likewise. (gfc_invalid_null_arg): Likewise. (gfc_is_finalizable): Likewise. (gfc_fix_implicit_pure): Likewise. (gfc_is_size_zero_array): Likewise. (gfc_is_reallocatable_lhs): Likewise. * gfortranspec.cc: Likewise. * interface.cc (compare_actual_expr): Likewise. * intrinsic.cc (add_functions): Likewise. * iresolve.cc (gfc_resolve_matmul): Likewise. (gfc_resolve_alarm_sub): Likewise. * iso-c-binding.def: Likewise. * lang-specs.h: Likewise. * libgfortran.h (GFC_STDERR_UNIT_NUMBER): Likewise. * match.cc (gfc_match_label): Likewise. (gfc_match_symbol): Likewise. (match_derived_type_spec): Likewise. (copy_ts_from_selector_to_associate): Likewise. * match.h (gfc_match_call): Likewise. (gfc_get_common): Likewise. (gfc_match_omp_end_single): Likewise. (gfc_match_volatile): Likewise. (gfc_match_bind_c): Likewise. (gfc_match_literal_constant): Likewise. (gfc_match_init_expr): Likewise. (gfc_match_array_constructor): Likewise. (gfc_match_end_interface): Likewise. (gfc_match_print): Likewise. (gfc_match_expr): Likewise. * matchexp.cc (next_operator): Likewise. * mathbuiltins.def: Likewise. * module.cc (free_true_name): Likewise. * openmp.cc (gfc_resolve_omp_parallel_blocks): Likewise. (gfc_omp_save_and_clear_state): Likewise. * parse.cc (parse_union): Likewise. (set_syms_host_assoc): Likewise. * resolve.cc (resolve_actual_arglist): Likewise. (resolve_elemental_actual): Likewise. (check_host_association): Likewise. (resolve_typebound_function): Likewise. (resolve_typebound_subroutine): Likewise. (gfc_resolve_expr): Likewise. (resolve_assoc_var): Likewise. (resolve_typebound_procedures): Likewise. (resolve_equivalence_derived): Likewise. * simplify.cc (simplify_bound): Likewise. * symbol.cc (gfc_set_default_type): Likewise. (gfc_add_ext_attribute): Likewise. * target-memory.cc (gfc_target_interpret_expr): Likewise. * target-memory.h (gfc_target_interpret_expr): Likewise. * trans-array.cc (gfc_get_cfi_dim_sm): Likewise. (gfc_conv_shift_descriptor_lbound): Likewise. (gfc_could_be_alias): Likewise. (gfc_get_dataptr_offset): Likewise. * trans-const.cc: Likewise. * trans-decl.cc (trans_function_start): Likewise. (gfc_trans_deferred_vars): Likewise. (generate_local_decl): Likewise. (gfc_generate_function_code): Likewise. * trans-expr.cc (gfc_vptr_size_get): Likewise. (gfc_trans_class_array_init_assign): Likewise. (POWI_TABLE_SIZE): Likewise. (gfc_conv_procedure_call): Likewise. (gfc_trans_arrayfunc_assign): Likewise. * trans-intrinsic.cc (gfc_conv_intrinsic_len): Likewise. (gfc_conv_intrinsic_loc): Likewise. (conv_intrinsic_event_query): Likewise. * trans-io.cc (gfc_build_st_parameter): Likewise. * trans-openmp.cc (gfc_omp_check_optional_argument): Likewise. (gfc_omp_unshare_expr_r): Likewise. (gfc_trans_omp_array_section): Likewise. (gfc_trans_omp_clauses): Likewise. * trans-stmt.cc (trans_associate_var): Likewise. (gfc_trans_deallocate): Likewise. * trans-stmt.h (gfc_trans_class_init_assign): Likewise. (gfc_trans_deallocate): Likewise. (gfc_trans_oacc_declare): Likewise. * trans-types.cc: Likewise. * trans-types.h (enum gfc_packed): Likewise. * trans.cc (N_): Likewise. (trans_code): Likewise. * trans.h (gfc_build_compare_string): Likewise. (gfc_conv_expr_type): Likewise. (gfc_trans_deferred_vars): Likewise. (getdecls): Likewise. (gfc_get_array_descr_info): Likewise. (gfc_omp_firstprivatize_type_sizes): Likewise. (GTY): Likewise. gcc/go/ChangeLog: * config-lang.in: Rename .c names to .cc. * go-backend.cc: Likewise. * go-lang.cc: Likewise. * gospec.cc: Likewise. * lang-specs.h: Likewise. gcc/jit/ChangeLog: * config-lang.in: Rename .c names to .cc. * docs/_build/texinfo/libgccjit.texi: Likewise. * docs/internals/index.rst: Likewise. * jit-builtins.cc (builtins_manager::make_builtin_function): Likewise. * jit-playback.cc (fold_const_var): Likewise. (playback::context::~context): Likewise. (new_field): Likewise. (new_bitfield): Likewise. (new_compound_type): Likewise. (playback::compound_type::set_fields): Likewise. (global_set_init_rvalue): Likewise. (load_blob_in_ctor): Likewise. (new_global_initialized): Likewise. (double>): Likewise. (new_string_literal): Likewise. (as_truth_value): Likewise. (build_call): Likewise. (playback::context::build_cast): Likewise. (new_array_access): Likewise. (new_field_access): Likewise. (dereference): Likewise. (postprocess): Likewise. (add_jump): Likewise. (add_switch): Likewise. (build_goto_operands): Likewise. (playback::context::read_dump_file): Likewise. (init_types): Likewise. * jit-recording.cc (recording::context::get_int_type): Likewise. * jit-recording.h: Likewise. * libgccjit.cc (compatible_types): Likewise. (gcc_jit_context_acquire): Likewise. (gcc_jit_context_release): Likewise. (gcc_jit_context_new_child_context): Likewise. (gcc_jit_type_as_object): Likewise. (gcc_jit_context_get_type): Likewise. (gcc_jit_context_get_int_type): Likewise. (gcc_jit_type_get_pointer): Likewise. (gcc_jit_type_get_const): Likewise. (gcc_jit_type_get_volatile): Likewise. (gcc_jit_type_dyncast_array): Likewise. (gcc_jit_type_is_bool): Likewise. (gcc_jit_type_is_pointer): Likewise. (gcc_jit_type_is_integral): Likewise. (gcc_jit_type_dyncast_vector): Likewise. (gcc_jit_type_is_struct): Likewise. (gcc_jit_vector_type_get_num_units): Likewise. (gcc_jit_vector_type_get_element_type): Likewise. (gcc_jit_type_unqualified): Likewise. (gcc_jit_type_dyncast_function_ptr_type): Likewise. (gcc_jit_function_type_get_return_type): Likewise. (gcc_jit_function_type_get_param_count): Likewise. (gcc_jit_function_type_get_param_type): Likewise. (gcc_jit_context_new_array_type): Likewise. (gcc_jit_context_new_field): Likewise. (gcc_jit_field_as_object): Likewise. (gcc_jit_context_new_struct_type): Likewise. (gcc_jit_struct_as_type): Likewise. (gcc_jit_struct_set_fields): Likewise. (gcc_jit_struct_get_field_count): Likewise. (gcc_jit_context_new_union_type): Likewise. (gcc_jit_context_new_function_ptr_type): Likewise. (gcc_jit_param_as_rvalue): Likewise. (gcc_jit_context_new_function): Likewise. (gcc_jit_function_get_return_type): Likewise. (gcc_jit_function_dump_to_dot): Likewise. (gcc_jit_block_get_function): Likewise. (gcc_jit_global_set_initializer_rvalue): Likewise. (gcc_jit_rvalue_get_type): Likewise. (gcc_jit_context_new_rvalue_from_int): Likewise. (gcc_jit_context_one): Likewise. (gcc_jit_context_new_rvalue_from_double): Likewise. (gcc_jit_context_null): Likewise. (gcc_jit_context_new_string_literal): Likewise. (valid_binary_op_p): Likewise. (gcc_jit_context_new_binary_op): Likewise. (gcc_jit_context_new_comparison): Likewise. (gcc_jit_context_new_call): Likewise. (is_valid_cast): Likewise. (gcc_jit_context_new_cast): Likewise. (gcc_jit_object_get_context): Likewise. (gcc_jit_object_get_debug_string): Likewise. (gcc_jit_lvalue_access_field): Likewise. (gcc_jit_rvalue_access_field): Likewise. (gcc_jit_rvalue_dereference_field): Likewise. (gcc_jit_rvalue_dereference): Likewise. (gcc_jit_lvalue_get_address): Likewise. (gcc_jit_lvalue_set_tls_model): Likewise. (gcc_jit_lvalue_set_link_section): Likewise. (gcc_jit_function_new_local): Likewise. (gcc_jit_block_add_eval): Likewise. (gcc_jit_block_add_assignment): Likewise. (is_bool): Likewise. (gcc_jit_block_end_with_conditional): Likewise. (gcc_jit_block_add_comment): Likewise. (gcc_jit_block_end_with_jump): Likewise. (gcc_jit_block_end_with_return): Likewise. (gcc_jit_block_end_with_void_return): Likewise. (case_range_validator::case_range_validator): Likewise. (case_range_validator::validate): Likewise. (case_range_validator::get_wide_int): Likewise. (gcc_jit_block_end_with_switch): Likewise. (gcc_jit_context_set_str_option): Likewise. (gcc_jit_context_set_int_option): Likewise. (gcc_jit_context_set_bool_option): Likewise. (gcc_jit_context_set_bool_allow_unreachable_blocks): Likewise. (gcc_jit_context_set_bool_use_external_driver): Likewise. (gcc_jit_context_add_command_line_option): Likewise. (gcc_jit_context_add_driver_option): Likewise. (gcc_jit_context_enable_dump): Likewise. (gcc_jit_context_compile): Likewise. (gcc_jit_context_compile_to_file): Likewise. (gcc_jit_context_set_logfile): Likewise. (gcc_jit_context_dump_reproducer_to_file): Likewise. (gcc_jit_context_get_first_error): Likewise. (gcc_jit_context_get_last_error): Likewise. (gcc_jit_result_get_code): Likewise. (gcc_jit_result_get_global): Likewise. (gcc_jit_rvalue_set_bool_require_tail_call): Likewise. (gcc_jit_type_get_aligned): Likewise. (gcc_jit_type_get_vector): Likewise. (gcc_jit_function_get_address): Likewise. (gcc_jit_version_patchlevel): Likewise. (gcc_jit_block_add_extended_asm): Likewise. (gcc_jit_extended_asm_as_object): Likewise. (gcc_jit_extended_asm_set_volatile_flag): Likewise. (gcc_jit_extended_asm_set_inline_flag): Likewise. (gcc_jit_extended_asm_add_output_operand): Likewise. (gcc_jit_extended_asm_add_input_operand): Likewise. (gcc_jit_extended_asm_add_clobber): Likewise. * notes.txt: Likewise. gcc/lto/ChangeLog: * config-lang.in: Rename .c names to .cc. * lang-specs.h: Likewise. * lto-common.cc (gimple_register_canonical_type_1): Likewise. * lto-common.h: Likewise. * lto-dump.cc (lto_main): Likewise. * lto-lang.cc (handle_fnspec_attribute): Likewise. (lto_getdecls): Likewise. (lto_init): Likewise. * lto.cc (lto_main): Likewise. * lto.h: Likewise. gcc/objc/ChangeLog: * Make-lang.in: Rename .c names to .cc. * config-lang.in: Likewise. * lang-specs.h: Likewise. * objc-act.cc (objc_build_component_ref): Likewise. (objc_copy_binfo): Likewise. (lookup_method_in_hash_lists): Likewise. (objc_finish_foreach_loop): Likewise. * objc-act.h (objc_common_init_ts): Likewise. * objc-gnu-runtime-abi-01.cc: Likewise. * objc-lang.cc (struct lang_hooks): Likewise. * objc-map.cc: Likewise. * objc-next-runtime-abi-01.cc (generate_objc_symtab_decl): Likewise. * objc-runtime-shared-support.cc: Likewise. * objc-runtime-shared-support.h (build_protocol_initializer): Likewise. gcc/objcp/ChangeLog: * Make-lang.in: Rename .c names to .cc. * config-lang.in: Likewise. * lang-specs.h: Likewise. * objcp-decl.cc (objcp_end_compound_stmt): Likewise. * objcp-lang.cc (struct lang_hooks): Likewise. gcc/po/ChangeLog: * EXCLUDES: Rename .c names to .cc. libcpp/ChangeLog: * Makefile.in: Rename .c names to .cc. * charset.cc (convert_escape): Likewise. * directives.cc (directive_diagnostics): Likewise. (_cpp_handle_directive): Likewise. (lex_macro_node): Likewise. * include/cpplib.h (struct _cpp_file): Likewise. (PURE_ZERO): Likewise. (cpp_defined): Likewise. (cpp_error_at): Likewise. (cpp_forall_identifiers): Likewise. (cpp_compare_macros): Likewise. (cpp_get_converted_source): Likewise. (cpp_read_state): Likewise. (cpp_directive_only_process): Likewise. (struct cpp_decoded_char): Likewise. * include/line-map.h (enum lc_reason): Likewise. (enum location_aspect): Likewise. * include/mkdeps.h: Likewise. * init.cc (cpp_destroy): Likewise. (cpp_finish): Likewise. * internal.h (struct cpp_reader): Likewise. (_cpp_defined_macro_p): Likewise. (_cpp_backup_tokens_direct): Likewise. (_cpp_destroy_hashtable): Likewise. (_cpp_has_header): Likewise. (_cpp_expand_op_stack): Likewise. (_cpp_commit_buff): Likewise. (_cpp_restore_special_builtin): Likewise. (_cpp_bracket_include): Likewise. (_cpp_replacement_text_len): Likewise. (ufputs): Likewise. * line-map.cc (linemap_macro_loc_to_exp_point): Likewise. (linemap_check_files_exited): Likewise. (line_map_new_raw): Likewise. * traditional.cc (enum ls): Likewise.
2511 lines
77 KiB
C++
2511 lines
77 KiB
C++
/* CPP Library - charsets
|
||
Copyright (C) 1998-2022 Free Software Foundation, Inc.
|
||
|
||
Broken out of c-lex.cc Apr 2003, adding valid C99 UCN ranges.
|
||
|
||
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 3, 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; see the file COPYING3. If not see
|
||
<http://www.gnu.org/licenses/>. */
|
||
|
||
#include "config.h"
|
||
#include "system.h"
|
||
#include "cpplib.h"
|
||
#include "internal.h"
|
||
|
||
/* Character set handling for C-family languages.
|
||
|
||
Terminological note: In what follows, "charset" or "character set"
|
||
will be taken to mean both an abstract set of characters and an
|
||
encoding for that set.
|
||
|
||
The C99 standard discusses two character sets: source and execution.
|
||
The source character set is used for internal processing in translation
|
||
phases 1 through 4; the execution character set is used thereafter.
|
||
Both are required by 5.2.1.2p1 to be multibyte encodings, not wide
|
||
character encodings (see 3.7.2, 3.7.3 for the standardese meanings
|
||
of these terms). Furthermore, the "basic character set" (listed in
|
||
5.2.1p3) is to be encoded in each with values one byte wide, and is
|
||
to appear in the initial shift state.
|
||
|
||
It is not explicitly mentioned, but there is also a "wide execution
|
||
character set" used to encode wide character constants and wide
|
||
string literals; this is supposed to be the result of applying the
|
||
standard library function mbstowcs() to an equivalent narrow string
|
||
(6.4.5p5). However, the behavior of hexadecimal and octal
|
||
\-escapes is at odds with this; they are supposed to be translated
|
||
directly to wchar_t values (6.4.4.4p5,6).
|
||
|
||
The source character set is not necessarily the character set used
|
||
to encode physical source files on disk; translation phase 1 converts
|
||
from whatever that encoding is to the source character set.
|
||
|
||
The presence of universal character names in C99 (6.4.3 et seq.)
|
||
forces the source character set to be isomorphic to ISO 10646,
|
||
that is, Unicode. There is no such constraint on the execution
|
||
character set; note also that the conversion from source to
|
||
execution character set does not occur for identifiers (5.1.1.2p1#5).
|
||
|
||
For convenience of implementation, the source character set's
|
||
encoding of the basic character set should be identical to the
|
||
execution character set OF THE HOST SYSTEM's encoding of the basic
|
||
character set, and it should not be a state-dependent encoding.
|
||
|
||
cpplib uses UTF-8 or UTF-EBCDIC for the source character set,
|
||
depending on whether the host is based on ASCII or EBCDIC (see
|
||
respectively Unicode section 2.3/ISO10646 Amendment 2, and Unicode
|
||
Technical Report #16). With limited exceptions, it relies on the
|
||
system library's iconv() primitive to do charset conversion
|
||
(specified in SUSv2). */
|
||
|
||
#if !HAVE_ICONV
|
||
/* Make certain that the uses of iconv(), iconv_open(), iconv_close()
|
||
below, which are guarded only by if statements with compile-time
|
||
constant conditions, do not cause link errors. */
|
||
#define iconv_open(x, y) (errno = EINVAL, (iconv_t)-1)
|
||
#define iconv(a,b,c,d,e) (errno = EINVAL, (size_t)-1)
|
||
#define iconv_close(x) (void)0
|
||
#define ICONV_CONST
|
||
#endif
|
||
|
||
#if HOST_CHARSET == HOST_CHARSET_ASCII
|
||
#define SOURCE_CHARSET "UTF-8"
|
||
#define LAST_POSSIBLY_BASIC_SOURCE_CHAR 0x7e
|
||
#elif HOST_CHARSET == HOST_CHARSET_EBCDIC
|
||
#define SOURCE_CHARSET "UTF-EBCDIC"
|
||
#define LAST_POSSIBLY_BASIC_SOURCE_CHAR 0xFF
|
||
#else
|
||
#error "Unrecognized basic host character set"
|
||
#endif
|
||
|
||
#ifndef EILSEQ
|
||
#define EILSEQ EINVAL
|
||
#endif
|
||
|
||
/* This structure is used for a resizable string buffer throughout. */
|
||
/* Don't call it strbuf, as that conflicts with unistd.h on systems
|
||
such as DYNIX/ptx where unistd.h includes stropts.h. */
|
||
struct _cpp_strbuf
|
||
{
|
||
uchar *text;
|
||
size_t asize;
|
||
size_t len;
|
||
};
|
||
|
||
/* This is enough to hold any string that fits on a single 80-column
|
||
line, even if iconv quadruples its size (e.g. conversion from
|
||
ASCII to UTF-32) rounded up to a power of two. */
|
||
#define OUTBUF_BLOCK_SIZE 256
|
||
|
||
/* Conversions between UTF-8 and UTF-16/32 are implemented by custom
|
||
logic. This is because a depressing number of systems lack iconv,
|
||
or have have iconv libraries that do not do these conversions, so
|
||
we need a fallback implementation for them. To ensure the fallback
|
||
doesn't break due to neglect, it is used on all systems.
|
||
|
||
UTF-32 encoding is nice and simple: a four-byte binary number,
|
||
constrained to the range 00000000-7FFFFFFF to avoid questions of
|
||
signedness. We do have to cope with big- and little-endian
|
||
variants.
|
||
|
||
UTF-16 encoding uses two-byte binary numbers, again in big- and
|
||
little-endian variants, for all values in the 00000000-0000FFFF
|
||
range. Values in the 00010000-0010FFFF range are encoded as pairs
|
||
of two-byte numbers, called "surrogate pairs": given a number S in
|
||
this range, it is mapped to a pair (H, L) as follows:
|
||
|
||
H = (S - 0x10000) / 0x400 + 0xD800
|
||
L = (S - 0x10000) % 0x400 + 0xDC00
|
||
|
||
Two-byte values in the D800...DFFF range are ill-formed except as a
|
||
component of a surrogate pair. Even if the encoding within a
|
||
two-byte value is little-endian, the H member of the surrogate pair
|
||
comes first.
|
||
|
||
There is no way to encode values in the 00110000-7FFFFFFF range,
|
||
which is not currently a problem as there are no assigned code
|
||
points in that range; however, the author expects that it will
|
||
eventually become necessary to abandon UTF-16 due to this
|
||
limitation. Note also that, because of these pairs, UTF-16 does
|
||
not meet the requirements of the C standard for a wide character
|
||
encoding (see 3.7.3 and 6.4.4.4p11).
|
||
|
||
UTF-8 encoding looks like this:
|
||
|
||
value range encoded as
|
||
00000000-0000007F 0xxxxxxx
|
||
00000080-000007FF 110xxxxx 10xxxxxx
|
||
00000800-0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
|
||
00010000-001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||
00200000-03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||
04000000-7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||
|
||
Values in the 0000D800 ... 0000DFFF range (surrogates) are invalid,
|
||
which means that three-byte sequences ED xx yy, with A0 <= xx <= BF,
|
||
never occur. Note also that any value that can be encoded by a
|
||
given row of the table can also be encoded by all successive rows,
|
||
but this is not done; only the shortest possible encoding for any
|
||
given value is valid. For instance, the character 07C0 could be
|
||
encoded as any of DF 80, E0 9F 80, F0 80 9F 80, F8 80 80 9F 80, or
|
||
FC 80 80 80 9F 80. Only the first is valid.
|
||
|
||
An implementation note: the transformation from UTF-16 to UTF-8, or
|
||
vice versa, is easiest done by using UTF-32 as an intermediary. */
|
||
|
||
/* Internal primitives which go from an UTF-8 byte stream to native-endian
|
||
UTF-32 in a cppchar_t, or vice versa; this avoids an extra marshal/unmarshal
|
||
operation in several places below. */
|
||
static inline int
|
||
one_utf8_to_cppchar (const uchar **inbufp, size_t *inbytesleftp,
|
||
cppchar_t *cp)
|
||
{
|
||
static const uchar masks[6] = { 0x7F, 0x1F, 0x0F, 0x07, 0x03, 0x01 };
|
||
static const uchar patns[6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||
|
||
cppchar_t c;
|
||
const uchar *inbuf = *inbufp;
|
||
size_t nbytes, i;
|
||
|
||
if (*inbytesleftp < 1)
|
||
return EINVAL;
|
||
|
||
c = *inbuf;
|
||
if (c < 0x80)
|
||
{
|
||
*cp = c;
|
||
*inbytesleftp -= 1;
|
||
*inbufp += 1;
|
||
return 0;
|
||
}
|
||
|
||
/* The number of leading 1-bits in the first byte indicates how many
|
||
bytes follow. */
|
||
for (nbytes = 2; nbytes < 7; nbytes++)
|
||
if ((c & ~masks[nbytes-1]) == patns[nbytes-1])
|
||
goto found;
|
||
return EILSEQ;
|
||
found:
|
||
|
||
if (*inbytesleftp < nbytes)
|
||
return EINVAL;
|
||
|
||
c = (c & masks[nbytes-1]);
|
||
inbuf++;
|
||
for (i = 1; i < nbytes; i++)
|
||
{
|
||
cppchar_t n = *inbuf++;
|
||
if ((n & 0xC0) != 0x80)
|
||
return EILSEQ;
|
||
c = ((c << 6) + (n & 0x3F));
|
||
}
|
||
|
||
/* Make sure the shortest possible encoding was used. */
|
||
if (c <= 0x7F && nbytes > 1) return EILSEQ;
|
||
if (c <= 0x7FF && nbytes > 2) return EILSEQ;
|
||
if (c <= 0xFFFF && nbytes > 3) return EILSEQ;
|
||
if (c <= 0x1FFFFF && nbytes > 4) return EILSEQ;
|
||
if (c <= 0x3FFFFFF && nbytes > 5) return EILSEQ;
|
||
|
||
/* Make sure the character is valid. */
|
||
if (c > 0x7FFFFFFF || (c >= 0xD800 && c <= 0xDFFF)) return EILSEQ;
|
||
|
||
*cp = c;
|
||
*inbufp = inbuf;
|
||
*inbytesleftp -= nbytes;
|
||
return 0;
|
||
}
|
||
|
||
static inline int
|
||
one_cppchar_to_utf8 (cppchar_t c, uchar **outbufp, size_t *outbytesleftp)
|
||
{
|
||
static const uchar masks[6] = { 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||
static const uchar limits[6] = { 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
|
||
size_t nbytes;
|
||
uchar buf[6], *p = &buf[6];
|
||
uchar *outbuf = *outbufp;
|
||
|
||
nbytes = 1;
|
||
if (c < 0x80)
|
||
*--p = c;
|
||
else
|
||
{
|
||
do
|
||
{
|
||
*--p = ((c & 0x3F) | 0x80);
|
||
c >>= 6;
|
||
nbytes++;
|
||
}
|
||
while (c >= 0x3F || (c & limits[nbytes-1]));
|
||
*--p = (c | masks[nbytes-1]);
|
||
}
|
||
|
||
if (*outbytesleftp < nbytes)
|
||
return E2BIG;
|
||
|
||
while (p < &buf[6])
|
||
*outbuf++ = *p++;
|
||
*outbytesleftp -= nbytes;
|
||
*outbufp = outbuf;
|
||
return 0;
|
||
}
|
||
|
||
/* The following four functions transform one character between the two
|
||
encodings named in the function name. All have the signature
|
||
int (*)(iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
|
||
uchar **outbufp, size_t *outbytesleftp)
|
||
|
||
BIGEND must have the value 0 or 1, coerced to (iconv_t); it is
|
||
interpreted as a boolean indicating whether big-endian or
|
||
little-endian encoding is to be used for the member of the pair
|
||
that is not UTF-8.
|
||
|
||
INBUFP, INBYTESLEFTP, OUTBUFP, OUTBYTESLEFTP work exactly as they
|
||
do for iconv.
|
||
|
||
The return value is either 0 for success, or an errno value for
|
||
failure, which may be E2BIG (need more space), EILSEQ (ill-formed
|
||
input sequence), ir EINVAL (incomplete input sequence). */
|
||
|
||
static inline int
|
||
one_utf8_to_utf32 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
|
||
uchar **outbufp, size_t *outbytesleftp)
|
||
{
|
||
uchar *outbuf;
|
||
cppchar_t s = 0;
|
||
int rval;
|
||
|
||
/* Check for space first, since we know exactly how much we need. */
|
||
if (*outbytesleftp < 4)
|
||
return E2BIG;
|
||
|
||
rval = one_utf8_to_cppchar (inbufp, inbytesleftp, &s);
|
||
if (rval)
|
||
return rval;
|
||
|
||
outbuf = *outbufp;
|
||
outbuf[bigend ? 3 : 0] = (s & 0x000000FF);
|
||
outbuf[bigend ? 2 : 1] = (s & 0x0000FF00) >> 8;
|
||
outbuf[bigend ? 1 : 2] = (s & 0x00FF0000) >> 16;
|
||
outbuf[bigend ? 0 : 3] = (s & 0xFF000000) >> 24;
|
||
|
||
*outbufp += 4;
|
||
*outbytesleftp -= 4;
|
||
return 0;
|
||
}
|
||
|
||
static inline int
|
||
one_utf32_to_utf8 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
|
||
uchar **outbufp, size_t *outbytesleftp)
|
||
{
|
||
cppchar_t s;
|
||
int rval;
|
||
const uchar *inbuf;
|
||
|
||
if (*inbytesleftp < 4)
|
||
return EINVAL;
|
||
|
||
inbuf = *inbufp;
|
||
|
||
s = inbuf[bigend ? 0 : 3] << 24;
|
||
s += inbuf[bigend ? 1 : 2] << 16;
|
||
s += inbuf[bigend ? 2 : 1] << 8;
|
||
s += inbuf[bigend ? 3 : 0];
|
||
|
||
if (s >= 0x7FFFFFFF || (s >= 0xD800 && s <= 0xDFFF))
|
||
return EILSEQ;
|
||
|
||
rval = one_cppchar_to_utf8 (s, outbufp, outbytesleftp);
|
||
if (rval)
|
||
return rval;
|
||
|
||
*inbufp += 4;
|
||
*inbytesleftp -= 4;
|
||
return 0;
|
||
}
|
||
|
||
static inline int
|
||
one_utf8_to_utf16 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
|
||
uchar **outbufp, size_t *outbytesleftp)
|
||
{
|
||
int rval;
|
||
cppchar_t s = 0;
|
||
const uchar *save_inbuf = *inbufp;
|
||
size_t save_inbytesleft = *inbytesleftp;
|
||
uchar *outbuf = *outbufp;
|
||
|
||
rval = one_utf8_to_cppchar (inbufp, inbytesleftp, &s);
|
||
if (rval)
|
||
return rval;
|
||
|
||
if (s > 0x0010FFFF)
|
||
{
|
||
*inbufp = save_inbuf;
|
||
*inbytesleftp = save_inbytesleft;
|
||
return EILSEQ;
|
||
}
|
||
|
||
if (s <= 0xFFFF)
|
||
{
|
||
if (*outbytesleftp < 2)
|
||
{
|
||
*inbufp = save_inbuf;
|
||
*inbytesleftp = save_inbytesleft;
|
||
return E2BIG;
|
||
}
|
||
outbuf[bigend ? 1 : 0] = (s & 0x00FF);
|
||
outbuf[bigend ? 0 : 1] = (s & 0xFF00) >> 8;
|
||
|
||
*outbufp += 2;
|
||
*outbytesleftp -= 2;
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
cppchar_t hi, lo;
|
||
|
||
if (*outbytesleftp < 4)
|
||
{
|
||
*inbufp = save_inbuf;
|
||
*inbytesleftp = save_inbytesleft;
|
||
return E2BIG;
|
||
}
|
||
|
||
hi = (s - 0x10000) / 0x400 + 0xD800;
|
||
lo = (s - 0x10000) % 0x400 + 0xDC00;
|
||
|
||
/* Even if we are little-endian, put the high surrogate first.
|
||
??? Matches practice? */
|
||
outbuf[bigend ? 1 : 0] = (hi & 0x00FF);
|
||
outbuf[bigend ? 0 : 1] = (hi & 0xFF00) >> 8;
|
||
outbuf[bigend ? 3 : 2] = (lo & 0x00FF);
|
||
outbuf[bigend ? 2 : 3] = (lo & 0xFF00) >> 8;
|
||
|
||
*outbufp += 4;
|
||
*outbytesleftp -= 4;
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
static inline int
|
||
one_utf16_to_utf8 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp,
|
||
uchar **outbufp, size_t *outbytesleftp)
|
||
{
|
||
cppchar_t s;
|
||
const uchar *inbuf = *inbufp;
|
||
int rval;
|
||
|
||
if (*inbytesleftp < 2)
|
||
return EINVAL;
|
||
s = inbuf[bigend ? 0 : 1] << 8;
|
||
s += inbuf[bigend ? 1 : 0];
|
||
|
||
/* Low surrogate without immediately preceding high surrogate is invalid. */
|
||
if (s >= 0xDC00 && s <= 0xDFFF)
|
||
return EILSEQ;
|
||
/* High surrogate must have a following low surrogate. */
|
||
else if (s >= 0xD800 && s <= 0xDBFF)
|
||
{
|
||
cppchar_t hi = s, lo;
|
||
if (*inbytesleftp < 4)
|
||
return EINVAL;
|
||
|
||
lo = inbuf[bigend ? 2 : 3] << 8;
|
||
lo += inbuf[bigend ? 3 : 2];
|
||
|
||
if (lo < 0xDC00 || lo > 0xDFFF)
|
||
return EILSEQ;
|
||
|
||
s = (hi - 0xD800) * 0x400 + (lo - 0xDC00) + 0x10000;
|
||
}
|
||
|
||
rval = one_cppchar_to_utf8 (s, outbufp, outbytesleftp);
|
||
if (rval)
|
||
return rval;
|
||
|
||
/* Success - update the input pointers (one_cppchar_to_utf8 has done
|
||
the output pointers for us). */
|
||
if (s <= 0xFFFF)
|
||
{
|
||
*inbufp += 2;
|
||
*inbytesleftp -= 2;
|
||
}
|
||
else
|
||
{
|
||
*inbufp += 4;
|
||
*inbytesleftp -= 4;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
/* Helper routine for the next few functions. The 'const' on
|
||
one_conversion means that we promise not to modify what function is
|
||
pointed to, which lets the inliner see through it. */
|
||
|
||
static inline bool
|
||
conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
|
||
uchar **, size_t *),
|
||
iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to)
|
||
{
|
||
const uchar *inbuf;
|
||
uchar *outbuf;
|
||
size_t inbytesleft, outbytesleft;
|
||
int rval;
|
||
|
||
inbuf = from;
|
||
inbytesleft = flen;
|
||
outbuf = to->text + to->len;
|
||
outbytesleft = to->asize - to->len;
|
||
|
||
for (;;)
|
||
{
|
||
do
|
||
rval = one_conversion (cd, &inbuf, &inbytesleft,
|
||
&outbuf, &outbytesleft);
|
||
while (inbytesleft && !rval);
|
||
|
||
if (__builtin_expect (inbytesleft == 0, 1))
|
||
{
|
||
to->len = to->asize - outbytesleft;
|
||
return true;
|
||
}
|
||
if (rval != E2BIG)
|
||
{
|
||
errno = rval;
|
||
return false;
|
||
}
|
||
|
||
outbytesleft += OUTBUF_BLOCK_SIZE;
|
||
to->asize += OUTBUF_BLOCK_SIZE;
|
||
to->text = XRESIZEVEC (uchar, to->text, to->asize);
|
||
outbuf = to->text + to->asize - outbytesleft;
|
||
}
|
||
}
|
||
|
||
|
||
/* These functions convert entire strings between character sets.
|
||
They all have the signature
|
||
|
||
bool (*)(iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to);
|
||
|
||
The input string FROM is converted as specified by the function
|
||
name plus the iconv descriptor CD (which may be fake), and the
|
||
result appended to TO. On any error, false is returned, otherwise true. */
|
||
|
||
/* These four use the custom conversion code above. */
|
||
static bool
|
||
convert_utf8_utf16 (iconv_t cd, const uchar *from, size_t flen,
|
||
struct _cpp_strbuf *to)
|
||
{
|
||
return conversion_loop (one_utf8_to_utf16, cd, from, flen, to);
|
||
}
|
||
|
||
static bool
|
||
convert_utf8_utf32 (iconv_t cd, const uchar *from, size_t flen,
|
||
struct _cpp_strbuf *to)
|
||
{
|
||
return conversion_loop (one_utf8_to_utf32, cd, from, flen, to);
|
||
}
|
||
|
||
static bool
|
||
convert_utf16_utf8 (iconv_t cd, const uchar *from, size_t flen,
|
||
struct _cpp_strbuf *to)
|
||
{
|
||
return conversion_loop (one_utf16_to_utf8, cd, from, flen, to);
|
||
}
|
||
|
||
static bool
|
||
convert_utf32_utf8 (iconv_t cd, const uchar *from, size_t flen,
|
||
struct _cpp_strbuf *to)
|
||
{
|
||
return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);
|
||
}
|
||
|
||
/* Identity conversion, used when we have no alternative. */
|
||
static bool
|
||
convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
|
||
const uchar *from, size_t flen, struct _cpp_strbuf *to)
|
||
{
|
||
if (to->len + flen > to->asize)
|
||
{
|
||
to->asize = to->len + flen;
|
||
to->asize += to->asize / 4;
|
||
to->text = XRESIZEVEC (uchar, to->text, to->asize);
|
||
}
|
||
memcpy (to->text + to->len, from, flen);
|
||
to->len += flen;
|
||
return true;
|
||
}
|
||
|
||
/* And this one uses the system iconv primitive. It's a little
|
||
different, since iconv's interface is a little different. */
|
||
#if HAVE_ICONV
|
||
|
||
#define CONVERT_ICONV_GROW_BUFFER \
|
||
do { \
|
||
outbytesleft += OUTBUF_BLOCK_SIZE; \
|
||
to->asize += OUTBUF_BLOCK_SIZE; \
|
||
to->text = XRESIZEVEC (uchar, to->text, to->asize); \
|
||
outbuf = (char *)to->text + to->asize - outbytesleft; \
|
||
} while (0)
|
||
|
||
static bool
|
||
convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
|
||
struct _cpp_strbuf *to)
|
||
{
|
||
ICONV_CONST char *inbuf;
|
||
char *outbuf;
|
||
size_t inbytesleft, outbytesleft;
|
||
|
||
/* Reset conversion descriptor and check that it is valid. */
|
||
if (iconv (cd, 0, 0, 0, 0) == (size_t)-1)
|
||
return false;
|
||
|
||
inbuf = (ICONV_CONST char *)from;
|
||
inbytesleft = flen;
|
||
outbuf = (char *)to->text + to->len;
|
||
outbytesleft = to->asize - to->len;
|
||
|
||
for (;;)
|
||
{
|
||
iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
|
||
if (__builtin_expect (inbytesleft == 0, 1))
|
||
{
|
||
/* Close out any shift states, returning to the initial state. */
|
||
if (iconv (cd, 0, 0, &outbuf, &outbytesleft) == (size_t)-1)
|
||
{
|
||
if (errno != E2BIG)
|
||
return false;
|
||
|
||
CONVERT_ICONV_GROW_BUFFER;
|
||
if (iconv (cd, 0, 0, &outbuf, &outbytesleft) == (size_t)-1)
|
||
return false;
|
||
}
|
||
|
||
to->len = to->asize - outbytesleft;
|
||
return true;
|
||
}
|
||
if (errno != E2BIG)
|
||
return false;
|
||
|
||
CONVERT_ICONV_GROW_BUFFER;
|
||
}
|
||
}
|
||
#else
|
||
#define convert_using_iconv 0 /* prevent undefined symbol error below */
|
||
#endif
|
||
|
||
/* Arrange for the above custom conversion logic to be used automatically
|
||
when conversion between a suitable pair of character sets is requested. */
|
||
|
||
#define APPLY_CONVERSION(CONVERTER, FROM, FLEN, TO) \
|
||
CONVERTER.func (CONVERTER.cd, FROM, FLEN, TO)
|
||
|
||
struct cpp_conversion
|
||
{
|
||
const char *pair;
|
||
convert_f func;
|
||
iconv_t fake_cd;
|
||
};
|
||
static const struct cpp_conversion conversion_tab[] = {
|
||
{ "UTF-8/UTF-32LE", convert_utf8_utf32, (iconv_t)0 },
|
||
{ "UTF-8/UTF-32BE", convert_utf8_utf32, (iconv_t)1 },
|
||
{ "UTF-8/UTF-16LE", convert_utf8_utf16, (iconv_t)0 },
|
||
{ "UTF-8/UTF-16BE", convert_utf8_utf16, (iconv_t)1 },
|
||
{ "UTF-32LE/UTF-8", convert_utf32_utf8, (iconv_t)0 },
|
||
{ "UTF-32BE/UTF-8", convert_utf32_utf8, (iconv_t)1 },
|
||
{ "UTF-16LE/UTF-8", convert_utf16_utf8, (iconv_t)0 },
|
||
{ "UTF-16BE/UTF-8", convert_utf16_utf8, (iconv_t)1 },
|
||
};
|
||
|
||
/* Subroutine of cpp_init_iconv: initialize and return a
|
||
cset_converter structure for conversion from FROM to TO. If
|
||
iconv_open() fails, issue an error and return an identity
|
||
converter. Silently return an identity converter if FROM and TO
|
||
are identical.
|
||
|
||
PFILE is only used for generating diagnostics; setting it to NULL
|
||
suppresses diagnostics. */
|
||
|
||
static struct cset_converter
|
||
init_iconv_desc (cpp_reader *pfile, const char *to, const char *from)
|
||
{
|
||
struct cset_converter ret;
|
||
char *pair;
|
||
size_t i;
|
||
|
||
ret.to = to;
|
||
ret.from = from;
|
||
|
||
if (!strcasecmp (to, from))
|
||
{
|
||
ret.func = convert_no_conversion;
|
||
ret.cd = (iconv_t) -1;
|
||
ret.width = -1;
|
||
return ret;
|
||
}
|
||
|
||
pair = (char *) alloca(strlen(to) + strlen(from) + 2);
|
||
|
||
strcpy(pair, from);
|
||
strcat(pair, "/");
|
||
strcat(pair, to);
|
||
for (i = 0; i < ARRAY_SIZE (conversion_tab); i++)
|
||
if (!strcasecmp (pair, conversion_tab[i].pair))
|
||
{
|
||
ret.func = conversion_tab[i].func;
|
||
ret.cd = conversion_tab[i].fake_cd;
|
||
ret.width = -1;
|
||
return ret;
|
||
}
|
||
|
||
/* No custom converter - try iconv. */
|
||
if (HAVE_ICONV)
|
||
{
|
||
ret.func = convert_using_iconv;
|
||
ret.cd = iconv_open (to, from);
|
||
ret.width = -1;
|
||
|
||
if (ret.cd == (iconv_t) -1)
|
||
{
|
||
if (pfile)
|
||
{
|
||
if (errno == EINVAL)
|
||
cpp_error (pfile, CPP_DL_ERROR, /* FIXME should be DL_SORRY */
|
||
"conversion from %s to %s not supported by iconv",
|
||
from, to);
|
||
else
|
||
cpp_errno (pfile, CPP_DL_ERROR, "iconv_open");
|
||
}
|
||
ret.func = convert_no_conversion;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pfile)
|
||
{
|
||
cpp_error (pfile, CPP_DL_ERROR, /* FIXME: should be DL_SORRY */
|
||
"no iconv implementation, cannot convert from %s to %s",
|
||
from, to);
|
||
}
|
||
ret.func = convert_no_conversion;
|
||
ret.cd = (iconv_t) -1;
|
||
ret.width = -1;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
/* If charset conversion is requested, initialize iconv(3) descriptors
|
||
for conversion from the source character set to the execution
|
||
character sets. If iconv is not present in the C library, and
|
||
conversion is requested, issue an error. */
|
||
|
||
void
|
||
cpp_init_iconv (cpp_reader *pfile)
|
||
{
|
||
const char *ncset = CPP_OPTION (pfile, narrow_charset);
|
||
const char *wcset = CPP_OPTION (pfile, wide_charset);
|
||
const char *default_wcset;
|
||
|
||
bool be = CPP_OPTION (pfile, bytes_big_endian);
|
||
|
||
if (CPP_OPTION (pfile, wchar_precision) >= 32)
|
||
default_wcset = be ? "UTF-32BE" : "UTF-32LE";
|
||
else if (CPP_OPTION (pfile, wchar_precision) >= 16)
|
||
default_wcset = be ? "UTF-16BE" : "UTF-16LE";
|
||
else
|
||
/* This effectively means that wide strings are not supported,
|
||
so don't do any conversion at all. */
|
||
default_wcset = SOURCE_CHARSET;
|
||
|
||
if (!ncset)
|
||
ncset = SOURCE_CHARSET;
|
||
if (!wcset)
|
||
wcset = default_wcset;
|
||
|
||
pfile->narrow_cset_desc = init_iconv_desc (pfile, ncset, SOURCE_CHARSET);
|
||
pfile->narrow_cset_desc.width = CPP_OPTION (pfile, char_precision);
|
||
pfile->utf8_cset_desc = init_iconv_desc (pfile, "UTF-8", SOURCE_CHARSET);
|
||
pfile->utf8_cset_desc.width = CPP_OPTION (pfile, char_precision);
|
||
pfile->char16_cset_desc = init_iconv_desc (pfile,
|
||
be ? "UTF-16BE" : "UTF-16LE",
|
||
SOURCE_CHARSET);
|
||
pfile->char16_cset_desc.width = 16;
|
||
pfile->char32_cset_desc = init_iconv_desc (pfile,
|
||
be ? "UTF-32BE" : "UTF-32LE",
|
||
SOURCE_CHARSET);
|
||
pfile->char32_cset_desc.width = 32;
|
||
pfile->wide_cset_desc = init_iconv_desc (pfile, wcset, SOURCE_CHARSET);
|
||
pfile->wide_cset_desc.width = CPP_OPTION (pfile, wchar_precision);
|
||
}
|
||
|
||
/* Destroy iconv(3) descriptors set up by cpp_init_iconv, if necessary. */
|
||
void
|
||
_cpp_destroy_iconv (cpp_reader *pfile)
|
||
{
|
||
if (HAVE_ICONV)
|
||
{
|
||
if (pfile->narrow_cset_desc.func == convert_using_iconv)
|
||
iconv_close (pfile->narrow_cset_desc.cd);
|
||
if (pfile->utf8_cset_desc.func == convert_using_iconv)
|
||
iconv_close (pfile->utf8_cset_desc.cd);
|
||
if (pfile->char16_cset_desc.func == convert_using_iconv)
|
||
iconv_close (pfile->char16_cset_desc.cd);
|
||
if (pfile->char32_cset_desc.func == convert_using_iconv)
|
||
iconv_close (pfile->char32_cset_desc.cd);
|
||
if (pfile->wide_cset_desc.func == convert_using_iconv)
|
||
iconv_close (pfile->wide_cset_desc.cd);
|
||
}
|
||
}
|
||
|
||
/* Utility routine for use by a full compiler. C is a character taken
|
||
from the *basic* source character set, encoded in the host's
|
||
execution encoding. Convert it to (the target's) execution
|
||
encoding, and return that value.
|
||
|
||
Issues an internal error if C's representation in the narrow
|
||
execution character set fails to be a single-byte value (C99
|
||
5.2.1p3: "The representation of each member of the source and
|
||
execution character sets shall fit in a byte.") May also issue an
|
||
internal error if C fails to be a member of the basic source
|
||
character set (testing this exactly is too hard, especially when
|
||
the host character set is EBCDIC). */
|
||
cppchar_t
|
||
cpp_host_to_exec_charset (cpp_reader *pfile, cppchar_t c)
|
||
{
|
||
uchar sbuf[1];
|
||
struct _cpp_strbuf tbuf;
|
||
|
||
/* This test is merely an approximation, but it suffices to catch
|
||
the most important thing, which is that we don't get handed a
|
||
character outside the unibyte range of the host character set. */
|
||
if (c > LAST_POSSIBLY_BASIC_SOURCE_CHAR)
|
||
{
|
||
cpp_error (pfile, CPP_DL_ICE,
|
||
"character 0x%lx is not in the basic source character set\n",
|
||
(unsigned long)c);
|
||
return 0;
|
||
}
|
||
|
||
/* Being a character in the unibyte range of the host character set,
|
||
we can safely splat it into a one-byte buffer and trust that that
|
||
is a well-formed string. */
|
||
sbuf[0] = c;
|
||
|
||
/* This should never need to reallocate, but just in case... */
|
||
tbuf.asize = 1;
|
||
tbuf.text = XNEWVEC (uchar, tbuf.asize);
|
||
tbuf.len = 0;
|
||
|
||
if (!APPLY_CONVERSION (pfile->narrow_cset_desc, sbuf, 1, &tbuf))
|
||
{
|
||
cpp_errno (pfile, CPP_DL_ICE, "converting to execution character set");
|
||
return 0;
|
||
}
|
||
if (tbuf.len != 1)
|
||
{
|
||
cpp_error (pfile, CPP_DL_ICE,
|
||
"character 0x%lx is not unibyte in execution character set",
|
||
(unsigned long)c);
|
||
return 0;
|
||
}
|
||
c = tbuf.text[0];
|
||
free(tbuf.text);
|
||
return c;
|
||
}
|
||
|
||
|
||
|
||
/* cpp_substring_ranges's constructor. */
|
||
|
||
cpp_substring_ranges::cpp_substring_ranges () :
|
||
m_ranges (NULL),
|
||
m_num_ranges (0),
|
||
m_alloc_ranges (8)
|
||
{
|
||
m_ranges = XNEWVEC (source_range, m_alloc_ranges);
|
||
}
|
||
|
||
/* cpp_substring_ranges's destructor. */
|
||
|
||
cpp_substring_ranges::~cpp_substring_ranges ()
|
||
{
|
||
free (m_ranges);
|
||
}
|
||
|
||
/* Add RANGE to the vector of source_range information. */
|
||
|
||
void
|
||
cpp_substring_ranges::add_range (source_range range)
|
||
{
|
||
if (m_num_ranges >= m_alloc_ranges)
|
||
{
|
||
m_alloc_ranges *= 2;
|
||
m_ranges
|
||
= (source_range *)xrealloc (m_ranges,
|
||
sizeof (source_range) * m_alloc_ranges);
|
||
}
|
||
m_ranges[m_num_ranges++] = range;
|
||
}
|
||
|
||
/* Read NUM ranges from LOC_READER, adding them to the vector of source_range
|
||
information. */
|
||
|
||
void
|
||
cpp_substring_ranges::add_n_ranges (int num,
|
||
cpp_string_location_reader &loc_reader)
|
||
{
|
||
for (int i = 0; i < num; i++)
|
||
add_range (loc_reader.get_next ());
|
||
}
|
||
|
||
|
||
|
||
/* Utility routine that computes a mask of the form 0000...111... with
|
||
WIDTH 1-bits. */
|
||
static inline size_t
|
||
width_to_mask (size_t width)
|
||
{
|
||
width = MIN (width, BITS_PER_CPPCHAR_T);
|
||
if (width >= CHAR_BIT * sizeof (size_t))
|
||
return ~(size_t) 0;
|
||
else
|
||
return ((size_t) 1 << width) - 1;
|
||
}
|
||
|
||
/* A large table of unicode character information. */
|
||
enum {
|
||
/* Valid in a C99 identifier? */
|
||
C99 = 1,
|
||
/* Valid in a C99 identifier, but not as the first character? */
|
||
N99 = 2,
|
||
/* Valid in a C++ identifier? */
|
||
CXX = 4,
|
||
/* Valid in a C11/C++11 identifier? */
|
||
C11 = 8,
|
||
/* Valid in a C11/C++11 identifier, but not as the first character? */
|
||
N11 = 16,
|
||
/* Valid in a C++23 identifier? */
|
||
CXX23 = 32,
|
||
/* Valid in a C++23 identifier, but not as the first character? */
|
||
NXX23 = 64,
|
||
/* NFC representation is not valid in an identifier? */
|
||
CID = 128,
|
||
/* Might be valid NFC form? */
|
||
NFC = 256,
|
||
/* Might be valid NFKC form? */
|
||
NKC = 512,
|
||
/* Certain preceding characters might make it not valid NFC/NKFC form? */
|
||
CTX = 1024
|
||
};
|
||
|
||
struct ucnrange {
|
||
/* Bitmap of flags above. */
|
||
unsigned short flags;
|
||
/* Combining class of the character. */
|
||
unsigned char combine;
|
||
/* Last character in the range described by this entry. */
|
||
unsigned int end;
|
||
};
|
||
#include "ucnid.h"
|
||
|
||
/* ISO 10646 defines the UCS codespace as the range 0-0x10FFFF inclusive. */
|
||
#define UCS_LIMIT 0x10FFFF
|
||
|
||
/* Returns 1 if C is valid in an identifier, 2 if C is valid except at
|
||
the start of an identifier, and 0 if C is not valid in an
|
||
identifier. We assume C has already gone through the checks of
|
||
_cpp_valid_ucn. Also update NST for C if returning nonzero. The
|
||
algorithm is a simple binary search on the table defined in
|
||
ucnid.h. */
|
||
|
||
static int
|
||
ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c,
|
||
struct normalize_state *nst)
|
||
{
|
||
int mn, mx, md;
|
||
unsigned short valid_flags, invalid_start_flags;
|
||
|
||
if (c > UCS_LIMIT)
|
||
return 0;
|
||
|
||
mn = 0;
|
||
mx = ARRAY_SIZE (ucnranges) - 1;
|
||
while (mx != mn)
|
||
{
|
||
md = (mn + mx) / 2;
|
||
if (c <= ucnranges[md].end)
|
||
mx = md;
|
||
else
|
||
mn = md + 1;
|
||
}
|
||
|
||
/* When -pedantic, we require the character to have been listed by
|
||
the standard for the current language. Otherwise, we accept the
|
||
union of the acceptable sets for all supported language versions. */
|
||
valid_flags = C99 | CXX | C11 | CXX23;
|
||
if (CPP_PEDANTIC (pfile))
|
||
{
|
||
if (CPP_OPTION (pfile, cplusplus))
|
||
valid_flags = CXX23;
|
||
else if (CPP_OPTION (pfile, c11_identifiers))
|
||
valid_flags = C11;
|
||
else if (CPP_OPTION (pfile, c99))
|
||
valid_flags = C99;
|
||
}
|
||
if (! (ucnranges[mn].flags & valid_flags))
|
||
return 0;
|
||
|
||
/* Update NST. */
|
||
if (ucnranges[mn].combine != 0 && ucnranges[mn].combine < nst->prev_class)
|
||
nst->level = normalized_none;
|
||
else if (ucnranges[mn].flags & CTX)
|
||
{
|
||
bool safe;
|
||
cppchar_t p = nst->previous;
|
||
|
||
/* For Hangul, characters in the range AC00-D7A3 are NFC/NFKC,
|
||
and are combined algorithmically from a sequence of the form
|
||
1100-1112 1161-1175 11A8-11C2
|
||
(if the third is not present, it is treated as 11A7, which is not
|
||
really a valid character).
|
||
Unfortunately, C99 allows (only) the NFC form, but C++ allows
|
||
only the combining characters. */
|
||
if (c >= 0x1161 && c <= 0x1175)
|
||
safe = p < 0x1100 || p > 0x1112;
|
||
else if (c >= 0x11A8 && c <= 0x11C2)
|
||
safe = (p < 0xAC00 || p > 0xD7A3 || (p - 0xAC00) % 28 != 0);
|
||
else
|
||
safe = check_nfc (pfile, c, p);
|
||
if (!safe)
|
||
{
|
||
if ((c >= 0x1161 && c <= 0x1175) || (c >= 0x11A8 && c <= 0x11C2))
|
||
nst->level = MAX (nst->level, normalized_identifier_C);
|
||
else
|
||
nst->level = normalized_none;
|
||
}
|
||
}
|
||
else if (ucnranges[mn].flags & NKC)
|
||
;
|
||
else if (ucnranges[mn].flags & NFC)
|
||
nst->level = MAX (nst->level, normalized_C);
|
||
else if (ucnranges[mn].flags & CID)
|
||
nst->level = MAX (nst->level, normalized_identifier_C);
|
||
else
|
||
nst->level = normalized_none;
|
||
if (ucnranges[mn].combine == 0)
|
||
nst->previous = c;
|
||
nst->prev_class = ucnranges[mn].combine;
|
||
|
||
if (!CPP_PEDANTIC (pfile))
|
||
{
|
||
/* If not -pedantic, accept as character that may
|
||
begin an identifier a union of characters allowed
|
||
at that position in each of the character sets. */
|
||
if ((ucnranges[mn].flags & (C99 | N99)) == C99
|
||
|| (ucnranges[mn].flags & CXX) != 0
|
||
|| (ucnranges[mn].flags & (C11 | N11)) == C11
|
||
|| (ucnranges[mn].flags & (CXX23 | NXX23)) == CXX23)
|
||
return 1;
|
||
return 2;
|
||
}
|
||
|
||
if (CPP_OPTION (pfile, cplusplus))
|
||
invalid_start_flags = NXX23;
|
||
else if (CPP_OPTION (pfile, c11_identifiers))
|
||
invalid_start_flags = N11;
|
||
else if (CPP_OPTION (pfile, c99))
|
||
invalid_start_flags = N99;
|
||
else
|
||
invalid_start_flags = 0;
|
||
|
||
/* In C99, UCN digits may not begin identifiers. In C11 and C++11,
|
||
UCN combining characters may not begin identifiers. */
|
||
if (ucnranges[mn].flags & invalid_start_flags)
|
||
return 2;
|
||
|
||
return 1;
|
||
}
|
||
|
||
/* [lex.charset]: The character designated by the universal character
|
||
name \UNNNNNNNN is that character whose character short name in
|
||
ISO/IEC 10646 is NNNNNNNN; the character designated by the
|
||
universal character name \uNNNN is that character whose character
|
||
short name in ISO/IEC 10646 is 0000NNNN. If the hexadecimal value
|
||
for a universal character name corresponds to a surrogate code point
|
||
(in the range 0xD800-0xDFFF, inclusive), the program is ill-formed.
|
||
Additionally, if the hexadecimal value for a universal-character-name
|
||
outside a character or string literal corresponds to a control character
|
||
(in either of the ranges 0x00-0x1F or 0x7F-0x9F, both inclusive) or to a
|
||
character in the basic source character set, the program is ill-formed.
|
||
|
||
C99 6.4.3: A universal character name shall not specify a character
|
||
whose short identifier is less than 00A0 other than 0024 ($), 0040 (@),
|
||
or 0060 (`), nor one in the range D800 through DFFF inclusive.
|
||
|
||
If the hexadecimal value is larger than the upper bound of the UCS
|
||
codespace specified in ISO/IEC 10646, a pedantic warning is issued
|
||
in all versions of C and in the C++20 or later versions of C++.
|
||
|
||
*PSTR must be preceded by "\u" or "\U"; it is assumed that the
|
||
buffer end is delimited by a non-hex digit. Returns false if the
|
||
UCN has not been consumed, true otherwise.
|
||
|
||
The value of the UCN, whether valid or invalid, is returned in *CP.
|
||
Diagnostics are emitted for invalid values. PSTR is updated to point
|
||
one beyond the UCN, or to the syntactically invalid character.
|
||
|
||
IDENTIFIER_POS is 0 when not in an identifier, 1 for the start of
|
||
an identifier, or 2 otherwise.
|
||
|
||
If LOC_READER is non-NULL, then position information is
|
||
read from *LOC_READER and CHAR_RANGE->m_finish is updated accordingly. */
|
||
|
||
bool
|
||
_cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
|
||
const uchar *limit, int identifier_pos,
|
||
struct normalize_state *nst, cppchar_t *cp,
|
||
source_range *char_range,
|
||
cpp_string_location_reader *loc_reader)
|
||
{
|
||
cppchar_t result, c;
|
||
unsigned int length;
|
||
const uchar *str = *pstr;
|
||
const uchar *base = str - 2;
|
||
|
||
if (!CPP_OPTION (pfile, cplusplus) && !CPP_OPTION (pfile, c99))
|
||
cpp_error (pfile, CPP_DL_WARNING,
|
||
"universal character names are only valid in C++ and C99");
|
||
else if (CPP_OPTION (pfile, cpp_warn_c90_c99_compat) > 0
|
||
&& !CPP_OPTION (pfile, cplusplus))
|
||
cpp_error (pfile, CPP_DL_WARNING,
|
||
"C99's universal character names are incompatible with C90");
|
||
else if (CPP_WTRADITIONAL (pfile) && identifier_pos == 0)
|
||
cpp_warning (pfile, CPP_W_TRADITIONAL,
|
||
"the meaning of '\\%c' is different in traditional C",
|
||
(int) str[-1]);
|
||
|
||
if (str[-1] == 'u')
|
||
length = 4;
|
||
else if (str[-1] == 'U')
|
||
length = 8;
|
||
else
|
||
{
|
||
cpp_error (pfile, CPP_DL_ICE, "In _cpp_valid_ucn but not a UCN");
|
||
length = 4;
|
||
}
|
||
|
||
result = 0;
|
||
do
|
||
{
|
||
c = *str;
|
||
if (!ISXDIGIT (c))
|
||
break;
|
||
str++;
|
||
if (loc_reader)
|
||
{
|
||
gcc_assert (char_range);
|
||
char_range->m_finish = loc_reader->get_next ().m_finish;
|
||
}
|
||
result = (result << 4) + hex_value (c);
|
||
}
|
||
while (--length && str < limit);
|
||
|
||
/* Partial UCNs are not valid in strings, but decompose into
|
||
multiple tokens in identifiers, so we can't give a helpful
|
||
error message in that case. */
|
||
if (length && identifier_pos)
|
||
{
|
||
*cp = 0;
|
||
return false;
|
||
}
|
||
|
||
*pstr = str;
|
||
if (length)
|
||
{
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"incomplete universal character name %.*s",
|
||
(int) (str - base), base);
|
||
result = 1;
|
||
}
|
||
/* The C99 standard permits $, @ and ` to be specified as UCNs. We use
|
||
hex escapes so that this also works with EBCDIC hosts.
|
||
C++0x permits everything below 0xa0 within literals;
|
||
ucn_valid_in_identifier will complain about identifiers. */
|
||
else if ((result < 0xa0
|
||
&& !CPP_OPTION (pfile, cplusplus)
|
||
&& (result != 0x24 && result != 0x40 && result != 0x60))
|
||
|| (result & 0x80000000)
|
||
|| (result >= 0xD800 && result <= 0xDFFF))
|
||
{
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"%.*s is not a valid universal character",
|
||
(int) (str - base), base);
|
||
result = 1;
|
||
}
|
||
else if (identifier_pos && result == 0x24
|
||
&& CPP_OPTION (pfile, dollars_in_ident))
|
||
{
|
||
if (CPP_OPTION (pfile, warn_dollars) && !pfile->state.skipping)
|
||
{
|
||
CPP_OPTION (pfile, warn_dollars) = 0;
|
||
cpp_error (pfile, CPP_DL_PEDWARN, "'$' in identifier or number");
|
||
}
|
||
NORMALIZE_STATE_UPDATE_IDNUM (nst, result);
|
||
}
|
||
else if (identifier_pos)
|
||
{
|
||
int validity = ucn_valid_in_identifier (pfile, result, nst);
|
||
|
||
if (validity == 0)
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"universal character %.*s is not valid in an identifier",
|
||
(int) (str - base), base);
|
||
else if (validity == 2 && identifier_pos == 1)
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"universal character %.*s is not valid at the start of an identifier",
|
||
(int) (str - base), base);
|
||
}
|
||
else if (result > UCS_LIMIT
|
||
&& (!CPP_OPTION (pfile, cplusplus)
|
||
|| CPP_OPTION (pfile, lang) > CLK_CXX17))
|
||
cpp_error (pfile, CPP_DL_PEDWARN,
|
||
"%.*s is outside the UCS codespace",
|
||
(int) (str - base), base);
|
||
|
||
*cp = result;
|
||
return true;
|
||
}
|
||
|
||
/* Convert an UCN, pointed to by FROM, to UTF-8 encoding, then translate
|
||
it to the execution character set and write the result into TBUF,
|
||
if TBUF is non-NULL.
|
||
An advanced pointer is returned. Issues all relevant diagnostics.
|
||
If LOC_READER is non-NULL, then RANGES must be non-NULL and CHAR_RANGE
|
||
contains the location of the character so far: location information
|
||
is read from *LOC_READER, and *RANGES is updated accordingly. */
|
||
static const uchar *
|
||
convert_ucn (cpp_reader *pfile, const uchar *from, const uchar *limit,
|
||
struct _cpp_strbuf *tbuf, struct cset_converter cvt,
|
||
source_range char_range,
|
||
cpp_string_location_reader *loc_reader,
|
||
cpp_substring_ranges *ranges)
|
||
{
|
||
cppchar_t ucn;
|
||
uchar buf[6];
|
||
uchar *bufp = buf;
|
||
size_t bytesleft = 6;
|
||
int rval;
|
||
struct normalize_state nst = INITIAL_NORMALIZE_STATE;
|
||
|
||
/* loc_reader and ranges must either be both NULL, or both be non-NULL. */
|
||
gcc_assert ((loc_reader != NULL) == (ranges != NULL));
|
||
|
||
from++; /* Skip u/U. */
|
||
|
||
if (loc_reader)
|
||
/* The u/U is part of the spelling of this character. */
|
||
char_range.m_finish = loc_reader->get_next ().m_finish;
|
||
|
||
_cpp_valid_ucn (pfile, &from, limit, 0, &nst,
|
||
&ucn, &char_range, loc_reader);
|
||
|
||
rval = one_cppchar_to_utf8 (ucn, &bufp, &bytesleft);
|
||
if (rval)
|
||
{
|
||
errno = rval;
|
||
cpp_errno (pfile, CPP_DL_ERROR,
|
||
"converting UCN to source character set");
|
||
}
|
||
else
|
||
{
|
||
if (tbuf)
|
||
if (!APPLY_CONVERSION (cvt, buf, 6 - bytesleft, tbuf))
|
||
cpp_errno (pfile, CPP_DL_ERROR,
|
||
"converting UCN to execution character set");
|
||
|
||
if (loc_reader)
|
||
{
|
||
int num_encoded_bytes = 6 - bytesleft;
|
||
for (int i = 0; i < num_encoded_bytes; i++)
|
||
ranges->add_range (char_range);
|
||
}
|
||
}
|
||
|
||
return from;
|
||
}
|
||
|
||
/* Performs a similar task as _cpp_valid_ucn, but parses UTF-8-encoded
|
||
extended characters rather than UCNs. If the return value is TRUE, then a
|
||
character was successfully decoded and stored in *CP; *PSTR has been
|
||
updated to point one past the valid UTF-8 sequence. Diagnostics may have
|
||
been emitted if the character parsed is not allowed in the current context.
|
||
If the return value is FALSE, then *PSTR has not been modified and *CP may
|
||
equal 0, to indicate that *PSTR does not form a valid UTF-8 sequence, or it
|
||
may, when processing an identifier in C mode, equal a codepoint that was
|
||
validly encoded but is not allowed to appear in an identifier. In either
|
||
case, no diagnostic is emitted, and the return value of FALSE should cause
|
||
a new token to be formed.
|
||
|
||
Unlike _cpp_valid_ucn, this will never be called when lexing a string; only
|
||
a potential identifier, or a CPP_OTHER token. NST is unused in the latter
|
||
case.
|
||
|
||
As in _cpp_valid_ucn, IDENTIFIER_POS is 0 when not in an identifier, 1 for
|
||
the start of an identifier, or 2 otherwise. */
|
||
|
||
extern bool
|
||
_cpp_valid_utf8 (cpp_reader *pfile,
|
||
const uchar **pstr,
|
||
const uchar *limit,
|
||
int identifier_pos,
|
||
struct normalize_state *nst,
|
||
cppchar_t *cp)
|
||
{
|
||
const uchar *base = *pstr;
|
||
size_t inbytesleft = limit - base;
|
||
if (one_utf8_to_cppchar (pstr, &inbytesleft, cp))
|
||
{
|
||
/* No diagnostic here as this byte will rather become a
|
||
new token. */
|
||
*cp = 0;
|
||
return false;
|
||
}
|
||
|
||
if (identifier_pos)
|
||
{
|
||
switch (ucn_valid_in_identifier (pfile, *cp, nst))
|
||
{
|
||
|
||
case 0:
|
||
/* In C++, this is an error for invalid character in an identifier
|
||
because logically, the UTF-8 was converted to a UCN during
|
||
translation phase 1 (even though we don't physically do it that
|
||
way). In C, this byte rather becomes grammatically a separate
|
||
token. */
|
||
|
||
if (CPP_OPTION (pfile, cplusplus))
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"extended character %.*s is not valid in an identifier",
|
||
(int) (*pstr - base), base);
|
||
else
|
||
{
|
||
*pstr = base;
|
||
return false;
|
||
}
|
||
|
||
break;
|
||
|
||
case 2:
|
||
if (identifier_pos == 1)
|
||
{
|
||
/* This is treated the same way in C++ or C99 -- lexed as an
|
||
identifier which is then invalid because an identifier is
|
||
not allowed to start with this character. */
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"extended character %.*s is not valid at the start of an identifier",
|
||
(int) (*pstr - base), base);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/* Subroutine of convert_hex and convert_oct. N is the representation
|
||
in the execution character set of a numeric escape; write it into the
|
||
string buffer TBUF and update the end-of-string pointer therein. WIDE
|
||
is true if it's a wide string that's being assembled in TBUF. This
|
||
function issues no diagnostics and never fails. */
|
||
static void
|
||
emit_numeric_escape (cpp_reader *pfile, cppchar_t n,
|
||
struct _cpp_strbuf *tbuf, struct cset_converter cvt)
|
||
{
|
||
size_t width = cvt.width;
|
||
|
||
if (width != CPP_OPTION (pfile, char_precision))
|
||
{
|
||
/* We have to render this into the target byte order, which may not
|
||
be our byte order. */
|
||
bool bigend = CPP_OPTION (pfile, bytes_big_endian);
|
||
size_t cwidth = CPP_OPTION (pfile, char_precision);
|
||
size_t cmask = width_to_mask (cwidth);
|
||
size_t nbwc = width / cwidth;
|
||
size_t i;
|
||
size_t off = tbuf->len;
|
||
cppchar_t c;
|
||
|
||
if (tbuf->len + nbwc > tbuf->asize)
|
||
{
|
||
tbuf->asize += OUTBUF_BLOCK_SIZE;
|
||
tbuf->text = XRESIZEVEC (uchar, tbuf->text, tbuf->asize);
|
||
}
|
||
|
||
for (i = 0; i < nbwc; i++)
|
||
{
|
||
c = n & cmask;
|
||
n >>= cwidth;
|
||
tbuf->text[off + (bigend ? nbwc - i - 1 : i)] = c;
|
||
}
|
||
tbuf->len += nbwc;
|
||
}
|
||
else
|
||
{
|
||
/* Note: this code does not handle the case where the target
|
||
and host have a different number of bits in a byte. */
|
||
if (tbuf->len + 1 > tbuf->asize)
|
||
{
|
||
tbuf->asize += OUTBUF_BLOCK_SIZE;
|
||
tbuf->text = XRESIZEVEC (uchar, tbuf->text, tbuf->asize);
|
||
}
|
||
tbuf->text[tbuf->len++] = n;
|
||
}
|
||
}
|
||
|
||
/* Convert a hexadecimal escape, pointed to by FROM, to the execution
|
||
character set and write it into the string buffer TBUF (if non-NULL).
|
||
Returns an advanced pointer, and issues diagnostics as necessary.
|
||
No character set translation occurs; this routine always produces the
|
||
execution-set character with numeric value equal to the given hex
|
||
number. You can, e.g. generate surrogate pairs this way.
|
||
If LOC_READER is non-NULL, then RANGES must be non-NULL and CHAR_RANGE
|
||
contains the location of the character so far: location information
|
||
is read from *LOC_READER, and *RANGES is updated accordingly. */
|
||
static const uchar *
|
||
convert_hex (cpp_reader *pfile, const uchar *from, const uchar *limit,
|
||
struct _cpp_strbuf *tbuf, struct cset_converter cvt,
|
||
source_range char_range,
|
||
cpp_string_location_reader *loc_reader,
|
||
cpp_substring_ranges *ranges)
|
||
{
|
||
cppchar_t c, n = 0, overflow = 0;
|
||
int digits_found = 0;
|
||
size_t width = cvt.width;
|
||
size_t mask = width_to_mask (width);
|
||
|
||
/* loc_reader and ranges must either be both NULL, or both be non-NULL. */
|
||
gcc_assert ((loc_reader != NULL) == (ranges != NULL));
|
||
|
||
if (CPP_WTRADITIONAL (pfile))
|
||
cpp_warning (pfile, CPP_W_TRADITIONAL,
|
||
"the meaning of '\\x' is different in traditional C");
|
||
|
||
/* Skip 'x'. */
|
||
from++;
|
||
|
||
/* The 'x' is part of the spelling of this character. */
|
||
if (loc_reader)
|
||
char_range.m_finish = loc_reader->get_next ().m_finish;
|
||
|
||
while (from < limit)
|
||
{
|
||
c = *from;
|
||
if (! hex_p (c))
|
||
break;
|
||
from++;
|
||
if (loc_reader)
|
||
char_range.m_finish = loc_reader->get_next ().m_finish;
|
||
overflow |= n ^ (n << 4 >> 4);
|
||
n = (n << 4) + hex_value (c);
|
||
digits_found = 1;
|
||
}
|
||
|
||
if (!digits_found)
|
||
{
|
||
cpp_error (pfile, CPP_DL_ERROR,
|
||
"\\x used with no following hex digits");
|
||
return from;
|
||
}
|
||
|
||
if (overflow | (n != (n & mask)))
|
||
{
|
||
cpp_error (pfile, CPP_DL_PEDWARN,
|
||
"hex escape sequence out of range");
|
||
n &= mask;
|
||
}
|
||
|
||
if (tbuf)
|
||
emit_numeric_escape (pfile, n, tbuf, cvt);
|
||
if (ranges)
|
||
ranges->add_range (char_range);
|
||
|
||
return from;
|
||
}
|
||
|
||
/* Convert an octal escape, pointed to by FROM, to the execution
|
||
character set and write it into the string buffer TBUF. Returns an
|
||
advanced pointer, and issues diagnostics as necessary.
|
||
No character set translation occurs; this routine always produces the
|
||
execution-set character with numeric value equal to the given octal
|
||
number.
|
||
If LOC_READER is non-NULL, then RANGES must be non-NULL and CHAR_RANGE
|
||
contains the location of the character so far: location information
|
||
is read from *LOC_READER, and *RANGES is updated accordingly. */
|
||
static const uchar *
|
||
convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit,
|
||
struct _cpp_strbuf *tbuf, struct cset_converter cvt,
|
||
source_range char_range,
|
||
cpp_string_location_reader *loc_reader,
|
||
cpp_substring_ranges *ranges)
|
||
{
|
||
size_t count = 0;
|
||
cppchar_t c, n = 0;
|
||
size_t width = cvt.width;
|
||
size_t mask = width_to_mask (width);
|
||
|
||
/* loc_reader and ranges must either be both NULL, or both be non-NULL. */
|
||
gcc_assert ((loc_reader != NULL) == (ranges != NULL));
|
||
|
||
while (from < limit && count++ < 3)
|
||
{
|
||
c = *from;
|
||
if (c < '0' || c > '7')
|
||
break;
|
||
from++;
|
||
if (loc_reader)
|
||
char_range.m_finish = loc_reader->get_next ().m_finish;
|
||
n = (n << 3) + c - '0';
|
||
}
|
||
|
||
if (n != (n & mask))
|
||
{
|
||
cpp_error (pfile, CPP_DL_PEDWARN,
|
||
"octal escape sequence out of range");
|
||
n &= mask;
|
||
}
|
||
|
||
if (tbuf)
|
||
emit_numeric_escape (pfile, n, tbuf, cvt);
|
||
if (ranges)
|
||
ranges->add_range (char_range);
|
||
|
||
return from;
|
||
}
|
||
|
||
/* Convert an escape sequence (pointed to by FROM) to its value on
|
||
the target, and to the execution character set. Do not scan past
|
||
LIMIT. Write the converted value into TBUF, if TBUF is non-NULL.
|
||
Returns an advanced pointer. Handles all relevant diagnostics.
|
||
If LOC_READER is non-NULL, then RANGES must be non-NULL: location
|
||
information is read from *LOC_READER, and *RANGES is updated
|
||
accordingly. */
|
||
static const uchar *
|
||
convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit,
|
||
struct _cpp_strbuf *tbuf, struct cset_converter cvt,
|
||
cpp_string_location_reader *loc_reader,
|
||
cpp_substring_ranges *ranges)
|
||
{
|
||
/* Values of \a \b \e \f \n \r \t \v respectively. */
|
||
#if HOST_CHARSET == HOST_CHARSET_ASCII
|
||
static const uchar charconsts[] = { 7, 8, 27, 12, 10, 13, 9, 11 };
|
||
#elif HOST_CHARSET == HOST_CHARSET_EBCDIC
|
||
static const uchar charconsts[] = { 47, 22, 39, 12, 21, 13, 5, 11 };
|
||
#else
|
||
#error "unknown host character set"
|
||
#endif
|
||
|
||
uchar c;
|
||
|
||
/* Record the location of the backslash. */
|
||
source_range char_range;
|
||
if (loc_reader)
|
||
char_range = loc_reader->get_next ();
|
||
|
||
c = *from;
|
||
switch (c)
|
||
{
|
||
/* UCNs, hex escapes, and octal escapes are processed separately. */
|
||
case 'u': case 'U':
|
||
return convert_ucn (pfile, from, limit, tbuf, cvt,
|
||
char_range, loc_reader, ranges);
|
||
|
||
case 'x':
|
||
return convert_hex (pfile, from, limit, tbuf, cvt,
|
||
char_range, loc_reader, ranges);
|
||
|
||
case '0': case '1': case '2': case '3':
|
||
case '4': case '5': case '6': case '7':
|
||
return convert_oct (pfile, from, limit, tbuf, cvt,
|
||
char_range, loc_reader, ranges);
|
||
|
||
/* Various letter escapes. Get the appropriate host-charset
|
||
value into C. */
|
||
case '\\': case '\'': case '"': case '?': break;
|
||
|
||
case '(': case '{': case '[': case '%':
|
||
/* '\(', etc, can be used at the beginning of a line in a long
|
||
string split onto multiple lines with \-newline, to prevent
|
||
Emacs or other text editors from getting confused. '\%' can
|
||
be used to prevent SCCS from mangling printf format strings. */
|
||
if (CPP_PEDANTIC (pfile))
|
||
goto unknown;
|
||
break;
|
||
|
||
case 'b': c = charconsts[1]; break;
|
||
case 'f': c = charconsts[3]; break;
|
||
case 'n': c = charconsts[4]; break;
|
||
case 'r': c = charconsts[5]; break;
|
||
case 't': c = charconsts[6]; break;
|
||
case 'v': c = charconsts[7]; break;
|
||
|
||
case 'a':
|
||
if (CPP_WTRADITIONAL (pfile))
|
||
cpp_warning (pfile, CPP_W_TRADITIONAL,
|
||
"the meaning of '\\a' is different in traditional C");
|
||
c = charconsts[0];
|
||
break;
|
||
|
||
case 'e': case 'E':
|
||
if (CPP_PEDANTIC (pfile))
|
||
cpp_error (pfile, CPP_DL_PEDWARN,
|
||
"non-ISO-standard escape sequence, '\\%c'", (int) c);
|
||
c = charconsts[2];
|
||
break;
|
||
|
||
default:
|
||
unknown:
|
||
if (ISGRAPH (c))
|
||
cpp_error (pfile, CPP_DL_PEDWARN,
|
||
"unknown escape sequence: '\\%c'", (int) c);
|
||
else
|
||
{
|
||
encoding_rich_location rich_loc (pfile);
|
||
|
||
/* diagnostic.cc does not support "%03o". When it does, this
|
||
code can use %03o directly in the diagnostic again. */
|
||
char buf[32];
|
||
sprintf(buf, "%03o", (int) c);
|
||
cpp_error_at (pfile, CPP_DL_PEDWARN, &rich_loc,
|
||
"unknown escape sequence: '\\%s'", buf);
|
||
}
|
||
}
|
||
|
||
if (tbuf)
|
||
/* Now convert what we have to the execution character set. */
|
||
if (!APPLY_CONVERSION (cvt, &c, 1, tbuf))
|
||
cpp_errno (pfile, CPP_DL_ERROR,
|
||
"converting escape sequence to execution character set");
|
||
|
||
if (loc_reader)
|
||
{
|
||
char_range.m_finish = loc_reader->get_next ().m_finish;
|
||
ranges->add_range (char_range);
|
||
}
|
||
|
||
return from + 1;
|
||
}
|
||
|
||
/* TYPE is a token type. The return value is the conversion needed to
|
||
convert from source to execution character set for the given type. */
|
||
static struct cset_converter
|
||
converter_for_type (cpp_reader *pfile, enum cpp_ttype type)
|
||
{
|
||
switch (type)
|
||
{
|
||
default:
|
||
return pfile->narrow_cset_desc;
|
||
case CPP_UTF8CHAR:
|
||
case CPP_UTF8STRING:
|
||
return pfile->utf8_cset_desc;
|
||
case CPP_CHAR16:
|
||
case CPP_STRING16:
|
||
return pfile->char16_cset_desc;
|
||
case CPP_CHAR32:
|
||
case CPP_STRING32:
|
||
return pfile->char32_cset_desc;
|
||
case CPP_WCHAR:
|
||
case CPP_WSTRING:
|
||
return pfile->wide_cset_desc;
|
||
}
|
||
}
|
||
|
||
/* FROM is an array of cpp_string structures of length COUNT. These
|
||
are to be converted from the source to the execution character set,
|
||
escape sequences translated, and finally all are to be
|
||
concatenated. WIDE indicates whether or not to produce a wide
|
||
string. If TO is non-NULL, the result is written into TO.
|
||
If LOC_READERS and OUT are non-NULL, then location information
|
||
is read from LOC_READERS (which must be an array of length COUNT),
|
||
and location information is written to *RANGES.
|
||
|
||
Returns true for success, false for failure. */
|
||
|
||
static bool
|
||
cpp_interpret_string_1 (cpp_reader *pfile, const cpp_string *from, size_t count,
|
||
cpp_string *to, enum cpp_ttype type,
|
||
cpp_string_location_reader *loc_readers,
|
||
cpp_substring_ranges *out)
|
||
{
|
||
struct _cpp_strbuf tbuf;
|
||
const uchar *p, *base, *limit;
|
||
size_t i;
|
||
struct cset_converter cvt = converter_for_type (pfile, type);
|
||
|
||
/* loc_readers and out must either be both NULL, or both be non-NULL. */
|
||
gcc_assert ((loc_readers != NULL) == (out != NULL));
|
||
|
||
if (to)
|
||
{
|
||
tbuf.asize = MAX (OUTBUF_BLOCK_SIZE, from->len);
|
||
tbuf.text = XNEWVEC (uchar, tbuf.asize);
|
||
tbuf.len = 0;
|
||
}
|
||
|
||
cpp_string_location_reader *loc_reader = NULL;
|
||
for (i = 0; i < count; i++)
|
||
{
|
||
if (loc_readers)
|
||
loc_reader = &loc_readers[i];
|
||
|
||
p = from[i].text;
|
||
if (*p == 'u')
|
||
{
|
||
p++;
|
||
if (loc_reader)
|
||
loc_reader->get_next ();
|
||
if (*p == '8')
|
||
{
|
||
p++;
|
||
if (loc_reader)
|
||
loc_reader->get_next ();
|
||
}
|
||
}
|
||
else if (*p == 'L' || *p == 'U') p++;
|
||
if (*p == 'R')
|
||
{
|
||
const uchar *prefix;
|
||
|
||
/* Skip over 'R"'. */
|
||
p += 2;
|
||
if (loc_reader)
|
||
{
|
||
loc_reader->get_next ();
|
||
loc_reader->get_next ();
|
||
}
|
||
prefix = p;
|
||
while (*p != '(')
|
||
{
|
||
p++;
|
||
if (loc_reader)
|
||
loc_reader->get_next ();
|
||
}
|
||
p++;
|
||
if (loc_reader)
|
||
loc_reader->get_next ();
|
||
limit = from[i].text + from[i].len;
|
||
if (limit >= p + (p - prefix) + 1)
|
||
limit -= (p - prefix) + 1;
|
||
|
||
/* Raw strings are all normal characters; these can be fed
|
||
directly to convert_cset. */
|
||
if (to)
|
||
if (!APPLY_CONVERSION (cvt, p, limit - p, &tbuf))
|
||
goto fail;
|
||
|
||
if (loc_reader)
|
||
{
|
||
/* If generating source ranges, assume we have a 1:1
|
||
correspondence between bytes in the source encoding and bytes
|
||
in the execution encoding (e.g. if we have a UTF-8 to UTF-8
|
||
conversion), so that this run of bytes in the source file
|
||
corresponds to a run of bytes in the execution string.
|
||
This requirement is guaranteed by an early-reject in
|
||
cpp_interpret_string_ranges. */
|
||
gcc_assert (cvt.func == convert_no_conversion);
|
||
out->add_n_ranges (limit - p, *loc_reader);
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
/* If we don't now have a leading quote, something has gone wrong.
|
||
This can occur if cpp_interpret_string_ranges is handling a
|
||
stringified macro argument, but should not be possible otherwise. */
|
||
if (*p != '"' && *p != '\'')
|
||
{
|
||
gcc_assert (out != NULL);
|
||
cpp_error (pfile, CPP_DL_ERROR, "missing open quote");
|
||
if (to)
|
||
free (tbuf.text);
|
||
return false;
|
||
}
|
||
|
||
/* Skip leading quote. */
|
||
p++;
|
||
if (loc_reader)
|
||
loc_reader->get_next ();
|
||
|
||
limit = from[i].text + from[i].len - 1; /* Skip trailing quote. */
|
||
|
||
for (;;)
|
||
{
|
||
base = p;
|
||
while (p < limit && *p != '\\')
|
||
p++;
|
||
if (p > base)
|
||
{
|
||
/* We have a run of normal characters; these can be fed
|
||
directly to convert_cset. */
|
||
if (to)
|
||
if (!APPLY_CONVERSION (cvt, base, p - base, &tbuf))
|
||
goto fail;
|
||
/* Similar to above: assumes we have a 1:1 correspondence
|
||
between bytes in the source encoding and bytes in the
|
||
execution encoding. */
|
||
if (loc_reader)
|
||
{
|
||
gcc_assert (cvt.func == convert_no_conversion);
|
||
out->add_n_ranges (p - base, *loc_reader);
|
||
}
|
||
}
|
||
if (p >= limit)
|
||
break;
|
||
|
||
struct _cpp_strbuf *tbuf_ptr = to ? &tbuf : NULL;
|
||
p = convert_escape (pfile, p + 1, limit, tbuf_ptr, cvt,
|
||
loc_reader, out);
|
||
}
|
||
}
|
||
|
||
if (to)
|
||
{
|
||
/* NUL-terminate the 'to' buffer and translate it to a cpp_string
|
||
structure. */
|
||
emit_numeric_escape (pfile, 0, &tbuf, cvt);
|
||
tbuf.text = XRESIZEVEC (uchar, tbuf.text, tbuf.len);
|
||
to->text = tbuf.text;
|
||
to->len = tbuf.len;
|
||
}
|
||
/* Use the location of the trailing quote as the location of the
|
||
NUL-terminator. */
|
||
if (loc_reader)
|
||
{
|
||
source_range range = loc_reader->get_next ();
|
||
out->add_range (range);
|
||
}
|
||
|
||
return true;
|
||
|
||
fail:
|
||
cpp_errno (pfile, CPP_DL_ERROR, "converting to execution character set");
|
||
if (to)
|
||
free (tbuf.text);
|
||
return false;
|
||
}
|
||
|
||
/* FROM is an array of cpp_string structures of length COUNT. These
|
||
are to be converted from the source to the execution character set,
|
||
escape sequences translated, and finally all are to be
|
||
concatenated. WIDE indicates whether or not to produce a wide
|
||
string. The result is written into TO. Returns true for success,
|
||
false for failure. */
|
||
bool
|
||
cpp_interpret_string (cpp_reader *pfile, const cpp_string *from, size_t count,
|
||
cpp_string *to, enum cpp_ttype type)
|
||
{
|
||
return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL);
|
||
}
|
||
|
||
/* A "do nothing" diagnostic-handling callback for use by
|
||
cpp_interpret_string_ranges, so that it can temporarily suppress
|
||
diagnostic-handling. */
|
||
|
||
static bool
|
||
noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
|
||
enum cpp_warning_reason, rich_location *,
|
||
const char *, va_list *)
|
||
{
|
||
/* no-op. */
|
||
return true;
|
||
}
|
||
|
||
/* This function mimics the behavior of cpp_interpret_string, but
|
||
rather than generating a string in the execution character set,
|
||
*OUT is written to with the source code ranges of the characters
|
||
in such a string.
|
||
FROM and LOC_READERS should both be arrays of length COUNT.
|
||
Returns NULL for success, or an error message for failure. */
|
||
|
||
const char *
|
||
cpp_interpret_string_ranges (cpp_reader *pfile, const cpp_string *from,
|
||
cpp_string_location_reader *loc_readers,
|
||
size_t count,
|
||
cpp_substring_ranges *out,
|
||
enum cpp_ttype type)
|
||
{
|
||
/* There are a couple of cases in the range-handling in
|
||
cpp_interpret_string_1 that rely on there being a 1:1 correspondence
|
||
between bytes in the source encoding and bytes in the execution
|
||
encoding, so that each byte in the execution string can correspond
|
||
to the location of a byte in the source string.
|
||
|
||
This holds for the typical case of a UTF-8 to UTF-8 conversion.
|
||
Enforce this requirement by only attempting to track substring
|
||
locations if we have source encoding == execution encoding.
|
||
|
||
This is a stronger condition than we need, since we could e.g.
|
||
have ASCII to EBCDIC (with 1 byte per character before and after),
|
||
but it seems to be a reasonable restriction. */
|
||
struct cset_converter cvt = converter_for_type (pfile, type);
|
||
if (cvt.func != convert_no_conversion)
|
||
return "execution character set != source character set";
|
||
|
||
/* For on-demand strings we have already lexed the strings, so there
|
||
should be no diagnostics. However, if we have bogus source location
|
||
data (or stringified macro arguments), the attempt to lex the
|
||
strings could fail with an diagnostic. Temporarily install an
|
||
diagnostic-handler to catch the diagnostic, so that it can lead to this call
|
||
failing, rather than being emitted as a user-visible diagnostic.
|
||
If an diagnostic does occur, we should see it via the return value of
|
||
cpp_interpret_string_1. */
|
||
bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
|
||
enum cpp_warning_reason, rich_location *,
|
||
const char *, va_list *)
|
||
ATTRIBUTE_FPTR_PRINTF(5,0);
|
||
|
||
saved_diagnostic_handler = pfile->cb.diagnostic;
|
||
pfile->cb.diagnostic = noop_diagnostic_cb;
|
||
|
||
bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
|
||
loc_readers, out);
|
||
|
||
/* Restore the saved diagnostic-handler. */
|
||
pfile->cb.diagnostic = saved_diagnostic_handler;
|
||
|
||
if (!result)
|
||
return "cpp_interpret_string_1 failed";
|
||
|
||
/* Success. */
|
||
return NULL;
|
||
}
|
||
|
||
/* Subroutine of do_line and do_linemarker. Convert escape sequences
|
||
in a string, but do not perform character set conversion. */
|
||
bool
|
||
cpp_interpret_string_notranslate (cpp_reader *pfile, const cpp_string *from,
|
||
size_t count, cpp_string *to,
|
||
enum cpp_ttype type ATTRIBUTE_UNUSED)
|
||
{
|
||
struct cset_converter save_narrow_cset_desc = pfile->narrow_cset_desc;
|
||
bool retval;
|
||
|
||
pfile->narrow_cset_desc.func = convert_no_conversion;
|
||
pfile->narrow_cset_desc.cd = (iconv_t) -1;
|
||
pfile->narrow_cset_desc.width = CPP_OPTION (pfile, char_precision);
|
||
|
||
retval = cpp_interpret_string (pfile, from, count, to, CPP_STRING);
|
||
|
||
pfile->narrow_cset_desc = save_narrow_cset_desc;
|
||
return retval;
|
||
}
|
||
|
||
|
||
/* Subroutine of cpp_interpret_charconst which performs the conversion
|
||
to a number, for narrow strings. STR is the string structure returned
|
||
by cpp_interpret_string. PCHARS_SEEN and UNSIGNEDP are as for
|
||
cpp_interpret_charconst. TYPE is the token type. */
|
||
static cppchar_t
|
||
narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
|
||
unsigned int *pchars_seen, int *unsignedp,
|
||
enum cpp_ttype type)
|
||
{
|
||
size_t width = CPP_OPTION (pfile, char_precision);
|
||
size_t max_chars = CPP_OPTION (pfile, int_precision) / width;
|
||
size_t mask = width_to_mask (width);
|
||
size_t i;
|
||
cppchar_t result, c;
|
||
bool unsigned_p;
|
||
|
||
/* The value of a multi-character character constant, or a
|
||
single-character character constant whose representation in the
|
||
execution character set is more than one byte long, is
|
||
implementation defined. This implementation defines it to be the
|
||
number formed by interpreting the byte sequence in memory as a
|
||
big-endian binary number. If overflow occurs, the high bytes are
|
||
lost, and a warning is issued.
|
||
|
||
We don't want to process the NUL terminator handed back by
|
||
cpp_interpret_string. */
|
||
result = 0;
|
||
for (i = 0; i < str.len - 1; i++)
|
||
{
|
||
c = str.text[i] & mask;
|
||
if (width < BITS_PER_CPPCHAR_T)
|
||
result = (result << width) | c;
|
||
else
|
||
result = c;
|
||
}
|
||
|
||
if (type == CPP_UTF8CHAR)
|
||
max_chars = 1;
|
||
if (i > max_chars)
|
||
{
|
||
i = max_chars;
|
||
cpp_error (pfile, type == CPP_UTF8CHAR ? CPP_DL_ERROR : CPP_DL_WARNING,
|
||
"character constant too long for its type");
|
||
}
|
||
else if (i > 1 && CPP_OPTION (pfile, warn_multichar))
|
||
cpp_warning (pfile, CPP_W_MULTICHAR, "multi-character character constant");
|
||
|
||
/* Multichar constants are of type int and therefore signed. */
|
||
if (i > 1)
|
||
unsigned_p = 0;
|
||
else if (type == CPP_UTF8CHAR && !CPP_OPTION (pfile, cplusplus))
|
||
unsigned_p = 1;
|
||
else
|
||
unsigned_p = CPP_OPTION (pfile, unsigned_char);
|
||
|
||
/* Truncate the constant to its natural width, and simultaneously
|
||
sign- or zero-extend to the full width of cppchar_t.
|
||
For single-character constants, the value is WIDTH bits wide.
|
||
For multi-character constants, the value is INT_PRECISION bits wide. */
|
||
if (i > 1)
|
||
width = CPP_OPTION (pfile, int_precision);
|
||
if (width < BITS_PER_CPPCHAR_T)
|
||
{
|
||
mask = ((cppchar_t) 1 << width) - 1;
|
||
if (unsigned_p || !(result & (1 << (width - 1))))
|
||
result &= mask;
|
||
else
|
||
result |= ~mask;
|
||
}
|
||
*pchars_seen = i;
|
||
*unsignedp = unsigned_p;
|
||
return result;
|
||
}
|
||
|
||
/* Subroutine of cpp_interpret_charconst which performs the conversion
|
||
to a number, for wide strings. STR is the string structure returned
|
||
by cpp_interpret_string. PCHARS_SEEN and UNSIGNEDP are as for
|
||
cpp_interpret_charconst. TYPE is the token type. */
|
||
static cppchar_t
|
||
wide_str_to_charconst (cpp_reader *pfile, cpp_string str,
|
||
unsigned int *pchars_seen, int *unsignedp,
|
||
enum cpp_ttype type)
|
||
{
|
||
bool bigend = CPP_OPTION (pfile, bytes_big_endian);
|
||
size_t width = converter_for_type (pfile, type).width;
|
||
size_t cwidth = CPP_OPTION (pfile, char_precision);
|
||
size_t mask = width_to_mask (width);
|
||
size_t cmask = width_to_mask (cwidth);
|
||
size_t nbwc = width / cwidth;
|
||
size_t off, i;
|
||
cppchar_t result = 0, c;
|
||
|
||
if (str.len <= nbwc)
|
||
{
|
||
/* Error recovery, if no errors have been diagnosed previously,
|
||
there should be at least two wide characters. Empty literals
|
||
are diagnosed earlier and we can get just the zero terminator
|
||
only if there were errors diagnosed during conversion. */
|
||
*pchars_seen = 0;
|
||
*unsignedp = 0;
|
||
return 0;
|
||
}
|
||
|
||
/* This is finicky because the string is in the target's byte order,
|
||
which may not be our byte order. Only the last character, ignoring
|
||
the NUL terminator, is relevant. */
|
||
off = str.len - (nbwc * 2);
|
||
result = 0;
|
||
for (i = 0; i < nbwc; i++)
|
||
{
|
||
c = bigend ? str.text[off + i] : str.text[off + nbwc - i - 1];
|
||
result = (result << cwidth) | (c & cmask);
|
||
}
|
||
|
||
/* Wide character constants have type wchar_t, and a single
|
||
character exactly fills a wchar_t, so a multi-character wide
|
||
character constant is guaranteed to overflow. */
|
||
if (str.len > nbwc * 2)
|
||
cpp_error (pfile, (CPP_OPTION (pfile, cplusplus)
|
||
&& (type == CPP_CHAR16 || type == CPP_CHAR32))
|
||
? CPP_DL_ERROR : CPP_DL_WARNING,
|
||
"character constant too long for its type");
|
||
|
||
/* Truncate the constant to its natural width, and simultaneously
|
||
sign- or zero-extend to the full width of cppchar_t. */
|
||
if (width < BITS_PER_CPPCHAR_T)
|
||
{
|
||
if (type == CPP_CHAR16 || type == CPP_CHAR32
|
||
|| CPP_OPTION (pfile, unsigned_wchar)
|
||
|| !(result & (1 << (width - 1))))
|
||
result &= mask;
|
||
else
|
||
result |= ~mask;
|
||
}
|
||
|
||
if (type == CPP_CHAR16 || type == CPP_CHAR32
|
||
|| CPP_OPTION (pfile, unsigned_wchar))
|
||
*unsignedp = 1;
|
||
else
|
||
*unsignedp = 0;
|
||
|
||
*pchars_seen = 1;
|
||
return result;
|
||
}
|
||
|
||
/* Interpret a (possibly wide) character constant in TOKEN.
|
||
PCHARS_SEEN points to a variable that is filled in with the number
|
||
of characters seen, and UNSIGNEDP to a variable that indicates
|
||
whether the result has signed type. */
|
||
cppchar_t
|
||
cpp_interpret_charconst (cpp_reader *pfile, const cpp_token *token,
|
||
unsigned int *pchars_seen, int *unsignedp)
|
||
{
|
||
cpp_string str = { 0, 0 };
|
||
bool wide = (token->type != CPP_CHAR && token->type != CPP_UTF8CHAR);
|
||
int u8 = 2 * int(token->type == CPP_UTF8CHAR);
|
||
cppchar_t result;
|
||
|
||
/* An empty constant will appear as L'', u'', U'', u8'', or '' */
|
||
if (token->val.str.len == (size_t) (2 + wide + u8))
|
||
{
|
||
cpp_error (pfile, CPP_DL_ERROR, "empty character constant");
|
||
*pchars_seen = 0;
|
||
*unsignedp = 0;
|
||
return 0;
|
||
}
|
||
else if (!cpp_interpret_string (pfile, &token->val.str, 1, &str,
|
||
token->type))
|
||
{
|
||
*pchars_seen = 0;
|
||
*unsignedp = 0;
|
||
return 0;
|
||
}
|
||
|
||
if (wide)
|
||
result = wide_str_to_charconst (pfile, str, pchars_seen, unsignedp,
|
||
token->type);
|
||
else
|
||
result = narrow_str_to_charconst (pfile, str, pchars_seen, unsignedp,
|
||
token->type);
|
||
|
||
if (str.text != token->val.str.text)
|
||
free ((void *)str.text);
|
||
|
||
return result;
|
||
}
|
||
|
||
/* Convert an identifier denoted by ID and LEN, which might contain
|
||
UCN escapes or UTF-8 multibyte chars, to the source character set,
|
||
either UTF-8 or UTF-EBCDIC. Assumes that the identifier is actually
|
||
a valid identifier. */
|
||
cpp_hashnode *
|
||
_cpp_interpret_identifier (cpp_reader *pfile, const uchar *id, size_t len)
|
||
{
|
||
/* It turns out that a UCN escape always turns into fewer characters
|
||
than the escape itself, so we can allocate a temporary in advance. */
|
||
uchar * buf = (uchar *) alloca (len + 1);
|
||
uchar * bufp = buf;
|
||
size_t idp;
|
||
|
||
for (idp = 0; idp < len; idp++)
|
||
if (id[idp] != '\\')
|
||
*bufp++ = id[idp];
|
||
else
|
||
{
|
||
unsigned length = id[idp+1] == 'u' ? 4 : 8;
|
||
cppchar_t value = 0;
|
||
size_t bufleft = len - (bufp - buf);
|
||
int rval;
|
||
|
||
idp += 2;
|
||
while (length && idp < len && ISXDIGIT (id[idp]))
|
||
{
|
||
value = (value << 4) + hex_value (id[idp]);
|
||
idp++;
|
||
length--;
|
||
}
|
||
idp--;
|
||
|
||
/* Special case for EBCDIC: if the identifier contains
|
||
a '$' specified using a UCN, translate it to EBCDIC. */
|
||
if (value == 0x24)
|
||
{
|
||
*bufp++ = '$';
|
||
continue;
|
||
}
|
||
|
||
rval = one_cppchar_to_utf8 (value, &bufp, &bufleft);
|
||
if (rval)
|
||
{
|
||
errno = rval;
|
||
cpp_errno (pfile, CPP_DL_ERROR,
|
||
"converting UCN to source character set");
|
||
break;
|
||
}
|
||
}
|
||
|
||
return CPP_HASHNODE (ht_lookup (pfile->hash_table,
|
||
buf, bufp - buf, HT_ALLOC));
|
||
}
|
||
|
||
|
||
/* Utility to strip a UTF-8 byte order marking from the beginning
|
||
of a buffer. Returns the number of bytes to skip, which currently
|
||
will be either 0 or 3. */
|
||
int
|
||
cpp_check_utf8_bom (const char *data, size_t data_length)
|
||
{
|
||
|
||
#if HOST_CHARSET == HOST_CHARSET_ASCII
|
||
const unsigned char *udata = (const unsigned char *) data;
|
||
if (data_length >= 3 && udata[0] == 0xef && udata[1] == 0xbb
|
||
&& udata[2] == 0xbf)
|
||
return 3;
|
||
#endif
|
||
|
||
return 0;
|
||
}
|
||
|
||
|
||
/* Convert an input buffer (containing the complete contents of one
|
||
source file) from INPUT_CHARSET to the source character set. INPUT
|
||
points to the input buffer, SIZE is its allocated size, and LEN is
|
||
the length of the meaningful data within the buffer. The
|
||
translated buffer is returned, *ST_SIZE is set to the length of
|
||
the meaningful data within the translated buffer, and *BUFFER_START
|
||
is set to the start of the returned buffer. *BUFFER_START may
|
||
differ from the return value in the case of a BOM or other ignored
|
||
marker information.
|
||
|
||
INPUT is expected to have been allocated with xmalloc. This
|
||
function will either set *BUFFER_START to INPUT, or free it and set
|
||
*BUFFER_START to a pointer to another xmalloc-allocated block of
|
||
memory.
|
||
|
||
PFILE is only used to generate diagnostics; setting it to NULL suppresses
|
||
diagnostics, and causes a return of NULL if there was any error instead. */
|
||
|
||
uchar *
|
||
_cpp_convert_input (cpp_reader *pfile, const char *input_charset,
|
||
uchar *input, size_t size, size_t len,
|
||
const unsigned char **buffer_start, off_t *st_size)
|
||
{
|
||
struct cset_converter input_cset;
|
||
struct _cpp_strbuf to;
|
||
unsigned char *buffer;
|
||
|
||
input_cset = init_iconv_desc (pfile, SOURCE_CHARSET, input_charset);
|
||
if (input_cset.func == convert_no_conversion)
|
||
{
|
||
to.text = input;
|
||
to.asize = size;
|
||
to.len = len;
|
||
}
|
||
else
|
||
{
|
||
to.asize = MAX (65536, len);
|
||
to.text = XNEWVEC (uchar, to.asize);
|
||
to.len = 0;
|
||
|
||
const bool ok = APPLY_CONVERSION (input_cset, input, len, &to);
|
||
free (input);
|
||
|
||
/* Clean up the mess. */
|
||
if (input_cset.func == convert_using_iconv)
|
||
iconv_close (input_cset.cd);
|
||
|
||
/* Handle conversion failure. */
|
||
if (!ok)
|
||
{
|
||
if (!pfile)
|
||
{
|
||
XDELETEVEC (to.text);
|
||
*buffer_start = NULL;
|
||
*st_size = 0;
|
||
return NULL;
|
||
}
|
||
cpp_error (pfile, CPP_DL_ERROR, "failure to convert %s to %s",
|
||
input_charset, SOURCE_CHARSET);
|
||
}
|
||
}
|
||
|
||
/* Resize buffer if we allocated substantially too much, or if we
|
||
haven't enough space for the \n-terminator or following
|
||
15 bytes of padding (used to quiet warnings from valgrind or
|
||
Address Sanitizer, when the optimized lexer accesses aligned
|
||
16-byte memory chunks, including the bytes after the malloced,
|
||
area, and stops lexing on '\n'). */
|
||
if (to.len + 4096 < to.asize || to.len + 16 > to.asize)
|
||
to.text = XRESIZEVEC (uchar, to.text, to.len + 16);
|
||
|
||
memset (to.text + to.len, '\0', 16);
|
||
|
||
/* If the file is using old-school Mac line endings (\r only),
|
||
terminate with another \r, not an \n, so that we do not mistake
|
||
the \r\n sequence for a single DOS line ending and erroneously
|
||
issue the "No newline at end of file" diagnostic. */
|
||
if (to.len && to.text[to.len - 1] == '\r')
|
||
to.text[to.len] = '\r';
|
||
else
|
||
to.text[to.len] = '\n';
|
||
|
||
buffer = to.text;
|
||
*st_size = to.len;
|
||
|
||
/* Ignore a UTF-8 BOM if we see one and the source charset is UTF-8. Note
|
||
that glib'c UTF-8 iconv() provider (as of glibc 2.7) does not ignore a
|
||
BOM -- however, even if it did, we would still need this code due
|
||
to the 'convert_no_conversion' case. */
|
||
const int bom_len = cpp_check_utf8_bom ((const char *) to.text, to.len);
|
||
*st_size -= bom_len;
|
||
buffer += bom_len;
|
||
|
||
*buffer_start = to.text;
|
||
return buffer;
|
||
}
|
||
|
||
/* Decide on the default encoding to assume for input files. */
|
||
const char *
|
||
_cpp_default_encoding (void)
|
||
{
|
||
const char *current_encoding = NULL;
|
||
|
||
/* We disable this because the default codeset is 7-bit ASCII on
|
||
most platforms, and this causes conversion failures on every
|
||
file in GCC that happens to have one of the upper 128 characters
|
||
in it -- most likely, as part of the name of a contributor.
|
||
We should definitely recognize in-band markers of file encoding,
|
||
like:
|
||
- the appropriate Unicode byte-order mark (FE FF) to recognize
|
||
UTF16 and UCS4 (in both big-endian and little-endian flavors)
|
||
and UTF8
|
||
- a "#i", "#d", "/ *", "//", " #p" or "#p" (for #pragma) to
|
||
distinguish ASCII and EBCDIC.
|
||
- now we can parse something like "#pragma GCC encoding <xyz>
|
||
on the first line, or even Emacs/VIM's mode line tags (there's
|
||
a problem here in that VIM uses the last line, and Emacs has
|
||
its more elaborate "local variables" convention).
|
||
- investigate whether Java has another common convention, which
|
||
would be friendly to support.
|
||
(Zack Weinberg and Paolo Bonzini, May 20th 2004) */
|
||
#if defined (HAVE_LOCALE_H) && defined (HAVE_LANGINFO_CODESET) && 0
|
||
setlocale (LC_CTYPE, "");
|
||
current_encoding = nl_langinfo (CODESET);
|
||
#endif
|
||
if (current_encoding == NULL || *current_encoding == '\0')
|
||
current_encoding = SOURCE_CHARSET;
|
||
|
||
return current_encoding;
|
||
}
|
||
|
||
/* Check if the configured input charset requires no conversion, other than
|
||
possibly stripping a UTF-8 BOM. */
|
||
bool cpp_input_conversion_is_trivial (const char *input_charset)
|
||
{
|
||
return !strcasecmp (input_charset, SOURCE_CHARSET);
|
||
}
|
||
|
||
/* Implementation of class cpp_string_location_reader. */
|
||
|
||
/* Constructor for cpp_string_location_reader. */
|
||
|
||
cpp_string_location_reader::
|
||
cpp_string_location_reader (location_t src_loc,
|
||
line_maps *line_table)
|
||
{
|
||
src_loc = get_range_from_loc (line_table, src_loc).m_start;
|
||
|
||
/* SRC_LOC might be a macro location. It only makes sense to do
|
||
column-by-column calculations on ordinary maps, so get the
|
||
corresponding location in an ordinary map. */
|
||
m_loc
|
||
= linemap_resolve_location (line_table, src_loc,
|
||
LRK_SPELLING_LOCATION, NULL);
|
||
|
||
const line_map_ordinary *map
|
||
= linemap_check_ordinary (linemap_lookup (line_table, m_loc));
|
||
m_offset_per_column = (1 << map->m_range_bits);
|
||
}
|
||
|
||
/* Get the range of the next source byte. */
|
||
|
||
source_range
|
||
cpp_string_location_reader::get_next ()
|
||
{
|
||
source_range result;
|
||
result.m_start = m_loc;
|
||
result.m_finish = m_loc;
|
||
if (m_loc <= LINE_MAP_MAX_LOCATION_WITH_COLS)
|
||
m_loc += m_offset_per_column;
|
||
return result;
|
||
}
|
||
|
||
cpp_display_width_computation::
|
||
cpp_display_width_computation (const char *data, int data_length,
|
||
const cpp_char_column_policy &policy) :
|
||
m_begin (data),
|
||
m_next (m_begin),
|
||
m_bytes_left (data_length),
|
||
m_policy (policy),
|
||
m_display_cols (0)
|
||
{
|
||
gcc_assert (policy.m_tabstop > 0);
|
||
gcc_assert (policy.m_width_cb);
|
||
}
|
||
|
||
|
||
/* The main implementation function for class cpp_display_width_computation.
|
||
m_next points on entry to the start of the UTF-8 encoding of the next
|
||
character, and is updated to point just after the last byte of the encoding.
|
||
m_bytes_left contains on entry the remaining size of the buffer into which
|
||
m_next points, and this is also updated accordingly. If m_next does not
|
||
point to a valid UTF-8-encoded sequence, then it will be treated as a single
|
||
byte with display width 1. m_cur_display_col is the current display column,
|
||
relative to which tab stops should be expanded. Returns the display width of
|
||
the codepoint just processed.
|
||
If OUT is non-NULL, it is populated. */
|
||
|
||
int
|
||
cpp_display_width_computation::process_next_codepoint (cpp_decoded_char *out)
|
||
{
|
||
cppchar_t c;
|
||
int next_width;
|
||
|
||
if (out)
|
||
out->m_start_byte = m_next;
|
||
|
||
if (*m_next == '\t')
|
||
{
|
||
++m_next;
|
||
--m_bytes_left;
|
||
next_width = m_policy.m_tabstop - (m_display_cols % m_policy.m_tabstop);
|
||
if (out)
|
||
{
|
||
out->m_ch = '\t';
|
||
out->m_valid_ch = true;
|
||
}
|
||
}
|
||
else if (one_utf8_to_cppchar ((const uchar **) &m_next, &m_bytes_left, &c)
|
||
!= 0)
|
||
{
|
||
/* Input is not convertible to UTF-8. This could be fine, e.g. in a
|
||
string literal, so don't complain. Just treat it as if it has a width
|
||
of one. */
|
||
++m_next;
|
||
--m_bytes_left;
|
||
next_width = m_policy.m_undecoded_byte_width;
|
||
if (out)
|
||
out->m_valid_ch = false;
|
||
}
|
||
else
|
||
{
|
||
/* one_utf8_to_cppchar() has updated m_next and m_bytes_left for us. */
|
||
next_width = m_policy.m_width_cb (c);
|
||
if (out)
|
||
{
|
||
out->m_ch = c;
|
||
out->m_valid_ch = true;
|
||
}
|
||
}
|
||
|
||
if (out)
|
||
out->m_next_byte = m_next;
|
||
|
||
m_display_cols += next_width;
|
||
return next_width;
|
||
}
|
||
|
||
/* Utility to advance the byte stream by the minimum amount needed to consume
|
||
N display columns. Returns the number of display columns that were
|
||
actually skipped. This could be less than N, if there was not enough data,
|
||
or more than N, if the last character to be skipped had a sufficiently large
|
||
display width. */
|
||
int
|
||
cpp_display_width_computation::advance_display_cols (int n)
|
||
{
|
||
const int start = m_display_cols;
|
||
const int target = start + n;
|
||
while (m_display_cols < target && !done ())
|
||
process_next_codepoint (NULL);
|
||
return m_display_cols - start;
|
||
}
|
||
|
||
/* For the string of length DATA_LENGTH bytes that begins at DATA, compute
|
||
how many display columns are occupied by the first COLUMN bytes. COLUMN
|
||
may exceed DATA_LENGTH, in which case the phantom bytes at the end are
|
||
treated as if they have display width 1. Tabs are expanded to the next tab
|
||
stop, relative to the start of DATA, and non-printable-ASCII characters
|
||
will be escaped as per POLICY. */
|
||
|
||
int
|
||
cpp_byte_column_to_display_column (const char *data, int data_length,
|
||
int column,
|
||
const cpp_char_column_policy &policy)
|
||
{
|
||
const int offset = MAX (0, column - data_length);
|
||
cpp_display_width_computation dw (data, column - offset, policy);
|
||
while (!dw.done ())
|
||
dw.process_next_codepoint (NULL);
|
||
return dw.display_cols_processed () + offset;
|
||
}
|
||
|
||
/* For the string of length DATA_LENGTH bytes that begins at DATA, compute
|
||
the least number of bytes that will result in at least DISPLAY_COL display
|
||
columns. The return value may exceed DATA_LENGTH if the entire string does
|
||
not occupy enough display columns. Non-printable-ASCII characters
|
||
will be escaped as per POLICY. */
|
||
|
||
int
|
||
cpp_display_column_to_byte_column (const char *data, int data_length,
|
||
int display_col,
|
||
const cpp_char_column_policy &policy)
|
||
{
|
||
cpp_display_width_computation dw (data, data_length, policy);
|
||
const int avail_display = dw.advance_display_cols (display_col);
|
||
return dw.bytes_processed () + MAX (0, display_col - avail_display);
|
||
}
|
||
|
||
/* Our own version of wcwidth(). We don't use the actual wcwidth() in glibc,
|
||
because that will inspect the user's locale, and in particular in an ASCII
|
||
locale, it will not return anything useful for extended characters. But GCC
|
||
in other respects (see e.g. _cpp_default_encoding()) behaves as if
|
||
everything is UTF-8. We also make some tweaks that are useful for the way
|
||
GCC needs to use this data, e.g. tabs and other control characters should be
|
||
treated as having width 1. The lookup tables are generated from
|
||
contrib/unicode/gen_wcwidth.py and were made by simply calling glibc
|
||
wcwidth() on all codepoints, then applying the small tweaks. These tables
|
||
are not highly optimized, but for the present purpose of outputting
|
||
diagnostics, they are sufficient. */
|
||
|
||
#include "generated_cpp_wcwidth.h"
|
||
int cpp_wcwidth (cppchar_t c)
|
||
{
|
||
if (__builtin_expect (c <= wcwidth_range_ends[0], true))
|
||
return wcwidth_widths[0];
|
||
|
||
/* Binary search the tables. */
|
||
int begin = 1;
|
||
static const int end
|
||
= sizeof wcwidth_range_ends / sizeof (*wcwidth_range_ends);
|
||
int len = end - begin;
|
||
do
|
||
{
|
||
int half = len/2;
|
||
int middle = begin + half;
|
||
if (c > wcwidth_range_ends[middle])
|
||
{
|
||
begin = middle + 1;
|
||
len -= half + 1;
|
||
}
|
||
else
|
||
len = half;
|
||
} while (len);
|
||
|
||
if (__builtin_expect (begin != end, true))
|
||
return wcwidth_widths[begin];
|
||
return 1;
|
||
}
|