191967 Commits

Author SHA1 Message Date
Tobias Burnus
a5c9b7c4f9 Fortran: Fix CLASS handling in SIZEOF intrinsic
gcc/fortran/ChangeLog:

	* trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Fix CLASS handling.

gcc/testsuite/ChangeLog:

	* gfortran.dg/sizeof_6.f90: New test.
2022-03-09 10:26:15 +01:00
Jakub Jelinek
d76511138d c, c++, c-family: -Wshift-negative-value and -Wshift-overflow* tweaks for -fwrapv and C++20+ [PR104711]
As mentioned in the PR, different standards have different definition
on what is an UB left shift.  They all agree on out of bounds (including
negative) shift count.
The rules used by ubsan are:
C99-C2x ((unsigned) x >> (uprecm1 - y)) != 0 then UB
C++11-C++17 x < 0 || ((unsigned) x >> (uprecm1 - y)) > 1 then UB
C++20 and later everything is well defined
Now, for C++20, I've in the P1236R1 implementation added an early
exit for -Wshift-overflow* warning so that it never warns, but apparently
-Wshift-negative-value remained as is.  As it is well defined in C++20,
the following patch doesn't enable -Wshift-negative-value from -Wextra
anymore for C++20 and later, if users want for compatibility with C++17
and earlier get the warning, they still can by using -Wshift-negative-value
explicitly.
Another thing is -fwrapv, that is an extension to the standards, so it is up
to us how exactly we define that case.  Our ubsan code treats
TYPE_OVERFLOW_WRAPS (type0) and cxx_dialect >= cxx20 the same as only
diagnosing out of bounds shift count and nothing else and IMHO it is most
sensical to treat -fwrapv signed left shifts the same as C++20 treats
them, https://eel.is/c++draft/expr.shift#2
"The value of E1 << E2 is the unique value congruent to E1×2^E2 modulo 2^N,
where N is the width of the type of the result.
[Note 1: E1 is left-shifted E2 bit positions; vacated bits are zero-filled.
— end note]"
with no UB dependent on the E1 values.  The UB is only
"The behavior is undefined if the right operand is negative, or greater
than or equal to the width of the promoted left operand."
Under the hood (except for FEs and ubsan from FEs) GCC middle-end doesn't
consider UB in left shifts dependent on the first operand's value, only
the out of bounds shifts.

While this change isn't a regression, I'd think it is useful for GCC 12,
it doesn't add new warnings, but just removes warnings that aren't
appropriate.

2022-03-09  Jakub Jelinek  <jakub@redhat.com>

	PR c/104711
gcc/
	* doc/invoke.texi (-Wextra): Document that -Wshift-negative-value
	is enabled by it only for C++11 to C++17 rather than for C++03 or
	later.
	(-Wshift-negative-value): Similarly (except here we stated
	that it is enabled for C++11 or later).
gcc/c-family/
	* c-opts.cc (c_common_post_options): Don't enable
	-Wshift-negative-value from -Wextra for C++20 or later.
	* c-ubsan.cc (ubsan_instrument_shift): Adjust comments.
	* c-warn.cc (maybe_warn_shift_overflow): Use TYPE_OVERFLOW_WRAPS
	instead of TYPE_UNSIGNED.
gcc/c/
	* c-fold.cc (c_fully_fold_internal): Don't emit
	-Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS.
	* c-typeck.cc (build_binary_op): Likewise.
gcc/cp/
	* constexpr.cc (cxx_eval_check_shift_p): Use TYPE_OVERFLOW_WRAPS
	instead of TYPE_UNSIGNED.
	* typeck.cc (cp_build_binary_op): Don't emit
	-Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS.
gcc/testsuite/
	* c-c++-common/Wshift-negative-value-1.c: Remove
	dg-additional-options, instead in target selectors of each diagnostic
	check for exact C++ versions where it should be diagnosed.
	* c-c++-common/Wshift-negative-value-2.c: Likewise.
	* c-c++-common/Wshift-negative-value-3.c: Likewise.
	* c-c++-common/Wshift-negative-value-4.c: Likewise.
	* c-c++-common/Wshift-negative-value-7.c: New test.
	* c-c++-common/Wshift-negative-value-8.c: New test.
	* c-c++-common/Wshift-negative-value-9.c: New test.
	* c-c++-common/Wshift-negative-value-10.c: New test.
	* c-c++-common/Wshift-overflow-1.c: Remove
	dg-additional-options, instead in target selectors of each diagnostic
	check for exact C++ versions where it should be diagnosed.
	* c-c++-common/Wshift-overflow-2.c: Likewise.
	* c-c++-common/Wshift-overflow-5.c: Likewise.
	* c-c++-common/Wshift-overflow-6.c: Likewise.
	* c-c++-common/Wshift-overflow-7.c: Likewise.
	* c-c++-common/Wshift-overflow-8.c: New test.
	* c-c++-common/Wshift-overflow-9.c: New test.
	* c-c++-common/Wshift-overflow-10.c: New test.
	* c-c++-common/Wshift-overflow-11.c: New test.
	* c-c++-common/Wshift-overflow-12.c: New test.
2022-03-09 09:15:28 +01:00
Jakub Jelinek
7ca24ae570 simplify-rtx: Fix up SUBREG_PROMOTED_SET arguments [PR104839]
The following testcase is miscompiled on powerpc64le-linux at -O1 and higher
(except for -Og).  The bug was introduced in r12-3252-gcad36f38576a6a7
which for SIGN_EXTEND from SUBREG_PROMOTED_SIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 1) (but that makes temp
SUBREG_PROMOTED_UNSIGNED_P because SRP_UNSIGNED is 1) and similarly the
ZERO_EXTEND from SUBREG_PROMOTED_UNSIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 0) (but that makes temp
SUBREG_PROMOTED_SIGNED_P because SRP_SIGNED is 0).
The following patch fixes that (swaps the 0s and 1s), but for better
readability uses the SRP_* constants.
rtl.h has:
/* Valid for subregs which are SUBREG_PROMOTED_VAR_P().  In that case
   this gives the necessary extensions:
   0  - signed (SPR_SIGNED)
   1  - normal unsigned (SPR_UNSIGNED)
   2  - value is both sign and unsign extended for mode
        (SPR_SIGNED_AND_UNSIGNED).
   -1 - pointer unsigned, which most often can be handled like unsigned
        extension, except for generating instructions where we need to
        emit special code (ptr_extend insns) on some architectures
        (SPR_POINTER). */
The expr.c change in the same commit looks ok to me (passes unsignedp
to SUBREG_PROMOTED_SET, so 0 for signed, 1 for unsigned).

2022-03-09  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/104839
	* simplify-rtx.cc (simplify_unary_operation_1) <case SIGN_EXTEND>:
	Use SRP_SIGNED instead of incorrect 1 in SUBREG_PROMOTED_SET.
	(simplify_unary_operation_1) <case ZERO_EXTEND>: Use SRP_UNSIGNED
	instead of incorrect 0 in SUBREG_PROMOTED_SET.

	* gcc.c-torture/execute/pr104839.c: New test.
2022-03-09 09:12:38 +01:00
Xi Ruoyao
2ab70a4a5c
mips: avoid signed overflow in LUI_OPERAND [PR104842]
gcc/

	PR target/104842
	* config/mips/mips.h (LUI_OPERAND): Cast the input to an unsigned
	value before adding an offset.
2022-03-09 11:21:08 +08:00
Jonathan Wakely
17bffa0c9f contrib: Fix non-portable sed commands in gcc-descr [PR102664/]
POSIX sed does not support \? or \+ in its Basic Regular Expression
grammar. Replace the \(tags/\)\? part of the pattern with a substitution
to remove ^tags/ before other substitutions. Replace \([0-9]\+\) with
\([0-9][0-9]*\) or with \([1-9][0-9]*\) in release branch numbers, where
a leading zero does not occur.

contrib/ChangeLog:

	PR other/102664
	* git-descr.sh: Use portable sed commands.
	* git-undescr.sh: Likewise.
2022-03-09 00:19:01 +00:00
GCC Administrator
8d038a841a Daily bump. 2022-03-09 00:16:29 +00:00
Roger Sayle
e52af9cac7 PR c++/96440: ICE-on-invalid-code error recovery.
This patch fixes PR c++/96440 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
	PR c++/96440
	* decl.cc (start_decl): Defend against prefix_attributes being
	error_mark_node.

gcc/testsuite/ChangeLog
	PR c++/96440
	* g++.dg/cpp0x/pr96440.C: New test case.
2022-03-08 23:33:46 +00:00
Tobias Burnus
48777d982a Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
PR fortran/104126
gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Handle NULL
	without MOLD.

gcc/testsuite/ChangeLog:

	* gfortran.dg/null_actual_2.f90: New test.
2022-03-09 00:27:45 +01:00
Roger Sayle
3093f8a18e PR c++/96437: ICE-on-invalid-code error recovery.
This patch fixes PR c++/96437 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
	PR c++/96437
	* parser.cc (synthesize_implicit_template_parm): Check that
	TREE_VALUE (new_parm) isn't error_mark_node before setting its
	DECL_VIRTUAL_P.

gcc/testsuite/ChangeLog
	PR c++/96437
	* g++.dg/cpp2a/pr96437.C: New test case.
2022-03-08 23:23:19 +00:00
Roger Sayle
8ab72ec7c4 PR c++/96329: ICE-on-invalid-code error recovery.
This patch fixes PR c++/96329 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
	PR c++/96329
	* parser.cc (cp_parser_linkage_specification): Treat the case where
	linkage is error_mark_node as "invalid linkage-specification".

gcc/testsuite/ChangeLog
	PR c++/96329
	* g++.dg/template/pr96329.C: New test case.
2022-03-08 23:18:34 +00:00
Marek Polacek
d54ce4641e c++: Wrong error with alias template in class tmpl [PR104108]
In r10-6329 I tried to optimize the number of calls to v_d_e_p in
convert_nontype_argument by remembering whether the expression was
value-dependent in a bool flag.  I did that wrongly assuming that its
value-dependence will not be changed by build_converted_constant_expr.
This testcase shows that it can: b_c_c_e gets a VAR_DECL for m_parameter,
which is not value-dependent, but we're converting it to "const int &"
so it returns

  (const int &)(const int *) &m_parameter

which suddenly becomes value-dependent because of the added ADDR_EXPR:
has_value_dependent_address is now true because m_parameter's context S<T>
is dependent.  With this bug in place, we went to the second branch here:

      if (TYPE_REF_OBJ_P (TREE_TYPE (expr)) && val_dep_p)
        /* OK, dependent reference.  We don't want to ask whether a DECL is
           itself value-dependent, since what we want here is its address.  */;
      else
        {
          expr = build_address (expr);

          if (invalid_tparm_referent_p (type, expr, complain))
            return NULL_TREE;
        }

wherein build_address created a bad tree and then i_t_r_p complained.

	PR c++/104108

gcc/cp/ChangeLog:

	* pt.cc (convert_nontype_argument): Recompute
	value_dependent_expression_p after build_converted_constant_expr.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-74.C: New test.
2022-03-08 17:37:22 -05:00
Ian Lance Taylor
2858e2afcb compiler: ignore function type result name in export data
This change ensures that we never output a result name in the export
data if there is only a single result.  Previously we would output a ?
if the single result had a name.  That made the output unstable,
because the hashing ignores the result name, so whether we output a ?
or not depended on how equal hash elements were handled.

For https://gcc.gnu.org/PR104832

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/390874
2022-03-08 13:53:59 -08:00
Marek Polacek
6f748bc1e7 c++: Attribute deprecated/unavailable divergence
Attributes deprecated and unavailable are largely the same, except
that the former produces a warning whereas the latter produces an error.
So is_late_template_attribute should treat them the same.  Confirmed by
Iain that this divergence is not intentional:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-February/591007.html>.

gcc/cp/ChangeLog:

	* decl2.cc (is_late_template_attribute): Do not defer attribute
	unavailable.
	* pt.cc (tsubst_enum): Set TREE_UNAVAILABLE.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-unavailable-9.C: Add dg-error.
2022-03-08 16:15:55 -05:00
Harald Anlauf
e3e369dad6 Fortran: do not frontend-optimize MINLOC/MAXLOC for character arrays
gcc/fortran/ChangeLog:

	PR fortran/104811
	* frontend-passes.cc (optimize_minmaxloc): Do not attempt
	frontend-optimization of MINLOC/MAXLOC for character arrays, as
	there is no suitable code yet for inline expansion.

gcc/testsuite/ChangeLog:

	PR fortran/104811
	* gfortran.dg/minmaxloc_16.f90: New test.
2022-03-08 21:47:04 +01:00
Jakub Jelinek
e480c3c06d c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
On the following testcase, we emit "did you mean '__dt '?" in the error
message.  "__dt " shows there because it is dtor_identifier, but we
shouldn't suggest those to the user, they are purely internal and can't
be really typed by the user because of the final space in it.

2022-03-08  Jakub Jelinek  <jakub@redhat.com>

	PR c++/104806
	* search.cc (lookup_field_fuzzy_info::fuzzy_lookup_field): Ignore
	identifiers with space at the end.

	* g++.dg/spellcheck-pr104806.C: New test.
2022-03-08 21:41:21 +01:00
Christophe Lyon
768956c0d1 arm: Remove unused variable arm_binop_none_none_unone_qualifiers
Commits r12-7342 and r12-7344 made some cleanup, leaving
arm_binop_none_none_unone_qualifiers unused.
This is causing build failures with -Werror (eg bootstrap).

This patch fixes the problem by removing the definition of
arm_binop_none_none_unone_qualifiers and
BINOP_NONE_NONE_UNONE_QUALIFIERS which are now unused.

Tested by bootstraping on arm-linux-gnueaibhf.

2022-03-04  Christophe Lyon  <christophe.lyon@arm.com>

	gcc/
	* config/arm/arm-builtins.cc
	(arm_binop_none_none_unone_qualifiers): Delete.
	(BINOP_NONE_NONE_UNONE_QUALIFIERS): Delete.
2022-03-08 21:21:03 +01:00
Iain Sandoe
34b45cc526 Darwin: Address a translation comment [PR104552].
This amends an error message to correct punctuation and a little
better wording.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

	PR translation/104552

gcc/ChangeLog:

	* config/host-darwin.cc (darwin_gt_pch_get_address): Amend
	the PCH out of memory error message punctuation and wording.
2022-03-08 19:29:47 +00:00
David Malcolm
b7175f3681 analyzer: more test coverage of leak detection [PR99771]
gcc/testsuite/ChangeLog:
	PR analyzer/99771
	* gcc.dg/analyzer/leak-4.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-03-08 14:16:48 -05:00
Marek Polacek
e1133c0205 rtl: ICE with thread_local and inline asm [PR104777]
In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can
jump to a label, the insn should be a JUMP_INSN.

However, as the following testcase shows, non-null ASM_OPERANDS_LABEL_VEC
doesn't guarantee that the rtx has any actual labels it can branch to.
Here, the rtvec has 0 elements because expand_asm_stmt created it:

  rtvec labelvec = rtvec_alloc (nlabels); // nlabels == 0

This causes an ICE in update_br_prob_note: BRANCH_EDGE (bb) crashes
because there's no branch edge.  I think we can fix this by checking
that there is at least one label the asm can jump to before wrapping
the ASM_OPERANDS in a JUMP_INSN.

	PR rtl-optimization/104777

gcc/ChangeLog:

	* rtl.cc (classify_insn): For ASM_OPERANDS, return JUMP_INSN only if
	ASM_OPERANDS_LABEL_VEC has at least one element.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/tls/pr104777.c: New test.
2022-03-08 14:00:32 -05:00
H.J. Lu
23ed4df521 x86: Disallow unsupported EH return
Disallow stack realignment and regparm nested function with EH return
since they don't work together.

gcc/

	PR target/104781
	* config/i386/i386.cc (ix86_expand_epilogue): Sorry if there is
	stack realignment or regparm nested function with EH return.

gcc/testsuite/

	PR target/104781
	* gcc.target/i386/eh_return-1.c: Add -mincoming-stack-boundary=4.
	* gcc.target/i386/eh_return-2.c: Likewise.
2022-03-08 09:56:02 -08:00
Andre Vieira
796f5220c8 arm: MVE: Relax addressing modes for full loads and stores
This patch relaxes the addressing modes for the mve full load and stores (by
full loads and stores I mean non-widening or narrowing loads and stores resp).
The code before was requiring a LO_REGNUM for these, where this is only a
requirement if the load is widening or the store narrowing.

gcc/ChangeLog:

	PR target/104790
	* config/arm/arm.h (MVE_STN_LDW_MODE): New MACRO.
	* config/arm/arm.cc (mve_vector_mem_operand): Relax constraint on base
	register for non widening loads or narrowing stores.
2022-03-08 17:50:51 +00:00
Eric Gallager
6319391d56 Fix typo in gcc/params.opt.
Addresses one of the points raised in #104552; checking in under
the "obvious" rule.

gcc/ChangeLog:
	PR translation/104552
	* params.opt: Fix typo.
2022-03-08 12:14:33 -05:00
Jonathan Wakely
10ecf5182a contrib: Fix gcc-descr script [PR102664]
POSIX expr does not support the 'match' keyword, so the git-descr.sh
scripts should use ':' instead.

contrib/ChangeLog:

	PR other/102664
	* git-descr.sh: Use portable form of expr match.
2022-03-08 16:46:36 +00:00
Richard Biener
058d19b42a tree-optimization/84201 - add --param vect-induction-float
This adds a --param to allow disabling of vectorization of
floating point inductions.  Ontop of -Ofast this should allow
549.fotonik3d_r to not miscompare.

2022-03-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/84201
	* params.opt (-param=vect-induction-float): Add.
	* doc/invoke.texi (vect-induction-float): Document.
	* tree-vect-loop.cc (vectorizable_induction): Honor
	param_vect_induction_float.

	* gcc.dg/vect/pr84201.c: New testcase.
2022-03-08 15:57:50 +01:00
Jonathan Wakely
7cce7b1c3d libstdc++: Remove incorrect copyright notice from header
This file has the SGI copyright notice, but contains no code from
the SGI STL. It was entirely written by me in 2019, originally as part
of the <memory> header. When I extracted it into a new header I
accidentally copied across the SGI copyright, but that only applies to
some much older parts of <memory>.

libstdc++-v3/ChangeLog:

	* include/bits/uses_allocator_args.h: Remove incorrect copyright
	notice.
2022-03-08 12:53:04 +00:00
Tamar Christina
5f07095d22 vect: disable bitmask tests on sparc
These testcases declare requiring vect_int which sparc declares as well however
sparc doesn't have an optab to vectorize comparisons so these testcases fail to
vectorize and so the tests fail.

As such best coure of action is to just skip them on sparc as comparisons are
somewhat expected from a target that can do SIMD.

gcc/testsuite/ChangeLog:

	PR tree-optimization/104755
	* gcc.dg/vect/vect-bic-bitmask-10.c: Disable sparc.
	* gcc.dg/vect/vect-bic-bitmask-11.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-12.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-2.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-23.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-3.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-4.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-5.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-6.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-8.c: Likewise.
	* gcc.dg/vect/vect-bic-bitmask-9.c: Likewise.
2022-03-08 11:32:59 +00:00
Martin Jambor
da2667cb02
params: Remove repeated word "that" in parameter description
One of the mistakes reported in PR 104552 is repeated "that" in
description of ipa-cp-recursive-freq-factor which I introduced.  This
patch removes one of them.

gcc/ChangeLog:

2022-03-07  Martin Jambor  <mjambor@suse.cz>

	PR translation/104552
	* params.opt (ipa-cp-recursive-freq-factor): Remove repeated word
	"that" in the description.
2022-03-08 11:47:56 +01:00
Richard Biener
dc46350d44 tree-optimization/104825 - guard modref query
The following makes sure to guard the modref query in VN on a
pointer typed argument.

2022-03-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104825
	* tree-ssa-sccvn.cc (visit_reference_op_call): Properly
	guard modref get_ao_ref on a pointer typed argument.

	* gcc.dg/torture/pr104825.c: New testcase.
2022-03-08 09:55:58 +01:00
liuhongt
b1a741a030 Optimize v4si broadcast for noavx512vl.
This will enable below

-       vbroadcastss    .LC1(%rip), %xmm0
+       movl    $-45, %edx
+       vmovd   %edx, %xmm0
+       vpshufd $0, %xmm0, %xmm0

According to microbenchmark, it's faster than broadcast from memory
for TARGET_INTER_UNIT_MOVES_TO_VEC.

gcc/ChangeLog:

	* config/i386/sse.md (*vec_dupv4si): Disable memory operand
	for !TARGET_INTER_UNIT_MOVES_TO_VEC when prefer_for_speed.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr100865-8a.c: Adjust testcase.
	* gcc.target/i386/pr100865-8c.c: Ditto.
	* gcc.target/i386/pr100865-9c.c: Ditto.
2022-03-08 09:02:05 +08:00
GCC Administrator
e6533e2ebe Daily bump. 2022-03-08 00:16:32 +00:00
Jason Merrill
03e0c807ef c++: tweak to (*(fn))() patch [PR104618]
Other callers of mark_single_function might also want to look through these
wrapapers.

	PR c++/104618

gcc/cp/ChangeLog:

	* decl2.cc (mark_single_function): Look through parens and location
	wrapper.
	* typeck.cc (cp_build_addr_expr_1): Not here.
2022-03-07 18:32:39 -05:00
Joseph Myers
b7dbe870bc Update gcc fr.po, sv.po
* fr.po, sv.po: Update.
2022-03-07 21:44:04 +00:00
Tobias Burnus
c0134b7383 Fortran: Fix gfc_maybe_dereference_var [PR104430][PR99585]
PR fortran/99585
	PR fortran/104430

gcc/fortran/ChangeLog:

	* trans-expr.cc (conv_parent_component_references): Fix comment;
	simplify comparison.
	(gfc_maybe_dereference_var): Avoid d referencing a nonpointer.

gcc/testsuite/ChangeLog:

	* gfortran.dg/class_result_10.f90: New test.
2022-03-07 22:11:33 +01:00
David Malcolm
0af37ad442 analyzer: fix leak suppression at end of 'main' [PR101983]
PR analyzer/101983 reports what I thought were false positives
from -Wanalyzer-malloc-leak, but on closer inspection, the
analyzer is correctly reporting heap-allocated buffers that are
no longer reachable.

However, these "leaks" occur at the end of "main".  The analyzer already
has some logic to avoid reporting leaks at the end of main, where the
leak is detected at the end of the EXIT basic block.  However, in this case,
the leak is detected at the clobber in BB 2 here:
  <bb 2> :
  func (&res);
  res ={v} {CLOBBER(eol)};
  _4 = 0;

  <bb 3> :
<L0>:
  return _4;

where we have a chain BB 2 -> BB 3 -> EXIT BB.

This patch generalizes the "are we at the end of 'main'" detection to
handle such cases, silencing -Wanalyzer-malloc-leak on them.

There's a remaining issue where the analyzer unhelpfully describes one
of the leaking values as '<unknown>', rather than 'res.a', but I'm
leaving that for a followup (covered by PR analyzer/99771).

gcc/analyzer/ChangeLog:
	PR analyzer/101983
	* engine.cc (returning_from_function_p): New.
	(impl_region_model_context::on_state_leak): Use it when rejecting
	leaks at the return from "main".

gcc/testsuite/ChangeLog:
	PR analyzer/101983
	* gcc.dg/analyzer/pr101983-main.c: New test.
	* gcc.dg/analyzer/pr101983-not-main.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-03-07 14:19:30 -05:00
Tobias Burnus
e3ca3e7993 Fortran: Fix typos
gcc/fortran/ChangeLog:

	* array.cc (gfc_ref_dimen_size): Fix comment typo.
	* dump-parse-tree.cc (gfc_dump_c_prototypes): Likewise.
	* frontend-passes.cc (cfe_code): Likewise.
	* gfortran.texi: Likewise.
	* resolve.cc (generate_component_assignments): Likewise.
	* simplify.cc (gfc_simplify_this_image): Likewise.
	* trans-expr.cc (trans_scalar_class_assign,
	gfc_maybe_dereference_var): Likewise.
	* intrinsic.texi: Remove word duplication.
	* invoke.texi: Likewise.
2022-03-07 17:20:52 +01:00
Jonathan Wakely
a86ca83a1b doc: Remove redundant sentence about modules being in C++20
As C++20 has already been published, we don't need to link to the draft
(which is now the C++23 draft anyway). And there's no need to say it's
part of the C++20 spec, or that there might be defect reports. That's
true for everything in C++20, so calling it out here just for Modules
isn't needed.

gcc/ChangeLog:

	* doc/invoke.texi (C++ Modules): Remove anachronism.
2022-03-07 16:08:10 +00:00
Jonathan Wakely
4cb935cb69 libstdc++: Use visibility pragmas instead of attributes [PR104807]
The _GLIBCXX_PSEUDO_VISIBILITY macro isn't defined until after including
os_defines.h, so we can't use _GLIBCXX_VISIBILITY early in c++config.
Replace the uses of that macro with #pragma visibility push(default)
instead.

libstdc++-v3/ChangeLog:

	PR libstdc++/104807
	* include/bits/c++config (__terminate, __glibcxx_assert_fail):
	Replace _GLIBCXX_VISIBILITY on function with visibility pragma.
	(__is_constant_evaluated): Add visibility pragma.
2022-03-07 15:10:29 +00:00
Martin Liska
111754595c opts: fix -gtoggle + optimize attribute
Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and
so we need to drop it if we are called from optimize attribute and the
option is unset.

	PR middle-end/104381

gcc/ChangeLog:

	* opts.cc (finish_options): If debug info is disabled
	(debug_info_level) and -fvar-tracking is unset, disable it.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr104381.c: New test.
2022-03-07 15:45:21 +01:00
Jakub Jelinek
02b7dd7f82 Add missing space in various string literals
After more than 2 years I've run my
https://gcc.gnu.org/ml/gcc-patches/2017-02/msg00844.html
script again.  While it has lots of false positives, it discovered
two bugs.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
	* c-parser.cc (c_parser_omp_clause_map): Add missing space in string
	literal.
gcc/cp/
	* parser.cc (cp_parser_omp_clause_map): Add missing space in string
	literal.
2022-03-07 15:16:56 +01:00
Jakub Jelinek
027e304144 Fix up duplicated duplicated words in comments
Like in r10-7215-g700d4cb08c88aec37c13e21e63dd61fd698baabc 2 years ago,
I've run
grep -v 'long long\|optab optab\|template template\|double double' *.{[chS],cc} */*.{[chS],cc} *.def config/*/* 2>/dev/null | grep ' \([a-zA-Z]\+\) \1 '
and for the cases that looked clearly wrong changed them, mostly by removing
one of the duplicated words but in some cases with other changes.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-ssa-propagate.cc: Fix up duplicated word issue in a comment.
	* config/riscv/riscv.cc: Likewise.
	* config/darwin.h: Likewise.
	* config/i386/i386.cc: Likewise.
	* config/aarch64/thunderx3t110.md: Likewise.
	* config/aarch64/fractional-cost.h: Likewise.
	* config/vax/vax.cc: Likewise.
	* config/rs6000/pcrel-opt.md: Likewise.
	* config/rs6000/predicates.md: Likewise.
	* ctfc.h: Likewise.
	* tree-ssa-uninit.cc: Likewise.
	* value-relation.h: Likewise.
	* gimple-range-gori.cc: Likewise.
	* ipa-polymorphic-call.cc: Likewise.
	* pointer-query.cc: Likewise.
	* ipa-sra.cc: Likewise.
	* internal-fn.cc: Likewise.
	* varasm.cc: Likewise.
	* gimple-ssa-warn-access.cc: Likewise.
gcc/analyzer/
	* store.cc: Fix up duplicated word issue in a comment.
	* analyzer.cc: Likewise.
	* engine.cc: Likewise.
	* sm-taint.cc: Likewise.
gcc/c-family/
	* c-attribs.cc: Fix up duplicated word issue in a comment.
gcc/cp/
	* cvt.cc: Fix up duplicated word issue in a comment.
	* pt.cc: Likewise.
	* module.cc: Likewise.
	* coroutines.cc: Likewise.
gcc/fortran/
	* trans-expr.cc: Fix up duplicated word issue in a comment.
	* gfortran.h: Likewise.
	* scanner.cc: Likewise.
gcc/jit/
	* libgccjit.h: Fix up duplicated word issue in a comment.
2022-03-07 15:00:20 +01:00
Martin Liska
b1d8198e7d arm: add missing space to error.
PR target/104794

gcc/ChangeLog:

	* config/arm/arm.cc (arm_option_override_internal): Add missing
	space.
2022-03-07 14:16:21 +01:00
Richard Biener
5db1d7f143 tree-optimization/104782 - adjust PR101636 fix
This reverts the reversion of r10-5979 amending the CTOR case
with a comment as to why the conversion is not necessary there.
It also adds a testcase (but not for the CTOR case).

2022-03-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104782
	* tree-vect-slp.cc (vectorize_slp_instance_root_stmt):
	Re-instantiate r10-5979 fix, add comment.

	* gcc.dg/vect/pr104782.c: New testcase.
2022-03-07 12:33:35 +01:00
Martin Liska
40c1d4a07e MSP430: fix error message.
PR target/104797

gcc/ChangeLog:

	* config/msp430/msp430.cc (msp430_expand_delay_cycles): Remove
	parenthesis from built-in name.
2022-03-07 11:41:52 +01:00
Martin Liska
fcc48d2ed6 arm: fix option quoting in error messages.
PR target/104794

gcc/ChangeLog:

	* config/arm/arm.cc (arm_option_override_internal): Fix quoting
	of options in error messages.
	(arm_option_reconfigure_globals): Likewise.
2022-03-07 11:38:18 +01:00
Martin Liska
cfb46c944e translation: reuse string and use switch for codes
PR target/104794

gcc/ChangeLog:

	* config/arm/arm-builtins.cc (arm_expand_builtin): Reuse error
	message.  Fix ARM_BUILTIN_WRORHI and ARM_BUILTIN_WRORH that can
	have only range [0,32].
2022-03-07 11:37:55 +01:00
Jakub Jelinek
2472dcaa8c s390: Fix up *cmp_and_trap_unsigned_int<mode> constraints [PR104775]
The following testcase fails to assemble due to clgte %r6,0(%r1,%r10)
insn not being accepted by assembler.
My rough understanding is that in the RSY-b insn format the spot
in other formats used for index registers is used instead for M3 what
kind of comparison it is, so this patch follows what other similar
instructions use for constraint (i.e. one without index register).

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/104775
	* config/s390/s390.md (*cmp_and_trap_unsigned_int<mode>): Use
	S constraint instead of T in the last alternative.

	* gcc.target/s390/pr104775.c: New test.
2022-03-07 11:14:04 +01:00
Martin Liska
93ecb25cc6 translation: small fixes
PR translation/90148

gcc/fortran/ChangeLog:

	* intrinsic.cc (gfc_is_intrinsic): Remove asterisk from error
	message.

gcc/ChangeLog:

	* plugin.cc (default_plugin_dir_name): Remove <dir> from error
	message.
2022-03-07 11:03:58 +01:00
Martin Liska
d73ae7a72a Fix translation strings.
PR translation/90148

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_linux64_override_options): Put
	quote to a proper place.
	* plugin.cc (default_plugin_dir_name): Likewise.

gcc/fortran/ChangeLog:

	* intrinsic.cc (gfc_is_intrinsic): Put
	quote to a proper place.
2022-03-07 10:41:11 +01:00
Martin Liska
024bdd2262 rx: Fix translation string.
PR target/99297

gcc/ChangeLog:

	* config/rx/rx.cc (rx_expand_builtin_mvtc): Fix translation
	string.
2022-03-07 10:33:57 +01:00
Jakub Jelinek
3bd11f791e i386: Fix up cond_{and,ior,xor,mul}* [PR104779]
The following testcase ICEs, because the cond_andv* expander
has vector_operand predicates in both of the commutative inputs
and calls gen_andv*_mask which calls ix86_binary_operator_ok
in its condition, but nothing calls ix86_fixup_binary_operands_no_copy
during the expansion, which means cond_* accepts even operands
like 2 MEMs which then can't be matched.

The following patch handles it like most other insns that the other
cond_* patterns use - by having a separate define_expand that calls
ix86_fixup_binary_operands_no_copy and define_ins with
ix86_binary_operator_ok.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/104779
	* config/i386/sse.md (avx512dq_mul<mode>3<mask_name>): New
	define_expand pattern.  Rename define_insn to ...
	(*avx512dq_mul<mode>3<mask_name>): ... this.
	(<code><mode>3_mask): New any_logic define_expand pattern.
	(<mask_codefor><code><mode>3<mask_name>): Rename to ...
	(*<code><mode>3<mask_name>): ... this.

	* gcc.target/i386/pr104779.c: New test.
2022-03-07 09:40:51 +01:00