This project is mirrored from Pull mirroring updated .
  1. 07 Oct, 2022 31 commits
    • Eugene Rozenfeld's avatar
      Set discriminators for call stmts on the same line within the same basic block. · f30e9fd3
      Eugene Rozenfeld authored
      Call statements are possible split points of a basic block so they may end up
      in different basic blocks by the time pass_ipa_auto_profile executes.
      This change will also simplify call site lookups since now location with discriminator
      will uniquely identify the call site (no callee function name is needed).
      This change is based on commit 1e6c4a7a8fb8e20545bb9f9032d3854f3f794c18
      by Dehao Chen in vendors/google/heads/gcc-4_8.
      Tested on x86_64-pc-linux-gnu.
      	* (assign_discriminators): Set discriminators for call stmts
      	on the same line within the same basic block.
    • qing zhao's avatar
      Use array_at_struct_end_p in __builtin_object_size [PR101836] · b9ad850e
      qing zhao authored
      Use array_at_struct_end_p to determine whether the trailing array
      of a structure is flexible array member in __builtin_object_size.
      	PR tree-optimization/101836
      	* (addr_object_size): Use array_at_struct_end_p
      	to determine a flexible array member reference.
      	PR tree-optimization/101836
      	* gcc.dg/pr101836.c: New test.
      	* gcc.dg/pr101836_1.c: New test.
      	* gcc.dg/pr101836_2.c: New test.
      	* gcc.dg/pr101836_3.c: New test.
      	* gcc.dg/pr101836_4.c: New test.
      	* gcc.dg/pr101836_5.c: New test.
      	* gcc.dg/strict-flex-array-2.c: New test.
      	* gcc.dg/strict-flex-array-3.c: New test.
    • qing zhao's avatar
      Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array · 1879e48f
      qing zhao authored
      Add the following new option -fstrict-flex-arrays[=n] and a corresponding
      attribute strict_flex_array to GCC:
           Control when to treat the trailing array of a structure as a flexible array
           member for the purpose of accessing the elements of such an array.
           The positive form is equivalent to '-fstrict-flex-arrays=3', which is the
           strictest.  A trailing array is treated as a flexible array member only when
           it declared as a flexible array member per C99 standard onwards.
           The negative form is equivalent to '-fstrict-flex-arrays=0', which is the
           least strict.  All trailing arrays of structures are treated as flexible
           array members.
           Control when to treat the trailing array of a structure as a flexible array
           member for the purpose of accessing the elements of such an array.  The value
           of LEVEL controls the level of strictness
           The possible values of LEVEL are the same as for the
           'strict_flex_array' attribute (*note Variable Attributes::).
           You can control this behavior for a specific trailing array field
           of a structure by using the variable attribute 'strict_flex_array'
           attribute (*note Variable Attributes::).
      'strict_flex_array (LEVEL)'
           The 'strict_flex_array' attribute should be attached to the trailing
           array field of a structure. It controls when to treat the trailing array
           field of a structure as a flexible array member for the purposes of accessing
           the elements of such an array. LEVEL must be an integer betwen 0 to 3.
           LEVEL=0 is the least strict level, all trailing arrays of
           structures are treated as flexible array members.  LEVEL=3 is the
           strictest level, only when the trailing array is declared as a
           flexible array member per C99 standard onwards ('[]'), it is
           treated as a flexible array member.
           There are two more levels in between 0 and 3, which are provided to
           support older codes that use GCC zero-length array extension
           ('[0]') or one-element array as flexible array members('[1]'): When
           LEVEL is 1, the trailing array is treated as a flexible array member
           when it is declared as either '[]', '[0]', or '[1]'; When
           LEVEL is 2, the trailing array is treated as a flexible array member
           when it is declared as either '[]', or '[0]'.
           This attribute can be used with or without the
           '-fstrict-flex-arrays'.  When both the attribute and the option
           present at the same time, the level of the strictness for the
           specific trailing array field is determined by the attribute.
      	* (handle_strict_flex_array_attribute): New function.
      	(c_common_attribute_table): New item for strict_flex_array.
      	* c.opt: (fstrict-flex-arrays): New option.
      	(fstrict-flex-arrays=): New option.
      	* (flexible_array_member_type_p): New function.
      	(one_element_array_type_p): Likewise.
      	(zero_length_array_type_p): Likewise.
      	(add_flexible_array_elts_to_size): Call new utility
      	routine flexible_array_member_type_p.
      	(is_flexible_array_member_p): New function.
      	(finish_struct): Set the new DECL_NOT_FLEXARRAY flag.
      	* (trees_out::core_bools): Stream out new bit
      	(trees_in::core_bools): Stream in new bit decl_not_flexarray.
      	* doc/extend.texi: Document strict_flex_array attribute.
      	* doc/invoke.texi: Document -fstrict-flex-arrays[=n] option.
      	* (print_node): Print new bit decl_not_flexarray.
      	* tree-core.h (struct tree_decl_common): New bit field
      	* (unpack_ts_decl_common_value_fields): Stream
      	in new bit decl_not_flexarray.
      	* (pack_ts_decl_common_value_fields): Stream
      	out new bit decl_not_flexarray.
      	* (array_at_struct_end_p): Update it with the new bit field
      	* tree.h (DECL_NOT_FLEXARRAY): New flag.
      	* g++.dg/strict-flex-array-1.C: New test.
      	* gcc.dg/strict-flex-array-1.c: New test.
    • Olivier Hainque's avatar
      Specialize paths to version.h in _vxworks-versions.h · 21e51a55
      Olivier Hainque authored
      The _vxworks-versions.h runtime file helps us control
      the compilation of some library components depending on
      the OS version extracted out of a system header.
      The system header name is "version.h", and gcc has a
      "version.h" file of its own.
      gcc's version.h is now generated and the current
      instance instead of the OS one, resulting in build failures
        #if !defined(_WRS_VXWORKS_MAJOR)
        #error "_WRS_VXWORKS_MAJOR undefined"
      This change introduces a twist in the way
      _vxworks-versions.h #includes version.h, using a relative
      path with components that will match in the OS include
      dirs only.
      The actual relative path is conditioned on _VSB_CONFIG_FILE
      to accommodate a change in the include dirs organisation between
      VxWorks 6 and 7.
      2022-10-07  Olivier Hainque  <>
      	* config/vxworks/_vxworks-versions.h: Use OS specific
      	paths in #include of version.h.
    • David Malcolm's avatar
      analyzer: extract bits from integer constants [PR105783] · f09b9955
      David Malcolm authored
      Fix a false positive from -Wanalyzer-null-dereference due to -fanalyzer
      failing to grok the value of a particular boolean field initialized to a
      	PR analyzer/105783
      	* (selftest::get_bit): New function.
      	(selftest::test_bits_within_svalue_folding): New.
      	(selfftest::analyzer_region_model_cc_tests): Call it.
      	* (constant_svalue::maybe_fold_bits_within): Handle the
      	case of extracting a single bit.
      	PR analyzer/105783
      	* gcc.dg/analyzer/pr105783.c: New test.
      Signed-off-by: David Malcolm's avatarDavid Malcolm <>
    • Nathan Sidwell's avatar
      libiberty: Demangle variadic template lambdas · eb491ea5
      Nathan Sidwell authored
      Now we have templated lambdas, we can have variadic template lambdas,
      and this leads to lambda signatures containing parameter packs.  But
      just like 'auto' inside such a signature, we don't have a containing
      template, and thus fail.  The fix is to check is_lambda_arg, just as
      for a template parameter.  This allows us to demangle g++'s manglings
      of such lambdas.
      It's not a totally accurate demangling, because we don't mangle the
      template head (that's a separate issue), but it is better than failing
      to demangle.
      Due to the way we print subexprs, we add an unnecessary parens around
      the argument of the pack.  That's an orthogonal problem, for which the
      solution is to have better knowledge of operator precedence.
      	* cp-demangle.c (d_print_comp_inner): Allow parameter packs
      	in a lambda signature.
      	* testsuite/demangle-expected: Add tests.
    • Patrick Palka's avatar
      c++ modules: ICE with bitfield in class template · f7f46280
      Patrick Palka authored
      According to grokbitfield, DECL_BIT_FIELD_REPRESENTATIVE contains the
      width of the bitfield until we layout the class type (after which it'll
      contain a decl).  Thus for a bitfield in a class template it'll always
      be the width, and this patch makes us avoid ICEing from mark_class_def
      in this case.
      	* (trees_out::mark_class_def): Guard against
      	DECL_BIT_FIELD_REPRESENTATIVE not being a decl.
      	* g++.dg/modules/bfield-3.H: New test.
    • Jason Merrill's avatar
      c++: catch parm initialization tweak · f8ba88b6
      Jason Merrill authored
      We want to push the INIT_EXPR inside the CLEANUP_POINT_EXPR for the same
      reason we want to push it into the MUST_NOT_THROW_EXPR: any cleanups follow
      the initialization.
      	* (expand_default_init): Also push the INIT_EXPR inside a
    • Martin Liska's avatar
      IPA: support -flto + -flive-patching=inline-clone · 1a308905
      Martin Liska authored
      There's no fundamental reason why -flive-patching=inline-clone can't
      coexist with -flto. Yes, one can theoretically have many more clone
      function that includes a live patch. It is pretty much the same
      as in-module inlining.
      	* (finish_options): Print sorry message only
      	for -flive-patching=inline-only-static.
      	* gcc.dg/live-patching-2.c: Update scanned pattern.
      	* gcc.dg/live-patching-5.c: New test.
    • Patrick Palka's avatar
      c++ modules: static var in inline function [PR104433] · edbb2551
      Patrick Palka authored
      The below testcase fails to link with the error
        undefined reference to `f()::y'
      ultimately because during stream out for the static VAR_DECL y we
      override DECL_EXTERNAL to true, which later during IPA confuses
      symbol_table::remove_unreachable_nodes into thinking it's safe
      to not emit the symbol.
      The streaming code here already avoids overriding DECL_EXTERNAL for
      inline vars and functions, so it seems natural to extend this to
      static vars from an inline function.
      	PR c++/104433
      	* (trees_out::core_bools): Don't override
      	DECL_EXTERNAL to true for static variables from an inline
      	* g++.dg/modules/static-2_a.H: New test.
      	* g++.dg/modules/static-2_b.C: New test.
    • Jason Merrill's avatar
      gimplify: prevent some C++ temporary elision · d3e54657
      Jason Merrill authored
      In this testcase, we were optimizing away the temporary for f(), but
      C++17 and above are clear that there is a temporary, and because its
      destructor has visible side-effects we can't optimize it away under the
      as-if rule.  So disable this optimization for TREE_ADDRESSABLE type.
      I moved the declaration of volatile_p after the call to
      gimple_fold_indirect_ref_rhs to minimize indentation changes; I don't see
      any way the value of that flag could be affected by the call.
      	* (gimplify_modify_expr_rhs): Don't optimize
      	x = *(A*)&<expr> to x = <expr> for a TREE_ADDRESSABLE type.
      	* g++.dg/init/elide9.C: New test.
    • Richard Biener's avatar
      tree-optimization/107153 - autopar SSA update issue · 89228e39
      Richard Biener authored
      autopar performs insertion of stores, eventually requiring a
      virtual loop PHI and assorted LC PHI adjustments which we intend
      to do once after the pass finishes.  But we also perform intermediate
      update_ssa after loop duplication which can lose this fact.  The
      following forces renaming of the virtual operand before the final
      SSA update to fix that.  It also removes the explicit update_ssa
      call from the gimple_duplicate_sese_tail utility as has been done
      for all other such utilities and instead performs the SSA update
      from autopar.
      	PR tree-optimization/107153
      	* (gimple_duplicate_sese_tail): Do not update
      	SSA form here.
      	* (gen_parallel_loop): Update SSA form
      	after to-exit-first transform, no PHI insertion is necessary.
      	(pass_parallelize_loops::execute): Force re-write of the
      	virtual operand SSA web.
      	* gcc.dg/autopar/pr107153.c: New testcase.
    • jwakely2's avatar
      libstdc++: Add --disable-libstdcxx-hosted as an alias for hosted-libstdcxx · 6bd2c123
      jwakely2 authored
      Most libstdc++ configure args are of the form --enable-libstdcxx-xxx but
      the option to build freestanding is --disable-hosted-libstdcxx. If you
      accidentally type --disable-libstdcxx-hosted then it will be ignored.
      This adds --disable-libstdcxx-hosted as an alias for the existing arg,
      so it works whichever way you say it. If both args are used explicitly
      and their values do not agree, configure fails with an error.
      	* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Add libstdcxx-hosted
      	enable arg as an alias for hosted-libstdcxx enable arg.
      	* configure: Regenerate.
    • jwakely2's avatar
      libstdc++: Shuffle header dependencies of <functional> · 93b3ab6c
      jwakely2 authored
      The <new> header is needed by std::function to use placement new, so
      include it in <bits/std_function.h> instead of in <functional>.
      	* include/bits/std_function.h: Include <new> but do not include
      	* include/std/functional: Do not include <new>.
    • jwakely2's avatar
      gcc: Fix comment typo · df78e152
      jwakely2 authored
      	* (irange::irange_contains_p): Fix comment typo.
    • jwakely2's avatar
      libstdc++: Use bold style for DR titles in the manual · 8e2f453d
      jwakely2 authored
      This matches how the issues are styled in the LWG issues list, and also
      allows us to use italics for "cv" (e.g. in issue 2487).
      	* doc/xml/manual/intro.xml: Add role="bold" attribute to
      	emphasis elements for issue titles.
      	* doc/html/manual/bugs.html: Regenerate.
    • Eric Botcazou's avatar
      Reduce DF computation at -O0 · 7b8a77eb
      Eric Botcazou authored
      Even at -O0 there may be a fair amount of DF computation performed when
      compiling large units and part of it appears to be useless.
      	* (thread_prologue_and_epilogue_insns): Update only
      	entry and exit blocks when not optimizing.  Remove dead statement.
    • Aldy Hernandez's avatar
      Convert nonzero mask back to tree. · ffaf244c
      Aldy Hernandez authored
      Having nonzero masks always set had a performance penalty of 10% in
      VRP, so mask==NULL is a shortcut to all bits set.
      	* (irange::irange_set): Convert nonzero mask to
      	(irange::irange_set_anti_range): Same.
      	(irange::set): Same.
      	(irange::verify_range): Same.
      	(irange::contains_p): Same.
      	(irange::invert): Same.
      	(irange::set_range_from_nonzero_bits): Same.
      	(irange::set_nonzero_bits): Same.
      	(mask_to_wi): Same.
      	(irange::intersect_nonzero_bits): Same.
      	(irange::union_nonzero_bits): Same.
      	* value-range.h (irange::varying_compatible_p): Same.
      	(gt_ggc_mx): Same.
      	(gt_pch_nx): Same.
      	(irange::set_undefined): Same.
      	(irange::set_varying): Same.
    • Martin Liska's avatar
      contrib: remove extra fetch from git_update_version · fce601fd
      Martin Liska authored
      Remove extra fetch call that didn't help with the issue
      we had (missing object).
      	* gcc-changelog/ Remove extra fetch.
    • Martin Liska's avatar
      libdecnumber: remove unused variable · 8a796859
      Martin Liska authored
      libdecnumber/dpd/decimal64.c:617:8: warning: variable 'n' set but not used [-Wunused-but-set-variable]
      	* dpd/decimal64.c (decDigitsToDPD): Remove unused variable.
    • Martin Liska's avatar
      fix clang warnings · e1d1842b
      Martin Liska authored
      gcc/c-family/name-hint.h:109:66: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
      gcc/config/i386/ warning: argument 'operands' of type 'rtx[3]' (aka 'rtx_def *[3]') with mismatched bound [-Warray-parameter]
      gcc/config/i386/ warning: argument 'operands' of type 'rtx[2]' (aka 'rtx_def *[2]') with mismatched bound [-Warray-parameter]
      gcc/cp/ warning: argument 'counts' of type 'unsigned int[8]' with mismatched bound [-Warray-parameter]
      gcc/cp/ warning: argument 'counts' of type 'unsigned int[8]' with mismatched bound [-Warray-parameter]
      gcc/cp/ warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
      	* name-hint.h: Use std::move.
      	* config/i386/i386-protos.h (ix86_binary_operator_ok): Add array
      	  size to function parameter.
      	(ix86_unary_operator_ok): Likewise.
      	* (enum module...
    • Martin Liska's avatar
      remove dead variables · bd0e3518
      Martin Liska authored
      Remove unused variables that are modified but not used.
      	* (get_inline_stack): Remove unused variable.
      	* (generate_static_references):
      	Remove unused variable.
    • Jakub Jelinek's avatar
      Fix comment typos · e66236c6
      Jakub Jelinek authored
      When looking at I've noticed a comment typo and grepped
      for similar typos elsewhere.
      2022-10-07  Jakub Jelinek  <>
      	* ipa-prop.h (ipa_constant_data): Fix comment typo.
      	* (irange::irange_contains_p): Likewise.
      	* (dom_oracle::set_one_relation): Likewise.
      	* (predicate::simplify_4): Likewise.
      	* (remap_ssa_name): Likewise.
    • Jakub Jelinek's avatar
      c++: Improve handling of foreigner namespace attributes · 88f04e90
      Jakub Jelinek authored
      In some cases we want to look up or remove both standard
      attributes and attributes from gnu namespace but not others.
      This patch arranges for ATTR_NS of "" to stand for ATTR_NS
      NULL or "gnu", so that we don't need 2 separate calls, and
      introduces is_attribute_namespace_p function which allows
      testing the namespace of an attribute similar way.
      The patch also uses the new lookup_attribute overload and extra
      tests to avoid emitting weird warnings on foreign namespace attributes
      which we should just ignore (perhaps with a warning), but shouldn't
      imply any meaning to them just because they have a name matching some
      standard or gnu attribute name.
      2022-10-07  Jakub Jelinek  <>
      	* attribs.h (is_attribute_namespace_p): New inline function.
      	(lookup_attribute): Document meaning of ATTR_NS equal to "".
      	* (remove_attribute): Use is_attribute_namespace_p.
      	(private_lookup_attribute): For ATTR_NS "" match either standard
      	attribute or "gnu" namespace one.
      	* (attribute_fallthrough_p): Lookup fallthrough attribute
      	only in gnu namespace or as standard attribute, treat fallthrough
      	attributes in other namespaces like any other unknown attribute.
      	* (cp_parser_check_std_attribute): Only do checks if
      	attribute is a standard attribute or in gnu namespace and only
      	lookup other attributes in those namespaces.
      	* (lookup_hotness_attribute): Adjust function comment.
      	Only return true for standard attribute or gnu namespace attribute.
      	(remove_hotness_attribute): Only remove hotness attributes when
      	they are standard or in gnu namespace, implement it in a single
      	loop rather than former 4 now 8 remove_attribute calls.
      	* g++.dg/cpp1z/fallthrough2.C: New test.
      	* g++.dg/cpp2a/attr-likely7.C: New test.
    • Jakub Jelinek's avatar
      fixincludes: Deal also with the _Float128x cases [PR107059] · 348e46fa
      Jakub Jelinek authored
      On Wed, Sep 28, 2022 at 08:19:43PM +0200, Jakub Jelinek via Gcc-patches wrote:
      > Another case are the following 3 snippets:
      > #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
      > #   error "_Float128X supported but no constant suffix"
      > #  else
      > #   define __f128x(x) x##f128x
      > #  endif
      > ...
      > #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
      > #   error "_Float128X supported but no complex type"
      > #  else
      > #   define __CFLOAT128X _Complex _Float128x
      > #  endif
      > ...
      > #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
      > #   error "_Float128x supported but no type"
      > #  endif
      > but as no target has _Float128x right now and don't see it
      > coming soon, it isn't a big deal (on the glibc side it is of
      > course ok to adjust those).
      This incremental patch deals handles the above 3 cases, so we
      fixinclude what glibc itself changed too.
      2022-10-07  Jakub Jelinek  <>
      	PR bootstrap/107059
      	* inclhack.def (glibc_cxx_floatn_5): New.
    • Jakub Jelinek's avatar
      fixincludes: Fix up powerpc floatn.h tweaks [PR107059] · 62ec780a
      Jakub Jelinek authored
      On Wed, Sep 28, 2022 at 12:23:31AM +0000, Joseph Myers wrote:
      > In general the changes match those made by fixincludes, though I think
      > the ones in sysdeps/powerpc/bits/floatn.h, where the header tests
      > __LDBL_MANT_DIG__ == 113 or uses #elif, wouldn't match the existing
      > fixincludes patterns.
      You're right, missed that.
      The header has:
       /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */
       # if __HAVE_FLOAT128
       #  if __LDBL_MANT_DIG__ == 113 && defined __cplusplus
       typedef long double _Float128;
       #   define __CFLOAT128 _Complex long double
       #  elif !__GNUC_PREREQ (7, 0) || defined __cplusplus
       /* The type _Float128 exist for powerpc only since GCC 7.0.  */
       typedef __float128 _Float128;
       /* Add a typedef for older GCC and C++ compilers which don't natively support
          _Complex _Float128.  */
       typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
       #   define __CFLOAT128 __cfloat128
       #  else
       #   define __CFLOAT128 _Complex _Float128
       #  endif
       # endif
      and my current rules don't do anything about that.
      The following patch fixes that.
      I've run additionally
      MACRO_LIST=`pwd`/../gcc/macro_list TARGET_MACHINE=x86_64-pc-linux-gnu \
        ../fixincludes/ /tmp/include-fixed \
          `echo /usr/src/libc | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`
      in the builddir/fixincludes directory where /usr/src/libc is latest glibc
      trunk checkout and seems the remaining defined __cplusplus cases in the floatn.h
      and floatn-common.h headers are ok or acceptable.
      The remaining cases are:
       #if __GNUC_PREREQ (7, 0) && !defined __cplusplus
       # define __HAVE_FLOATN_NOT_TYPEDEF 1
       # define __HAVE_FLOATN_NOT_TYPEDEF 0
      which is IMHO ok because this is only used in tgmath.h or tgmath-like math.h
      stuff which is C only, as C++ doesn't have _Generic.
      Another case are the following 3 snippets:
       #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
       #   error "_Float128X supported but no constant suffix"
       #  else
       #   define __f128x(x) x##f128x
       #  endif
       #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
       #   error "_Float128X supported but no complex type"
       #  else
       #   define __CFLOAT128X _Complex _Float128x
       #  endif
       #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
       #   error "_Float128x supported but no type"
       #  endif
      but as no target has _Float128x right now and don't see it
      coming soon, it isn't a big deal (on the glibc side it is of
      course ok to adjust those).
      OT, besides floatn.h and floatn-common.h headers, the only
      one remaining in /tmp/include-fixed is sysdeps/arm/unwind.h, perhaps
      -#if defined(linux) || defined(__NetBSD__)
      +#if defined(__linux__) || defined(__NetBSD__)
      should be done in that header (and libgcc/config/arm/unwind-arm.h
      2022-10-07  Jakub Jelinek  <>
      	PR bootstrap/107059
      	* inclhack.def (glibc_cxx_floatn_2): Handle #elif the same as #if.
      	(glibc_cxx_floatn_4): New.
      	* fixincl.x: Regenerated.
      	* tests/base/bits/floatn.h: Regenerated.
    • Olivier Hainque's avatar
      Downgrade DWARF_VERSION_DEFAULT to 3 for VxWorks >= 7 · b6ab375c
      Olivier Hainque authored
      Using 4 as the DWARF_VERSION_DEFAULT value for VxWorks observably
      still hangs recent system debuggers on tbreak for some contructs,
      and downgrading to 3 improves the situation.
      2022-03-06  Olivier Hainque  <>
      	* config/vxworks.h (DWARF_VERSION_DEFAULT): Adjust from
      	4 to 3 for VxWorks >= 7.
    • Olivier Hainque's avatar
      Introduce DWARF_VERSION_DEFAULT and redefine for VxWorks · 8dffd0e9
      Olivier Hainque authored
      This change introduces a target overridable macro to replace
      the hardcoded value used to initialize dwarf_version from common.opt.
      The main advantage compared to special code in a target
      override_options hook is that redefinitions by target config files
      are visible by both the compiler proper and by the driver, which
      might refer to dwarf_version in ASM_DEBUG_SPECs and friends.
      This is useful at least on VxWorks, where we usually need to
      default to dwarf 4 or even 2 to accommodate non-gdb debuggers
      provided by the environment, including for assembly sources
      used in libgcc for some ports (witnessed with lse.S on aarch64).
      2022-02-28  Olivier Hainque  <>
      	* defaults.h (DWARF_DEFAULT_VERSION): Define if not
      	defined already.
      	* common.opt (gdwarf-): Use it.
      	* doc/ (DWARF_DEFAULT_VERSION): Document.
      	* doc/tm.texi: Update accordingly.
      	* config/vxworks.h (DWARF_DEFAULT_VERSION): Redefine.
      	* config/ Remo...
    • Olivier Hainque's avatar
      undef offsetof before defining it in stddef.h · 8307b7d6
      Olivier Hainque authored
      This prevents redefinition warnings by -Wsystem-headers on
      OSses where system headers happen to provide a definition of
      their own, such as VxWorks.
      2022-02-15  Olivier Hainque  <>
      	* ginclude/stddef.h: #undef offsetof before #define.
    • Than McIntosh's avatar
      compiler: better arg type checking for selected builtins · 8a9e92b2
      Than McIntosh authored
      Tighten up the argument type checking for Builtin_call_expression to
      catch erroneous cases such as
      where an argument void type is being passed to panic/alignof/sizeof.
      Fixes golang/go#56071.
    • GCC Administrator's avatar
      Daily bump. · 629d04d3
      GCC Administrator authored
  2. 06 Oct, 2022 9 commits
    • Jakub Jelinek's avatar
      libgcc, arc: Fix build · 20462a14
      Jakub Jelinek authored
      Missed one spot in the r13-3108-g146e45914032 change (my sed script
      didn't expect nested []s).
      2022-10-07  Jakub Jelinek  <>
      	* config/arc/linux-unwind.h (arc_fallback_frame_state): Use
      	fs->[X] instead of fs->regs.reg[X].how.
    • Jason Merrill's avatar
      c++: fix broken conversion in coroutines · 0143b277
      Jason Merrill authored
      You can't use CONVERT_EXPR to convert between two class types.
      VIEW_CONVERT_EXPR takes liberties with the C++ type system, but is probably
      safe in this context.  Let's also only use it when the type isn't already
      what we want.
      	* (expand_one_await_expression): Change conversion
      	* (cp_genericize_r) [CONVERT_EXPR]: Add assert.
    • Aldy Hernandez's avatar
      [PR107170] Avoid copying incompatible types in legacy VRP. · 49b9a8c8
      Aldy Hernandez authored
      Legacy VRP is calling ranger deep inside the bowels, and then trying to
      copy an incompatible type.  My previous patch in this area assumed that
      the only possibility out of vr_values::get_value_range for an
      unsupported type was VARYING, but UNDEFINED can also be returned.
      	PR tree-optimization/107170
      	* (vr_values::range_of_expr):  Do not die on
      	unsupported types.
      	* gcc.dg/tree-ssa/pr107170.c: New test.
    • David Malcolm's avatar
      analyzer: fix another ICE in PR 107158 · 629b4813
      David Malcolm authored
      I overreduced PR analyzer/107158 in r13-3096-gef878564
      , and there
      was another ICE in the original reproducer, which this patch fixes.
      	PR analyzer/107158
      	* (store::replay_call_summary_cluster): Eliminate
      	special-casing of RK_HEAP_ALLOCATED in favor of sharing code with
      	RK_DECL, avoiding an ICE due to attempting to bind a
      	compound_svalue into a binding_cluster when an svalue in the
      	summary cluster converts to a compound_svalue in the caller.
      	PR analyzer/107158
      	* gcc.dg/analyzer/call-summaries-pr107158-2.c: New test.
      Signed-off-by: David Malcolm's avatarDavid Malcolm <>
    • David Malcolm's avatar
      analyzer: fixes to call_summary_replay::dump_to_pp · 30d63567
      David Malcolm authored
      	* (call_summary_replay::dump_to_pp): Bulletproof
      	against NULL caller regions/svalues.
      Signed-off-by: David Malcolm's avatarDavid Malcolm <>
    • Tobias Burnus's avatar
      openmp: Map holds clause to IFN_ASSUME for Fortran · 50c35c69
      Tobias Burnus authored
      Same as r13-3107-g847f5add did for C/C++.
      Convert '!$omp assume holds(cond)' to IFN_ASSUME (cond).
      	* (gfc_trans_omp_assume): New.
      	(gfc_trans_omp_directive): Call it.
      	* gfortran.dg/gomp/assume-3.f90: New test.
      	* gfortran.dg/gomp/assume-4.f90: New test.
    • Joseph Myers's avatar
      c: C2x typeof · fa258f68
      Joseph Myers authored
      C2x adds typeof as a standard feature.  In general this follows
      existing GNU C semantics very closely, but there are various ways in
      which the implementation involves more than simply enabling the
      keyword for C2x:
      * As well as typeof, there is a typeof_unqual variant, which removes
        all qualifiers and _Atomic from the resulting type (whereas typeof
        preserves qualifiers and _Atomic on qualified or atomic (lvalue or
        type name) operands).
      * The typeof keyword is disabled by -fno-asm, so enabling it for C2x
        needs to be implemented in a way that preserves the disabling by
        -fno-asm for older standard versions (which having -fno-asm having
        no effect on it in C2x mode).  This is done via adding a new D_EXT11
        mask (which is also where the C++ front-end change comes from, to
        handle D_EXT11 appropriately there for -fno-asm and
      * GNU typeof treats the noreturn property of a function (as specified
        in standard C with _Noreturn or [[noreturn]]) as being part of the
        type of a pointer to function, but it is not part of the type in
        standard terms.  Thus a special case is needed in the typeof
        implementation, just like in the _Generic implementation, to avoid
        treating it as a type for standard typeof.  It seems plausible this
        is being used when copying the type of one object to another using
        typeof, so the existing semantics are preserved for __typeof__, and
        for typeof in pre-C2x modes, while typeof for C2x or later has the
        standard semantics.
      * It turns out that, even after Martin Uecker's changes in this area,
        there were still cases where rvalues could wrongly have a qualified
        or atomic type in GCC.  This applied to ++ and -- increment and
        decrement expressions, and also to calls to functions returning an
        atomic type.  (For the latter, the working draft doesn't actually
        explicitly exclude the function call expression having an atomic
        type, but given all the changes that have gone into C17 and C2x to
        avoid rvalues ever having qualified types, and given that
        lvalue-to-rvalue conversion removes both qualifiers and _Atomic, it
        seems unlikely that this (or casts, where GCC already removes
        _Atomic) is actually intended as a route to allow an
        _Atomic-qualified rvalue; I've noted this to raise as an NB comment
        on the CD ballot.)
      Bootstrapped with no regressions for x86_64-pc-linux-gnu.  OK to
      commit (C+
      	* doc/invoke.texi (-fno-asm): Update description of effects on
      	typeof keyword.
      	* (c_common_reswords): Mark typeof as D_EXT11.  Add
      	* c-common.h (enum rid): Add RID_TYPEOF_UNQUAL.
      	(D_EXT11): New macro.  Values of subsequent macros updated.
      	* (c_parse_init): Add D_EXT11 to mask if flag_no_asm
      	and not C2x.
      	(c_keyword_starts_typename, c_token_starts_declspecs)
      	(c_parser_declspecs, c_parser_objc_selector): Handle
      	(c_parser_typeof_specifier): Handle RID_TYPEOF_UNQUAL.
      	Distinguish typeof for C2x from __typeof__ for all standard
      	versions and typeof before C2x.
      	* (build_function_call_vec): Use unqualified version
      	of non-void return type.
      	(build_unary_op): Use unqualified type for increment and
      	* (init_reswords): Handle D_EXT11.
      	* gcc.dg/c11-typeof-1.c, gcc.dg/c2x-typeof-1.c,
      	gcc.dg/c2x-typeof-2.c, gcc.dg/c2x-typeof-3.c,
      	gcc.dg/gnu11-typeof-1.c, gcc.dg/gnu11-typeof-2.c,
      	gcc.dg/gnu2x-typeof-1.c: New tests.
    • Patrick Palka's avatar
      c++: remove optimize_specialization_lookup_p · 09df0d8b
      Patrick Palka authored
      Roughly speaking, optimize_specialization_lookup_p returns true for a
      non-template member function of a class template, e.g.
        template<class T> struct A { int f(); };
      The idea behind the optimization guarded by this predicate is that if
      we want to look up the specialization A<T>::f [with T=int], then we can
      just do a name lookup for f in A<int> and avoid having to add a
      spec_entry for f in the decl_specializations table.
      But the benefit of this optimization seems questionable because in
      order to do the name lookup we first need to look up A<T> [with T=int]
      in the type_specializations table, which is as expensive as the
      decl_specializations lookup we're avoiding.  And according to some
      experiments (using stdc++.h, range-v3 and libstdc++ tests) the compiler
      is slightly (<1%) _faster_ if we disable this optimization.
      Additionally, this optimization means we won't record an explicit
      specialization in decl_specializations for such a template either, which
      is an unfortunate inconsistency that apparently breaks the below modules
      So since this optimization doesn't improve performance, and complicates
      the explicit specialization story which causes issues with modules, this
      patch proposes to remove it.
      	* (optimize_specialization_lookup_p): Remove.
      	(retrieve_specialization): Assume the above returns false
      	and simplify accordingly.
      	(register_specialization): Likewise.
      	* g++.dg/modules/indirect-3_b.C: Expect that the entity
      	foo::TPL<0>::frob is tagged as a specialization instead
      	of as a declaration.
      	* g++.dg/modules/tpl-spec-8_a.H: New test.
      	* g++.dg/modules/tpl-spec-8_b.C: New test.
    • Eric Botcazou's avatar
      Fix wrong code generated by unroll-and-jam pass · 3ec926d3
      Eric Botcazou authored
      There is a loophole in the unroll-and-jam pass that can quickly result in
      wrong code generation.  The code reads:
          if (!compute_data_dependences_for_loop (outer, true, &loop_nest,
                                      &datarefs, &dependences))
                if (dump_file && (dump_flags & TDF_DETAILS))
                  fprintf (dump_file, "Cannot analyze data dependencies\n");
                free_data_refs (datarefs);
                free_dependence_relations (dependences);
      but compute_data_dependences_for_loop may return true even if the analysis
      is reported as failing by compute_affine_dependence for a dependence pair:
        ref_a: data[_14], stmt_a: data[_14] = i_59;
        ref_b: data[_14], stmt_b: data[_14] = i_59;
      Data ref a:
      Data ref b:
      affine dependence test not usable: access function not affine or constant.
      ) -> dependence analysis failed
      Note that this is a self-dependence pair and the code for them reads:
                /* Nothing interesting for the self dependencies. */
                if (dra == drb)
      This means that the pass may reorder "complex" accesses to the same memory
      location in successive iterations, which is OK for reads but not for writes.
      	* (tree_loop_unroll_and_jam): Bail out for a self
      	dependency that is a write-after-write if the access function is not
      	affine or constant.
      	* gcc.c-torture/execute/20221006-1.c: New test.