Commit Graph

1135 Commits

Author SHA1 Message Date
Jiong Wang ff971abe60 Add DW_CFA_AARCH64_negate_ra_state to dwarf2.def/h and dwarfnames.c
A new vendor CFA DW_CFA_AARCH64_negate_ra_state was introduced for ARMv8.3-A
return address signing, it is multiplexing DW_CFA_GNU_window_save in CFA vendor
extension space.

  This patch adds necessary code to make it available to external, the GDB
patch (https://sourceware.org/ml/gdb-patches/2017-08/msg00215.html) is intended
to use it.

  A new DW_CFA_DUP for it is added in dwarf2.def.  The use of DW_CFA_DUP is to
avoid duplicated case value issue when included in libiberty/dwarfnames.

  Native x86 builds OK to make sure no macro expanding errors.

Committed on behalf of Jiong Wang.

    include/
	* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
	* dwarf2.h (DW_CFA_DUP): New define.

    libiberty/
	* dwarfnames.c (DW_CFA_DUP): New define.

From-SVN: r252037
2017-09-12 16:39:59 +00:00
Martin Liska 39baa1d35e Fix warning for simple-object-elf.c.
2017-09-01  Martin Liska  <mliska@suse.cz>

	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Remove duplicite declaration.

From-SVN: r251584
2017-09-01 11:22:04 +00:00
Richard Biener a621861e39 re PR lto/81968 (early lto debug objects make Solaris ld SEGV)
2017-08-31  Richard Biener  <rguenther@suse.de>

	PR lto/81968
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_section):
	Keep names of removed global symbols.

From-SVN: r251560
2017-08-31 11:21:40 +00:00
Tony Reix 62663034af simple-object-xcoff.c (simple_object_xcoff_find_sections): Improve .go_export csect handling.
* simple-object-xcoff.c (simple_object_xcoff_find_sections):
	Improve .go_export csect handling.  Don't make assumptions
	on containing section or number of auxiliary entries.

From-SVN: r251533
2017-08-30 14:08:00 +00:00
Richard Biener 1963f60adb re PR lto/81968 (early lto debug objects make Solaris ld SEGV)
2017-08-28  Richard Biener  <rguenther@suse.de>

	PR lto/81968
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_section):
	Adjust field with for sh_type write, set SHF_EXCLUDE only for
	removed sections.

From-SVN: r251384
2017-08-28 13:14:28 +00:00
Richard Biener d4c550fd0e re PR lto/81925 (early lto debug link failure on aarch64_be)
2017-08-22  Richard Biener  <rguenther@suse.de>

	PR lto/81925
	* simple-object-elf.c (simple_object_elf_write_shdr): Adjust
	type of sh_addralign and sh_entsize and properly write
	sh_entsize as Elf_Addr.
	(simple_object_elf_write_to_file): Read sh_entsize as Elf_Addr.

From-SVN: r251276
2017-08-22 13:54:01 +00:00
Richard Biener 1ea85365b4 re PR go/78628 (GO fails to build a translation unit decl)
2017-08-21  Richard Biener  <rguenther@suse.de>

	include/
	* simple-object.h (simple_object_copy_lto_debug_sections): New
	function.

	libiberty/
	* simple-object-common.h (struct simple_object_functions): Add
	copy_lto_debug_sections hook.
	* simple-object.c: Include fcntl.h.
	(handle_lto_debug_sections): New helper function.
	(simple_object_copy_lto_debug_sections): New function copying
	early LTO debug sections to regular debug sections in a new file.
	(simple_object_start_write): Handle NULL segment_name.
	* simple-object-coff.c (simple_object_coff_functions): Adjust
	for not implemented copy_lto_debug_sections hook.
	* simple-object-mach-o.c (simple_object_mach_o_functions): Likewise.
	* simple-object-xcoff.c (simple_object_xcoff_functions): Likewise.
	* simple-object-elf.c (SHT_NULL, SHT_SYMTAB, SHT_RELA, SHT_REL,
	SHT_GROUP): Add various sectopn header types.
	(SHF_EXCLUDE): Add flag.
	(Elf32_External_Sym, Elf64_External_Sym): Add symbol struct.
	(ELF_ST_BIND, ELF_ST_TYPE, ELF_ST_INFO): Add accessors.
	(STT_OBJECT, STT_FUNC, STT_TLS, STT_GNU_IFUNC): Add Symbol types.
	(STV_DEFAULT): Add symbol visibility.
	(SHN_COMMON): Add special section index name.
	(struct simple_object_elf_write): New.
	(simple_object_elf_start_write): Adjust for new private data.
	(simple_object_elf_write_shdr): Pass in values for all fields
	we write.
	(simple_object_elf_write_to_file): Adjust.  Copy from recorded
	section headers if requested.
	(simple_object_elf_release_write): Release private data.
	(simple_object_elf_copy_lto_debug_sections): Copy and rename sections
	as denoted by PFN and all their dependences, symbols and relocations
	to the empty destination file.
	(simple_object_elf_functions): Adjust for copy_lto_debug_sections hook.

        gcc/
        * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
        register_external_die hooks.
        (debug_false_tree_charstarstar_uhwistar): Declare.
        (debug_nothing_tree_charstar_uhwi): Likewise.
        * debug.c (do_nothing_debug_hooks): Adjust.
        (debug_false_tree_charstarstar_uhwistar): New do nothing.
        (debug_nothing_tree_charstar_uhwi): Likewise.
        * dbxout.c (dbx_debug_hooks): Adjust.
        (xcoff_debug_hooks): Likewise.
        * sdbout.c (sdb_debug_hooks): Likewise.
        * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
        * dwarf2out.c (macinfo_label_base): New global.
	(dwarf2out_register_external_die): New function for the
	register_external_die hook.
        (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
        (dwarf2_debug_hooks): Use them.
        (dwarf2_lineno_debug_hooks): Adjust.
        (struct die_struct): Add with_offset flag.
        (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
        DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
        DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
        DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
        DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
        DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
        defining section names for the early LTO debug variants.
	(reset_indirect_string): New helper.
        (add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
        (print_dw_val): Add support for offsetted symbol references.
	(get_ultimate_context): Split out from is_cxx.
	(is_cxx): Use get_ultimate_context.
	(is_fortran): Add decl overload.
        (compute_comp_unit_symbol): Split out worker from
	compute_section_prefix.
        (compute_section_prefix): Call compute_comp_unit_symbol and
	set comdat_type_p here.
        (output_die): Skip DIE symbol output for the LTO added one.
        Handle DIE symbol references with offset.
        (output_comp_unit): Guard section name mangling properly.
        For LTO debug sections emit a symbol at the section beginning
        which we use to refer to its DIEs.
        (add_abstract_origin_attribute): For DIEs registered via
        dwarf2out_register_external_die directly refer to the early
        DIE rather than indirectly through the shadow one we created.
	Remove obsolete call to dwarf2out_abstract_function for
	non-function/block origins.
        (gen_array_type_die): When generating early LTO debug do
        not emit DW_AT_string_length.
        (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
        late when in LTO.  As suggested place a gcc_unreachable for
	the DECL_ABSTRACT_P case.
        (gen_subprogram_die): Avoid another specification DIE
        for early built declarations/definitions for the late LTO case.
        (gen_variable_die): Add type references for late duplicated VLA dies
        when in late LTO.
        (gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
        we have the abstract instance already.
        (process_scope_var): Adjust decl DIE contexts in LTO which
        first puts them in limbo.
        (gen_decl_die): Do not generate type DIEs late apart from
        types for VLAs or for decls we do not yet have a DIE.  Do not
	call dwarf2out_abstract_function late.
        (dwarf2out_early_global_decl): Make sure to create DIEs
        for abstract instances of a decl first.
        (dwarf2out_late_global_decl): Adjust comment.
        (output_macinfo_op): With multiple macro sections use
	macinfo_label_base to distinguish labels.
        (output_macinfo): Likewise.  Update macinfo_label_base.
	Pass in the line info label.
	(note_variable_value_in_expr): When generating LTO resolve
	all variable values here by generating DIEs as needed.
        (init_sections_and_labels): Add early LTO debug flag parameter
        and generate different sections and names if set.  Add generation
        counter for the labels so we can have multiple of them.
        (reset_dies): Helper to allow DIEs to be output multiple times.
        (dwarf2out_finish): When outputting DIEs to the fat part of an
	LTO object first reset DIEs.
        (dwarf2out_early_finish): Output early DIEs when generating LTO.
	(modified_type_die): Check for decl_ultimate_origin being self
	before recursing.
	(gen_type_die_with_usage): Likewise.
	(gen_typedef_die): Allow decl_ultimate_origin being self.
        (set_decl_abstract_flags): Remove.
        (set_block_abstract_flags): Likewise.
        (dwarf2out_abstract_function): Treat the early generated DIEs
        as the abstract copy and only add DW_AT_inline and
        DW_AT_artificial here and call set_decl_origin_self.
	If the DIE has an abstract origin don't do anything.
	* tree.c (free_lang_data): Build a dummy TRANSLATION_UNIT_DECL
	if we have none yet (Go fails to build one, PR78628).
	(variably_modified_type_p): Prevent endless recursion for Ada
	cyclic pointer types.
        * lto-streamer-in.c: Include debug.h.
        (dref_queue): New global.
        (lto_read_tree_1): Stream in DIE references.
        (lto_input_tree): Register DIE references.
	(input_function): Stream DECL_DEBUG_ARGS.
        * lto-streamer-out.c: Include debug.h.
        (lto_write_tree_1): Output DIE references.
        (DFS::DFS_write_tree_body): Follow DECL_ABSTRACT_ORIGIN.
	Force a TRANSLATION_UNIT_DECL DECL_CONTEXT for file-scope decls.
	(output_function): Stream DECL_DEBUG_ARGS.
        * tree-streamer-in.c (lto_input_ts_decl_common_tree_pointers):
        Stream DECL_ABSTRACT_ORIGIN.
        * tree-streamer-out.c (write_ts_decl_common_tree_pointers): Likewise.
	(write_ts_decl_minimal_tree_pointers): Force a TRANSLATION_UNIT_DECL
	DECL_CONTEXT for file-scope decls.
        * lto-streamer.h (struct dref_entry): Declare.
        (dref_queue): Likewise.
	* cfgexpand.c (pass_expand::execute): Do not call the
	outlining_inline_function hook here.
        * lto-wrapper.c (debug_obj): New global.
        (tool_cleanup): Unlink it if required.
        (debug_objcopy): New function.
        (run_gcc): Handle early debug sections in the IL files by
        extracting them to separate files, partially linkin them and
        feeding the result back as result to the linker.

        * config/darwin.h (DEBUG_LTO_INFO_SECTION, DEBUG_LTO_ABBREV_SECTION,
        DEBUG_LTO_MACINFO_SECTION, DEBUG_LTO_LINE_SECTION,
        DEBUG_STR_LTO_SECTION, DEBUG_LTO_MACRO_SECTION): Put early debug
        sections into a separate segment.
        * config/darwin.c (darwin_asm_named_section): Handle __GNU_DWARF_LTO
        segments.
        (darwin_asm_dwarf_section): Likewise.
        (darwin_asm_output_dwarf_offset): Likewise.

	* config/i386/i386.c (make_resolver_func): Set DECL_IGNORED_P.

        lto/
        * lto.c (unify_scc): Truncate DIE reference queue for dropped SCCs.
        (lto_read_decls): Process TRANSLATION_UNIT_DECLs.  Remove
        TYPE_DECL debug processing, register DIE references from
        prevailing SCCs with the debug machinery.
        (lto_section_with_id): Handle LTO debug sections.

	libstdc++/
	* testsuite/libstdc++-prettyprinters/prettyprinters.exp: Run all
	tests with -flto as well if supported.

        testsuite/
	* c-c++-common/asan/global-overflow-1.c: Adjust diagnostic location
	regex to handle the LTO case.
	* c-c++-common/asan/heap-overflow-1.c: Likewise.
	* c-c++-common/asan/misalign-1.c: Likewise.
	* c-c++-common/asan/misalign-2.c: Likewise.
	* c-c++-common/asan/null-deref-1.c: Likewise.
	* c-c++-common/asan/stack-overflow-1.c: Likewise.
	* c-c++-common/asan/strncpy-overflow-1.c: Likewise.
	* c-c++-common/asan/use-after-free-1.c: Likewise.
	* c-c++-common/asan/alloca_big_alignment.c: Likewise.
	* c-c++-common/asan/alloca_detect_custom_size.c: Likewise.
	* c-c++-common/asan/alloca_overflow_partial.c: Likewise.
	* c-c++-common/asan/alloca_overflow_right.c: Likewise.
	* c-c++-common/asan/alloca_underflow_left.c: Likewise.
	* g++.dg/asan/large-func-test-1.C: Likewise.
	* gfortran.dg/save_6.f90: Add -flto -g variant of save_5.f90.

From-SVN: r251220
2017-08-21 10:29:00 +00:00
Jan Kratochvil ef29f5dd77 include/ChangeLog
2017-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

        * dwarf2.def (DW_IDX_compile_unit, DW_IDX_type_unit, DW_IDX_die_offset)
        (DW_IDX_parent, DW_IDX_type_hash, DW_IDX_lo_user, DW_IDX_hi_user)
        (DW_IDX_GNU_internal, DW_IDX_GNU_external): New.
        * dwarf2.h (DW_IDX, DW_IDX_DUP, DW_FIRST_IDX, DW_END_IDX): New.
        (enum dwarf_name_index_attribute): Remove.
        (get_DW_IDX_name): New declaration.

libiberty/ChangeLog
2017-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

        * dwarfnames.c (DW_FIRST_IDX, DW_END_IDX, DW_IDX, DW_IDX_DUP): New.

From-SVN: r249883
2017-07-02 20:00:48 +00:00
Tony Reix c1d2490437 simple-object-xcoff.c (simple_object_xcoff_find_sections): Search symbol table for .go_export symbol and apply pfn if found.
2017-06-07  Tony Reix  <tony.reix@atos.net>
            Matthieu Sarter  <matthieu.sarter.external@atos.net>
            David Edelsohn  <dje.gcc@gmail.com>

        * simple-object-xcoff.c (simple_object_xcoff_find_sections):
        Search symbol table for .go_export symbol and apply pfn if found.

Co-Authored-By: David Edelsohn <dje.gcc@gmail.com>
Co-Authored-By: Matthieu Sarter <matthieu.sarter.external@atos.net>

From-SVN: r248999
2017-06-07 19:23:55 -04:00
DJ Delorie 63d9caf904 configure.ac (strnlen): Add to AC_CHECK_DECLS.
* configure.ac (strnlen): Add to AC_CHECK_DECLS.
* configure: Likewise.
* config.in: Add HACE_DECL_STRNLEN.

From-SVN: r248721
2017-05-31 00:16:45 -04:00
Iain Buclaw dc64856fdf d-demangle.c (dlang_identifier): Prefix mangled init symbols with `initializer for'.
libiberty/ChangeLog:

	* d-demangle.c (dlang_identifier): Prefix mangled init symbols
	with `initializer for'.
	* testsuite/demangle-expected: Update tests.

From-SVN: r248539
2017-05-27 11:30:22 +00:00
Iain Buclaw 0e3712f6aa d-demangle.c (dlang_call_convention_p): Move declaration before dlang_type.
libiberty/ChangeLog:

	* d-demangle.c (dlang_call_convention_p): Move declaration
	before dlang_type.
	(dlang_type): Handle function types.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r248538
2017-05-27 11:29:52 +00:00
Iain Buclaw 1a122a71ee d-demangle.c (dlang_parse_real): Remove stack buffer, write the demangled hexadecimal directly to string.
libiberty/ChangeLog:

	* d-demangle.c (dlang_parse_real): Remove stack buffer, write
	the demangled hexadecimal directly to string.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r248537
2017-05-27 11:29:38 +00:00
Eli Zaretskii 1ab4db9379 waitpid.c (wait): Define as a macro that calls _cwait, so that this function works on MinGW.
2017-05-24  Eli Zaretskii  <eliz@gnu.org>
* libiberty/waitpid.c (wait) [__MINGW32__]: Define as a macro
that calls _cwait, so that this function works on MinGW.

From-SVN: r248430
2017-05-24 17:35:59 -04:00
Iain Buclaw 5398cab9ca d-demangle.c (dlang_hexdigit): New function.
libiberty/ChangeLog:

	* d-demangle.c (dlang_hexdigit): New function.
	(ascii2hex): Remove function.
	(dlang_parse_string): Update to call dlang_hexdigit.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247455
2017-05-01 23:38:50 +00:00
Iain Buclaw dbe65f77ff d-demangle.c (strtol): Remove declaration.
libiberty/ChangeLog:

	* d-demangle.c (strtol): Remove declaration.
	Updated all callers to use dlang_number.
	(dlang_number): New function.
	(dlang_value): Moved check for ISDIGIT into dlang_parse_integer.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247453
2017-05-01 23:31:24 +00:00
Iain Buclaw 5a4dbf7d31 d-demangle.c (dlang_parse_symbol): Remove function.
libiberty/ChangeLog:

	* d-demangle.c (dlang_parse_symbol): Remove function.
	(dlang_parse_qualified): New function.
	(dlang_parse_mangle): New function.
	(dlang_type): Update to call dlang_parse_qualified.
	(dlang_identifier): Update to call either dlang_parse_qualified or
	dlang_parse_mangle.
	(dlang_type_modifier_p): Remove function.
	(dlang_call_convention_p): Don't allow type modifiers in mangle.
	(dlang_template_args): Update to call dlang_identifier.
	(dlang_demangle): Update to call dlang_parse_mangle.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247450
2017-05-01 22:51:04 +00:00
Iain Buclaw dd03444ba5 d-demangle.c (dlang_value): Add comment explaining why cases for digits are required.
libiberty/ChangeLog:

	* d-demangle.c (dlang_value): Add comment explaining why cases for
	digits are required.
	* testsuite/d-demangle-expected: Update integer value tests.

From-SVN: r247436
2017-05-01 11:01:02 +00:00
Iain Buclaw 98bb7ee2da d-demangle.c (dlang_parse_symbol): Skip over anonymous symbols.
libiberty/ChangeLog:

	* d-demangle.c (dlang_parse_symbol): Skip over anonymous symbols.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247434
2017-05-01 10:50:58 +00:00
Iain Buclaw c6f44bae7e d-demangle.c (dlang_identifier): Handle template constraint symbols.
libiberty/ChangeLog:

	* d-demangle.c (dlang_identifier): Handle template constraint symbols.
	(dlang_parse_template): Only advance if template symbol prefix is
	followed by a digit.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247433
2017-05-01 10:45:35 +00:00
Iain Buclaw ec89d258a0 d-demangle.c (dlang_attributes): Handle scope attributes.
libiberty/ChangeLog:

	* d-demangle.c (dlang_attributes): Handle scope attributes.
	* testsuite/d-demangle-expected: Add tests.

From-SVN: r247432
2017-05-01 10:39:52 +00:00
Jonathan Wakely de3b531c9a PR demangler/80513 check for overflows and invalid characters in thunks
PR demangler/80513
	* cp-demangle.c (d_number): Check for overflow.
	* cplus-dem.c (consume_count): Fix overflow check.
	(gnu_special): Check for underscore after thunk delta.
	* testsuite/demangle-expected: Add tests for overflows and invalid
	characters in thunks.

From-SVN: r247300
2017-04-27 10:44:28 +01:00
Mark Wielaard 6b086d35b7 libiberty: Limit demangler maximum d_print_comp recursion call depth.
The fix for PR demangler/70909 and 67264 (endless demangler recursion)
catches when a demangle_component is printed in a cycle. But that doesn't
protect the call stack blowing up from non-cyclic nested types printed
recursively through d_print_comp. This can happen by a (very) long mangled
string that simply creates a very deep pointer or qualifier chain. Limit
the recursive d_print_comp call depth for a d_print_info to 1K nested
types.

libiberty/ChangeLog:

        * cp-demangle.c (MAX_RECURSION_COUNT): New constant.
        (struct d_print_info): Add recursion field.
        (d_print_init): Initialize recursion.
        (d_print_comp): Check and update d_print_info recursion depth.

From-SVN: r247056
2017-04-21 09:02:03 +00:00
Mark Wielaard 13b6ef76dc libiberty: Always return NULL if d_add_substitution fails.
d_add_substitution can fail for various reasons, like when the subs array
is full. If d_add_substitution fails d_substitution should return NULL
early and not try to continue. Every other call of d_add_substitution
is handled in the same way.

libiberty/ChangeLog:

	* cp-demangle.c (d_substitution): Return NULL if d_add_substitution
	fails.

From-SVN: r247055
2017-04-21 09:01:56 +00:00
Mark Wielaard 1240212c6b libiberty: Don't update and remove did_subs field from demangler structs.
The d_info field did_subs was used for estimating the string output
size. It was no longer used when the malloc-less callback interface
was introduced in 2007 (svn r121305). But the field was still updated.
When backtracking was introduced in 2013 (svn r205292) did_subs was
also added to the d_info_checkpoint struct. But except for updating
the field it was still not used.

Since it is never used just stop updating the field and remove it
from the two structs.

libiberty/ChangeLog:

	* cp-demangle.h (struct d_info): Remove did_subs field.
	* cp-demangle.c (struct d_info_checkpoint): Likewise.
	(d_template_param): Don't update did_subs.
	(d_substitution): Likewise.
	(d_checkpoint): Don't assign did_subs.
	(d_backtrack): Likewise.
	(cplus_demangle_init_info): Don't initialize did_subs.

From-SVN: r247054
2017-04-21 09:01:44 +00:00
Pedro Alves 7a312bbd41 cplus_demangle_fill_component: Handle DEMANGLE_COMPONENT_RVALUE_REFERENCE
This patch almost a decade ago:

...
    2007-08-31  Douglas Gregor  <doug.gregor@gmail.com>

        * cp-demangle.c (d_dump): Handle
        DEMANGLE_COMPONENT_RVALUE_REFERENCE.
        (d_make_comp): Ditto.
...

... missed doing the same change to cplus_demangle_fill_component that
was done to d_make_comp.  I.e., teach it to only validate that we're
not passing in a "right" subtree.  GDB has recently (finally) learned
about rvalue references, and a change to make it use
cplus_demangle_fill_component more ran into an assertion because of
this.

(GDB is the only user of cplus_demangle_fill_component in both the gcc
and binutils-gdb trees.)

libiberty/ChangeLog:
2017-03-27  Pedro Alves  <palves@redhat.com>

	* cp-demint.c (cplus_demangle_fill_component): Handle
	DEMANGLE_COMPONENT_RVALUE_REFERENCE.

From-SVN: r246502
2017-03-27 14:23:49 +00:00
Mark Wielaard 9905ca975c libiberty: Initialize d_printing in all cplus_demangle_fill_* functions.
While integrating the d_printing recursion guard change into gdb I
noticed we forgot to initialize the demangle_component d_printing
field in cplus_demangle_fill_{name,extended_operator,ctor,dtor}.
As is done in cplus_demangle_fill_{component,builtin_type,operator}.
It happened to work because in gcc all demangle_components were
allocated through d_make_empty. But gdb has its own allocation
mechanism (as might other users).

libiberty/ChangeLog:

       * cp-demangle.c (cplus_demangle_fill_name): Initialize
       demangle_component d_printing.
       (cplus_demangle_fill_extended_operator): Likewise.
       (cplus_demangle_fill_ctor): Likewise.
       (cplus_demangle_fill_dtor): Likewise.

From-SVN: r246105
2017-03-13 18:26:47 +00:00
Mark Wielaard a46586c34f Fix PR demangler/70909 and 67264 (endless demangler recursion)
ChangeLog:

       PR demangler/70909
       PR demangler/67264
       * include/demangle.h: Add d_printing to struct demangle_component
       and pass struct demangle_component as non const.

libiberty/ChangeLog:

       PR demangler/70909
       PR demangler/67264
       * cp-demangle.c: Fix endless recursion. Pass
       struct demangle_component as non const.
       (d_make_empty): Initialize variable.
       (d_print_comp_inner): Limit recursion.
       (d_print_comp): Decrement variable.
       * cp-demint.c (cplus_demangle_fill_component): Initialize
       variable.
       (cplus_demangle_fill_builtin_type): Likewise.
       (cplus_demangle_fill_operator): Likewise.
       * testsuite/demangle-expected: Add tests.

From-SVN: r245978
2017-03-08 14:28:38 +00:00
Markus Trippelsdorf 4bbc35f33f Fix PR70182 -- missing "on" in mangling of unresolved operators
The ABI says:

<unresolved-name>
   ::= [gs] <base-unresolved-name>
   ::= sr <unresolved-type> <base-unresolved-name>
   ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name>
   ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name>

<base-unresolved-name>
   ::= <simple-id>
   ::= on <operator-name>
   ::= on <operator-name> <template-args>
   ::= dn <destructor-name

libiberty:

	PR c++/70182
	* cp-demangle.c (d_unqualified_name): Handle "on" for
	operator names.
	* testsuite/demangle-expected: Add tests.

gcc/cp:

	PR c++/70182
	* mangle.c (write_template_args): Add "on" for operator names.

gcc:

	PR c++/70182
	* doc/invoke.texi (fabi-version): Mention mangling fix for
	operator names.

From-SVN: r244567
2017-01-18 08:49:11 +00:00
Markus Trippelsdorf f6efea5163 Fix PR77489 -- mangling of discriminator >= 1
libiberty:

	PR c++/77489
	* cp-demangle.c (d_discriminator): Handle discriminator >= 10.
	* testsuite/demangle-expected: Add tests for discriminator.

gcc:
	PR c++/77489
	* doc/invoke.texi (fabi-version): Document discriminator mangling.

gcc/cp:

	PR c++/77489
	* mangle.c (write_discriminator): Handle discriminator >= 10.

From-SVN: r244566
2017-01-18 08:40:05 +00:00
Jakub Jelinek 2afd3180c5 Update copyright years.
From-SVN: r244052
2017-01-04 12:30:51 +01:00
Alan Modra 8f56cb5163 Update configure deps, remove stray \xA0 in picflag.m4, regenerate
Also fix a stray changelog entry.  Some of the regen here is due to
previous changes not being regenerated properly, in part due to the
missing configure dependencies.

	* configure: Regenerate.
config/
	* picflag.m4: Remove stray \xA0 in comment.
gcc/
	* Makefile.in (aclocal_deps): Update and order as per aclocal.m4.
	* configure: Regenerate.
	* config.in: Regenerate.
libada/
	* Makefile.in (configure_deps): Update and order as per
	configure.ac sinclude.
	* configure: Regenerate.
libgcc/
	* Makefile.in (configure_deps): Update.
	* configure: Regenerate.
libiberty/
	* Makefile.in (configure_deps): Update.
	* configure: Regenerate.
libitm/
	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

From-SVN: r244049
2017-01-04 18:59:34 +10:30
Jakub Jelinek 816f431440 re PR c++/78761 (C++14, compiler generate mangled name that can not be demangled)
PR c++/78761
	* cp-demangle.c (cplus_demangle_type): Demangle Dc as decltype(auto).
	* testsuite/demangle-expected: Add test for decltype(auto).

From-SVN: r243593
2016-12-13 07:16:05 +01:00
Nathan Sidwell 8e09a726e6 re PR other/78252 (C++ demangler crashes with infinite recursion with lambda (auto))
libiberty/
	PR c++/78252
	* cp-demangle.c (struct d_print_info): Add is_lambda_arg field.
	(d_print_init): Initialize it.
	(d_print_comp_inner) <DEMANGLE_COMPONENT_TEMPLATE_PARAM>: Check
	is_lambda_arg for auto.
	<DEMANGLE_COMPONENT_REFERENCE,
	DEMANGLE_COMPONENT_RVALUE_REFERENCE>: Skip smashing check when
	is_lambda_arg.
	<DEMANGLE_COMPONENT_LAMBDA>: Increment is_lambda_arg around arg
	printing.
	* testsuite/demangle-expected: Add lambda auto mangling cases.

	gcc/testsuite/
	PR c++/78252
	* g++.dg/cpp1y/lambda-mangle-1.C: New.

From-SVN: r243566
2016-12-12 17:00:37 +00:00
DJ Delorie 1d2ccddf2e Oops, fix date
From-SVN: r243281
2016-12-06 01:40:07 -05:00
DJ Delorie 2207ff5dd1 * argv.c (expandargv): Check for directories passed as @-files.
From-SVN: r243280
2016-12-06 01:38:23 -05:00
David Malcolm e613205cef libiberty: avoid reading past end of buffer in strndup/xstrndup (PR c/78498)
gcc/ChangeLog:
	PR c/78498
	* selftest.c (selftest::assert_strndup_eq): New function.
	(selftest::test_strndup): New function.
	(selftest::test_libiberty): New function.
	(selftest::selftest_c_tests): Call test_libiberty.

gcc/testsuite/ChangeLog:
	PR c/78498
	* gcc.dg/format/pr78494.c: New test case.

libiberty/ChangeLog:
	PR c/78498
	* strndup.c (strlen): Delete decl.
	(strnlen): Add decl.
	(strndup): Call strnlen rather than strlen.
	* xstrndup.c (xstrndup): Likewise.

From-SVN: r243030
2016-11-30 14:50:43 +00:00
Nathan Sidwell 8684b29203 * cp-demangle.c (d_print_comp_inner): Fix parameter indentation.
From-SVN: r242963
2016-11-29 15:28:52 +00:00
David Tolnay 10d48c59b0 libiberty: Add Rust symbol demangling.
Adds Rust symbol demangler. Rust mangles symbols using GNU_V3 style,
adding a hash and various special character subtitutions. This adds
a new rust style to cplus_demangle and adds 3 helper functions
rust_demangle, rust_demangle_sym and rust_is_mangled.

rust-demangle.c was written by David. Mark did the code formatting to
GNU style and integration into the gcc/libiberty build system and
testsuite.

include/ChangeLog:

2016-11-03  David Tolnay <dtolnay@gmail.com>
           Mark Wielaard  <mark@klomp.org>

       * demangle.h (DMGL_RUST): New macro.
       (DMGL_STYLE_MASK): Add DMGL_RUST.
       (demangling_styles): Add dlang_rust.
       (RUST_DEMANGLING_STYLE_STRING): New macro.
       (RUST_DEMANGLING): New macro.
       (rust_demangle): New prototype.
       (rust_is_mangled): Likewise.
       (rust_demangle_sym): Likewise.

libiberty/ChangeLog:

2016-11-03  David Tolnay <dtolnay@gmail.com>
           Mark Wielaard  <mark@klomp.org>

       * Makefile.in (CFILES): Add rust-demangle.c.
       (REQUIRED_OFILES): Add rust-demangle.o.
       * cplus-dem.c (libiberty_demanglers): Add rust_demangling case.
       (cplus_demangle): Handle RUST_DEMANGLING.
       (rust_demangle): New function.
       * rust-demangle.c: New file.
       * testsuite/Makefile.in (really-check): Add check-rust-demangle.
       (check-rust-demangle): New rule.
       * testsuite/rust-demangle-expected: New file.

Co-Authored-By: Mark Wielaard <mark@klomp.org>

From-SVN: r242524
2016-11-16 23:09:27 +00:00
Mark Wielaard 168126e598 libiberty: demangler crash with missing :? or fold expression component.
When constructing an :? or fold expression that requires a third
expression only the first and second were explicitly checked to
not be NULL. Since the third expression is also required in these
constructs it needs to be explicitly checked and rejected when missing.
Otherwise the demangler will crash once it tries to d_print the
NULL component. Added two examples to demangle-expected of strings
that would crash before this fix.

Found by American Fuzzy Lop (afl) fuzzer.

From-SVN: r242451
2016-11-15 19:31:59 +00:00
Mark Wielaard 0d0bfbf47c libiberty: Fix some demangler crashes caused by reading past end of input.
In various situations the cplus_demangle () function could read past the
end of input causing crashes. Add checks in various places to not advance
the demangle string location and fail early when end of string is reached.
Add various examples of input strings to the testsuite that would crash
test-demangle before the fixes.

Found by using the American Fuzzy Lop (afl) fuzzer.

libiberty/ChangeLog:

       * cplus-dem.c (demangle_signature): After 'H', template function,
       no success and don't advance position if end of string reached.
       (demangle_template): After 'z', template name, return zero on
       premature end of string.
       (gnu_special): Guard strchr against searching for zero characters.
       (do_type): If member, only advance mangled string when 'F' found.
       * testsuite/demangle-expected: Add examples of strings that could
       crash the demangler by reading past end of input.

From-SVN: r242450
2016-11-15 19:31:50 +00:00
Matthias Klose 2b60167833 - Revert last commit, restore the regenerated files aclocal.m4 and configure
From-SVN: r242438
2016-11-15 17:27:39 +00:00
Matthias Klose 84c1b9d3d4 config-ml.in: Remove references to GCJ.
<toplevel>

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* config-ml.in: Remove references to GCJ.
	* configure.ac: Likewise.
	* configure: Regenerate.

config/

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	multi.m4: Don't set GCJ.

gcc/

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* doc/install.texi: Remove references to gcj/libjava.
	* doc/invoke.texi: Likewise.

*/ (where necessary)

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* configure: Regenerate.

From-SVN: r242433
2016-11-15 16:34:02 +00:00
Mark Wielaard 3eb89071d6 libiberty: Add -Wshadow=local to warning flags (if supported).
libiberty/ChangeLog:

       * configure.ac (ac_libiberty_warn_cflags): Add -Wshadow=local.
       * configure: Regenerated.

From-SVN: r242396
2016-11-14 19:46:26 +00:00
Jason Merrill 51dc660315 Implement P0012R1, Make exception specifications part of the type system.
gcc/cp/
	* cp-tree.h (enum tsubst_flags): Add tf_fndecl_type.
	(flag_noexcept_type, ce_type): New.
	* call.c (build_conv): Add ck_fnptr.
	(enum conversion_kind): Change ck_tsafe to ck_fnptr.
	(convert_like_real): Likewise.
	(standard_conversion): Likewise.  Allow function pointer
	conversions for pointers to member functions.
	(reference_compatible_p): Allow function pointer conversions.
	(direct_reference_binding): Likewise.
	(reference_binding): Reference-compatible is no longer a subset of
	reference-related.
	(is_subseq): Also strip ck_lvalue after next_conversion.
	* class.c (instantiate_type): Check fnptr_conv_p.
	(resolve_address_of_overloaded_function): Likewise.
	* cvt.c (can_convert_tx_safety): Now static.
	(noexcept_conv_p, fnptr_conv_p, strip_fnptr_conv): New.
	* decl.c (flag_noexcept_type): Define.
	(cxx_init_decl_processing): Set it.
	(bad_specifiers): Check it.
	(grokdeclarator) [cdk_function]: Add exception-spec to type here.
	* lambda.c (maybe_add_lambda_conv_op): Add exception-spec to
	returned pointer.
	* mangle.c (struct globals): Add need_cxx1z_warning.
	(mangle_decl): Check it.
	(write_exception_spec): New.
	(write_function_type): Call it.
	(canonicalize_for_substitution): Handle exception spec.
	(write_type): Likewise.
	(write_encoding): Set processing_template_decl across mangling of
	partially-instantiated type.
	* pt.c (determine_specialization): Pass tf_fndecl_type.
	(tsubst_decl, fn_type_unification): Likewise.
	(tsubst): Strip tf_fndecl_type, pass it to
	tsubst_exception_specification.
	(convert_nontype_argument_function): Handle function pointer
	conversion.
	(convert_nontype_argument): Likewise.
	(unify, for_each_template_parm_r): Walk into noexcept-specifier.
	* rtti.c (ptr_initializer): Encode noexcept.
	* tree.c (canonical_eh_spec): New.
	(build_exception_variant): Use it.
	* typeck.c (composite_pointer_type): Handle fnptr conversion.
	(comp_except_specs): Compare canonical EH specs.
	(structural_comptypes): Call it.
gcc/c-family/
	* c.opt (Wc++1z-compat): New.
	* c-cppbuiltin.c (c_cpp_builtins): Add __cpp_noexcept_function_type.
libstdc++-v3/
	* include/bits/c++config (_GLIBCXX_NOEXCEPT_PARM)
	(_GLIBCXX_NOEXCEPT_QUAL): New.
	* include/std/type_traits (is_function): Use them.
	* libsubc++/new (launder): Likewise.
	* libsupc++/cxxabi.h (__pbase_type_info::__masks): Add
	__noexcept_mask.
	* libsupc++/pbase_type_info.cc (__do_catch): Handle function
	pointer conversion.
libiberty/
	* cp-demangle.c (is_fnqual_component_type): New.
	(d_encoding, d_print_comp_inner, d_print_mod_list): Use it.
	(FNQUAL_COMPONENT_CASE): New.
	(d_make_comp, has_return_type, d_print_comp_inner)
	(d_print_function_type): Use it.
	(next_is_type_qual): New.
	(d_cv_qualifiers, d_print_mod): Handle noexcept and throw-spec.
include/
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_THROW_SPEC.

From-SVN: r241944
2016-11-07 18:09:29 -05:00
Mark Wielaard c4ec8585dc libiberty: Fix -Wimplicit-fallthrough warnings.
Adjust some comments, add some explicit fall through comments or explicit
returns where necessary to not get implicit-fallthrough warnings.

All fall throughs were deliberate. In one case I added an explicit return
false for clarity instead of falling through a default case (that also
would return false).

libiberty/ChangeLog:

       * cplus-dem.c (demangle_signature): Move fall through comment.
       (demangle_fund_type): Add fall through comment between 'G' and 'I'.
       * hashtab.c (iterative_hash): Add fall through comments.
       * regex.c (regex_compile): Add Fall through comment after '+'/'?'.
       (byte_re_match_2_internal): Add Fall through comment after jump_n.
       Change "Note fall through" to "Fall through".
       (common_op_match_null_string_p): Return false after set_number_at
       instead of fall through.

From-SVN: r241864
2016-11-04 23:55:01 +00:00
Jason Merrill 31f7f784fe Implement P0136R1, Rewording inheriting constructors.
gcc/c-family/
	* c.opt (-fnew-inheriting-ctors): New.
	* c-opts.c: Default to on for ABI 11+.
gcc/cp/
	* call.c (enum rejection_reason_code): Add rr_inherited_ctor.
	(inherited_ctor_rejection): New.
	(add_function_candidate): Reject inherited ctors for copying.
	(enforce_access): Use strip_inheriting_ctors.
	(print_z_candidate): Likewise.  Handle rr_inherited_ctor.
	(convert_like_real): Avoid copying inheriting ctor parameters.
	(build_over_call): Likewise.  A base ctor inheriting from vbase
	has no parms.  Sorry about varargs.
	(joust): A local constructor beats inherited with the same convs.
	* class.c (add_method): Handle hiding inheriting ctors.
	(one_inherited_ctor): Handle new semantics.
	(add_implicitly_declared_members): Pass using_decl down.
	(build_clone): A base ctor inheriting from vbase has no parms.
	* cp-tree.h (DECL_INHERITED_CTOR): Store this instead of the base.
	(SET_DECL_INHERITED_CTOR): Likewise.
	(DECL_INHERITED_CTOR_BASE): Adjust.
	* constexpr.c: Adjust.
	* error.c (dump_function_decl): Decorate inheriting ctors.
	* init.c (emit_mem_initializers): Suppress access control in
	inheriting ctor.
	* mangle.c (write_special_name_constructor): Handle new inheriting
	ctor mangling.
	* method.c (strip_inheriting_ctors, inherited_ctor_binfo)
	(ctor_omit_inherited_parms, binfo_inherited_from): New.
	(synthesized_method_walk): Use binfo_inherited_from.  Suppress
	access control in inheriting ctor.
	(deduce_inheriting_ctor): Deleted if ambiguous ctor inheritance.
	(maybe_explain_implicit_delete): Explain ambigous ctor inheritance.
	(add_one_base_init, do_build_copy_constructor): Adjust.
	(locate_fn_flags, explain_implicit_non_constexpr): Adjust.
	(implicitly_declare_fn): Adjust.
	(get_inherited_ctor): Remove.
	* name-lookup.c (do_class_using_decl): Check for indirect ctor
	inheritance.
	* optimize.c (cdtor_comdat_group): Adjust for new mangling.
	(maybe_clone_body): Handle omitted parms in base clone.
	(maybe_thunk_body): Don't thunk if base clone omits parms.
	* pt.c (tsubst_decl): Adjust.
	(instantiate_template_1): Suppress access control in inheriting
	ctor.
	(fn_type_unification): Do deduction with inherited ctor.
	* tree.c (special_function_p): Adjust.
gcc/
	* tree-inline.c (copy_tree_body_r): Only copy the taken branch of
	a COND_EXPR with constant condition.
libiberty/
	* cp-demangle.c (d_ctor_dtor_name): Handle inheriting constructor.

From-SVN: r241765
2016-11-01 21:50:29 -04:00
Mark Wielaard a3f3eec079 libiberty: Fix memory leak in ada_demangle when symbol cannot be demangled.
When a symbol cannot be demangled in ada_demangle a new demangled VEC
will be allocated without deleting the demangled VEC already in use.

Running testsuite/test-demangle under valgrind will show the leak for
this entry in testsuite/demangle-expected:

    # Elaborated flag (not demangled)
    --format=gnat
    x_E
    <x_E>

 11 bytes in 1 blocks are definitely lost in loss record 1 of 1
    at 0x4C27BE3: malloc (vg_replace_malloc.c:299)
    by 0x413FE7: xmalloc (xmalloc.c:148)
    by 0x4025EC: ada_demangle (cplus-dem.c:930)
    by 0x402C59: cplus_demangle (cplus-dem.c:892)
    by 0x400FEC: main (test-demangle.c:317)

libiberty/ChangeLog:

	* cplus-dem.c (ada_demangle): Initialize demangled to NULL and
	XDELETEVEC demangled when unknown.

From-SVN: r241760
2016-11-01 23:13:10 +00:00
Andrew Stubbs 471a0d47ae Fix zero-length parameter bug in pex_run.
2016-09-19  Andrew Stubbs  <ams@codesourcery.com>

	libiberty/
	* pex-win32.c (argv_to_cmdline): Quote zero-length parameters.

	libiberty/testsuite/
	* test-pexecute.c (main): Insert check for zero-length parameters.

From-SVN: r240229
2016-09-19 10:02:56 +00:00
Mark Wielaard 99e77371ca Fix -Wshadow warning in libiberty/cp-demangle.c
valgrind contains a copy of the libiberty demangler which gets compiled
with -Wshadow. That shows the following warning:

cp-demangle.c: In function ‘d_substitution’:
cp-demangle.c:3772:35: warning: declaration of ‘c’ shadows a previous local
        struct demangle_component *c;
                                   ^
cp-demangle.c:3708:8: note: shadowed declaration is here
   char c;
        ^

Fix that by renaming the struct demangle_component variable to dc.

libiberty/ChangeLog:

	* cp-demangle.c (d_substitution): Change struct demangle_component
	variable name from c to dc.

From-SVN: r240068
2016-09-10 10:37:35 +00:00
Marek Polacek 191816a36b re PR c/7652 (-Wswitch-break : Warn if a switch case falls through)
PR c/7652
gcc/
	* alias.c (find_base_value): Adjust fall through comment.
	* cfgexpand.c (expand_debug_expr): Likewise.
	* combine.c (find_split_point): Likewise.
	(expand_compound_operation): Likewise.  Add FALLTHRU.
	(make_compound_operation): Adjust fall through comment.
	(canon_reg_for_combine): Add FALLTHRU.
	(force_to_mode): Adjust fall through comment.
	(simplify_shift_const_1): Likewise.
	(simplify_comparison): Likewise.
	* config/aarch64/aarch64-builtins.c (aarch64_simd_expand_args): Add
	FALLTHRU.
	* config/aarch64/predicates.md: Likewise.
	* config/i386/i386.c (function_arg_advance_32): Likewise.
	(ix86_gimplify_va_arg): Likewise.
	(print_reg): Likewise.
	(ix86_print_operand): Likewise.
	(ix86_build_const_vector): Likewise.
	(ix86_expand_branch): Likewise.
	(ix86_sched_init_global): Adjust fall through comment.
	(ix86_expand_args_builtin): Add FALLTHRU.
	(ix86_expand_builtin): Likewise.
	(ix86_expand_vector_init_one_var): Likewise.
	* config/rs6000/rs6000.c (rs6000_emit_vector_compare_inner): Likewise.
	(rs6000_adjust_cost): Likewise.
	(insn_must_be_first_in_group): Likewise.
	* config/rs6000/rs6000.md: Likewise.  Adjust fall through comment.
	* dbxout.c (dbxout_symbol): Adjust fall through comment.
	* df-scan.c (df_uses_record): Likewise.
	* dojump.c (do_jump): Add FALLTHRU.
	* dwarf2out.c (mem_loc_descriptor): Likewise.  Adjust fall through
	comment.
	(resolve_args_picking_1): Adjust fall through comment.
	(loc_list_from_tree_1): Likewise.
	* expmed.c (make_tree): Likewise.
	* expr.c (expand_expr_real_2): Add FALLTHRU.
	(expand_expr_real_1): Likewise.  Adjust fall through comment.
	* fold-const.c (const_binop): Adjust fall through comment.
	(fold_truth_not_expr): Likewise.
	(fold_cond_expr_with_comparison): Add FALLTHRU.
	(fold_binary_loc): Likewise.
	(contains_label_1): Adjust fall through comment.
	(multiple_of_p): Likewise.
	* gcov-tool.c (process_args): Add FALLTHRU.
	* genattrtab.c (check_attr_test): Likewise.
	(write_test_expr): Likewise.
	* genconfig.c (walk_insn_part): Likewise.
	* genpreds.c (validate_exp): Adjust fall through comment.
	(needs_variable): Likewise.
	* gensupport.c (get_alternatives_number): Add FALLTHRU.
	(subst_dup): Likewise.
	* gimple-pretty-print.c (dump_gimple_assign): Likewise.
	* gimplify.c (gimplify_addr_expr): Adjust fall through comment.
	(gimplify_scan_omp_clauses): Add FALLTHRU.
	(goa_stabilize_expr): Likewise.
	* graphite-isl-ast-to-gimple.c (substitute_ssa_name): Adjust fall
	through comment.
	* hsa-gen.c (get_address_from_value): Likewise.
	* ipa-icf.c (sem_function::hash_stmt): Likewise.
	* ira.c (ira_setup_alts): Add FALLTHRU.
	* lra-eliminations.c (lra_eliminate_regs_1): Adjust fall through
	comment.
	* lto-streamer-out.c (lto_output_tree_ref): Add FALLTHRU.
	* opts.c (common_handle_option): Likewise.
	* read-rtl.c (read_rtx_code): Likewise.
	* real.c (round_for_format): Likewise.
	* recog.c (asm_operand_ok): Likewise.
	* reginfo.c (reg_scan_mark_refs): Adjust fall through comment.
	* reload1.c (set_label_offsets): Likewise.
	(eliminate_regs_1): Likewise.
	(reload_reg_reaches_end_p): Likewise.
	* rtlanal.c (commutative_operand_precedence): Add FALLTHRU.
	(rtx_cost): Likewise.
	* sched-rgn.c (is_exception_free): Likewise.
	* simplify-rtx.c (simplify_rtx): Adjust fall through comment.
	* stor-layout.c (int_mode_for_mode): Likewise.
	* toplev.c (print_to_asm_out_file): Likewise.
	(print_to_stderr): Likewise.
	* tree-cfg.c (gimple_verify_flow_info): Likewise.
	* tree-chrec.c (chrec_fold_plus_1): Add FALLTHRU.
	(chrec_fold_multiply): Likewise.
	(evolution_function_is_invariant_rec_p): Likewise.
	(for_each_scev_op): Likewise.
	* tree-data-ref.c (siv_subscript_p): Likewise.
	(get_references_in_stmt): Likewise.
	* tree.c (find_placeholder_in_expr): Adjust fall through comment.
	(substitute_in_expr): Likewise.
	(type_cache_hasher::equal): Likewise.
	(walk_type_fields): Likewise.
	* var-tracking.c (adjust_mems): Add FALLTHRU.
	(set_dv_changed): Adjust fall through comment.
	* varasm.c (default_function_section): Add FALLTHRU.
gcc/c-family/
	* c-common.c (scalar_to_vector): Adjust fall through comment.
	* c-opts.c (c_common_handle_option): Likewise.
	* c-pragma.c (handle_pragma_pack): Add FALLTHRU.
	* c-pretty-print.c (c_pretty_printer::postfix_expression): Adjust
	fall through comment.
	* cilk.c (extract_free_variables): Add FALLTHRU.
gcc/c/
	* c-parser.c (c_parser_external_declaration): Add FALLTHRU.
	(c_parser_postfix_expression): Likewise.
	* c-typeck.c (build_unary_op): Adjust fall through comment.
	(c_mark_addressable): Likewise.
gcc/cp/
	* call.c (add_builtin_candidate): Add FALLTHRU.
	(build_integral_nontype_arg_conv): Adjust fall through comment.
	(build_new_op_1): Add FALLTHRU.
	(convert_like_real): Adjust fall through comment.
	* class.c (fixed_type_or_null): Likewise.
	* constexpr.c (cxx_eval_constant_expression): Likewise.
	(potential_constant_expression_1): Likewise.  Add FALLTHRU.
	* cp-gimplify.c (cp_gimplify_expr): Adjust fall through comment.
	(cp_fold): Add FALLTHRU.
	* cvt.c (build_expr_type_conversion): Adjust fall through comment.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Add FALLTHRU.
	(pp_cxx_qualified_id): Likewise.
	(cxx_pretty_printer::constant): Adjust fall through comment.
	(cxx_pretty_printer::primary_expression): Add FALLTHRU.
	(pp_cxx_pm_expression): Adjust fall through comment.
	(cxx_pretty_printer::expression): Add FALLTHRU.
	(cxx_pretty_printer::declaration_specifiers): Reformat code.
	(pp_cxx_type_specifier_seq): Adjust fall through comment.
	(pp_cxx_ptr_operator): Likewise.  Add FALLTHRU.
	* error.c (dump_type): Adjust fall through comment.
	(dump_decl): Likewise.
	* mangle.c (write_type): Likewise.
	* method.c (synthesized_method_walk): Add FALLTHRU.
	* name-lookup.c (arg_assoc_type): Likewise.
	* parser.c (cp_lexer_print_token): Adjust fall through comment.
	(cp_parser_primary_expression): Add FALLTHRU.
	(cp_parser_operator): Likewise.
	* pt.c (find_parameter_packs_r): Likewise.
	(tsubst_aggr_type): Adjust fall through comment.
	* semantics.c (finish_omp_clauses): Add FALLTHRU.
	* tree.c (lvalue_kind): Likewise.
gcc/fortran/
	* decl.c (match_attr_spec): Add FALLTHRU.
	* primary.c (match_arg_list_function): Likewise.
	* resolve.c (resolve_operator): Adjust fall through comment.
	(fixup_charlen): Add FALLTHRU.
	(resolve_allocate_expr): Adjust fall through comment.
	* trans-array.c (gfc_conv_ss_startstride): Add FALLTHRU.
	* trans-intrinsic.c (gfc_conv_intrinsic_len): Adjust fall through
	comment.
gcc/java/
	* expr.c (java_truthvalue_conversion): Adjust fall through comment.
	* jcf-io.c (verify_constant_pool): Likewise.
	* typeck.c (promote_type): Likewise.
gcc/objc/
	* objc-encoding.c (encode_type): Add FALLTHRU.
libcpp/
	* lex.c (search_line_fast): Add FALLTHRU.
	(_cpp_lex_direct): Likewise.
	(cpp_token_val_index): Adjust fall through comment.
	* macro.c (parse_params): Add FALLTHRU.
	* pch.c (count_defs): Adjust fall through comment.
	(write_defs): Likewise.
libiberty/
	* cp-demangle.c (d_print_mod): Add FALLTHRU.

From-SVN: r239410
2016-08-12 10:30:47 +00:00
Marcel Böhme 1841e25ca5 re PR c++/71696 (Libiberty Demangler segfaults (6))
2016-08-04  Marcel Böhme  <boehme.marcel@gmail.com>

	PR c++/71696
	* cplus-dem.c: Prevent infinite recursion when there is a cycle
	in the referencing of remembered mangled types.
	(work_stuff): New stack to keep track of the remembered mangled
	types that are currently being processed.
	(push_processed_type): New method to push currently processed
	remembered type onto the stack.
	(pop_processed_type): New method to pop currently processed
	remembered type from the stack.
	(work_stuff_copy_to_from): Copy values of new variables.
	(delete_non_B_K_work_stuff): Free stack memory.
	(demangle_args): Push/Pop currently processed remembered type.
	(do_type): Do not demangle a cyclic reference and push/pop
	referenced remembered type.

From-SVN: r239143
2016-08-04 10:53:18 -06:00
Aldy Hernandez ac631cbe70 libiberty.h (MAX_ALLOCA_SIZE): New macro.
include/
	* libiberty.h (MAX_ALLOCA_SIZE): New macro.

libiberty/
	* make-relative-prefix.c (make_relative_prefix_1): Fall back to
	malloc if alloca argument is greater than MAX_ALLOCA_SIZE.

From-SVN: r238880
2016-07-29 16:40:55 +00:00
Jason Merrill 7864eaaff7 Demangle C++17 fold-expressions.
* cp-demangle.c (cplus_demangle_operators): Add f[lrLR].
	(d_expression_1): Handle them.
	(d_maybe_print_fold_expression): New.
	(d_print_comp_inner): Use it.
	(d_index_template_argument): Handle negative index.

From-SVN: r238437
2016-07-18 11:28:51 -04:00
Jason Merrill 34bbc4c502 PR c++/71814 - mangling sizeof... (sP and sZ)
gcc/cp/
	* mangle.c (write_expression): Handle sizeof... an argument pack.
libiberty/
	* cp-demangle.c (cplus_demangle_operators): Add sP and sZ.
	(d_print_comp_inner): Handle them.
	(d_template_args_1): Split out from d_template_args.
	(d_args_length): New.

From-SVN: r238389
2016-07-15 14:38:15 -04:00
Marcel Böhme 03ef0c6c55 re PR c++/70926 (Libiberty Demangler segfaults (5))
PR c++/70926
	* cplus-dem.c: Handle large values and overflow when demangling
	length variables.
	(demangle_template_value_parm): Read only until end of mangled string.
	(do_hpacc_template_literal): Likewise.
	(do_type): Handle overflow when demangling array indices.

From-SVN: r238313
2016-07-13 16:06:09 -06:00
Brooks Moses 3f39385351 cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length VLAs.
2016-06-12  Brooks Moses  <bmoses@google.com>

	* cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length
	  VLAs.

From-SVN: r238233
2016-07-11 16:48:41 -07:00
Alan Modra 051154a1f6 Don't needlessly clear xmemdup allocated memory.
* xmemdup.c (xmemdup): Use xmalloc rather than xcalloc.

From-SVN: r236917
2016-05-31 20:38:54 +09:30
Jakub Jelinek 73fb6a9d96 Move ChangeLog entry to the right file.
PR other/61321
	PR other/61233
	* demangle.h (enum demangle_component_type)
	<DEMANGLE_COMPONENT_CONVERSION>: New value.

From-SVN: r236449
2016-05-19 11:55:01 +02:00
Jakub Jelinek 969ac969c7 Remove libiberty/ path prefixes.
From-SVN: r236448
2016-05-19 11:27:57 +02:00
Jakub Jelinek e1fe3c698f re PR c++/70498 (Libiberty Demangler segfaults (3))
PR c++/70498
	* cp-demangle.c (d_expression_1): Formatting fix.

From-SVN: r236445
2016-05-19 10:49:30 +02:00
Jakub Jelinek a3fa753567 Fix up 2 ChangeLog entries.
From-SVN: r236443
2016-05-19 10:34:39 +02:00
Artemiy Volkov 9b27f1138f cplus-dem.c (enum type_kind_t): Add tk_rvalue_reference constant.
* cplus-dem.c (enum type_kind_t): Add tk_rvalue_reference
        constant.
        (demangle_template_value_parm): Handle tk_rvalue_reference
        type kind.
        (do_type): Support 'O' type id (rvalue references).

        * testsuite/demangle-expected: Add tests.

From-SVN: r236434
2016-05-18 15:52:26 -06:00
Marcel Böhme bfbc839a0b Demangler integer overflow fixes from Marcel Böhme.
PR c++/70498
	* cp-demangle.c: Parse numbers as integer instead of long to avoid
	overflow after sanity checks. Include <limits.h> if available.
	(INT_MAX): Define if necessary.
	(d_make_template_param): Takes integer argument instead of long.
	(d_make_function_param): Likewise.
	(d_append_num): Likewise.
	(d_identifier): Likewise.
	(d_number): Parse as and return integer.
	(d_compact_number): Handle overflow.
	(d_source_name): Change variable type to integer for parsed number.
	(d_java_resource): Likewise.
	(d_special_name): Likewise.
	(d_discriminator): Likewise.
	(d_unnamed_type): Likewise.
	* testsuite/demangle-expected: Add regression test cases.

From-SVN: r235767
2016-05-02 17:06:40 +00:00
Oleg Endo bc6d901463 config.guess: Remove SH5 support.
/
	* config.guess:  Remove SH5 support.
	* config.sub: Likewise.
	* configure: Likewise.
	* configure.ac: Likewise.

config/
	* picflag.m4:  Remove SH5 support.

gcc/
	* config/sh/t-sh: Remove SH5 support.
	* config.gcc: Likewise.
	* configure: Likewise.

contrib/
	* compare-all-tests: Remove SH5 support.
	* config-list.mk: Likewise.

libada/
	* configure: Remove SH5 support.

libgcc/
	* config.host: Remove SH5 support.
	* configure: Likewise.

libiberty/
	* configure: Remove SH5 support.

libjava/
	* classpath/config.guess: Remove SH5 support.
	* classpath/config.sub: Likewise.

From-SVN: r235676
2016-04-30 09:11:03 +00:00
Bernd Schmidt cb2763b5c4 Fix PR number in ChangeLog
From-SVN: r234830
2016-04-08 12:17:03 +00:00
Marcel Böhme bdf66f7734 Fix memory allocation size overflows (PR69687, patch by Marcel Böhme)
PR c++/69687
	* cplus-dem.c: Include <limits.h> if available.
	(INT_MAX): Define if necessary.
	(remember_type, remember_Ktype, register_Btype, string_need):
	Abort if we detect cases where we the size of the allocation would
	overflow.

From-SVN: r234829
2016-04-08 12:10:21 +00:00
Marcel Böhme 59dad006fa Handle an overflow case (PR70498, patch by Marcel Böhme).
PR c++/70498
	* cplus-dem.c (gnu_special): Handle case where consume_count returns
	-1.

From-SVN: r234828
2016-04-08 12:06:59 +00:00
Jeff Law c1c341ab92 Add BZ markers to last commit
From-SVN: r234646
2016-03-31 11:23:21 -06:00
Mikhail Maltsev 916268f1f2 cplus-dem.c (squangle_mop_up): Zero bsize/ksize after freeing btypevec/ktypevec.
* cplus-dem.c (squangle_mop_up): Zero bsize/ksize after freeing
	btypevec/ktypevec.
	* testsuite/demangle-expected: Add coverage tests.

From-SVN: r234645
2016-03-31 11:20:53 -06:00
Iain Buclaw 13617162e3 d-demangle.c (dlang_call_convention): Handle extern Objective-C function calling convention.
libiberty/ChangeLog:

2016-01-26  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_call_convention): Handle extern Objective-C
	function calling convention.
	(dlang_call_convention_p): Likewise.
	(dlang_type): Likewise.
	* testsuite/d-demangle-expected: Add coverage tests.

From-SVN: r232864
2016-01-27 01:07:26 +00:00
Iain Buclaw acf1f7da96 d-demangle.c (dlang_function_args): Append ',' for variadic functions only if parameters were seen before the...
libiberty/ChangeLog:

2016-01-26  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_function_args): Append ',' for variadic functions
	only if parameters were seen before the elipsis symbol.
	* testsuite/d-demangle-expected: Add coverage test for parameter-less
	variadic functions.

From-SVN: r232863
2016-01-27 01:07:17 +00:00
Iain Buclaw 0f4b8b316f d-demangle.c (dlang_type): Handle function types only in the context of seeing a pointer type symbol.
libiberty/ChangeLog:

2016-01-27  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_type): Handle function types only in the context
	of seeing a pointer type symbol.
	* testsuite/d-demangle-expected: Update function pointer tests.

From-SVN: r232862
2016-01-27 01:07:08 +00:00
Mike Frysinger 66f49f07d8 libiberty: {count,dup,write}argv: constify argv input slightly
Would be more useful if we could use "const char * const *", but there's
a long standing bug where gcc warns about incompatible pointers when you
try to pass in "char **".  We can at least constify the array itself as
gcc will not warn in that case.

From-SVN: r232089
2016-01-05 20:23:30 +00:00
Mike Frysinger ae120683c6 libiberty: dupargv: rewrite to use xstrdup
This func is basically open coding the xstrdup function, so gut it
and use that directly.

From-SVN: r232086
2016-01-05 19:55:21 +00:00
Patrick Palka f3ce64372c Tweak the documentation of libiberty's xcrc32 function
libiberty/ChangeLog;

	* crc32.c: In the documentation, don't refer to GDB's
	now-nonexistent crc32 implementation.  In the table-generation
	program embedded within the documentation, change the type of
	the induction variables i and j from int to unsigned int, to
	avoid undefined behavior.

From-SVN: r231983
2015-12-28 22:00:14 +00:00
Nick Clifton f8e663301f re PR other/66827 (left shifts of negative value warnings due to C++14 switch)
PR 66827
	* regex.c (EXTRACT_NUMBER): Cast sign byte to unsigned before left
	shifting.

From-SVN: r231873
2015-12-21 08:23:35 +00:00
Pedro Alves 921da19854 PR other/61321 - demangler crash on casts in template parameters
The fix for bug 59195:

 [C++ demangler handles conversion operator incorrectly]
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59195

unfortunately makes the demangler crash due to infinite recursion, in
case of casts in template parameters.

For example, with:

 template<int> struct A {};
 template <typename Y> void function_temp(A<sizeof ((Y)(999))>) {}
 template void function_temp<int>(A<sizeof (int)>);

The 'function_temp<int>' instantiation above mangles to:

  _Z13function_tempIiEv1AIXszcvT_Li999EEE

The demangler parses this as:

typed name
  template
    name 'function_temp'
    template argument list
      builtin type int
  function type
    builtin type void
    argument list
      template                          (*)
        name 'A'
        template argument list
          unary operator
            operator sizeof
            unary operator
              cast
                template parameter 0    (**)
              literal
                builtin type int
                name '999'

And after the fix for 59195, due to:

 static void
 d_print_cast (struct d_print_info *dpi, int options,
	       const struct demangle_component *dc)
 {
 ...
   /* For a cast operator, we need the template parameters from
      the enclosing template in scope for processing the type.  */
   if (dpi->current_template != NULL)
     {
       dpt.next = dpi->templates;
       dpi->templates = &dpt;
       dpt.template_decl = dpi->current_template;
     }

when printing the template argument list of A (what should be "<sizeof
(int)>"), the template parameter 0 (that is, "T_", the '**' above) now
refers to the first parameter of the the template argument list of the
'A' template (the '*' above), exactly what we were already trying to
print.  This leads to infinite recursion, and stack exaustion.  The
template parameter 0 should actually refer to the first parameter of
the 'function_temp' template.

Where it reads "for the cast operator" in the comment in d_print_cast
(above), it's really talking about a conversion operator, like:

  struct A { template <typename U> explicit operator U(); };

We don't want to inject the template parameters from the enclosing
template in scope when processing a cast _expression_, only when
handling a conversion operator.

The problem is that DEMANGLE_COMPONENT_CAST is currently ambiguous,
and means _both_ 'conversion operator' and 'cast expression'.

Fix this by adding a new DEMANGLE_COMPONENT_CONVERSION component type,
which does what DEMANGLE_COMPONENT_CAST does today, and making
DEMANGLE_COMPONENT_CAST just simply print its component subtree.

I think we could instead reuse DEMANGLE_COMPONENT_CAST and in
d_print_comp_inner still do:

 @@ -5001,9 +5013,9 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
        d_print_comp (dpi, options, dc->u.s_extended_operator.name);
        return;

     case DEMANGLE_COMPONENT_CAST:
       d_append_string (dpi, "operator ");
 -     d_print_cast (dpi, options, dc);
 +     d_print_conversion (dpi, options, dc);
       return;

leaving the unary cast case below calling d_print_cast, but seems to
me that spliting the component types makes it easier to reason about
the code.

g++'s testsuite actually generates three symbols that crash the
demangler in the same way.  I've added those as tests in the demangler
testsuite as well.

And then this fixes PR other/61233 too, which happens to be a
demangler crash originally reported to GDB, at:
https://sourceware.org/bugzilla/show_bug.cgi?id=16957

Bootstrapped and regtested on x86_64 Fedora 20.

Also ran this through GDB's testsuite.  GDB will require a small
update to use DEMANGLE_COMPONENT_CONVERSION in one place it's using
DEMANGLE_COMPONENT_CAST in its sources.

libiberty/
2015-11-27  Pedro Alves  <palves@redhat.com>

        PR other/61321
        PR other/61233
        * demangle.h (enum demangle_component_type)
        <DEMANGLE_COMPONENT_CONVERSION>: New value.
        * cp-demangle.c (d_demangle_callback, d_make_comp): Handle
        DEMANGLE_COMPONENT_CONVERSION.
        (is_ctor_dtor_or_conversion): Handle DEMANGLE_COMPONENT_CONVERSION
        instead of DEMANGLE_COMPONENT_CAST.
        (d_operator_name): Return a DEMANGLE_COMPONENT_CONVERSION
        component if handling a conversion.
        (d_count_templates_scopes, d_print_comp_inner): Handle
        DEMANGLE_COMPONENT_CONVERSION.
        (d_print_comp_inner): Handle DEMANGLE_COMPONENT_CONVERSION instead
        of DEMANGLE_COMPONENT_CAST.
        (d_print_cast): Rename as ...
        (d_print_conversion): ... this.  Adjust comments.
        (d_print_cast): Rewrite - simply print the left subcomponent.
        * cp-demint.c (cplus_demangle_fill_component): Handle
        DEMANGLE_COMPONENT_CONVERSION.

        * testsuite/demangle-expected: Add tests.

From-SVN: r231020
2015-11-27 14:48:21 +00:00
Mike Stump 633ce97157 * Makefile.in (etags tags TAGS): Use && instead of ;.
From-SVN: r230270
2015-11-12 19:18:54 +00:00
Alan Modra 61c94e79eb Configury changes for obstack optimization
Missed from last patch

	* config.in: Regenerate.

From-SVN: r229991
2015-11-09 15:24:15 +10:30
Alan Modra 126e0b6b61 Configury changes for obstack optimization
* configure.ac: Check size of size_t.
	* configure: Regenerate.

From-SVN: r229990
2015-11-09 15:02:08 +10:30
Alan Modra a186d523f2 Silence obstack.c -Wc++compat warning
* obstack.c (_obstack_newchunk): Silence -Wc++compat warning.
	(_obstack_begin_worker): Likewise.  Move assignment to h->chunk
	after alloc failure check.

From-SVN: r229989
2015-11-09 15:00:26 +10:30
Alan Modra f0e525fe18 Modify obstack.[hc] to avoid having to include other gnulib files
Using the standard gnulib obstack source requires importing quite a
lot of other files from gnulib, and requires build changes.

include/
	* obstack.h (__attribute_pure__): Expand _GL_ATTRIBUTE_PURE.
libiberty/
	* obstack.c (__alignof__): Expand alignof_type from alignof.h.
	(obstack_exit_failure): Don't use exitfail.h.
	(_): Include libintl.h when HAVE_LIBINTL_H and nls enabled.
	Provide default.  Don't include gettext.h.
	(_Noreturn): Define.
	* obstacks.texi: Adjust node references to external libc info files.

From-SVN: r229988
2015-11-09 14:58:21 +10:30
Alan Modra c9f265c945 Copy gnulib obstack files
This copies obstack.[ch] from gnulib, and updates the docs.  The next
patch should be applied if someone repeats the import at a later date.

include/
	* obstack.h: Import current gnulib file.
libiberty/
	* obstack.c: Import current gnulib file.
	* obstacks.texi: Updated doc, from glibc's manual/memory.texi.

From-SVN: r229987
2015-11-09 14:56:32 +10:30
Joel Brobecker 41fdbd5440 Do not use libiberty's getpagesize on Android
libiberty/ChangeLog:

        * configure.ac: Set AC_CV_FUNC_GETPAGESIZE to "yes" on
        Android hosts.
        * configure: Regenerate.

From-SVN: r229893
2015-11-06 21:37:49 +00:00
Jason Merrill 08585fba89 Make-lang.in (c.tags): Also include libcpp TAGS.
gcc/c/
	* Make-lang.in (c.tags): Also include libcpp TAGS.
gcc/cp/
	* Make-lang.in (c++.tags): Also include libcpp TAGS.

From-SVN: r229504
2015-10-28 15:45:33 -04:00
Roland McGrath efd40fc416 Fix PR63758 by using the _NSGetEnviron() API on Darwin
include/

	Roland McGrath  <roland@gnu.org>

	PR other/63758
	* environ.h: New file.

libiberty/

	Roland McGrath  <roland@gnu.org>
	Iain Sandoe  <iain@codesourcery.com>

	PR other/63758
	* pex-unix.c: Obtain the environment interface from settings in environ.h
	rather than in-line code.  Update copyright date.
	* setenv.c: Likewise.
	* xmalloc.c: Likewise.



Co-Authored-By: Iain Sandoe <iain@codesourcery.com>

From-SVN: r228942
2015-10-18 10:33:37 +00:00
Jason Merrill b8fd7909c0 Implement N4514, C++ Extensions for Transactional Memory.
gcc/
	* builtins.def (BUILT_IN_ABORT): Add transaction_pure attribute.
gcc/c-family/
	* c-common.c (c_common_reswords): Add C++ TM TS keywords.
	(c_common_attribute_table): Add transaction_safe_dynamic.
	transaction_safe now affects type identity.
	(handle_tm_attribute): Handle transaction_safe_dynamic.
	* c-common.h (enum rid): Add RID_ATOMIC_NOEXCEPT,
	RID_ATOMIC_CANCEL, RID_SYNCHRONIZED.
	(OBJC_IS_CXX_KEYWORD): Add RID_SYNCHRONIZED.
	(D_TRANSMEM): New.
	* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_transactional_memory.
	* c-pretty-print.c (pp_c_attributes_display): Don't print
	transaction_safe in C++.
gcc/c/
	* c-parser.c (c_lex_one_token): Handle @synchronized.
	* c-decl.c (match_builtin_function_types): A declaration of a built-in
	can change whether the function is transaction_safe.
gcc/cp/
	* cp-tree.h (struct cp_declarator): Add tx_qualifier field.
	(BCS_NORMAL, BCS_TRANSACTION): New enumerators.
	* lex.c (init_reswords): Limit TM kewords to -fgnu-tm.
	* parser.c (cp_lexer_get_preprocessor_token): Fix @synchronized.
	(make_call_declarator): Take tx_qualifier.
	(cp_parser_tx_qualifier_opt): New.
	(cp_parser_lambda_declarator_opt): Use it.
	(cp_parser_direct_declarator): Likewise.
	(cp_parser_statement): Handle atomic_noexcept, atomic_cancel.
	(cp_parser_compound_statement): Change in_try parameter to bcs_flags.
	(cp_parser_std_attribute): Map optimize_for_synchronized to
	transaction_callable.
	(cp_parser_transaction): Take the token.  Handle atomic_noexcept.
	* lambda.c (maybe_add_lambda_conv_op): Handle transaction-safety.
	* call.c (enum conversion_kind): Add ck_tsafe.
	(standard_conversion): Handle transaction-safety conversion.
	(convert_like_real, resolve_address_of_overloaded_function): Likewise.
	(check_methods): Diagnose transaction_safe_dynamic on non-virtual
	function.
	(look_for_tm_attr_overrides): Don't inherit transaction_safe_dynamic.
	* cvt.c (tx_safe_fn_type_p, tx_unsafe_fn_variant)
	(can_convert_tx_safety): New.
	* typeck.c (composite_pointer_type): Handle transaction-safety.
	* name-lookup.h (enum scope_kind): Add sk_transaction.
	* name-lookup.c (begin_scope): Handle it.
	* semantics.c (begin_compound_stmt): Pass it.
	* decl.c (check_previous_goto_1): Check it.
	(struct named_label_entry): Add in_transaction_scope.
	(poplevel_named_label_1): Set it.
	(check_goto): Check it.
	(duplicate_decls): A specialization can be transaction_safe
	independently of its template.
	(grokdeclarator): Handle tx-qualifier.
	* rtti.c (ptr_initializer): Handle transaction-safe.
	* search.c (check_final_overrider): Check transaction_safe_dynamic.
	Don't check transaction_safe.
	* mangle.c (write_function_type): Mangle transaction_safe here.
	(write_CV_qualifiers_for_type): Not here.
	(write_type): Preserve transaction_safe when stripping attributes.
	* error.c (dump_type_suffix): Print transaction_safe.
libiberty/
	* cp-demangle.c (d_cv_qualifiers): Dx means transaction_safe.
	(cplus_demangle_type): Let d_cv_qualifiers handle it.
	(d_dump, d_make_comp, has_return_type, d_encoding)
	(d_count_templates_scopes, d_print_comp_inner)
	(d_print_mod_list, d_print_mod, d_print_function_type)
	(is_ctor_or_dtor): Handle DEMANGLE_COMPONENT_TRANSACTION_SAFE.

From-SVN: r228462
2015-10-04 15:17:19 -04:00
Ian Lance Taylor 68bac64063 cp-demangle.c (d_abi_tags): Preserve di->last_name across any ABI tags.
* cp-demangle.c (d_abi_tags): Preserve di->last_name across any
	ABI tags.

From-SVN: r226910
2015-08-15 13:23:30 +00:00
Iain Buclaw fd91ffb805 Fix test failure on Solaris 9 where strtod() does not accept hexadecimals
2015-08-11  Iain Buclaw  <ibuclaw@gdcproject.org>

libiberty/

	* d-demangle.c (dlang_parse_real): Remove call to strtod.
	(strtod): Remove declaration.
	* testsuite/d-demangle-expected: Update float and complex literal
	tests to check correct hexadecimal demangling.

From-SVN: r226774
2015-08-11 07:12:19 +00:00
Mikhail Maltsev 76d96a5a6f Fix several crashes of C++ demangler on fuzzed input.
libiberty/
	* cp-demangle.c (d_dump): Fix syntax error.
	(d_identifier): Adjust type of len to match d_source_name.
	(d_expression_1): Fix out-of-bounds access.  Check code variable for
	NULL before dereferencing it.
	(d_find_pack): Do not recurse for FIXED_TYPE, DEFAULT_ARG and NUMBER.
	(d_print_comp_inner): Add NULL pointer check.
	* cp-demangle.h (d_peek_next_char): Define as inline function when
	CHECK_DEMANGLER is defined.
	(d_advance): Likewise.
	* testsuite/demangle-expected: Add new testcases.

From-SVN: r225727
2015-07-13 05:49:54 +00:00
Uros Bizjak 9b004cd378 getruntime.c (RUSAGE_SELF): Define if not already defined.
* getruntime.c (RUSAGE_SELF): Define if not already defined.
	(get_runtime): Use RUSAGE_SELF as argument 1 of getrusage call.

From-SVN: r225614
2015-07-09 17:06:00 +02:00
Uros Bizjak 62ee314561 getruntime.c (get_run_time): Use RUSAGE_SELF as argument 1 of getrusage call.
* getruntime.c (get_run_time) [__USE_GNU]: Use RUSAGE_SELF as
	argument 1 of getrusage call.

From-SVN: r225534
2015-07-08 09:05:11 +02:00
Jason Merrill 603eaec49a re PR c++/44282 (fastcall is not mangled at all)
PR c++/44282
gcc/cp/
	* mangle.c (attr_strcmp): New.
	(write_CV_qualifiers_for_type): Also write out attributes that
	affect type identity.
	(write_type): Strip all attributes after writing qualifiers.
libiberty/
	* cp-demangle.c (cplus_demangle_type): Handle arguments to vendor
	extended qualifier.

From-SVN: r224007
2015-06-01 22:28:19 -04:00
Yunlian Jiang f50f17e670 libiberty.h (asprintf): Don't declare if HAVE_DECL_ASPRINTF is not defined.
include/:
	* libiberty.h (asprintf): Don't declare if HAVE_DECL_ASPRINTF is
	not defined.
libiberty/:
	* configure.ac: Add AC_GNU_SOURCE.
	* Makefile.in (COMPILE.c): Add -D_GNU_SOURCE.
	* configure, config.in: Rebuild.
	* floatformat.c (_GNU_SOURCE): Don't define if already defined.

From-SVN: r223589
2015-05-22 20:53:45 +00:00
Iain Buclaw 7e8655412c d-demangle.c (dlang_symbol_kinds): New enum.
libiberty/ChangeLog:

2015-05-16  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_symbol_kinds): New enum.
	(dlang_parse_symbol): Update signature.  Handle an ambiguity between
	pascal functions and template value arguments.  Only check for a type
	if parsing a function, or at the top level.  Return failure if the
	entire symbol was not successfully demangled.
	(dlang_identifier): Update signature.  Handle an ambiguity between two
	adjacent digits in a mangled symbol string.
	(dlang_type): Update call to dlang_parse_symbol.
	(dlang_template_args): Likewise.
	(dlang_parse_template): Likewise.
	(dlang_demangle): Likewise.
	* testsuite/d-demangle-expected: Fix bad tests found, and add problematic
	examples to the unittests.

From-SVN: r223247
2015-05-16 16:50:30 +00:00
Iain Buclaw ed4cdb8502 d-demangle.c (dlang_template_args): Skip over specialized template parameters in mangled symbol.
libiberty/ChangeLog:

2015-05-16  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_template_args): Skip over specialized template
	parameters in mangled symbol.
	* testsuite/d-demangle-expected: Add coverage and unittest for specialized
	template parameters.

From-SVN: r223246
2015-05-16 16:50:19 +00:00
Iain Buclaw 59251a7367 d-demangle.c (dlang_type): Handle cent and ucent types.
libiberty/ChangeLog:

2015-05-16  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_type): Handle cent and ucent types.
	* testsuite/d-demangle-expected: Add coverage tests for cent and ucent.

From-SVN: r223245
2015-05-16 16:50:08 +00:00
Iain Buclaw 7ce4461f37 d-demangle.c (dlang_attributes): Handle return attributes, ignoring return parameters in the mangled string.
libiberty/ChangeLog:

2015-05-16  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_attributes): Handle return attributes, ignoring
	return parameters in the mangled string.  Return NULL if have encountered
	an unknown attribute.
	(dlang_function_args): Handle return parameters in the mangled string.
	* testsuite/d-demangle-expected: Add coverage tests for functions with
	return parameters and return attributes.

From-SVN: r223244
2015-05-16 16:49:57 +00:00
Iain Buclaw 5cc158e9a9 d-demangle.c (dlang_identifier): Check encoded length of identifier to verify strncmp matches entire string.
libiberty/ChangeLog:

2015-05-16  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-demangle.c (dlang_identifier): Check encoded length of identifier
	to verify strncmp matches entire string.
	* testsuite/d-demangle-expected: Fix wrong test for postblit symbol.

From-SVN: r223243
2015-05-16 16:49:46 +00:00