Commit Graph

192309 Commits

Author SHA1 Message Date
Harald Anlauf
0712f35637 Fortran: character length of pointer assignments in structure constructors
gcc/fortran/ChangeLog:

	PR fortran/50549
	* resolve.cc (resolve_structure_cons): Reject pointer assignments
	of character with different lengths in structure constructor.

gcc/testsuite/ChangeLog:

	PR fortran/50549
	* gfortran.dg/char_pointer_assign_7.f90: New test.
2022-03-29 20:30:56 +02:00
Marek Polacek
d886a5248e gimple: Wrong -Wimplicit-fallthrough with if(1) [PR103597]
This patch fixes a wrong -Wimplicit-fallthrough warning for

    case 0:
      if (1)  // wrong may fallthrough
	return 0;
    case 1:

which in .gimple looks like

    <D.1981>: // case 0
    if (1 != 0) goto <D.1985>; else goto <D.1986>;
    <D.1985>:
    D.1987 = 0;
    // predicted unlikely by early return (on trees) predictor.
    return D.1987;
    <D.1986>:  // dead
    <D.1982>: // case 1

and the warning thinks that <D.1986>: falls through to <D.1982>:.  It
does not know that <D.1986> is effectively a dead label, only reachable
through fallthrough from previous instructions, never jumped to.  To
that effect, Jakub introduced UNUSED_LABEL_P, which is set on such dead
labels.

collect_fallthrough_labels has code to deal with cases like

    case 2:
      if (e != 10)
	i++; // this may fallthru, warn
      else
	return 44;
    case 3:

which collects labels that may fall through.  Here it sees the "goto <D.1990>;"
at the end of the then branch and so when the warning reaches

    ...
    <D.1990>: // from if-then
    <D.1984>: // case 3

it knows it should warn about the possible fallthrough.  But an UNUSED_LABEL_P
is not a label that can fallthrough like that, so it should ignore those.

However, we still want to warn about this:

    case 0:
      if (1)
	n++; // falls through
    case 1:

so collect_fallthrough_labels needs to return the "n = n + 1;" statement, rather
than the dead label.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>

	PR middle-end/103597

gcc/ChangeLog:

	* gimplify.cc (collect_fallthrough_labels): Don't push UNUSED_LABEL_Ps
	into labels.  Maybe set prev to the statement preceding UNUSED_LABEL_P.
	(gimplify_cond_expr): Set UNUSED_LABEL_P.
	* tree.h (UNUSED_LABEL_P): New.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wimplicit-fallthrough-39.c: New test.
2022-03-29 14:10:37 -04:00
Patrick Palka
89976d0824 c-family: Add -Wmisleading-indentation testcase [PR71637]
We no longer emit a bogus warning for the below testcase after
r11-3266-g4839de55e2c986.

	PR c++/71637

gcc/testsuite/ChangeLog:

	* c-c++-common/Wmisleading-indentation-6.c: New test.
2022-03-29 13:44:05 -04:00
Michael Meissner
9f9ccc4a57 Allow vsx_extract_<mode> to use Altivec registers.
I noticed that the vsx_extract_<mode> pattern for V2DImode and V2DFmode
only allowed traditional floating point registers, and it did not allow
Altivec registers.  The original code was written a few years ago when we
used the old register allocator, and support for scalar floating point in
Altivec registers was just being added to GCC.

I have built the spec 2017 benchmark suite With all 4 patches in this
series applied, and compared it to the build with the previous 3 patches
applied.  In addition to the changes from the previous 3 patches, this
patch now changes the code for the following 3 benchmarks (2 floating
point, 1 integer):

	bwaves_r, fotonik3d_r, xalancbmk_r

I have built bootstrap versions on the following systems.  There were no
regressions in the runs:

	Power9 little endian, --with-cpu=power9
	Power10 little endian, --with-cpu=power10
	Power8 big endian, --with-cpu=power8 (both 32-bit & 64-bit tests)

2022-03-29   Michael Meissner  <meissner@linux.ibm.com>

gcc/
	* config/rs6000/vsx.md (vsx_extract_<mode>): Allow destination to
	be any VSX register.
2022-03-29 13:17:05 -04:00
Richard Earnshaw
b243ad1afb aarch64: correctly handle zero-sized bit-fields in AAPCS64 [PR102024]
On aarch64 the AAPCS64 states that an HFA is determined by the 'shape' of
the object after layout has been completed, so anything that adds no
members and does not cause the layout to be modified should be ignored
for the purposes of determining which registers are used for parameter
passing.

A zero-sized bit-field falls into this category.  This was not handled
correctly for C structs and in G++-11 only handled correctly because
such fields were eliminated early by the front end.

gcc/ChangeLog:

	PR target/102024
	* config/aarch64/aarch64.cc (aapcs_vfp_sub_candidate): Handle
	zero-sized bit-fields.  Detect cases where a warning may be needed.
	(aarch64_vfp_is_call_or_return_candidate): Emit a note if a
	zero-sized bit-field has caused parameter passing to change.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/aapcs64/test_28.c: New test.
2022-03-29 17:38:31 +01:00
Richard Earnshaw
3032df28f2 arm: correctly handle zero-sized bit-fields in AAPCS [PR102024]
On arm the AAPCS states that an HFA is determined by the 'shape' of
the object after layout has been completed, so anything that adds no
members and does not cause the layout to be modified should be ignored
for the purposes of determining which registers are used for parameter
passing.

A zero-sized bit-field falls into this category.  This was not handled
correctly for C structs and in G++-11 only handled correctly because
such fields were eliminated early by the front end.

gcc/ChangeLog:

	PR target/102024
	* config/arm/arm.cc (aapcs_vfp_sub_candidate): Handle zero-sized
	bit-fields.  Detect cases where a warning may be needed.
	(aapcs_vfp_is_call_or_return_candidate): Emit a note if
	a zero-sized bit-field has caused parameter passing to change.

gcc/testsuite/ChangeLog:

	PR target/102024
	* gcc.target/arm/aapcs/vfp26.c: New test.
2022-03-29 17:37:15 +01:00
Richard Earnshaw
1dca4ca1bf arm: temporarily disable 'local' pcs selection (PR96882)
The arm port has an optimization used during selection of the
function's ABI to permit deviation from the strict ABI when the
function does not escape the current translation unit.

Unfortunately, the ABI selection it makes can be unsafe if it changes
how a result is returned because not enough information is available
via the RETURN_IN_MEMORY hook to determine where the function gets
used.  This can result in some parts of the compiler thinking a value
is returned in memory while others think it is returned in registers.

To mitigate this, this patch temporarily disables the optimization and
falls back to using the default ABI for the translation.

gcc/ChangeLog:

	PR target/96882
	* config/arm/arm.cc (arm_get_pcs_model): Disable selection of
	ARM_PCS_AAPCS_LOCAL.
2022-03-29 16:59:37 +01:00
Tom de Vries
a2eacdbd4c [nvptx] Add __PTX_ISA_VERSION_{MAJOR,MINOR}__
Add preprocessor macros __PTX_ISA_VERSION_MAJOR__ and
__PTX_ISA_VERSION_MINOR__.

For the default 6.0, we have:
...
 $ echo | cc1 -E -dD - 2>&1 | grep PTX_ISA_VERSION
 #define __PTX_ISA_VERSION_MAJOR__ 6
 #define __PTX_ISA_VERSION_MINOR__ 0
...
and for 3.1, we have:
...
 $ echo | cc1 -mptx=3.1 -E -dD - 2>&1 | grep PTX_ISA_VERSION
 #define __PTX_ISA_VERSION_MAJOR__ 3
 #define __PTX_ISA_VERSION_MINOR__ 1
...

These can be used to express things like:
...
 #if __PTX_ISA_VERSION_MAJOR__ >= 4 && __PTX_ISA_VERSION_MAJOR__ >= 1
   /* Code using %dynamic_smem_size.  */
 #else
   /* Fallback code.  */
 #endif
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	PR target/104857
	* config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Emit
	__PTX_ISA_VERSION_MAJOR__ and __PTX_ISA_VERSION_MINOR__.
	* config/nvptx/nvptx.cc (ptx_version_to_number): New function.
	* config/nvptx/nvptx-protos.h (ptx_version_to_number): Declare.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	PR target/104857
	* gcc.target/nvptx/ptx31.c: New test.
	* gcc.target/nvptx/ptx60.c: New test.
	* gcc.target/nvptx/ptx63.c: New test.
	* gcc.target/nvptx/ptx70.c: New test.
2022-03-29 16:16:31 +02:00
Tom de Vries
1625e893cc [nvptx] Update help text for m64
In the docs we have for m64:
...
Ignored, but preserved for backward compatibility.  Only 64-bit ABI is
supported.
...

But with --target-help, we have instead:
...
$ gcc --target-help
  ...
  -m64    Generate code for a 64-bit ABI.
...
which could be interpreted as meaning that generating code for a 32-bit ABI is
still possible.

Fix this by instead emitting the same text as in the docs:
...
  -m64    Ignored, but preserved for backward compatibility.  Only 64-bit
          ABI is supported.
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	* config/nvptx/nvptx.opt (m64): Update help text to reflect that it
	is ignored.
2022-03-29 14:35:44 +02:00
Tom de Vries
de0ef04419 [nvptx] Add march-map
Say we have an sm_50 board, and we want to run a benchmark using the highest
possible march setting.

Currently there's march=sm_30, march=sm_35, march=sm_53, but no march=sm_50.

So, we'd need to pick march=sm_35.

Likewise, for a test script that handles multiple boards, we'd need a mapping
from native board sm_xx to march, which might have to be updated with newer
gcc releases.

Add an option march-map, such that we can just specify march-map=sm_50, and
let the compiler map this to the appropriate march.

The option is implemented as a list of aliases, such that we have a somewhat
lengthy (17 lines in total):
...
$ gcc --help=target
  ...
  -march-map=sm_30            Same as -misa=sm_30.
  -march-map=sm_32            Same as -misa=sm_30.
  ...
  -march-map=sm_87            Same as -misa=sm_80.
  -march-map=sm_90            Same as -misa=sm_80.
...

This implementation was chosen in the hope that it'll be easier if
we end up with some misa multilib.

It would be nice to have the mapping list generated from an updated
nvptx-sm.def, but for now it's spelled out in nvptx.opt.

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	PR target/104714
	* config/nvptx/nvptx.opt (march-map=*): Add aliases.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	PR target/104714
	* gcc.target/nvptx/march-map.c: New test.
2022-03-29 14:00:25 +02:00
Jan Hubicka
871266756c Disable gathers for znver3 for vectors with 2 or 4 elements
gcc/ChangeLog:

2022-03-28  Jan Hubicka  <hubicka@ucw.cz>

	* config/i386/i386-builtins.cc (ix86_vectorize_builtin_gather): Test
	TARGET_USE_GATHER_2PARTS and TARGET_USE_GATHER_4PARTS.
	* config/i386/i386.h (TARGET_USE_GATHER_2PARTS): New macro.
	(TARGET_USE_GATHER_4PARTS): New macro.
	* config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): New tune
	(X86_TUNE_USE_GATHER_4PARTS): New tune
2022-03-29 13:59:14 +02:00
Tom de Vries
c5db32a143 [nvptx] Add march alias for misa
The target option misa has the following description:
...
$ gcc --target-help 2>&1 | grep misa
  -misa=                      Specify the PTX ISA target architecture to use.
...

The name misa is somewhat poorly chosen.  It suggests that for a use
-misa=sm_30, sm_30 is the name of a specific Instruction Set Architecture.
Instead, sm_30 is the name of a specific target architecture in the generic
PTX Instruction Set Architecture.

Futhermore, there's mptx, which also has ISA in the description:
...
  -mptx=                      Specify the PTX ISA version to use.
...

Add the more intuitive alias march for misa:
...
$ gcc --target-help 2>&1 | grep march
  -march=                     Alias:  Same as -misa=.
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	* config/nvptx/nvptx.opt (march): Add alias of misa.

gcc/testsuite/ChangeLog:

2022-03-29  Tom de Vries  <tdevries@suse.de>

	* gcc.target/nvptx/main.c: New test.
	* gcc.target/nvptx/march.c: New test.
2022-03-29 12:55:35 +02:00
Chenghua Xu
06ff470638 MAINTAINERS: Add myself and Lulu as LoongArch port maintainer.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>

ChangeLog:

	* MAINTAINERS: (CPU Port Maintainers): Add myself and
	Lulu as LoongArch port maintainer.
2022-03-29 17:56:06 +08:00
chenglulu
8766689a78 LoongArch Port: Add doc.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* doc/install.texi: Add LoongArch options section.
	* doc/invoke.texi: Add LoongArch options section.
	* doc/md.texi: Add LoongArch options section.

contrib/ChangeLog:

	* config-list.mk: Add LoongArch triplet.
2022-03-29 17:43:36 +08:00
chenglulu
4ae54e8dec LoongArch Port: gcc/testsuite
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-rom.C: Add build options for LoongArch.
	* g++.old-deja/g++.abi/ptrmem.C: Add LoongArch support.
	* g++.old-deja/g++.pt/ptrmem6.C: xfail for LoongArch.
	* gcc.dg/20020312-2.c: Add LoongArch support.
	* c-c++-common/zero-scratch-regs-10.c: Like wise
	* c-c++-common/zero-scratch-regs-11.c: Like wise
	* c-c++-common/zero-scratch-regs-8.c: Like wise
	* c-c++-common/zero-scratch-regs-9.c: Like wise
	* gcc.dg/loop-8.c: Skip on LoongArch.
	* gcc.dg/torture/stackalign/builtin-apply-2.c: Likewise.
	* gcc.dg/tree-ssa/ssa-fre-3.c: Likewise.
	* go.test/go-test.exp: Define the LoongArch target.
	* lib/target-supports.exp: Like wise.
	* gcc.target/loongarch/loongarch.exp: New file.
	* gcc.target/loongarch/tst-asm-const.c: Like wise.
	* gcc.target/loongarch/larch-builtin.c: Like wise.
2022-03-29 17:43:36 +08:00
chenglulu
34024b7150 LoongArch Port: libgomp
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

libgomp/ChangeLog:

	* configure.tgt: Add LoongArch triplet.
2022-03-29 17:43:35 +08:00
chenglulu
b38100eb08 LoongArch Port: Regenerate libgcc/configure.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

libgcc/ChangeLog:

	* configure: Regenerate file.
2022-03-29 17:43:35 +08:00
chenglulu
bf291a4330 LoongArch Port: libgcc
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

libgcc/ChangeLog:

	* config/loongarch/crtfastmath.c: New file.
	* config/loongarch/linux-unwind.h: Like wise.
	* config/loongarch/sfp-machine.h: Like wise.
	* config/loongarch/t-crtstuff: Like wise.
	* config/loongarch/t-loongarch: Like wise.
	* config/loongarch/t-loongarch64: Like wise.
	* config/loongarch/t-softfp-tf: Like wise.
	* config.host: Add LoongArch tuples.
	* configure.ac: Add LoongArch support.
2022-03-29 17:43:35 +08:00
chenglulu
7e60c24caa LoongArch Port: Builtin macros.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* config/loongarch/loongarch-c.cc
2022-03-29 17:43:35 +08:00
chenglulu
2aca9d5b92 LoongArch Port: Builtin functions.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* config/loongarch/larchintrin.h: New file.
	* config/loongarch/loongarch-builtins.cc: New file.
2022-03-29 17:43:34 +08:00
chenglulu
62ec3b5352 LoongArch Port: Machine description C files and .h files.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* config/host-linux.cc: Add LoongArch support.
	* config/loongarch/loongarch-protos.h: New file.
	* config/loongarch/loongarch-tune.h: Likewise.
	* config/loongarch/loongarch.cc: Likewise.
	* config/loongarch/loongarch.h: Likewise.
2022-03-29 17:43:34 +08:00
chenglulu
bcaf571cf9 LoongArch Port: Machine description files.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* config/loongarch/constraints.md: New file.
	* config/loongarch/generic.md: New file.
	* config/loongarch/la464.md: New file.
	* config/loongarch/loongarch-ftypes.def: New file.
	* config/loongarch/loongarch-modes.def: New file.
	* config/loongarch/loongarch.md: New file.
	* config/loongarch/predicates.md: New file.
	* config/loongarch/sync.md: New file.
2022-03-29 17:43:33 +08:00
chenglulu
225761396d LoongArch Port: Regenerate gcc/configure.
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* configure: Regenerate file.
2022-03-29 17:43:33 +08:00
chenglulu
b44786f640 LoongArch Port: gcc build
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

gcc/ChangeLog:

	* common/config/loongarch/loongarch-common.cc: New file.
	* config/loongarch/genopts/genstr.sh: New file.
	* config/loongarch/genopts/loongarch-strings: New file.
	* config/loongarch/genopts/loongarch.opt.in: New file.
	* config/loongarch/loongarch-str.h: New file.
	* config/loongarch/gnu-user.h: New file.
	* config/loongarch/linux.h: New file.
	* config/loongarch/loongarch-cpu.cc: New file.
	* config/loongarch/loongarch-cpu.h: New file.
	* config/loongarch/loongarch-def.c: New file.
	* config/loongarch/loongarch-def.h: New file.
	* config/loongarch/loongarch-driver.cc: New file.
	* config/loongarch/loongarch-driver.h: New file.
	* config/loongarch/loongarch-opts.cc: New file.
	* config/loongarch/loongarch-opts.h: New file.
	* config/loongarch/loongarch.opt: New file.
	* config/loongarch/t-linux: New file.
	* config/loongarch/t-loongarch: New file.
	* config.gcc: Add LoongArch support.
	* configure.ac: Add LoongArch support.

contrib/ChangeLog:

	* gcc_update (files_and_dependencies): Add
	  config/loongarch/loongarch.opt and config/loongarch/loongarch-str.h.
2022-03-29 17:43:32 +08:00
chenglulu
c6c0594ef8 LoongArch Port: Regenerate configure
2022-03-29  Chenghua Xu  <xuchenghua@loongson.cn>
	    Lulu Cheng  <chenglulu@loongson.cn>

ChangeLog:

	* configure.ac: Add LoongArch tuples.
	* configure: Regenerate.

config/ChangeLog:

	* picflag.m4: Default add build option '-fpic' for LoongArch.
2022-03-29 17:43:32 +08:00
Thomas Schwinge
2788d42bdc options: Fix 'enabledby_negargs' typo in 'LangEnabledBy' option property diagnostics
Originally introduced almost ten years ago in
r193303/commit 0829c7f7c5
"optc-gen.awk: Factor code out to...".

	gcc/
	* opt-functions.awk (lang_enabled_by): Fix 'enabledby_negargs'
	typo.
2022-03-29 11:18:36 +02:00
Jonathan Wakely
8bbeffc102 libstdc++: Workaround for missing 'using enum' in Clang 12
Once we no longer care about older compilers without this feature, we
can drop these static data members, so the names don't have to be
visible at class scope.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_order) [!__cpp_using_enum]: Add
	static data members for _Fp_fmt enumerators.
2022-03-29 10:06:33 +01:00
Jonathan Wakely
7255d29c57 libstdc++: Fix incorrect preprocessor conditions in <version>
The conditions that guard the feature test macros in <version> should
match the main definitions of the macros in other headers.

This doesn't matter for GCC, because it supports all the conditions
being tested here, but it does matter for non-GCC compilers without the
relevant C++20 features.

libstdc++-v3/ChangeLog:

	* include/std/version (__cpp_lib_variant): Fix conditions to
	match <variant>.
	(__cpp_lib_expected): Fix condition to match <expected>.
2022-03-29 10:06:33 +01:00
Marc Poulhiès
35464c7903 testsuite: Check fpic support in pr103275.c
Test must check for effective support of fpic.

gcc/testsuite/ChangeLog:
	* gcc.target/i386/pr103275.c: Add missing
	dg-require-effective-target for checking fpic.
2022-03-29 10:36:36 +02:00
Marc Poulhiès
b6cccf88cb testsuite: fixup pr97521.c and pr96713.c on i686-*
On targets that do not have MXX/SSE enabled by default, pr97521
and pr96713 fail because they emit warnings:

pr97521.c:12:1: warning: MMX vector return without MMX enabled
                changes the ABI [-Wpsabi]
pr97521.c:11:1: note: the ABI for passing parameters with
                16-byte alignment has changed in GCC 4.6
pr97521.c:11:1: warning: SSE vector argument without SSE enabled
                changes the ABI [-Wpsabi]

Add -Wno-psabi to dg-options.

gcc/testsuite/ChangeLog:
	* gcc.target/i386/pr97521.c: Add -Wno-psabi to dg-options.
	* gcc.dg/analyzer/pr96713.c: Likewise.
2022-03-29 10:36:30 +02:00
Richard Biener
28c5df7930 tree-optimization/105080 - make sure SCEV is available for ranger
When doing format diagnostics at -O0 we should make sure to make
SCEV available to avoid false positives due to ranges we otherwise
can trivially compute.

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

	PR tree-optimization/105080
	* tree-ssa-strlen.cc (printf_strlen_execute): Always init
	loops and SCEV.

	* gcc.dg/pr105080.c: New testcase.
2022-03-29 08:14:40 +02:00
David Malcolm
3734527dfa analyzer: ensure that we purge state when reusing a conjured_svalue [PR105087]
PR analyzer/105087 describes a false positive from
-Wanalyzer-double-free in which the analyzer erroneously considers two
successive inlined vasprintf calls to have allocated the same pointer.

The root cause is that the result written back from vasprintf is a
conjured_svalue, and that we normally purge state when reusing a
conjured_svalue, but various places in the code were calling
region_model_manager::get_or_create_conjured_svalue but failing to
then call region_model::purge_state_involving on the result.

This patch fixes things by moving responsibility for calling
region_model::purge_state_involving into
region_model_manager::get_or_create_conjured_svalue, so that it is
always called when reusing a conjured_svalue, fixing the false positive.

gcc/analyzer/ChangeLog:
	PR analyzer/105087
	* analyzer.h (class conjured_purge): New forward decl.
	* region-model-asm.cc (region_model::on_asm_stmt): Add
	conjured_purge param to calls binding_cluster::on_asm and
	region_model_manager::get_or_create_conjured_svalue.
	* region-model-impl-calls.cc
	(call_details::get_or_create_conjured_svalue): Likewise for call
	to region_model_manager::get_or_create_conjured_svalue.
	(region_model::impl_call_fgets): Remove call to
	region_model::purge_state_involving, as this is now done
	implicitly by call_details::get_or_create_conjured_svalue.
	(region_model::impl_call_fread): Likewise.
	(region_model::impl_call_strchr): Pass conjured_purge param to
	call to region_model_manager::get_or_create_conjured_svalue.
	* region-model-manager.cc (conjured_purge::purge): New.
	(region_model_manager::get_or_create_conjured_svalue): Add
	param "p".  Use it to purge state when reusing an existing
	conjured_svalue.
	* region-model.cc (region_model::on_call_pre): Replace call to
	region_model::purge_state_involving with passing conjured_purge
	to region_model_manager::get_or_create_conjured_svalue.
	(region_model::handle_unrecognized_call): Pass conjured_purge to
	store::on_unknown_fncall.
	* region-model.h
	(region_model_manager::get_or_create_conjured_svalue): Add param
	"p".
	* store.cc (binding_cluster::on_unknown_fncall): Likewise.  Pass
	it on to region_model_manager::get_or_create_conjured_svalue.
	(binding_cluster::on_asm): Likewise.
	(store::on_unknown_fncall): Add param "p" and pass it on to
	binding_cluster::on_unknown_fncall.
	* store.h (binding_cluster::on_unknown_fncall): Add param p.
	(binding_cluster::on_asm): Likewise.
	(store::on_unknown_fncall): Likewise.
	* svalue.h (class conjured_purge): New.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/pr105087-1.c: New test.
	* gcc.dg/analyzer/pr105087-2.c: New test.
	* gcc.dg/analyzer/vasprintf-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-03-28 20:41:23 -04:00
David Malcolm
1203e8f788 analyzer: fix ICE with incorrect lookup of cgraph node [PR105074]
gcc/analyzer/ChangeLog:
	PR analyzer/105074
	* region.cc (ipa_ref_requires_tracking): Drop "context_fndecl",
	instead using the ref->referring to get the cgraph node of the
	caller.
	(symnode_requires_tracking_p): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/105074
	* gcc.dg/analyzer/pr105074.c: New test.
	* gcc.dg/analyzer/untracked-1.c (extern_fn_char_ptr): New decl.
	(test_13): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-03-28 20:40:16 -04:00
GCC Administrator
aab0127dae Daily bump. 2022-03-29 00:17:13 +00:00
Indu Bhagat
eed9d091de ctfout: use ctfc_get_num_ctf_vars instead
A minor cosmetic fix.

2022-03-28  Indu Bhagat  <indu.bhagat@oracle.com>

gcc/ChangeLog:

	* ctfout.cc (ctf_preprocess): Use ctfc_get_num_ctf_vars instead.
	(output_ctf_vars): Likewise.
2022-03-28 14:06:46 -07:00
Tom Tromey
88252529f0 Remove --with-gmp-dir and --with-mpfr-dir
The top-level configure options --with-gmp-dir and --with-mpfr-dir
were obsoleted and marked as "REMOVED" back in 2006.  I think that's
long enough ago for everyone to have updated their scripts, so this
patch removes them entirely.  While doing this, I also found one other
leftover that wasn't removed by the earlier patch.  This is also
removed here.

2022-03-28  Tom Tromey  <tromey@adacore.com>

	* configure.ac: Remove --with-mpfr-dir and --with-gmp-dir.
	* configure: Rebuild.
2022-03-28 14:18:57 -06:00
Joseph Myers
00635b6cf3 Update gcc sv.po
* sv.po: Update.
2022-03-28 20:04:59 +00:00
Jason Merrill
83a21c9934 c++: Fix __has_trivial_* docs [PR59426]
These have been misdocumented since C++98 POD was split into C++11 trivial
and standard-layout in r149721.

	PR c++/59426

gcc/ChangeLog:

	* doc/extend.texi: Refer to __is_trivial instead of __is_pod.
2022-03-28 15:36:13 -04:00
Jason Merrill
f8093854c7 c++: add comment
gcc/cp/ChangeLog:

	* pt.cc (determine_specialization): Add comment.
2022-03-28 15:36:12 -04:00
Patrick Palka
23e57329c6 c++: reject concept w/ multiple tparm lists [PR105067]
We weren't rejecting a concept declared with multiple template
parameter lists.

	PR c++/105067

gcc/cp/ChangeLog:

	* pt.cc (finish_concept_definition): Check that a concept is
	declared with exactly one template parameter list.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-err4.C: New test.
2022-03-28 14:15:39 -04:00
Patrick Palka
ecb4882e36 c++: constrained template friend matching ICE [PR105064]
Here during declaration matching for the two constrained template
friends, we crash from maybe_substitute_reqs_for because the second
friend doesn't yet have DECL_TEMPLATE_INFO set (we're being called
indirectly from push_template_decl).

As far as I can tell, this situation happens only when declaring a
constrained template friend within a non-template class (as in the
testcase), in which case the substitution would be a no-op anyway.
So this patch rearranges maybe_substitute_reqs_for to gracefully
handle missing DECL_TEMPLATE_INFO by just skipping the substitution.

	PR c++/105064

gcc/cp/ChangeLog:

	* constraint.cc (maybe_substitute_reqs_for): Don't assume
	DECL_TEMPLATE_INFO is available.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-friend9.C: New test.
2022-03-28 14:15:16 -04:00
H.J. Lu
cccbb77658 x86: Also use Yw in *ssse3_pshufbv8qi3 clobber
PR target/105068
	* config/i386/sse.md (*ssse3_pshufbv8qi3): Also replace "Yv" with
	"Yw" in clobber.
2022-03-28 10:47:02 -07:00
Tom de Vries
0127fb1b78 [nvptx] Improve help description of misa and mptx
Currently we have:
...
$ gcc --target-help 2>&1 | egrep "misa|mptx"
  -misa=                      Specify the version of the ptx ISA to use.
  -mptx=                      Specify the version of the ptx version to use.
  Known PTX ISA versions (for use with the -misa= option):
  Known PTX versions (for use with the -mptx= option):
...

As reported in PR104818, the "version of the ptx version" doesn't make much
sense.

Furthermore, the description of misa (and 'Known ISA versions') is misleading
because it does not specify the version of the PTX ISA, but rather the PTX ISA
target architecture.

Fix this by printing instead:
...
$ gcc --target-help 2>&1 | egrep "misa|mptx"
  -misa=                      Specify the PTX ISA target architecture to use.
  -mptx=                      Specify the PTX ISA version to use.
  Known PTX ISA target architectures (for use with the -misa= option):
  Known PTX ISA versions (for use with the -mptx= option):
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-28  Tom de Vries  <tdevries@suse.de>

	PR target/104818
	* config/nvptx/gen-opt.sh (ptx_isa): Improve help text.
	* config/nvptx/nvptx-gen.opt: Regenerate.
	* config/nvptx/nvptx.opt (misa, mptx, ptx_version): Improve help text.
	* config/nvptx/t-nvptx (s-nvptx-gen-opt): Add missing dependency on
	gen-opt.sh.
2022-03-28 18:38:57 +02:00
Jason Merrill
fc50d9a252 c++: hash table ICE with variadic alias [PR105003]
For PR104008 we thought it might be enough to keep strip_typedefs from
removing this alias template specialization, but this PR demonstrates that
other parts of the compiler also need to know to consider it dependent.

So, this patch changes complex_alias_template_p to no longer consider
template parameters used when their only use appears in a pack expansion,
unless they are the parameter packs being expanded.

To do that I also needed to change it to use cp_walk_tree instead of
for_each_template_parm.  It occurs to me that find_template_parameters
should probably also use cp_walk_tree, but I'm not messing with that now.

	PR c++/105003
	PR c++/104008
	PR c++/102869

gcc/cp/ChangeLog:

	* pt.cc (complex_alias_template_r): walk_tree callback,	replacing
	uses_all_template_parms_r, complex_pack_expansion_r.
	(complex_alias_template_p): Adjust.
	* tree.cc (strip_typedefs): Revert r12-7710 change.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/variadic-alias6.C: New test.
	* g++.dg/cpp0x/variadic-alias7.C: New test.
2022-03-28 10:57:08 -04:00
David Malcolm
875342766d gimple-fold: fix location of loads for memory ops [PR104308]
PR analyzer/104308 reports that when -Wanalyzer-use-of-uninitialized-value
complains about certain memmove operations where the source is
uninitialized, the diagnostic uses UNKNOWN_LOCATION:

In function 'main':
cc1: warning: use of uninitialized value '*(short unsigned int *)&s + 1' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
  'main': event 1
    |
    |pr104308.c:5:8:
    |    5 |   char s[5]; /* { dg-message "region created on stack here" } */
    |      |        ^
    |      |        |
    |      |        (1) region created on stack here
    |
  'main': event 2
    |
    |cc1:
    | (2): use of uninitialized value '*(short unsigned int *)&s + 1' here
    |

The issue is that gimple_fold_builtin_memory_op converts a memmove to:

  _3 = MEM <unsigned short> [(char * {ref-all})_1];
  MEM <unsigned short> [(char * {ref-all})&s] = _3;

but only sets the location of the 2nd stmt, not the 1st.

Fixed thusly, giving:

pr104308.c: In function 'main':
pr104308.c:6:3: warning: use of uninitialized value '*(short unsigned int *)&s + 1' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
    6 |   memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
      |   ^~~~~~~~~~~~~~~~~~~~
  'main': events 1-2
    |
    |    5 |   char s[5]; /* { dg-message "region created on stack here" } */
    |      |        ^
    |      |        |
    |      |        (1) region created on stack here
    |    6 |   memmove(s, s + 1, 2); /* { dg-warning "use of uninitialized value" } */
    |      |   ~~~~~~~~~~~~~~~~~~~~
    |      |   |
    |      |   (2) use of uninitialized value '*(short unsigned int *)&s + 1' here
    |

One side-effect of this change is a change in part of the output of
gcc.dg/uninit-40.c from:

  uninit-40.c:47:3: warning: ‘*(long unsigned int *)(&u[1][0][0])’ is used uninitialized [-Wuninitialized]
     47 |   __builtin_memcpy (&v[1], &u[1], sizeof (V));
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  uninit-40.c:45:5: note: ‘*(long unsigned int *)(&u[1][0][0])’ was declared here
     45 |   V u[2], v[2];
        |     ^

to:

  uninit-40.c:47:3: warning: ‘u’ is used uninitialized [-Wuninitialized]
     47 |   __builtin_memcpy (&v[1], &u[1], sizeof (V));
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  uninit-40.c:45:5: note: ‘u’ declared here
     45 |   V u[2], v[2];
        |     ^

What's happening is that pass "early_uninit"(29)'s call to
maybe_warn_operand is guarded by this condition:
  1051            else if (gimple_assign_load_p (stmt)
  1052                     && gimple_has_location (stmt))

Before the patch, the stmt:
  _3 = MEM <unsigned long> [(char * {ref-all})&u + 8B];
has no location, and so early_uninit skips this operand at line
1052 above.  Later, pass "uninit"(217) tests the var_decl "u$8", and
emits a warning for it.

With the patch, the stmt has a location, and so early_uninit emits a
warning for "u" and sets a NW_UNINIT warning suppression at that
location.  Later, pass "uninit"(217)'s test of "u$8" is rejected
due to that per-location suppression of uninit warnings, from the
earlier warning.

gcc/ChangeLog:
	PR analyzer/104308
	* gimple-fold.cc (gimple_fold_builtin_memory_op): When optimizing
	to loads then stores, set the location of the new load stmt.

gcc/testsuite/ChangeLog:
	PR analyzer/104308
	* gcc.dg/analyzer/pr104308.c: New test.
	* gcc.dg/uninit-40.c (foo): Update expression in expected message.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-03-28 09:43:07 -04:00
Jason Merrill
19b87a0648 c++: low -faligned-new [PR102071]
This test ICEd after the constexpr new patch (r10-3661) because alloc_call
had a NOP_EXPR around it; fixed by moving the NOP_EXPR to alloc_expr.  And
the PR pointed out that the size_t cookie might need more alignment, so I
fix that as well.

	PR c++/102071

gcc/cp/ChangeLog:

	* init.cc (build_new_1): Include cookie in alignment.  Omit
	constexpr wrapper from alloc_call.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/aligned-new9.C: New test.
2022-03-28 09:35:58 -04:00
Jason Merrill
8796eb27e2 c++: visibility of local extern [PR103291]
When setting up the hidden namespace-scope decl for a local extern, we also
need to set its visibility.

	PR c++/103291

gcc/cp/ChangeLog:

	* name-lookup.cc (push_local_extern_decl_alias): Call
	determine_visibility.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/visibility/visibility-local-extern1.C: New test.
2022-03-28 09:35:58 -04:00
Jason Merrill
b854ce130e c++: CTAD and member alias template [PR102123]
When building a deduction guide from the Test constructor, we need to
rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template
_dummy.  We were using SCOPE_REF for both type and non-type templates; we
need to use UNBOUND_CLASS_TEMPLATE for type templates.

	PR c++/102123

gcc/cp/ChangeLog:

	* pt.cc (tsubst_copy): Use make_unbound_class_template for rewriting
	a type template reference.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction110.C: New test.
2022-03-28 09:35:58 -04:00
Jason Merrill
c7361eb36f c++: member alias declaration [PR103968]
Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is
not value-dependent because neither the type nor the (value of) c_options
are dependent, but since we're binding it to a reference we also need to
consider that it has a value-dependent address.

	PR c++/103968

gcc/cp/ChangeLog:

	* pt.cc (value_dependent_expression_p): Check
	has_value_dependent_address for conversion to reference.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-mem1.C: New test.
2022-03-28 09:35:58 -04:00
Jason Merrill
8bc5cdaafa c++: CTAD and member function references [PR103943]
More quirks of rewriting member references to dependent references for
CTAD.  A reference to a member of dependent scope is definitely dependent.
And since r11-7044, tsubst_baselink builds a SCOPE_REF, so
tsubst_qualified_id should just use it.

	PR c++/103943

gcc/cp/ChangeLog:

	* pt.cc (tsubst_qualified_id): Handle getting SCOPE_REF from
	tsubst_baselink.
	(instantiation_dependent_scope_ref_p): Check dependent_scope_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction109.C: New test.
2022-03-28 09:35:58 -04:00