Commit Graph

288 Commits

Author SHA1 Message Date
Marek Polacek ae36f83963 preprocessor: -Wbidi-chars and UCNs [PR104030]
Stephan Bergmann reported that our -Wbidi-chars breaks the build
of LibreOffice because we warn about UCNs even when their usage
is correct: LibreOffice constructs strings piecewise, as in:

  aText = u"\u202D" + aText;

and warning about that is overzealous.  Since no editor (AFAIK)
interprets UCNs to show them as Unicode characters, there's less
risk in misinterpreting them, and so perhaps we shouldn't warn
about them by default.  However, identifiers containing UCNs or
programs generating other programs could still cause confusion,
so I'm keeping the UCN checking.  To turn it on, you just need
to use -Wbidi-chars=unpaired,ucn or -Wbidi-chars=any,ucn.

The implementation is done by using the new EnumSet feature.

	PR preprocessor/104030

gcc/c-family/ChangeLog:

	* c.opt (Wbidi-chars): Mark as EnumSet.  Also accept =ucn.

gcc/ChangeLog:

	* doc/invoke.texi: Update documentation for -Wbidi-chars.

libcpp/ChangeLog:

	* include/cpplib.h (enum cpp_bidirectional_level): Add
	bidirectional_ucn.  Set values explicitly.
	* internal.h (cpp_reader): Adjust warn_bidi_p.
	* lex.cc (maybe_warn_bidi_on_close): Don't warn about UCNs
	unless UCN checking is on.
	(maybe_warn_bidi_on_char): Likewise.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wbidi-chars-10.c: Turn on UCN checking.
	* c-c++-common/Wbidi-chars-11.c: Likewise.
	* c-c++-common/Wbidi-chars-14.c: Likewise.
	* c-c++-common/Wbidi-chars-16.c: Likewise.
	* c-c++-common/Wbidi-chars-17.c: Likewise.
	* c-c++-common/Wbidi-chars-4.c: Likewise.
	* c-c++-common/Wbidi-chars-5.c: Likewise.
	* c-c++-common/Wbidi-chars-6.c: Likewise.
	* c-c++-common/Wbidi-chars-7.c: Likewise.
	* c-c++-common/Wbidi-chars-8.c: Likewise.
	* c-c++-common/Wbidi-chars-9.c: Likewise.
	* c-c++-common/Wbidi-chars-ranges.c: Likewise.
	* c-c++-common/Wbidi-chars-18.c: New test.
	* c-c++-common/Wbidi-chars-19.c: New test.
	* c-c++-common/Wbidi-chars-20.c: New test.
	* c-c++-common/Wbidi-chars-21.c: New test.
	* c-c++-common/Wbidi-chars-22.c: New test.
	* c-c++-common/Wbidi-chars-23.c: New test.
2022-01-24 17:48:23 -05:00
Richard Biener 4288b57aff pack fields in line-map data structures
As pointed out by pahole.

2022-01-18  Richard Biener  <rguenther@suse.de>

libcpp/
	* include/line-map.h (class line_maps): Re-arrange fields
	to minimize padding.
	(class rich_location): Likewise.
	* line-map.cc (rich_location::rich_location): Adjust.
2022-01-18 14:33:01 +01:00
Martin Liska e53b6e564a Change references of .c files to .cc files
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.
2022-01-17 22:12:07 +01:00
Clément Chigot 14e0d83297 aix: handle 64bit inodes for include directories
On AIX, stat will store inodes in 32bit even when using LARGE_FILES.
If the inode is larger, it will return -1 in st_ino.
Thus, in incpath.c when comparing include directories, if several
of them have 64bit inodes, they will be considered as duplicated.

gcc/ChangeLog:
2022-01-12  Clément Chigot  <clement.chigot@atos.net>

	* configure.ac: Check sizeof ino_t and dev_t.
	(HOST_STAT_FOR_64BIT_INODES): New AC_DEFINE to provide stat
	syscall being able to handle 64bit inodes.
	* config.in: Regenerate.
	* configure: Regenerate.
	* incpath.c (HOST_STAT_FOR_64BIT_INODES): New define.
	(remove_duplicates): Use it.

libcpp/ChangeLog:
2022-01-12  Clément Chigot  <clement.chigot@atos.net>

	* configure.ac: Check sizeof ino_t and dev_t.
	* config.in: Regenerate.
	* configure: Regenerate.
	* include/cpplib.h (INO_T_CPP): Change for AIX.
	(DEV_T_CPP): New macro.
	(struct cpp_dir): Use it.
2022-01-12 16:59:47 +01:00
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jakub Jelinek fe7c3ecff1 pch: Add support for PCH for relocatable executables [PR71934]
So, if we want to make PCH work for PIEs, I'd say we can:
1) add a new GTY option, say callback, which would act like
   skip for non-PCH and for PCH would make us skip it but
   remember for address bias translation
2) drop the skip for tree_translation_unit_decl::language
3) change get_unnamed_section to have const char * as
   last argument instead of const void *, change
   unnamed_section::data also to const char * and update
   everything related to that
4) maybe add a host hook whether it is ok to support binaries
   changing addresses (the only thing I'm worried is if
   some host that uses function descriptors allocates them
   dynamically instead of having them somewhere in the
   executable)
5) maybe add a gengtype warning if it sees in GTY tracked
   structure a function pointer without that new callback
   option

Here is 1), 2), 3) implemented.

Note, on stdc++.h.gch/O2g.gch there are just those 10 relocations without
the second patch, with it a few more, but nothing huge.  And for non-PIEs
there isn't really any extra work on the load side except freading two scalar
values and fseek.

2021-12-03  Jakub Jelinek  <jakub@redhat.com>

	PR pch/71934
gcc/
	* ggc.h (gt_pch_note_callback): Declare.
	* gengtype.h (enum typekind): Add TYPE_CALLBACK.
	(callback_type): Declare.
	* gengtype.c (dbgprint_count_type_at): Handle TYPE_CALLBACK.
	(callback_type): New variable.
	(process_gc_options): Add CALLBACK argument, handle callback
	option.
	(set_gc_used_type): Adjust process_gc_options caller, if callback,
	set type to &callback_type.
	(output_mangled_typename): Handle TYPE_CALLBACK.
	(walk_type): Likewise.  Handle callback option.
	(write_types_process_field): Handle TYPE_CALLBACK.
	(write_types_local_user_process_field): Likewise.
	(write_types_local_process_field): Likewise.
	(write_root): Likewise.
	(dump_typekind): Likewise.
	(dump_type): Likewise.
	* gengtype-state.c (type_lineloc): Handle TYPE_CALLBACK.
	(state_writer::write_state_callback_type): New method.
	(state_writer::write_state_type): Handle TYPE_CALLBACK.
	(read_state_callback_type): New function.
	(read_state_type): Handle TYPE_CALLBACK.
	* ggc-common.c (callback_vec): New variable.
	(gt_pch_note_callback): New function.
	(gt_pch_save): Stream out gt_pch_save function address and relocation
	table.
	(gt_pch_restore): Stream in saved gt_pch_save function address and
	relocation table and apply relocations if needed.
	* doc/gty.texi (callback): Document new GTY option.
	* varasm.c (get_unnamed_section): Change callback argument's type and
	last argument's type from const void * to const char *.
	(output_section_asm_op): Change argument's type from const void *
	to const char *, remove unnecessary cast.
	* tree-core.h (struct tree_translation_unit_decl): Drop GTY((skip))
	from language member.
	* output.h (unnamed_section_callback): Change argument type from
	const void * to const char *.
	(struct unnamed_section): Use GTY((callback)) instead of GTY((skip))
	for callback member.  Change data member type from const void *
	to const char *.
	(struct noswitch_section): Use GTY((callback)) instead of GTY((skip))
	for callback member.
	(get_unnamed_section): Change callback argument's type and
	last argument's type from const void * to const char *.
	(output_section_asm_op): Change argument's type from const void *
	to const char *.
	* config/avr/avr.c (avr_output_progmem_section_asm_op): Likewise.
	Remove unneeded cast.
	* config/darwin.c (output_objc_section_asm_op): Change argument's type
	from const void * to const char *.
	* config/pa/pa.c (som_output_text_section_asm_op): Likewise.
	(som_output_comdat_data_section_asm_op): Likewise.
	* config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op):
	Likewise.
	(rs6000_xcoff_output_readonly_section_asm_op): Likewise.  Instead
	of dereferencing directive hardcode variable names and decide based on
	whether directive is NULL or not.
	(rs6000_xcoff_output_readwrite_section_asm_op): Change argument's type
	from const void * to const char *.
	(rs6000_xcoff_output_tls_section_asm_op): Likewise.  Instead
	of dereferencing directive hardcode variable names and decide based on
	whether directive is NULL or not.
	(rs6000_xcoff_output_toc_section_asm_op): Change argument's type
	from const void * to const char *.
	(rs6000_xcoff_asm_init_sections): Adjust get_unnamed_section callers.
gcc/c-family/
	* c-pch.c (struct c_pch_validity): Remove pch_init member.
	(pch_init): Don't initialize v.pch_init.
	(c_common_valid_pch): Don't warn and punt if .text addresses change.
libcpp/
	* include/line-map.h (class line_maps): Add GTY((callback)) to
	reallocator and round_alloc_size members.
2021-12-03 11:03:30 +01:00
Jakub Jelinek c264208e16 libcpp: Enable P1949R7 for C++98 too [PR100977]
On Mon, Nov 29, 2021 at 05:53:58PM -0500, Jason Merrill wrote:
> I'm inclined to go ahead and change C++98 as well; I doubt anyone is relying
> on the particular C++98 extended character set rules, and we already accept
> the union of the different sets when not pedantic.

Ok, here is an incremental patch to do that also for -std={c,gnu}++98.

2021-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/100977
	* init.c (struct lang_flags): Remove cxx23_identifiers.
	(lang_defaults): Remove cxx23_identifiers initializers.
	(cpp_set_lang): Don't copy cxx23_identifiers.
	* include/cpplib.h (struct cpp_options): Adjust comment about
	c11_identifiers.  Remove cxx23_identifiers field.
	* lex.c (warn_about_normalization): Use cplusplus instead of
	cxx23_identifiers.
	* charset.c (ucn_valid_in_identifier): Likewise.

	* g++.dg/cpp/ucnid-1.C: Adjust expected diagnostics.
	* g++.dg/cpp/ucnid-1-utf8.C: Likewise.
2021-12-01 10:21:20 +01:00
Marek Polacek 51c500269b libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]
From a link below:
"An issue was discovered in the Bidirectional Algorithm in the Unicode
Specification through 14.0. It permits the visual reordering of
characters via control sequences, which can be used to craft source code
that renders different logic than the logical ordering of tokens
ingested by compilers and interpreters. Adversaries can leverage this to
encode source code for compilers accepting Unicode such that targeted
vulnerabilities are introduced invisibly to human reviewers."

More info:
https://nvd.nist.gov/vuln/detail/CVE-2021-42574
https://trojansource.codes/

This is not a compiler bug.  However, to mitigate the problem, this patch
implements -Wbidi-chars=[none|unpaired|any] to warn about possibly
misleading Unicode bidirectional control characters the preprocessor may
encounter.

The default is =unpaired, which warns about improperly terminated
bidirectional control characters; e.g. a LRE without its corresponding PDF.
The level =any warns about any use of bidirectional control characters.

This patch handles both UCNs and UTF-8 characters.  UCNs designating
bidi characters in identifiers are accepted since r204886.  Then r217144
enabled -fextended-identifiers by default.  Extended characters in C/C++
identifiers have been accepted since r275979.  However, this patch still
warns about mixing UTF-8 and UCN bidi characters; there seems to be no
good reason to allow mixing them.

We warn in different contexts: comments (both C and C++-style), string
literals, character constants, and identifiers.  Expectedly, UCNs are ignored
in comments and raw string literals.  The bidirectional control characters
can nest so this patch handles that as well.

I have not included nor tested this at all with Fortran (which also has
string literals and line comments).

Dave M. posted patches improving diagnostic involving Unicode characters.
This patch does not make use of this new infrastructure yet.

	PR preprocessor/103026

gcc/c-family/ChangeLog:

	* c.opt (Wbidi-chars, Wbidi-chars=): New option.

gcc/ChangeLog:

	* doc/invoke.texi: Document -Wbidi-chars.

libcpp/ChangeLog:

	* include/cpplib.h (enum cpp_bidirectional_level): New.
	(struct cpp_options): Add cpp_warn_bidirectional.
	(enum cpp_warning_reason): Add CPP_W_BIDIRECTIONAL.
	* internal.h (struct cpp_reader): Add warn_bidi_p member
	function.
	* init.c (cpp_create_reader): Set cpp_warn_bidirectional.
	* lex.c (bidi): New namespace.
	(get_bidi_utf8): New function.
	(get_bidi_ucn): Likewise.
	(maybe_warn_bidi_on_close): Likewise.
	(maybe_warn_bidi_on_char): Likewise.
	(_cpp_skip_block_comment): Implement warning about bidirectional
	control characters.
	(skip_line_comment): Likewise.
	(forms_identifier_p): Likewise.
	(lex_identifier): Likewise.
	(lex_string): Likewise.
	(lex_raw_string): Likewise.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wbidi-chars-1.c: New test.
	* c-c++-common/Wbidi-chars-2.c: New test.
	* c-c++-common/Wbidi-chars-3.c: New test.
	* c-c++-common/Wbidi-chars-4.c: New test.
	* c-c++-common/Wbidi-chars-5.c: New test.
	* c-c++-common/Wbidi-chars-6.c: New test.
	* c-c++-common/Wbidi-chars-7.c: New test.
	* c-c++-common/Wbidi-chars-8.c: New test.
	* c-c++-common/Wbidi-chars-9.c: New test.
	* c-c++-common/Wbidi-chars-10.c: New test.
	* c-c++-common/Wbidi-chars-11.c: New test.
	* c-c++-common/Wbidi-chars-12.c: New test.
	* c-c++-common/Wbidi-chars-13.c: New test.
	* c-c++-common/Wbidi-chars-14.c: New test.
	* c-c++-common/Wbidi-chars-15.c: New test.
	* c-c++-common/Wbidi-chars-16.c: New test.
	* c-c++-common/Wbidi-chars-17.c: New test.
2021-11-16 21:56:16 -05:00
David Malcolm bd5e882cf6 diagnostics: escape non-ASCII source bytes for certain diagnostics
This patch adds support to GCC's diagnostic subsystem for escaping certain
bytes and Unicode characters when quoting source code.

Specifically, this patch adds a new flag rich_location::m_escape_on_output
which is a hint from a diagnostic that non-ASCII bytes in the pertinent
lines of the user's source code should be escaped when printed.

The patch sets this for the following diagnostics:
- when complaining about stray bytes in the program (when these
are non-printable)
- when complaining about "null character(s) ignored");
- for -Wnormalized= (and generate source ranges for such warnings)

The escaping is controlled by a new option:
  -fdiagnostics-escape-format=[unicode|bytes]

For example, consider a diagnostic involing a source line containing the
string "before" followed by the Unicode character U+03C0 ("GREEK SMALL
LETTER PI", with UTF-8 encoding 0xCF 0x80) followed by the byte 0xBF
(a stray UTF-8 trailing byte), followed by the string "after", where the
diagnostic highlights the U+03C0 character.

By default, this line will be printed verbatim to the user when
reporting a diagnostic at it, as:

 beforeπXafter
       ^

(using X for the stray byte to avoid putting invalid UTF-8 in this
commit message)

If the diagnostic sets the "escape" flag, it will be printed as:

 before<U+03C0><BF>after
       ^~~~~~~~

with -fdiagnostics-escape-format=unicode (the default), or as:

  before<CF><80><BF>after
        ^~~~~~~~

if the user supplies -fdiagnostics-escape-format=bytes.

This only affects how the source is printed; it does not affect
how column numbers that are printed (as per -fdiagnostics-column-unit=
and -fdiagnostics-column-origin=).

gcc/c-family/ChangeLog:
	* c-lex.c (c_lex_with_flags): When complaining about non-printable
	CPP_OTHER tokens, set the "escape on output" flag.

gcc/ChangeLog:
	* common.opt (fdiagnostics-escape-format=): New.
	(diagnostics_escape_format): New enum.
	(DIAGNOSTICS_ESCAPE_FORMAT_UNICODE): New enum value.
	(DIAGNOSTICS_ESCAPE_FORMAT_BYTES): Likewise.
	* diagnostic-format-json.cc (json_end_diagnostic): Add
	"escape-source" attribute.
	* diagnostic-show-locus.c
	(exploc_with_display_col::exploc_with_display_col): Replace
	"tabstop" param with a cpp_char_column_policy and add an "aspect"
	param.  Use these to compute m_display_col accordingly.
	(struct char_display_policy): New struct.
	(layout::m_policy): New field.
	(layout::m_escape_on_output): New field.
	(def_policy): New function.
	(make_range): Update for changes to exploc_with_display_col ctor.
	(default_print_decoded_ch): New.
	(width_per_escaped_byte): New.
	(escape_as_bytes_width): New.
	(escape_as_bytes_print): New.
	(escape_as_unicode_width): New.
	(escape_as_unicode_print): New.
	(make_policy): New.
	(layout::layout): Initialize new fields.  Update m_exploc ctor
	call for above change to ctor.
	(layout::maybe_add_location_range): Update for changes to
	exploc_with_display_col ctor.
	(layout::calculate_x_offset_display): Update for change to
	cpp_display_width.
	(layout::print_source_line): Pass policy
	to cpp_display_width_computation. Capture cpp_decoded_char when
	calling process_next_codepoint.  Move printing of source code to
	m_policy.m_print_cb.
	(line_label::line_label): Pass in policy rather than context.
	(layout::print_any_labels): Update for change to line_label ctor.
	(get_affected_range): Pass in policy rather than context, updating
	calls to location_compute_display_column accordingly.
	(get_printed_columns): Likewise, also for cpp_display_width.
	(correction::correction): Pass in policy rather than tabstop.
	(correction::compute_display_cols): Pass m_policy rather than
	m_tabstop to cpp_display_width.
	(correction::m_tabstop): Replace with...
	(correction::m_policy): ...this.
	(line_corrections::line_corrections): Pass in policy rather than
	context.
	(line_corrections::m_context): Replace with...
	(line_corrections::m_policy): ...this.
	(line_corrections::add_hint): Update to use m_policy rather than
	m_context.
	(line_corrections::add_hint): Likewise.
	(layout::print_trailing_fixits): Likewise.
	(selftest::test_display_widths): New.
	(selftest::test_layout_x_offset_display_utf8): Update to use
	policy rather than tabstop.
	(selftest::test_one_liner_labels_utf8): Add test of escaping
	source lines.
	(selftest::test_diagnostic_show_locus_one_liner_utf8): Update to
	use policy rather than tabstop.
	(selftest::test_overlapped_fixit_printing): Likewise.
	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
	(selftest::test_overlapped_fixit_printing_2): Likewise.
	(selftest::test_tab_expansion): Likewise.
	(selftest::test_escaping_bytes_1): New.
	(selftest::test_escaping_bytes_2): New.
	(selftest::diagnostic_show_locus_c_tests): Call the new tests.
	* diagnostic.c (diagnostic_initialize): Initialize
	context->escape_format.
	(convert_column_unit): Update to use default character width policy.
	(selftest::test_diagnostic_get_location_text): Likewise.
	* diagnostic.h (enum diagnostics_escape_format): New enum.
	(diagnostic_context::escape_format): New field.
	* doc/invoke.texi (-fdiagnostics-escape-format=): New option.
	(-fdiagnostics-format=): Add "escape-source" attribute to examples
	of JSON output, and document it.
	* input.c (location_compute_display_column): Pass in "policy"
	rather than "tabstop", passing to
	cpp_byte_column_to_display_column.
	(selftest::test_cpp_utf8): Update to use cpp_char_column_policy.
	* input.h (class cpp_char_column_policy): New forward decl.
	(location_compute_display_column): Pass in "policy" rather than
	"tabstop".
	* opts.c (common_handle_option): Handle
	OPT_fdiagnostics_escape_format_.
	* selftest.c (temp_source_file::temp_source_file): New ctor
	overload taking a size_t.
	* selftest.h (temp_source_file::temp_source_file): Likewise.

gcc/testsuite/ChangeLog:
	* c-c++-common/diagnostic-format-json-1.c: Add regexp to consume
	"escape-source" attribute.
	* c-c++-common/diagnostic-format-json-2.c: Likewise.
	* c-c++-common/diagnostic-format-json-3.c: Likewise.
	* c-c++-common/diagnostic-format-json-4.c: Likewise, twice.
	* c-c++-common/diagnostic-format-json-5.c: Likewise.
	* gcc.dg/cpp/warn-normalized-4-bytes.c: New test.
	* gcc.dg/cpp/warn-normalized-4-unicode.c: New test.
	* gcc.dg/encoding-issues-bytes.c: New test.
	* gcc.dg/encoding-issues-unicode.c: New test.
	* gfortran.dg/diagnostic-format-json-1.F90: Add regexp to consume
	"escape-source" attribute.
	* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
	* gfortran.dg/diagnostic-format-json-3.F90: Likewise.

libcpp/ChangeLog:
	* charset.c (convert_escape): Use encoding_rich_location when
	complaining about nonprintable unknown escape sequences.
	(cpp_display_width_computation::::cpp_display_width_computation):
	Pass in policy rather than tabstop.
	(cpp_display_width_computation::process_next_codepoint): Add "out"
	param and populate *out if non-NULL.
	(cpp_display_width_computation::advance_display_cols): Pass NULL
	to process_next_codepoint.
	(cpp_byte_column_to_display_column): Pass in policy rather than
	tabstop.  Pass NULL to process_next_codepoint.
	(cpp_display_column_to_byte_column): Pass in policy rather than
	tabstop.
	* errors.c (cpp_diagnostic_get_current_location): New function,
	splitting out the logic from...
	(cpp_diagnostic): ...here.
	(cpp_warning_at): New function.
	(cpp_pedwarning_at): New function.
	* include/cpplib.h (cpp_warning_at): New decl for rich_location.
	(cpp_pedwarning_at): Likewise.
	(struct cpp_decoded_char): New.
	(struct cpp_char_column_policy): New.
	(cpp_display_width_computation::cpp_display_width_computation):
	Replace "tabstop" param with "policy".
	(cpp_display_width_computation::process_next_codepoint): Add "out"
	param.
	(cpp_display_width_computation::m_tabstop): Replace with...
	(cpp_display_width_computation::m_policy): ...this.
	(cpp_byte_column_to_display_column): Replace "tabstop" param with
	"policy".
	(cpp_display_width): Likewise.
	(cpp_display_column_to_byte_column): Likewise.
	* include/line-map.h (rich_location::escape_on_output_p): New.
	(rich_location::set_escape_on_output): New.
	(rich_location::m_escape_on_output): New.
	* internal.h (cpp_diagnostic_get_current_location): New decl.
	(class encoding_rich_location): New.
	* lex.c (skip_whitespace): Use encoding_rich_location when
	complaining about null characters.
	(warn_about_normalization): Generate a source range when
	complaining about improperly normalized tokens, rather than just a
	point, and use encoding_rich_location so that the source code
	is escaped on printing.
	* line-map.c (rich_location::rich_location): Initialize
	m_escape_on_output.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-11-01 09:35:46 -04:00
Tobias Burnus 0078a058a5 libcpp: Fix _Pragma expansion [PR102409]
Both #pragma and _Pragma ended up as CPP_PRAGMA. Presumably since
r131819 (2008, GCC 4.3) for PR34692, pragmas are not expanded in
macro arguments but are output as is before. From the old bug report,
that was to fix usage like
  FOO (
    #pragma GCC diagnostic
  )
However, that change also affected _Pragma such that
  BAR (
    "1";
    _Pragma("omp ..."); )
yielded
  #pragma omp ...
followed by what BAR expanded too, possibly including '"1";'.

This commit adds a flag, PRAGMA_OP, to tokens to make the two
distinguishable - and include again _Pragma in the expanded arguments.

libcpp/ChangeLog:

	PR c++/102409
	* directives.c (destringize_and_run): Add PRAGMA_OP to the
	CPP_PRAGMA token's flags to mark is as coming from _Pragma.
	* include/cpplib.h (PRAGMA_OP): #define, to be used with token flags.
	* macro.c (collect_args): Only handle CPP_PRAGMA special if PRAGMA_OP
	is set.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/pragma-1.c: New test.
	* c-c++-common/gomp/pragma-2.c: New test.
2021-10-29 22:55:32 +02:00
Jakub Jelinek c4d6dcacfc libcpp: Implement C++23 P1949R7 - C++ Identifier Syntax using Unicode Standard Annex 31
The following patch implements the
P1949R7 - C++ Identifier Syntax using Unicode Standard Annex 31
paper.  We already allow UTF-8 characters in the source, so that part
is already implemented, so IMHO all we need to do is pedwarn instead of
just warn for the (default) -Wnormalize=nfc (or for -Wnormalize={id,nkfc})
if the character is not in NFC and to use the unicode XID_Start and
XID_Continue derived code properties to find out what characters are allowed
(the standard actually adds U+005F to XID_Start, but we are handling the
ASCII compatible characters differently already and they aren't allowed
in UCNs in identifiers).  Instead of hardcoding the large tables
in ucnid.tab, this patch makes makeucnid.c read them from the Unicode
tables (13.0.0 version at this point).

For non-pedantic mode, we accept as 2nd+ char in identifiers a union
of valid characters in all supported modes, but for the 1st char it
was actually pedantically requiring that it is not any of the characters
that may not appear in the currently chosen standard as the first character.
This patch changes it such that also what is allowed at the start of an
identifier is a union of characters valid at the start of an identifier
in any of the pedantic modes.

2021-09-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/100977
libcpp/
	* include/cpplib.h (struct cpp_options): Add cxx23_identifiers.
	* charset.c (CXX23, NXX23): New enumerators.
	(CID, NFC, NKC, CTX): Renumber.
	(ucn_valid_in_identifier): Implement P1949R7 - use CXX23 and
	NXX23 flags for cxx23_identifiers.  For start character in
	non-pedantic mode, allow characters that are allowed as start
	characters in any of the supported language modes, rather than
	disallowing characters allowed only as non-start characters in
	current mode but for characters from other language modes allowing
	them even if they are never allowed at start.
	* init.c (struct lang_flags): Add cxx23_identifiers.
	(lang_defaults): Add cxx23_identifiers column.
	(cpp_set_lang): Initialize CPP_OPTION (pfile, cxx23_identifiers).
	* lex.c (warn_about_normalization): If cxx23_identifiers, use
	cpp_pedwarning_with_line instead of cpp_warning_with_line for
	"is not in NFC" diagnostics.
	* makeucnid.c: Adjust usage comment.
	(CXX23, NXX23): New enumerators.
	(all_languages): Add CXX23.
	(not_NFC, not_NFKC, maybe_not_NFC): Renumber.
	(read_derivedcore): New function.
	(write_table): Print also CXX23 and NXX23 columns.
	(main): Require 5 arguments instead of 4, call read_derivedcore.
	* ucnid.h: Regenerated using Unicode 13.0.0 files.
gcc/testsuite/
	* g++.dg/cpp23/normalize1.C: New test.
	* g++.dg/cpp23/normalize2.C: New test.
	* g++.dg/cpp23/normalize3.C: New test.
	* g++.dg/cpp23/normalize4.C: New test.
	* g++.dg/cpp23/normalize5.C: New test.
	* g++.dg/cpp23/normalize6.C: New test.
	* g++.dg/cpp23/normalize7.C: New test.
	* g++.dg/cpp23/ucnid-1-utf8.C: New test.
	* g++.dg/cpp23/ucnid-2-utf8.C: New test.
	* gcc.dg/cpp/ucnid-4.c: Don't expect
	"not valid at the start of an identifier" errors.
	* gcc.dg/cpp/ucnid-4-utf8.c: Likewise.
	* gcc.dg/cpp/ucnid-5-utf8.c: New test.
2021-09-01 22:33:06 +02:00
Martin Sebor e4d2305adf Disable gcc_rich_location copying and assignment.
gcc/cp/ChangeLog:

	* parser.c (cp_parser_selection_statement): Use direct initialization
	instead of copy.

gcc/ChangeLog:

	* gcc-rich-location.h (gcc_rich_location): Make ctor explicit.

libcpp/ChangeLog:

	* include/line-map.h (class rich_location): Disable copying and
	assignment.
2021-08-31 11:15:21 -06:00
Lewis Hyatt 3ac6b5cff1 diagnostics: Support for -finput-charset [PR93067]
Adds the logic to handle -finput-charset in layout_get_source_line(), so that
source lines are converted from their input encodings prior to being output by
diagnostics machinery. Also adds the ability to strip a UTF-8 BOM similarly.

gcc/c-family/ChangeLog:

	PR other/93067
	* c-opts.c (c_common_input_charset_cb): New function.
	(c_common_post_options): Call new function
	diagnostic_initialize_input_context().

gcc/d/ChangeLog:

	PR other/93067
	* d-lang.cc (d_input_charset_callback): New function.
	(d_init): Call new function
	diagnostic_initialize_input_context().

gcc/fortran/ChangeLog:

	PR other/93067
	* cpp.c (gfc_cpp_post_options): Call new function
	diagnostic_initialize_input_context().

gcc/ChangeLog:

	PR other/93067
	* coretypes.h (typedef diagnostic_input_charset_callback): Declare.
	* diagnostic.c (diagnostic_initialize_input_context): New function.
	* diagnostic.h (diagnostic_initialize_input_context): Declare.
	* input.c (default_charset_callback): New function.
	(file_cache::initialize_input_context): New function.
	(file_cache_slot::create): Added ability to convert the input
	according to the input context.
	(file_cache::file_cache): Initialize the new input context.
	(class file_cache_slot): Added new m_alloc_offset member.
	(file_cache_slot::file_cache_slot): Initialize the new member.
	(file_cache_slot::~file_cache_slot): Handle potentially offset buffer.
	(file_cache_slot::maybe_grow): Likewise.
	(file_cache_slot::needs_read_p): Handle NULL fp, which is now possible.
	(file_cache_slot::get_next_line): Likewise.
	* input.h (class file_cache): Added input context member.

libcpp/ChangeLog:

	PR other/93067
	* charset.c (init_iconv_desc): Adapt to permit PFILE argument to
	be NULL.
	(_cpp_convert_input): Likewise. Also move UTF-8 BOM logic to...
	(cpp_check_utf8_bom): ...here.  New function.
	(cpp_input_conversion_is_trivial): New function.
	* files.c (read_file_guts): Allow PFILE argument to be NULL.  Add
	INPUT_CHARSET argument as an alternate source of this information.
	(read_file): Pass the new argument to read_file_guts.
	(cpp_get_converted_source): New function.
	* include/cpplib.h (struct cpp_converted_source): Declare.
	(cpp_get_converted_source): Declare.
	(cpp_input_conversion_is_trivial): Declare.
	(cpp_check_utf8_bom): Declare.

gcc/testsuite/ChangeLog:

	PR other/93067
	* gcc.dg/diagnostic-input-charset-1.c: New test.
	* gcc.dg/diagnostic-input-utf8-bom.c: New test.
2021-08-25 11:15:28 -04:00
Christophe Lyon 1a9b3f04c1 c: Add support for __FILE_NAME__ macro (PR c/42579)
The toolchain provided by ST for stm32 has had support for
__FILENAME__ for a while, but clang/llvm has recently implemented
support for __FILE_NAME__, so it seems better to use the same macro
name in GCC.

It happens that the ST patch is similar to the one proposed in PR
c/42579.

Given these input files:
::::::::::::::
mydir/myinc.h
::::::::::::::
char* mystringh_file = __FILE__;
char* mystringh_filename = __FILE_NAME__;
char* mystringh_base_file = __BASE_FILE__;
::::::::::::::
mydir/mysrc.c
::::::::::::::

char* mystring_file = __FILE__;
char* mystring_filename = __FILE_NAME__;
char* mystring_base_file = __BASE_FILE__;

we produce:
$ gcc mydir/mysrc.c -I . -E
char* mystringh_file = "./mydir/myinc.h";
char* mystringh_filename = "myinc.h";
char* mystringh_base_file = "mydir/mysrc.c";

char* mystring_file = "mydir/mysrc.c";
char* mystring_filename = "mysrc.c";
char* mystring_base_file = "mydir/mysrc.c";

2021-05-20  Christophe Lyon  <christophe.lyon@linaro.org>
	    Torbjörn Svensson  <torbjorn.svensson@st.com>

	PR c/42579
	libcpp/
	* include/cpplib.h (cpp_builtin_type): Add BT_FILE_NAME entry.
	* init.c (builtin_array): Likewise.
	* macro.c (_cpp_builtin_macro_text): Add support for BT_FILE_NAME.

	gcc/
	* doc/cpp.texi (Common Predefined Macros): Document __FILE_NAME__.

	gcc/testsuite/
	* c-c++-common/spellcheck-reserved.c: Add tests for __FILE_NAME__.
	* c-c++-common/cpp/file-name-1.c: New test.
2021-05-20 08:12:41 +00:00
Joseph Myers 71d38ec800 preprocessor: Support C2X #elifdef, #elifndef
C2X adds #elifdef and #elifndef preprocessor directives; these have
also been proposed for C++.  Implement these directives in libcpp
accordingly.

In this implementation, #elifdef and #elifndef are treated as
non-directives for any language version other than c2x and gnu2x (if
the feature is accepted for C++, it can trivially be enabled for
relevant C++ versions).  In strict conformance modes for prior
language versions, this is required, as illustrated by the
c11-elifdef-1.c test added.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

libcpp/
	* include/cpplib.h (struct cpp_options): Add elifdef.
	* init.c (struct lang_flags): Add elifdef.
	(lang_defaults): Update to include elifdef initializers.
	(cpp_set_lang): Set elifdef for pfile based on language.
	* directives.c (STDC2X, ELIFDEF): New macros.
	(EXTENSION): Increase value to 3.
	(DIRECTIVE_TABLE): Add #elifdef and #elifndef.
	(_cpp_handle_directive): Do not treat ELIFDEF directives as
	directives for language versions without the #elifdef feature.
	(do_elif): Handle #elifdef and #elifndef.
	(do_elifdef, do_elifndef): New functions.

gcc/testsuite/
	* gcc.dg/cpp/c11-elifdef-1.c, gcc.dg/cpp/c2x-elifdef-1.c,
	gcc.dg/cpp/c2x-elifdef-2.c: New tests.
2021-05-11 23:54:01 +00:00
Eric Botcazou 1174314811 Fix thinko in libcpp preparation patch for modules
The problem is that the new IS_MACRO_LOC macro:

inline bool
IS_MACRO_LOC (location_t loc)
{
  return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
}

is not fully correct since the position of the macro lines is not fixed:

/* Returns the lowest location [of a token resulting from macro
   expansion] encoded in this line table.  */
inline location_t
LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set)
{
  return LINEMAPS_MACRO_USED (set)
         ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set))
         : MAX_LOCATION_T + 1;
}

In Ada, LINEMAPS_MACRO_USED is false so LINEMAPS_MACRO_LOWEST_LOCATION is
MAX_LOCATION_T + 1, but IS_MACRO_LOC nevertheless returns true for anything
in the range [LINE_MAP_MAX_LOCATION; MAX_LOCATION_T], thus yielding an ICE
in linemap_macro_map_lookup for very large files.

libcpp/
	* include/line-map.h (IS_MACRO_LOC): Delete.
	* line-map.c (linemap_location_from_macro_expansion_p): Test
	LINEMAPS_MACRO_LOWEST_LOCATION of the linemap.
gcc/cp/
	* module.cc (ordinary_loc_of): Test LINEMAPS_MACRO_LOWEST_LOCATION
	of the linemap.
	(module_state::write_location): Likewise.
2021-04-13 11:57:55 +02:00
Nathan Sidwell f207eed69e c++: Macro location fixes [PR 98718]
This fixes some issues with macro maps.  We were incorrectly
calculating the number of macro expansions in a location span, and I
had a workaround that partially covered that up.  Further, while macro
location spans are monotonic, that is not true of ordinary location
spans.  Thus we need to insert an indirection array when binary
searching the latter. (We load ordinary locations before loading
imports, but macro locations afterwards.  We make sure an import
location is de-macrofied, if needed.)

	PR c++/98718
	gcc/cp/
	* module.cc (ool): New indirection vector.
	(loc_spans::maybe_propagate): Location is not optional.
	(loc_spans::open): Likewise.  Assert monotonically advancing.
	(module_for_ordinary_loc): Use ool indirection vector.
	(module_state::write_prepare_maps): Do not count empty macro
	expansions.  Elide empty spans.
	(module_state::write_macro_maps): Skip empty expansions.
	(ool_cmp): New qsort comparator.
	(module_state::write): Create and destroy ool vector.
	(name_pending_imports): Fix dump push/pop.
	(preprocess_module): Likewise.  Add more dumping.
	(preprocessed_module): Likewise.
	libcpp/
	* include/line-map.h
	* line-map.c
	gcc/testsuite/
	* g++.dg/modules/pr98718_a.C: New.
	* g++.dg/modules/pr98718_b.C: New.
2021-02-24 12:46:09 -08:00
Nathan Sidwell 1f9db6929d c++: header-unit build capability [PR 99023]
This defect really required building header-units and include translation
of pieces of the standard library.  This adds smarts to the modules
test harness to do that -- accept .X files as the source file, but
provide '-x c++-system-header $HDR' in the options.  The .X file will
be considered by the driver to be a linker script and ignored (with a
warning).

Using this we can add 2 tests that end up building list_initializer
and iostream, along with a test that iostream's build
include-translates list_initializer's #include.  That discovered a set
of issues with the -flang-info-include-translate=HDR handling, also
fixed and documented here.

	PR c++/99023
	gcc/cp/
	* module.cc (canonicalize_header_name): Use
	cpp_probe_header_unit.
	(maybe_translate_include): Fix note_includes comparison.
	(init_modules): Fix note_includes string termination.
	libcpp/
	* include/cpplib.h (cpp_find_header_unit): Rename to ...
	(cpp_probe_header_unit): ... this.
	* internal.h (_cp_find_header_unit): Declare.
	* files.c (cpp_find_header_unit): Break apart to ..
	(test_header_unit): ... this, and ...
	(_cpp_find_header_unit): ... and, or and ...
	(cpp_probe_header_unit): ... this.
	* macro.c (cpp_get_token_1): Call _cpp_find_header_unit.
	gcc/
	* doc/invoke.texi (flang-info-include-translate): Document header
	lookup behaviour.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Bail on cross-testing.  Add support
	for .X files.
	* g++.dg/modules/pr99023_a.X: New.
	* g++.dg/modules/pr99023_b.X: New.
2021-02-18 13:22:48 -08:00
Ed Smith-Rowland 1f69e63cfc c++: Implement C++23 P0330 - Literal Suffixes for ptrdiff_t and size_t.
Integer literal suffixes for signed size ('z') and unsigned size
(some permutation od 'zu') are provided as a language addition.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_size_t_suffix.
	* c-lex.c (interpret_integer): Set node type for size literal.

libcpp/ChangeLog:

	* expr.c (interpret_int_suffix): Detect 'z' integer suffix.
	(cpp_classify_number): Compat warning for use of 'z' suffix.
	* include/cpplib.h (struct cpp_options): New flag.
	(enum cpp_warning_reason): New flag.
	(CPP_N_USERDEF): Comment C++0x -> C++11.
	(CPP_N_SIZE_T): New flag for cpp_classify_number.
	* init.c (cpp_set_lang): Initialize new flag.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/udlit-shadow-neg.C: Test for 'z' and 'zu' shadowing.
	* g++.dg/cpp23/feat-cxx2b.C: New test.
	* g++.dg/cpp23/size_t-literals.C: New test.
	* g++.dg/warn/Wsize_t-literals.C: New test.
2021-02-03 12:12:31 -05:00
Paul Fee 78739c2df7 c++: Add support for -std=c++23
Derived from the changes that added C++2a support in 2017.
r8-3237-g026a79f70cf33f836ea5275eda72d4870a3041e5

No C++23 features are added here.
Use of -std=c++23 sets __cplusplus to 202100L.

$ g++ -std=c++23 -dM -E -x c++ - < /dev/null | grep cplusplus
 #define __cplusplus 202100L

gcc/
	* doc/cpp.texi (__cplusplus): Document value for -std=c++23
	or -std=gnu++23.
	* doc/invoke.texi: Document -std=c++23 and -std=gnu++23.
	* dwarf2out.c (highest_c_language): Recognise C++20 and C++23.
	(gen_compile_unit_die): Recognise C++23.

gcc/c-family/
	* c-common.h (cxx_dialect): Add cxx23 as a dialect.
	* c.opt: Add options for -std=c++23, std=c++2b, -std=gnu++23
	and -std=gnu++2b
	* c-opts.c (set_std_cxx23): New.
	(c_common_handle_option): Set options when -std=c++23 is enabled.
	(c_common_post_options): Adjust comments.
	(set_std_cxx20): Likewise.

gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_c++2a):
	Check for C++2a or C++23.
	(check_effective_target_c++20_down): New.
	(check_effective_target_c++23_only): New.
	(check_effective_target_c++23): New.
	* g++.dg/cpp23/cplusplus.C: New.

libcpp/
	* include/cpplib.h (c_lang): Add CXX23 and GNUCXX23.
	* init.c (lang_defaults): Add rows for CXX23 and GNUCXX23.
	(cpp_init_builtins): Set __cplusplus to 202100L for C++23.
2021-01-26 17:11:34 -05:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Nathan Sidwell 62c5ea5228 preprocessor: Deferred macro support
For deferred macros we also need a new field on the macro itself, so
that the module machinery can determine the macro was imported.  Also
the documentation for the hashnode's deferred field was incomplete.

	libcpp/
	* include/cpplib.h (struct cpp_macro): Add imported_p field.
	(struct cpp_hashnode): Tweak deferred field documentation.
	* macro.c (_cpp_new_macro): Clear new field.
	(cpp_get_deferred_macro, get_deferred_or_lazy_macro): Assert
	more.
2020-12-14 07:23:59 -08:00
JeanHeyd Meneide eccec86841 Feature: Macros for identifying the wide and narrow execution string literal encoding
gcc/c-family
	* c-cppbuiltin.c (c_cpp_builtins): Add predefined
	{__GNUC_EXECUTION_CHARSET_NAME} and
	_WIDE_EXECUTION_CHARSET_NAME} macros.

gcc/
	* doc/cpp.texi: Document new macros.

gcc/testsuite/
	* c-c++-common/cpp/wide-narrow-predef-macros.c: New test.

libcpp/
	* charset.c (init_iconv_desc): Initialize "to" and "from" fields.
	* directives.c (cpp_get_narrow_charset_name): New function.
	(cpp_get_wide_charset_name): Likewise.
	* include/cpplib.h (cpp_get_narrow_charset_name): Prototype.
	(cpp_get_wide_charset_name): Likewise.
	* internal.h (cset_converter): Add "to" and "from" fields.
2020-12-01 14:46:51 -07:00
Nathan Sidwell 13f93cf533 preprocessor: Add deferred macros
Deferred macros are needed for C++ modules.  Header units may export
macro definitions and undefinitions.  These are resolved lazily at the
point of (potential) use.  (The language specifies that, it's not just
a useful optimization.)  Thus, identifier nodes grow a 'deferred'
field, which fortunately doesn't expand the structure on 64-bit
systems as there was padding there.  This is non-zero on NT_MACRO
nodes, if the macro is deferred.  When such an identifier is lexed, it
is resolved via a callback that I added recently.  That will either
provide the macro definition, or discover it there was an overriding
undef.  Either way the identifier is no longer a deferred macro.
Notice it is now possible for NT_MACRO nodes to have a NULL macro
expansion.

	libcpp/
	* include/cpplib.h (struct cpp_hashnode): Add deferred field.
	(cpp_set_deferred_macro): Define.
	(cpp_get_deferred_macro): Declare.
	(cpp_macro_definition): Reformat, add overload.
	(cpp_macro_definition_location): Deal with deferred macro.
	(cpp_alloc_token_string, cpp_compare_macro): Declare.
	* internal.h (_cpp_notify_macro_use): Return bool
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (do_undef): Check macro is not undef before
	warning.
	(do_ifdef, do_ifndef): Deal with deferred macro.
	* expr.c (parse_defined): Likewise.
	* lex.c (cpp_allocate_token_string): Break out of ...
	(create_literal): ... here.  Call it.
	(cpp_maybe_module_directive): Deal with deferred macro.
	* macro.c (cpp_get_token_1): Deal with deferred macro.
	(warn_of_redefinition): Deal with deferred macro.
	(compare_macros): Rename to ...
	(cpp_compare_macro): ... here.  Make extern.
	(cpp_get_deferred_macro): New.
	(_cpp_notify_macro_use): Deal with deferred macro, return bool
	indicating definedness.
	(cpp_macro_definition): Deal with deferred macro.
2020-11-24 08:31:03 -08:00
Nathan Sidwell 9844497a93 preprocessor: main file searching
This adds the capability to locate the main file on the user or system
include paths.  That's extremely useful to users building header
units.  Searching has to be requiested (plain header-unit compilation
will not search).  Also, to make include_next work as expected when
building a header unit, we add a mechanism to retrofit a non-searched
source file as one on the include path.

	libcpp/
	* include/cpplib.h (enum cpp_main_search): New.
	(struct cpp_options): Add main_search field.
	(cpp_main_loc): Declare.
	(cpp_retrofit_as_include): Declare.
	* internal.h (struct cpp_reader): Add main_loc field.
	(_cpp_in_main_source_file): Not main if main is a header.
	* init.c (cpp_read_main_file): Use main_search option to locate
	main file.  Set main_loc
	* files.c (cpp_retrofit_as_include): New.
2020-11-19 07:05:08 -08:00
Nathan Sidwell c9c3d5f28a preprocessor: C++ module-directives
C++20 modules introduces a new kind of preprocessor directive -- a
module directive.  These are directives but without the leading '#'.
We have to detect them by sniffing the start of a logical line.  When
detected we replace the initial identifiers with unspellable tokens
and pass them through to the language parser the same way deferred
pragmas are.  There's a PRAGMA_EOL at the logical end of line too.

One additional complication is that we have to do header-name lexing
after the initial tokens, and that requires changes in the macro-aware
piece of the preprocessor.  The above sniffer sets a counter in the
lexer state, and that triggers at the appropriate point.  We then do
the same header-name lexing that occurs on a #include directive or
has_include pseudo-macro.  Except that the header name ends up in the
token stream.

A couple of token emitters need to deal with the new token possibility.

	gcc/c-family/
	* c-lex.c (c_lex_with_flags): CPP_HEADER_NAMEs can now be seen.
	libcpp/
	* include/cpplib.h (struct cpp_options): Add module_directives
	option.
	(NODE_MODULE): New node flag.
	(struct cpp_hashnode): Make rid-code a bitfield, increase bits in
	flags and swap with type field.
	* init.c (post_options): Create module-directive identifier nodes.
	* internal.h (struct lexer_state): Add directive_file_token &
	n_modules fields.  Add module node enumerator.
	* lex.c (cpp_maybe_module_directive): New.
	(_cpp_lex_token): Call it.
	(cpp_output_token): Add '"' around CPP_HEADER_NAME token.
	(do_peek_ident, do_peek_module): New.
	(cpp_directives_only): Detect module-directive lines.
	* macro.c (cpp_get_token_1): Deal with directive_file_token
	triggering.
2020-11-18 10:24:12 -08:00
Nathan Sidwell 7ceb899e93 preprocessor: Add support for header unit translation
libcpp/
	* files.c (struct _cpp_file): Add header_unit field.
	(_cpp_stack_file): Add header unit support.
	(cpp_find_header_unit): New.
	* include/cpplib.h (cpp_find_header_unit): Declare.
2020-11-18 08:45:46 -08:00
Nathan Sidwell db87f19ae3 preprocessor: Update mkdeps for modules
This is slightly different to the original patch I posted.  This adds
separate module target and dependency functions (rather than a single
bi-modal function).

	libcpp/
	* include/cpplib.h (struct cpp_options): Add modules to
	dep-options.
	* include/mkdeps.h (deps_add_module_target): Declare.
	(deps_add_module_dep): Declare.
	* mkdeps.c (class mkdeps): Add modules, module_name, cmi_name,
	is_header_unit fields.  Adjust cdtors.
	(deps_add_module_target, deps_add_module_dep): New.
	(make_write): Write module dependencies, if enabled.
2020-11-18 08:44:49 -08:00
Nathan Sidwell b196e76aec preprocessor: new callbacks
These two callbacks are needed for C++ modules.  The first is for
handling macros from header-units.  These are resolved lazily.  The
second is for include-translation -- whether a #include gets turned
into a header-unit import.

	libcpp/
	* include/cpplib.h (struct cpp_callbacks): Add
	user_deferred_macro & translate_include.
2020-11-17 08:22:02 -08:00
Nathan Sidwell 1f8ac75991 preprocessor: module line maps
This patch adds LC_MODULE as a map kind, used to indicate a c++
module.  Unlike a regular source file, it only contains a single
location, and the source locations in that module are represented by
ordinary locations whose 'included_from' location is the module.

It also exposes some entry points that modules will use to create
blocks of line maps.

In the original posting, I'd missed the deletion of the
linemap_enter_macro from internal.h.  That's included here.

	libcpp/
	* include/line-map.h (enum lc_reason): Add LC_MODULE.
	(MAP_MODULE_P): New.
	(line_map_new_raw): Declare.
	(linemap_enter_macro): Move declaration from internal.h
	(linemap_module_loc, linemap_module_reparent)
	(linemap_module_restore): Declare.
	(linemap_lookup_macro_indec): Declare.
	* internal.h (linemap_enter_macro): Moved to line-map.h.
	* line-map.c (linemap_new_raw): New, broken out of ...
	(new_linemap): ... here.  Call it.
	(LAST_SOURCE_LINE_LOCATION): New.
	(liemap_module_loc, linemap_module_reparent)
	(linemap_module_restore): New.
	(linemap_lookup_macro_index): New, broken out of ...
	(linemap_macro_map_lookup): ... here.  Call it.
	(linemap_dump): Add module dump.
2020-11-17 08:10:56 -08:00
Piotr H. Dabrowski 6f1ae1ecd3 Do not warn about unused macros while processing #pragma GCC optimize
libcpp

	PR c++/91318
	* include/cpplib.h: Added cpp_define_unused(), cpp_define_formatted_unused()
	* directives.c: Likewise.

gcc/c-family

	PR c++/91318
	* c-cppbuiltin.c: c_cpp_builtins_optimize_pragma(): use cpp_define_unused()
2020-11-13 12:28:33 -05:00
Joseph Myers 1d00f8c863 c: C2x __has_c_attribute
C2x adds the __has_c_attribute preprocessor operator, similar to C++
__has_cpp_attribute.

GCC implements __has_cpp_attribute as exactly equivalent to
__has_attribute.  (The documentation says they differ regarding the
values returned for standard attributes, but that's actually only a
matter of the particular nonzero value returned not being specified in
the documentation for __has_attribute; the implementation makes no
distinction between the two.)

I don't think having them exactly equivalent is actually correct,
either for __has_cpp_attribute or for __has_c_attribute.
Specifically, I think it is only correct for __has_cpp_attribute or
__has_c_attribute to return nonzero if the given attribute is
supported, with the particular pp-tokens passed to __has_cpp_attribute
or __has_c_attribute, with [[]] syntax, not if it's only accepted in
__attribute__ or with gnu:: added in [[]].  For example, they should
return nonzero for gnu::packed, but zero for plain packed, because
[[gnu::packed]] is accepted but [[packed]] is ignored as not a
standard attribute.

This patch implements that for __has_c_attribute, leaving any changes
to __has_cpp_attribute for the C++ maintainers.  A new
BT_HAS_STD_ATTRIBUTE is added for __has_c_attribute (which I think,
based on the above, would actually be correct to use for
__has_cpp_attribute as well).  The code in c_common_has_attribute that
deals with scopes has its C++ conditional removed; instead, whether
the language is C or C++ is used only to determine the numeric values
returned for standard attributes (and which standard attributes are
handled there at all).  A new argument is passed to
c_common_has_attribute to distinguish BT_HAS_STD_ATTRIBUTE from
BT_HAS_ATTRIBUTE, and that argument is used to stop attributes with no
scope specified from being accepted with __has_c_attribute unless they
are one of the known standard attributes and so handled specially.

Although the standard specify constants ending with 'L' as the values
for the standard attributes, there is no correctness issue with the
lack of code in GCC to add that 'L' to the expansion:
__has_c_attribute and __has_cpp_attribute are expanded in #if after
other macro expansion has occurred, with no semantics being specified
if they occur outside #if, so there is no way for a conforming program
to inspect the exact text of the expansion of those macros, only to
use the resulting pp-number in a #if expression, where long and int
have the same set of values.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* doc/cpp.texi (__has_attribute): Document when scopes are allowed
	for C.
	(__has_c_attribute): New.

gcc/c-family/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* c-lex.c (c_common_has_attribute): Take argument std_syntax.
	Allow scope for C.  Handle standard attributes for C.  Do not
	accept unscoped attributes if std_syntax and not handled as
	standard attributes.
	* c-common.h (c_common_has_attribute): Update prototype.

gcc/testsuite/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/c2x-has-c-attribute-1.c, gcc.dg/c2x-has-c-attribute-2.c,
	gcc.dg/c2x-has-c-attribute-3.c, gcc.dg/c2x-has-c-attribute-4.c:
	New tests.

libcpp/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* include/cpplib.h (struct cpp_callbacks): Add bool argument to
	has_attribute.
	(enum cpp_builtin_type): Add BT_HAS_STD_ATTRIBUTE.
	* init.c (builtin_array): Add __has_c_attribute.
	(cpp_init_special_builtins): Handle BT_HAS_STD_ATTRIBUTE.
	* macro.c (_cpp_builtin_macro_text): Handle BT_HAS_STD_ATTRIBUTE.
	Update call to has_attribute for BT_HAS_ATTRIBUTE.
	* traditional.c (fun_like_macro): Handle BT_HAS_STD_ATTRIBUTE.
2020-11-12 21:13:51 +00:00
Nathan Sidwell 4b5f564a5d libcpp: Provide date routine
Joseph pointed me at cb_get_source_date_epoch, which allows repeatable
builds and solves a FIXME I had on the modules branch.  Unfortunately
it's used exclusively to generate __DATE__ and __TIME__ values, which
fallback to using a time(2) call.  It'd be nicer if the preprocessor
made whatever time value it determined available to the rest of the
compiler.  So this patch adds a new cpp_get_date function, which
abstracts the call to the get_source_date_epoch hook, or uses time
directly.  The value is cached.  Thus the timestamp I end up putting
on CMI files matches __DATE__ and __TIME__ expansions.  That seems
worthwhile.

	libcpp/
	* include/cpplib.h (enum class CPP_time_kind): New.
	(cpp_get_date): Declare.
	* internal.h (struct cpp_reader): Replace source_date_epoch with
	time_stamp and time_stamp_kind.
	* init.c (cpp_create_reader): Initialize them.
	* macro.c (_cpp_builtin_macro_text): Use cpp_get_date.
	(cpp_get_date): Broken out from _cpp_builtin_macro_text and
	genericized.
2020-11-06 08:59:20 -08:00
Nathan Sidwell 918e8b10a7 libcpp: dependency emission tidying
This patch cleans up the interface to the dependency generation a
little.  We now only check the option in one place, and the
cpp_get_deps function returns nullptr if there are no dependencies.  I
also reworded the -MT and -MQ help text to be make agnostic -- as
there are ideas about emitting, say, JSON.

	libcpp/
	* include/mkdeps.h: Include cpplib.h
	(deps_write): Adjust first parm type.
	* mkdeps.c: Include internal.h
	(make_write): Adjust first parm type.  Check phony option
	directly.
	(deps_write): Adjust first parm type.
	* init.c (cpp_read_main_file): Use get_deps.
	* directives.c (cpp_get_deps): Check option before initializing.
	gcc/c-family/
	* c.opt (MQ,MT): Reword description to be make-agnostic.
	gcc/fortran/
	* cpp.c (gfc_cpp_add_dep): Only add dependency if we're recording
	them.
	(gfc_cpp_init): Likewise for target.
2020-11-03 05:16:19 -08:00
Patrick Palka 4839de55e2 c-family: Macro support in -Wmisleading-indentation [PR80076]
Currently the -Wmisleading-indentation warning doesn't do any analysis
when the guarded statement or the statement after it is produced by a
macro.  This means we warn for:

  if (flag)
    foo ();
    bar ();

but not for:

  #define BAR bar
  if (flag)
    foo ();
    BAR ();

This patch extends the -Wmisleading-indentation implementation to
support analyzing such statements and their tokens.  This is done in the
"natural" way by resolving the location of each of the three tokens to
the token's macro expansion point.  (Additionally, if the tokens all
resolve to the same macro expansion point then we instead use their
locations within the macro definition.)  When these resolved locations
are all different, then we can proceed with applying the warning
heuristics to them as if no macros were involved.

gcc/c-family/ChangeLog:

	PR c/80076
	* c-indentation.c (should_warn_for_misleading_indentation): Move
	declarations of local variables closer to their first use.
	Handle virtual token locations by resolving them to their
	respective macro expansion points.  If all three tokens are
	produced from the same macro expansion, then instead use their
	loci within the macro definition.

gcc/objc/ChangeLog:

	PR c/80076
	* objc-gnu-runtime-abi-01.c
	(gnu_runtime_abi_01_get_class_super_ref): Reduce indentation of
	misleadingly indented return statements.
	* objc-next-runtime-abi-01.c
	(next_runtime_abi_01_get_class_super_ref): Likewise.

gcc/ChangeLog:

	PR c/80076
	* gensupport.c (alter_attrs_for_subst_insn) <case SET_ATTR>:
	Reduce indentation of misleadingly indented code fragment.
	* lra-constraints.c (multi_block_pseudo_p): Likewise.
	* sel-sched-ir.c (merge_fences): Likewise.

libcpp/ChangeLog:

	PR c/80076
	* include/line-map.h (first_map_in_common): Declare.
	* line-map.c (first_map_in_common): Remove static.

gcc/testsuite/ChangeLog:

	PR c/80076
	* c-c++-common/Wmisleading-indentation-5.c: New test.
2020-09-17 14:27:22 -04:00
Lewis Hyatt 004bb936d6 diagnostics: Support conversion of tabs to spaces [PR49973] [PR86904]
Supports conversion of tabs to spaces when outputting diagnostics. Also
adds -fdiagnostics-column-unit and -fdiagnostics-column-origin options to
control how the column number is output, thereby resolving the two PRs.

gcc/c-family/ChangeLog:

	PR other/86904
	* c-indentation.c (should_warn_for_misleading_indentation): Get
	global tabstop from the new source.
	* c-opts.c (c_common_handle_option): Remove handling of -ftabstop, which
	is now a common option.
	* c.opt: Likewise.

gcc/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* common.opt: Handle -ftabstop here instead of in c-family
	options.  Add -fdiagnostics-column-unit= and
	-fdiagnostics-column-origin= options.
	* opts.c (common_handle_option): Handle the new options.
	* diagnostic-format-json.cc (json_from_expanded_location): Add
	diagnostic_context argument.  Use it to convert column numbers as per
	the new options.
	(json_from_location_range): Likewise.
	(json_from_fixit_hint): Likewise.
	(json_end_diagnostic): Pass the new context argument to helper
	functions above.  Add "column-origin" field to the output.
	(test_unknown_location): Add the new context argument to calls to
	helper functions.
	(test_bad_endpoints): Likewise.
	* diagnostic-show-locus.c
	(exploc_with_display_col::exploc_with_display_col): Support
	tabstop parameter.
	(layout_point::layout_point): Make use of class
	exploc_with_display_col.
	(layout_range::layout_range): Likewise.
	(struct line_bounds): Clarify that the units are now always
	display columns.  Rename members accordingly.  Add constructor.
	(layout::print_source_line): Add support for tab expansion.
	(make_range): Adapt to class layout_range changes.
	(layout::maybe_add_location_range): Likewise.
	(layout::layout): Adapt to class exploc_with_display_col changes.
	(layout::calculate_x_offset_display): Support tabstop parameter.
	(layout::print_annotation_line): Adapt to struct line_bounds changes.
	(layout::print_line): Likewise.
	(line_label::line_label): Add diagnostic_context argument.
	(get_affected_range): Likewise.
	(get_printed_columns): Likewise.
	(layout::print_any_labels): Adapt to struct line_label changes.
	(class correction): Add m_tabstop member.
	(correction::correction): Add tabstop argument.
	(correction::compute_display_cols): Use m_tabstop.
	(class line_corrections): Add m_context member.
	(line_corrections::line_corrections): Add diagnostic_context argument.
	(line_corrections::add_hint): Use m_context to handle tabstops.
	(layout::print_trailing_fixits): Adapt to class line_corrections
	changes.
	(test_layout_x_offset_display_utf8): Support tabstop parameter.
	(test_layout_x_offset_display_tab): New selftest.
	(test_one_liner_colorized_utf8): Likewise.
	(test_tab_expansion): Likewise.
	(test_diagnostic_show_locus_one_liner_utf8): Call the new tests.
	(diagnostic_show_locus_c_tests): Likewise.
	(test_overlapped_fixit_printing): Adapt to helper class and
	function changes.
	(test_overlapped_fixit_printing_utf8): Likewise.
	(test_overlapped_fixit_printing_2): Likewise.
	* diagnostic.h (enum diagnostics_column_unit): New enum.
	(struct diagnostic_context): Add members for the new options.
	(diagnostic_converted_column): Declare.
	(json_from_expanded_location): Add new context argument.
	* diagnostic.c (diagnostic_initialize): Initialize new members.
	(diagnostic_converted_column): New function.
	(maybe_line_and_column): Be willing to output a column of 0.
	(diagnostic_get_location_text): Convert column number as per the new
	options.
	(diagnostic_report_current_module): Likewise.
	(assert_location_text): Add origin and column_unit arguments for
	testing the new functionality.
	(test_diagnostic_get_location_text): Test the new functionality.
	* doc/invoke.texi: Document the new options and behavior.
	* input.h (location_compute_display_column): Add tabstop argument.
	* input.c (location_compute_display_column): Likewise.
	(test_cpp_utf8): Add selftests for tab expansion.
	* tree-diagnostic-path.cc (default_tree_make_json_for_path): Pass the
	new context argument to json_from_expanded_location().

libcpp/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* include/cpplib.h (struct cpp_options):  Removed support for -ftabstop,
	which is now handled by diagnostic_context.
	(class cpp_display_width_computation): New class.
	(cpp_byte_column_to_display_column): Add optional tabstop argument.
	(cpp_display_width): Likewise.
	(cpp_display_column_to_byte_column): Likewise.
	* charset.c
	(cpp_display_width_computation::cpp_display_width_computation): New
	function.
	(cpp_display_width_computation::advance_display_cols): Likewise.
	(compute_next_display_width): Removed and implemented this
	functionality in a new function...
	(cpp_display_width_computation::process_next_codepoint): ...here.
	(cpp_byte_column_to_display_column): Added tabstop argument.
	Reimplemented in terms of class cpp_display_width_computation.
	(cpp_display_column_to_byte_column): Likewise.
	* init.c (cpp_create_reader): Remove handling of -ftabstop, which is now
	handled by diagnostic_context.

gcc/testsuite/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* c-c++-common/Wmisleading-indentation-3.c: Adjust expected output
	for new defaults.
	* c-c++-common/Wmisleading-indentation.c: Likewise.
	* c-c++-common/diagnostic-format-json-1.c: Likewise.
	* c-c++-common/diagnostic-format-json-2.c: Likewise.
	* c-c++-common/diagnostic-format-json-3.c: Likewise.
	* c-c++-common/diagnostic-format-json-4.c: Likewise.
	* c-c++-common/diagnostic-format-json-5.c: Likewise.
	* c-c++-common/missing-close-symbol.c: Likewise.
	* g++.dg/diagnostic/bad-binary-ops.C: Likewise.
	* g++.dg/parse/error4.C: Likewise.
	* g++.old-deja/g++.brendan/crash11.C: Likewise.
	* g++.old-deja/g++.pt/overload2.C: Likewise.
	* g++.old-deja/g++.robertl/eb109.C: Likewise.
	* gcc.dg/analyzer/malloc-paths-9.c: Likewise.
	* gcc.dg/bad-binary-ops.c: Likewise.
	* gcc.dg/format/branch-1.c: Likewise.
	* gcc.dg/format/pr79210.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-expressions-1.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-string-literals-1.c: Likewise.
	* gcc.dg/redecl-4.c: Likewise.
	* gfortran.dg/diagnostic-format-json-1.F90: Likewise.
	* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
	* gfortran.dg/diagnostic-format-json-3.F90: Likewise.
	* go.dg/arrayclear.go: Add a comment explaining why adding a
	comment was necessary to work around a dejagnu bug.
	* c-c++-common/diagnostic-units-1.c: New test.
	* c-c++-common/diagnostic-units-2.c: New test.
	* c-c++-common/diagnostic-units-3.c: New test.
	* c-c++-common/diagnostic-units-4.c: New test.
	* c-c++-common/diagnostic-units-5.c: New test.
	* c-c++-common/diagnostic-units-6.c: New test.
	* c-c++-common/diagnostic-units-7.c: New test.
	* c-c++-common/diagnostic-units-8.c: New test.
2020-07-14 12:05:56 -04:00
Nathan Sidwell 6bf2ff0d52 preprocessor: Better line info for <builtin> & <command-line>
With C++ module header units it becomes important to distinguish
between macros defined in forced headers (& commandline & builtins)
from those defined in the header file being processed.  We weren't
making that easy because we treated the builtins and command-line
locations somewhat file-like, with incrementing line numbers, and
showing them as included from line 1 of the main file.  This patch does
3 things:

0) extend the idiom that 'line 0' of a file means 'the file as a whole'

1) builtins and command-line macros are shown as-if included from line zero.

2) when emitting preprocessed output we keep resetting the line number
so that re-reading that preprocessed output will get the same set of
locations for the command line etc.

For instance the new c-c++-common/cpp/line-2.c test, now emits

In file included from <command-line>:
./line-2.h:4:2: error: #error wrong
    4 | #error wrong
      |  ^~~~~
line-2.c:3:11: error: macro "bill" passed 1 arguments, but takes just 0
    3 | int bill(1);
      |           ^
In file included from <command-line>:
./line-2.h:3: note: macro "bill" defined here
    3 | #define bill() 2
      |

Before it told you about including from <command-line>:31.

the preprocessed output looks like:
...

(There's a new optimization in do_line_marker to stop each of these
line markers causing a new line map.  We can simply rewind the
location, and keep using the same line map.)

	libcpp/
	* directives.c (do_linemarker): Optimize rewinding to line zero.
	* files.c (_cpp_stack_file): Start on line zero when about to inject
	headers.
	(cpp_push_include, cpp_push_default_include): Use highest_line as
	the location.
	* include/cpplib.h (cpp_read_main_file): Add injecting parm.
	* init.c (cpp_read_main_file): Likewise, inform _cpp_stack_file.
	* internal.h (enum include_type): Add IT_MAIN_INJECT.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Add 'injecting' arg to
	cpp_read_main_file.
	(c_finish_options): Add linemap_line_start calls for builtin and cmd
	maps.  Force token position to line_table's highest line.
	* c-ppoutput.c (print_line_1): Refactor, print line zero.
	(cb_define): Always increment source line.
	gcc/testsuite/
	* c-c++-common/cpp/line-2.c: New.
	* c-c++-common/cpp/line-2.h: New.
	* c-c++-common/cpp/line-3.c: New.
	* c-c++-common/cpp/line-4.c: New.
	* c-c++-common/cpp/line-4.h: New.
2020-07-07 11:40:04 -07:00
Nathan Sidwell 7cf3f604fb preprocessor: Random cleanups
This fixes a bunch of poorly formatted decls, marks some getters as
PURE, deletes some C-relevant bool hackery, and finally uses a
passed-in location rather than deducing a closely-related but not
necessarily the same location.

	* include/cpplib.h (cpp_get_otions, cpp_get_callbacks)
	(cpp_get_deps): Mark as PURE.
	* include/line-map.h (get_combined_adhoc_loc)
	(get_location_from_adhoc_loc, get_pure_location): Reformat decls.
	* internal.h (struct lexer_state): Clarify comment.
	* system.h: Remove now-unneeded bool hackery.
	* files.c (_cpp_find_file): Store LOC not highest_location.
2020-05-19 13:23:47 -07:00
Jason Merrill b04445d4a8 c++: Replace "C++2a" with "C++20".
C++20 isn't final quite yet, but all that remains is formalities, so let's
go ahead and change all the references.

I think for the next C++ standard we can just call it C++23 rather than
C++2b, since the committee has been consistent about time-based releases
rather than feature-based.

gcc/c-family/ChangeLog
2020-05-13  Jason Merrill  <jason@redhat.com>

	* c.opt (std=c++20): Make c++2a the alias.
	(std=gnu++20): Likewise.
	* c-common.h (cxx_dialect): Change cxx2a to cxx20.
	* c-opts.c: Adjust.
	* c-cppbuiltin.c: Adjust.
	* c-ubsan.c: Adjust.
	* c-warn.c: Adjust.

gcc/cp/ChangeLog
2020-05-13  Jason Merrill  <jason@redhat.com>

	* call.c, class.c, constexpr.c, constraint.cc, decl.c, init.c,
	lambda.c, lex.c, method.c, name-lookup.c, parser.c, pt.c, tree.c,
	typeck2.c: Change cxx2a to cxx20.

libcpp/ChangeLog
2020-05-13  Jason Merrill  <jason@redhat.com>

	* include/cpplib.h (enum c_lang): Change CXX2A to CXX20.
	* init.c, lex.c: Adjust.
2020-05-13 15:16:49 -04:00
Nathan Sidwell b224c3763e preprocessor: Reimplement directives only processing, support raw literals.
The existing directives-only code (a) punched a hole through the
libcpp interface and (b) didn't support raw string literals.  This
reimplements this preprocessing mode.  I added a proper callback
interface, and adjusted c-ppoutput to use it.  Sadly I cannot get rid
of the libcpp/internal.h include for unrelated reasons.

The new scanner is in lex.x, and works doing some backwards scanning
when it finds a charater of interest.  This reduces the number of
cases one has to deal with in forward scanning.  It may have different
failure mode than forward scanning on bad tokenization.

Finally, Moved some cpp tests from the c-specific dg.gcc/cpp directory
to the c-c++-common/cpp shared directory,

	libcpp/
	* directives-only.c: Delete.
	* Makefile.in (libcpp_a_OBJS, libcpp_a_SOURCES): Remove it.
	* include/cpplib.h (enum CPP_DO_task): New enum.
	(cpp_directive_only_preprocess): Declare.
	* internal.h (_cpp_dir_only_callbacks): Delete.
	(_cpp_preprocess_dir_only): Delete.
	* lex.c (do_peek_backslask, do_peek_next, do_peek_prev): New.
	(cpp_directives_only_process): New implementation.

	gcc/c-family/
	Reimplement directives only processing.
	* c-ppoutput.c (token_streamer): Ne.
	(directives_only_cb): New.  Swallow ...
	(print_lines_directives_only): ... this.
	(scan_translation_unit_directives_only): Reimplment using the
	published interface.

	gcc/testsuite/
	* gcc.dg/cpp/counter-[23].c: Move to c-c+_-common/cpp.
	* gcc.dg/cpp/dir-only-*: Likewise.
	* c-c++-common/cpp/dir-only-[78].c: New.
2020-05-08 11:13:29 -07:00
Martin Sebor 297aa66829 Remove trailing comma to avoid pedantic warning in C++ 98 mode: comma at end of enumerator list 2020-02-05 17:14:42 -07:00
Nathan Sidwell 3d056cbfb3 preprocessor: Make __has_include a builtin macro [PR93452]
The clever hack of '#define __has_include __has_include' breaks -dD
and -fdirectives-only, because that emits definitions.  This turns
__has_include into a proper builtin macro.  Thus it's never emitted
via -dD, and because use outside of directive processing is undefined,
we can just expand it anywhere.

	PR preprocessor/93452
	* internal.h (struct spec_nodes): Drop n__has_include{,_next}.
	* directives.c (lex_macro_node): Don't check __has_include redef.
	* expr.c (eval_token): Drop __has_include eval.
	(parse_has_include): Move to ...
	* macro.c (builtin_has_include): ... here.
	(_cpp_builtin_macro_text): Eval __has_include{,_next}.
	* include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_INCLUDE{,_NEXT}.
	* init.c (builtin_array): Add them.
	(cpp_init_builtins): Drop __has_include{,_next} init here ...
	* pch.c (cpp_read_state): ... and here.
	* traditional.c (enum ls): Drop has_include states ...
	(_cpp_scan_out_logical_line): ... and here.
2020-01-28 08:02:17 -08:00
Nathan Sidwell ad1a3914ae [PR 80005] Fix __has_include
__has_include is funky in that it is macro-like from the POV of #ifdef and
friends, but lexes its parenthesize argument #include-like.  We were
failing the second part of that, because we used a forwarding macro to an
internal name, and hence always lexed the argument in macro-parameter
context.  We componded that by not setting the right flag when lexing, so
it didn't even know.  Mostly users got lucky.

This reimplements the handline.
1) Remove the forwarding, but declare object-like macros that
expand to themselves.  This satisfies the #ifdef requirement

2) Correctly set angled_brackets when lexing the parameter.  This tells
the lexer (a) <...> is a header name and (b) "..." is too (not a string).

3) Remove the in__has_include lexer state, just tell find_file that that's
what's happenning, so it doesn't emit an error.

We lose the (undocumented) ability to #undef __has_include.  That may well
have been an accident of implementation.  There are no tests for it.

We gain __has_include behaviour for all users of the preprocessors -- not
just the C-family ones that defined a forwarding macro.

	libcpp/
	PR preprocessor/80005
	* include/cpplib.h (BT_HAS_ATTRIBUTE): Fix comment.
	* internal.h (struct lexer_state): Delete in__has_include field.
	(struct spec_nodes): Rename n__has_include{,_next}__ fields.
	(_cpp_defined_macro_p): New.
	(_cpp_find_file): Add has_include parm.
	* directives.c (lex_macro_node): Combine defined,
	__has_inline{,_next} checking.
	(do_ifdef, do_ifndef): Use _cpp_defined_macro_p.
	(_cpp_init_directives): Refactor.
	* expr.c (parse_defined): Use _cpp_defined_macro_p.
	(eval_token): Adjust parse_has_include calls.
	(parse_has_include): Add OP parameter.  Reimplement.
	* files.c (_cpp_find_file): Add HAS_INCLUDE parm.  Use it to
	inhibit error message.
	(_cpp_stack_include): Adjust _cpp_find_file call.
	(_cpp_fake_include, _cpp_compare_file_date): Likewise.
	(open_file_failed): Remove in__has_include check.
	(_cpp_has_header): Adjust _cpp_find_file call.
	* identifiers.c (_cpp_init_hashtable): Don't init
	__has_include{,_next} here ...
	* init.c (cpp_init_builtins): ... init them here.  Define as
	macros.
	(cpp_read_main_file): Adjust _cpp_find_file call.
	* pch.c (cpp_read_state): Adjust __has_include{,_next} access.
	* traditional.c (_cpp_scan_out_locgical_line): Likewise.

	gcc/c-family/
	PR preprocessor/80005
	* c-cppbuiltins.c (c_cpp_builtins): Don't define __has_include{,_next}.

	gcc/testsuite/
	PR preprocessor/80005
	* g++.dg/cpp1y/feat-cxx14.C: Adjust.
	* g++.dg/cpp1z/feat-cxx17.C: Adjust.
	* g++.dg/cpp2a/feat-cxx2a.C: Adjust.
	* g++.dg/cpp/pr80005.C: New.
2020-01-20 05:39:59 -08:00
David Malcolm 4bc1899b2e Add diagnostic paths
This patch adds support for associating a "diagnostic_path" with a
diagnostic: a sequence of events predicted by the compiler that leads to
the problem occurring, with their locations in the user's source,
text descriptions, and stack information (for handling interprocedural
paths).

For example, the following (hypothetical) error has a 3-event
intraprocedural path:

test.c: In function 'demo':
test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which
  requires a non-NULL parameter
   29 |     PyList_Append(list, item);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
  'demo': events 1-3
     |
     |   25 |   list = PyList_New(0);
     |      |          ^~~~~~~~~~~~~
     |      |          |
     |      |          (1) when 'PyList_New' fails, returning NULL
     |   26 |
     |   27 |   for (i = 0; i < count; i++) {
     |      |   ~~~
     |      |   |
     |      |   (2) when 'i < count'
     |   28 |     item = PyLong_FromLong(random());
     |   29 |     PyList_Append(list, item);
     |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~
     |      |     |
     |      |     (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
     |

The patch adds a new "%@" format code for printing event IDs, so that
in the above, the description of event (3) mentions event (1), showing
the user where the bogus NULL value comes from (the event IDs are
colorized to draw the user's attention to them).

There is a separation between data vs presentation: the above shows how
the diagnostic-printing code has consolidated the path into a single run
of events, since all the events are near each other and within the same
function; more complicated examples (such as interprocedural paths)
might be printed as multiple runs of events.

Examples of how interprocedural paths are printed can be seen in the
test suite (which uses a plugin to exercise the code without relying
on specific warnings using this functionality).

Other output formats include
- JSON,
- printing each event as a separate "note", and
- to not emit paths.

gcc/ChangeLog:
	* Makefile.in (OBJS): Add tree-diagnostic-path.o.
	* common.opt (fdiagnostics-path-format=): New option.
	(diagnostic_path_format): New enum.
	(fdiagnostics-show-path-depths): New option.
	* coretypes.h (diagnostic_event_id_t): New forward decl.
	* diagnostic-color.c (color_dict): Add "path".
	* diagnostic-event-id.h: New file.
	* diagnostic-format-json.cc (json_from_expanded_location): Make
	non-static.
	(json_end_diagnostic): Call context->make_json_for_path if it
	exists and the diagnostic has a path.
	(diagnostic_output_format_init): Clear context->print_path.
	* diagnostic-path.h: New file.
	* diagnostic-show-locus.c (colorizer::set_range): Special-case
	when printing a run of events in a diagnostic_path so that they
	all get the same color.
	(layout::m_diagnostic_path_p): New field.
	(layout::layout): Initialize it.
	(layout::print_any_labels): Don't colorize the label text for an
	event in a diagnostic_path.
	(gcc_rich_location::add_location_if_nearby): Add
	"restrict_to_current_line_spans" and "label" params.  Pass the
	former to layout.maybe_add_location_range; pass the latter
	when calling add_range.
	* diagnostic.c: Include "diagnostic-path.h".
	(diagnostic_initialize): Initialize context->path_format and
	context->show_path_depths.
	(diagnostic_show_any_path): New function.
	(diagnostic_path::interprocedural_p): New function.
	(diagnostic_report_diagnostic): Call diagnostic_show_any_path.
	(simple_diagnostic_path::num_events): New function.
	(simple_diagnostic_path::get_event): New function.
	(simple_diagnostic_path::add_event): New function.
	(simple_diagnostic_event::simple_diagnostic_event): New ctor.
	(simple_diagnostic_event::~simple_diagnostic_event): New dtor.
	(debug): New overload taking a diagnostic_path *.
	* diagnostic.def (DK_DIAGNOSTIC_PATH): New.
	* diagnostic.h (enum diagnostic_path_format): New enum.
	(json::value): New forward decl.
	(diagnostic_context::path_format): New field.
	(diagnostic_context::show_path_depths): New field.
	(diagnostic_context::print_path): New callback field.
	(diagnostic_context::make_json_for_path): New callback field.
	(diagnostic_show_any_path): New decl.
	(json_from_expanded_location): New decl.
	* doc/invoke.texi (-fdiagnostics-path-format=): New option.
	(-fdiagnostics-show-path-depths): New option.
	(-fdiagnostics-color): Add "path" to description of default
	GCC_COLORS; describe it.
	(-fdiagnostics-format=json): Document how diagnostic paths are
	represented in the JSON output format.
	* gcc-rich-location.h (gcc_rich_location::add_location_if_nearby):
	Add optional params "restrict_to_current_line_spans" and "label".
	* opts.c (common_handle_option): Handle
	OPT_fdiagnostics_path_format_ and
	OPT_fdiagnostics_show_path_depths.
	* pretty-print.c: Include "diagnostic-event-id.h".
	(pp_format): Implement "%@" format code for printing
	diagnostic_event_id_t *.
	(selftest::test_pp_format): Add tests for "%@".
	* selftest-run-tests.c (selftest::run_tests): Call
	selftest::tree_diagnostic_path_cc_tests.
	* selftest.h (selftest::tree_diagnostic_path_cc_tests): New decl.
	* toplev.c (general_init): Initialize global_dc->path_format and
	global_dc->show_path_depths.
	* tree-diagnostic-path.cc: New file.
	* tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Make
	non-static.  Drop "diagnostic" param in favor of storing the
	original value of "where" and re-using it.
	(virt_loc_aware_diagnostic_finalizer): Update for dropped param of
	maybe_unwind_expanded_macro_loc.
	(tree_diagnostics_defaults): Initialize context->print_path and
	context->make_json_for_path.
	* tree-diagnostic.h (default_tree_diagnostic_path_printer): New
	decl.
	(default_tree_make_json_for_path): New decl.
	(maybe_unwind_expanded_macro_loc): New decl.

gcc/c-family/ChangeLog:
	* c-format.c (local_event_ptr_node): New.
	(PP_FORMAT_CHAR_TABLE): Add entry for "%@".
	(init_dynamic_diag_info): Initialize local_event_ptr_node.
	* c-format.h (T_EVENT_PTR): New define.

gcc/testsuite/ChangeLog:
	* gcc.dg/format/gcc_diag-10.c (diagnostic_event_id_t): New
	typedef.
	(test_diag): Add coverage of "%@".
	* gcc.dg/plugin/diagnostic-path-format-default.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-1.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-2.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-3.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-none.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-1.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-2.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-3.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-4.c: New test.
	* gcc.dg/plugin/diagnostic_plugin_test_paths.c: New.
	* gcc.dg/plugin/plugin.exp: Add the new plugin and test cases.

libcpp/ChangeLog:
	* include/line-map.h (class diagnostic_path): New forward decl.
	(rich_location::get_path): New accessor.
	(rich_location::set_path): New function.
	(rich_location::m_path): New field.
	* line-map.c (rich_location::rich_location): Initialize m_path.

From-SVN: r280142
2020-01-10 21:22:12 +00:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
David Malcolm 6dd0c82021 Drop unused member from cpp_string_location_reader (PR preprocessor/92982)
libcpp/ChangeLog:
	PR preprocessor/92982
	* charset.c
	(cpp_string_location_reader::cpp_string_location_reader): Delete
	initialization of m_line_table.
	* include/cpplib.h (cpp_string_location_reader::m_line_table):
	Delete unused member.

From-SVN: r279541
2019-12-18 17:26:01 +00:00
David Malcolm d68f5d458d Replace label_text ctor with "borrow" and "take"
libcpp's label_text class wraps a text buffer, along with a flag to
determine if it "owns" the buffer.

The existing ctor exposed this directly, but I found it difficult
to remember the sense of flag, so this patch hides the ctor, in
favor of static member functions "borrow" and "take", to make
the effect on ownership explicit in the name.

gcc/c-family/ChangeLog:
	* c-format.c (range_label_for_format_type_mismatch::get_text):
	Replace label_text ctor called with true with label_text::take.

gcc/c/ChangeLog:
	* c-objc-common.c (range_label_for_type_mismatch::get_text):
	Replace label_text ctor calls.

gcc/cp/ChangeLog:
	* error.c (range_label_for_type_mismatch::get_text): Replace
	label_text ctor calls with label_text::borrow.

gcc/ChangeLog:
	* gcc-rich-location.c
	(maybe_range_label_for_tree_type_mismatch::get_text): Replace
	label_text ctor call with label_text::borrow.
	* gcc-rich-location.h (text_range_label::get_text): Replace
	label_text ctor called with false with label_text::borrow.

libcpp/ChangeLog:
	* include/line-map.h (label_text::label_text): Make private.
	(label_text::borrow): New.
	(label_text::take): New.
	(label_text::take_or_copy): New.

From-SVN: r279153
2019-12-10 02:02:38 +00:00
Lewis Hyatt ee9256409f Byte vs column awareness for diagnostic-show-locus.c (PR 49973)
contrib/ChangeLog

2019-12-09  Lewis Hyatt  <lhyatt@gmail.com>

	PR preprocessor/49973
	* unicode/from_glibc/unicode_utils.py: Support script from
	glibc (commit 464cd3) to extract character widths from Unicode data
	files.
	* unicode/from_glibc/utf8_gen.py: Likewise.
	* unicode/UnicodeData.txt: Unicode v. 12.1.0 data file.
	* unicode/EastAsianWidth.txt: Likewise.
	* unicode/PropList.txt: Likewise.
	* unicode/gen_wcwidth.py: New utility to generate
	libcpp/generated_cpp_wcwidth.h with help from the glibc support
	scripts and the Unicode data files.
	* unicode/unicode-license.txt: Added.
	* unicode/README: New explanatory file.

libcpp/ChangeLog

2019-12-09  Lewis Hyatt  <lhyatt@gmail.com>

	PR preprocessor/49973
	* generated_cpp_wcwidth.h: New file generated by
	../contrib/unicode/gen_wcwidth.py, supports new cpp_wcwidth function.
	* charset.c (compute_next_display_width): New function to help
	implement display columns.
	(cpp_byte_column_to_display_column): Likewise.
	(cpp_display_column_to_byte_column): Likewise.
	(cpp_wcwidth): Likewise.
	* include/cpplib.h (cpp_byte_column_to_display_column): Declare.
	(cpp_display_column_to_byte_column): Declare.
	(cpp_wcwidth): Declare.
	(cpp_display_width): New function.

gcc/ChangeLog

2019-12-09  Lewis Hyatt  <lhyatt@gmail.com>

	PR preprocessor/49973
	* input.c (location_compute_display_column): New function to help with
	multibyte awareness in diagnostics.
	(test_cpp_utf8): New self-test.
	(input_c_tests): Call the new test.
	* input.h (location_compute_display_column): Declare.
	* diagnostic-show-locus.c: Pervasive changes to add multibyte awareness
	to all classes and functions.
	(enum column_unit): New enum.
	(class exploc_with_display_col): New class.
	(class layout_point): Convert m_column member to array m_columns[2].
	(layout_range::contains_point): Add col_unit argument.
	(test_layout_range_for_single_point): Pass new argument.
	(test_layout_range_for_single_line): Likewise.
	(test_layout_range_for_multiple_lines): Likewise.
	(line_bounds::convert_to_display_cols): New function.
	(layout::get_state_at_point): Add col_unit argument.
	(make_range): Use empty filename rather than dummy filename.
	(get_line_width_without_trailing_whitespace): Rename to...
	(get_line_bytes_without_trailing_whitespace): ...this.
	(test_get_line_width_without_trailing_whitespace): Rename to...
	(test_get_line_bytes_without_trailing_whitespace): ...this.
	(class layout): m_exploc changed to exploc_with_display_col from
	plain expanded_location.
	(layout::get_linenum_width): New accessor member function.
	(layout::get_x_offset_display): Likewise.
	(layout::calculate_linenum_width): New subroutine for the constuctor.
	(layout::calculate_x_offset_display): Likewise.
	(layout::layout): Use the new subroutines. Add multibyte awareness.
	(layout::print_source_line): Add multibyte awareness.
	(layout::print_line): Likewise.
	(layout::print_annotation_line): Likewise.
	(line_label::line_label): Likewise.
	(layout::print_any_labels): Likewise.
	(layout::annotation_line_showed_range_p): Likewise.
	(get_printed_columns): Likewise.
	(class line_label): Rename m_length to m_display_width.
	(get_affected_columns): Rename to...
	(get_affected_range): ...this; add col_unit argument and multibyte
	awareness.
	(class correction): Add m_affected_bytes and m_display_cols
	members.  Rename m_len to m_byte_length for clarity.  Add multibyte
	awareness throughout.
	(correction::insertion_p): Add multibyte awareness.
	(correction::compute_display_cols): New function.
	(correction::ensure_terminated): Use new member name m_byte_length.
	(line_corrections::add_hint): Add multibyte awareness.
	(layout::print_trailing_fixits): Likewise.
	(layout::get_x_bound_for_row): Likewise.
	(test_one_liner_simple_caret_utf8): New self-test analogous to the one
	with _utf8 suffix removed, testing multibyte awareness.
	(test_one_liner_caret_and_range_utf8): Likewise.
	(test_one_liner_multiple_carets_and_ranges_utf8): Likewise.
	(test_one_liner_fixit_insert_before_utf8): Likewise.
	(test_one_liner_fixit_insert_after_utf8): Likewise.
	(test_one_liner_fixit_remove_utf8): Likewise.
	(test_one_liner_fixit_replace_utf8): Likewise.
	(test_one_liner_fixit_replace_non_equal_range_utf8): Likewise.
	(test_one_liner_fixit_replace_equal_secondary_range_utf8): Likewise.
	(test_one_liner_fixit_validation_adhoc_locations_utf8): Likewise.
	(test_one_liner_many_fixits_1_utf8): Likewise.
	(test_one_liner_many_fixits_2_utf8): Likewise.
	(test_one_liner_labels_utf8): Likewise.
	(test_diagnostic_show_locus_one_liner_utf8): Likewise.
	(test_overlapped_fixit_printing_utf8): Likewise.
	(test_overlapped_fixit_printing): Adapt for changes to
	get_affected_columns, get_printed_columns and class corrections.
	(test_overlapped_fixit_printing_2): Likewise.
	(test_linenum_sep): New constant.
	(test_left_margin): Likewise.
	(test_offset_impl): Helper function for new test.
	(test_layout_x_offset_display_utf8): New test.
	(diagnostic_show_locus_c_tests): Call new tests.

gcc/testsuite/ChangeLog:

2019-12-09  Lewis Hyatt  <lhyatt@gmail.com>

	PR preprocessor/49973
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
	(test_show_locus): Tweak so that expected output is the same as
	before the diagnostic-show-locus.c changes.
	* gcc.dg/cpp/pr66415-1.c: Likewise.

From-SVN: r279137
2019-12-09 20:03:47 +00:00
Jason Merrill b7689b962d Implement C++20 operator<=>.
There are three major pieces to this support: scalar operator<=>,
synthesis of comparison operators, and rewritten/reversed overload
resolution (e.g. a < b becomes 0 > b <=> a).

Unlike other defaulted functions, where we use synthesized_method_walk to
semi-simulate what the definition of the function will be like, this patch
determines the characteristics of a comparison operator by trying to define
it.

My handling of non-dependent rewritten operators in templates can still use
some work: build_min_non_dep_op_overload can't understand the rewrites and
crashes, so I'm avoiding it for now by clearing *overload.  This means we'll
do name lookup again at instantiation time, which can incorrectly mean a
different result.  I'll poke at this more in stage 3.

I'm leaving out a fourth section ("strong structural equality") even though
I've implemented it, because it seems likely to change radically tomorrow.

Thanks to Tim van Deurzen and Jakub for implementing lexing of the <=>
operator, and Jonathan for the initial <compare> header.

gcc/cp/
	* cp-tree.h (struct lang_decl_fn): Add maybe_deleted bitfield.
	(DECL_MAYBE_DELETED): New.
	(enum special_function_kind): Add sfk_comparison.
	(LOOKUP_REWRITTEN, LOOKUP_REVERSED): New.
	* call.c (struct z_candidate): Add rewritten and reversed methods.
	(add_builtin_candidate): Handle SPACESHIP_EXPR.
	(add_builtin_candidates): Likewise.
	(add_candidates): Don't add a reversed candidate if the parms are
	the same.
	(add_operator_candidates): Split out from build_new_op_1.  Handle
	rewritten and reversed candidates.
	(add_candidate): Swap conversions of reversed candidate.
	(build_new_op_1): Swap them back.  Build a second operation for
	rewritten candidates.
	(extract_call_expr): Handle rewritten calls.
	(same_fn_or_template): New.
	(joust): Handle rewritten and reversed candidates.
	* class.c (add_implicitly_declared_members): Add implicit op==.
	(classtype_has_op, classtype_has_defaulted_op): New.
	* constexpr.c (cxx_eval_binary_expression): Handle SPACESHIP_EXPR.
	(cxx_eval_constant_expression, potential_constant_expression_1):
	Likewise.
	* cp-gimplify.c (genericize_spaceship): New.
	(cp_genericize_r): Use it.
	* cp-objcp-common.c (cp_common_init_ts): Handle SPACESHIP_EXPR.
	* decl.c (finish_function): Handle deleted function.
	* decl2.c (grokfield): SET_DECL_FRIEND_CONTEXT on defaulted friend.
	(mark_used): Check DECL_MAYBE_DELETED.  Remove assumption that
	defaulted functions are non-static members.
	* error.c (dump_expr): Handle SPACESHIP_EXPR.
	* method.c (type_has_trivial_fn): False for sfk_comparison.
	(enum comp_cat_tag, struct comp_cat_info_t): New types.
	(comp_cat_cache): New array variable.
	(lookup_comparison_result, lookup_comparison_category)
	(is_cat, cat_tag_for, spaceship_comp_cat)
	(spaceship_type, genericize_spaceship)
	(common_comparison_type, early_check_defaulted_comparison)
	(comp_info, build_comparison_op): New.
	(synthesize_method): Handle sfk_comparison.  Handle deleted.
	(get_defaulted_eh_spec, maybe_explain_implicit_delete)
	(explain_implicit_non_constexpr, implicitly_declare_fn)
	(defaulted_late_check, defaultable_fn_check): Handle sfk_comparison.
	* name-lookup.c (get_std_name_hint): Add comparison categories.
	* tree.c (special_function_p): Add sfk_comparison.
	* typeck.c (cp_build_binary_op): Handle SPACESHIP_EXPR.

2019-11-05  Tim van Deurzen  <tim@kompiler.org>

	Add new tree code for the spaceship operator.
gcc/cp/
	* cp-tree.def: Add new tree code.
	* operators.def: New binary operator.
	* parser.c: Add new token and tree code.
libcpp/
	* cpplib.h: Add spaceship operator for C++.
	* lex.c: Implement conditional lexing of spaceship operator for C++20.

2019-11-05  Jonathan Wakely  <jwakely@redhat.com>

libstdc++-v3/
	* libsupc++/compare: New header.
	* libsupc++/Makefile.am (std_HEADERS): Add compare.
	* include/std/version: Define __cpp_lib_three_way_comparison.
	* include/std/functional: #include <compare>.

From-SVN: r277865
2019-11-05 18:56:18 -05:00
Martin Sebor ad1539d555 PR c/66970 - Add __has_builtin() macro
gcc/ChangeLog:

	PR c/66970
	* doc/cpp.texi (__has_builtin): Document.
	* doc/extend.texi (__builtin_frob_return_addr): Correct spelling.

gcc/c/ChangeLog:

	PR c/66970
	* c-decl.c (names_builtin_p): Define a new function.

gcc/c-family/ChangeLog:

	PR c/66970
	* c-common.c (c_common_nodes_and_builtins): Call c_define_builtins
	even when only preprocessing.
	* c-common.h (names_builtin_p): Declare new function.
	* c-lex.c (init_c_lex): Set has_builtin.
	(c_common_has_builtin): Define a new function.
	* c-ppoutput.c (init_pp_output): Set has_builtin.

gcc/cp/ChangeLog:

	PR c/66970
	* cp-objcp-common.c (names_builtin_p): Define new function.

gcc/testsuite/ChangeLog:

	PR c/66970
	* c-c++-common/cpp/has-builtin-2.c: New test.
	* c-c++-common/cpp/has-builtin-3.c: New test.
	* c-c++-common/cpp/has-builtin.c: New test.

From-SVN: r277544
2019-10-28 16:46:28 -06:00