Commit Graph

191389 Commits

Author SHA1 Message Date
Jakub Jelinek 7f3915b83e rs6000: Fix bootstrap
> On 18/01/2022 22:42, Segher Boessenkool wrote:
> > > +    default:
> > > +      break;
> > Please don't do that.  You can do
> >
> >    default:
> >      break;
> >      break;
> >      /* And just to make sure:  */
> >      break;
> >      break;
> >
> > and it will do exactly the same as not having a default at all.  Not
> > having such useless code is by far the most readable, so please don't
> > include a default case at all.
>
> I removed the default case. I hope this is what you wanted.

Unfortunately the removal of default: break; breaks bootstrap:
../../gcc/config/rs6000/rs6000.cc: In function ‘const char* rs6000_machine_from_flags()’:
../../gcc/config/rs6000/rs6000.cc:5940:10: error: enumeration value ‘PROCESSOR_PPC601’ not handled in switch [-Werror=switch]
 5940 |   switch (rs6000_cpu)
      |          ^
../../gcc/config/rs6000/rs6000.cc:5940:10: error: enumeration value ‘PROCESSOR_PPC603’ not handled in switch [-Werror=switch]
...
default: break; is needed to tell the -Wswitch warning that it is intentional
that not all enumerators are handled in the switch.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	* config/rs6000/rs6000.cc (rs6000_machine_from_flags): Add default:.
2022-01-19 12:22:02 +01:00
Martin Liska 34ba4275dc Enable -Werror=format-diag during bootstrap.
gcc/ChangeLog:

	* configure.ac: Remove -Wno-error=format-diag.
	* configure: Regenerate.
2022-01-19 12:16:04 +01:00
Martin Liska fdf31ae25f Update on riscv -Wformat-diag string.
gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_handle_type_attribute):
	Update one -Wformat-diag string in warning message.
2022-01-19 10:33:01 +01:00
Jakub Jelinek 53836c887a gimple-ssa-warn-access: Fix up asan_test.C -Wdangling-pointer regression [PR104103]
As reported in the PR or as I've seen since the weekend, asan_test.C fails
because of many warnings like:
gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
gcc/testsuite/g++.dg/asan/asan_test.cc:1157:10: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
gcc/testsuite/g++.dg/asan/asan_test.cc:1162:27: error: using a dangling pointer to an unnamed temporary [-Werror=dangling-pointer=]
...
(lots of them).
There are no dangling pointers though, the warning pass sees:
  some_automatic_var ={v} {CLOBBER};
  .ASAN_MARK (POISON, &some_automatic_var, 8);
and warns on that (both on user vars and on e.g. TARGET_EXPR temporaries).
There is nothing wrong on that, .ASAN_MARK is compiler instrumentation,
which doesn't even touch the variable in any way nor make it escaped.
What it instead does is change bytes in the shadow memory corresponding
to the variable to reflect that the variable is out of scope and make
sure that access to it would be diagnosed at runtime.
So, for all purposes of the -Wdangling-pointer and -Wuse-after-free
warnings, we should ignore this internal call.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/104103
	* gimple-ssa-warn-access.cc (pass_waccess::check_call): Don't check
	.ASAN_MARK calls.
2022-01-19 09:28:25 +01:00
Jakub Jelinek b834435c8f fold-const: Optimize &"foo"[0] == "foo" [PR89074]
This is a non-C++ related part from the PR89074 address_compare changes.
For "foo" == "foo" we already optimize this from the (cmp @0 @0)
simplification, because we use operand_equal_p in that case
and operand_equal_p also compares the STRING_CSTs bytes rather than
just addresses.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89074
	* fold-const.cc (address_compare): Consider different STRING_CSTs
	with the same lengths that memcmp the same as equal, not different.

	* gcc.dg/tree-ssa/pr89074.c: New test.
2022-01-19 09:26:13 +01:00
Jakub Jelinek 29a6db635f i386: Fix *aes<aeswideklvariant>u8
grep '{[^|}]*}"' *.md

found another spot, though dunno if we have sufficient effective targets
etc. to add an -masm=intel test for it (and my installed binutils doesn't
support it anyway).
Binutils trunk testsuite shows the argument isn't omitted even in the Intel
syntax:
grep aesencwide *.s
keylocker.s:    aesencwide128kl 126(%edx)
keylocker.s:    aesencwide256kl 126(%edx)
keylocker.s:    aesencwide128kl [edx+126]
keylocker.s:    aesencwide256kl [edx+126]
property-10.s:   aesencwide128kl (%eax)
x86-64-keylocker.s:     aesencwide128kl 126(%rdx)
x86-64-keylocker.s:     aesencwide256kl 126(%rdx)
x86-64-keylocker.s:     aesencwide128kl [rdx+126]
x86-64-keylocker.s:     aesencwide256kl [rdx+126]
and doesn't use any WHATEVER PTR.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/sse.md (*aes<aeswideklvariant>u*): Use %0 instead of
	{%0}.
2022-01-19 09:17:54 +01:00
Martin Liska 03b0bf7830 Come up with git-fix-changelog.py script.
contrib/ChangeLog:

	* git-backport.py: Use it.
	* git-fix-changelog.py: New file.
	* gcc-git-customization.sh: Add new alias git gcc-fix-changelog.
2022-01-19 09:08:51 +01:00
Martin Liska 2aea19bdb1 nvptx: update fix for -Wformat-diag
gcc/ChangeLog:

	* config/nvptx/nvptx.cc (nvptx_goacc_validate_dims_1): Update
	warning messages.

libgomp/ChangeLog:

	* testsuite/libgomp.oacc-c++/privatized-ref-2.C: Update scanning
	patterns.
	* testsuite/libgomp.oacc-c++/privatized-ref-3.C: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/kernels-loop-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/pr85486.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-64-1.c:
	Likewise.
	* testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90:
	Likewise.
	* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90:
	Likewise.
	* testsuite/libgomp.oacc-fortran/kernels-loop-2.f95: Likewise.
	* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: Likewise.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-01-19 08:27:00 +01:00
Richard Biener 54e33cf120 testsuite/102833 - fix gcc.dg/vect/bb-slp-17.c dump scanning
The desired transform requires V2SI vector add support, the closest
we have is vect64 so check that which at least fixes the i?86 fail.

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

	PR testsuite/102833
	* gcc.dg/vect/bb-slp-17.c: Require vect64.
2022-01-19 08:18:52 +01:00
Sebastian Huber 1ead972cef powerc: Fix asm machine directive for some CPUs
For some CPUs, the assembler machine directive cannot be determined by ISA
flags.

gcc/

	PR target/104090
	* config/rs6000/rs6000.cc (rs6000_machine_from_flags): Use also
	rs6000_cpu.
2022-01-19 07:50:49 +01:00
Rimvydas Jasinskas 8160b41051 Fix tsvc test build on DragonFly.
Currently all tsvc tests fail to build on DragonFly BSD because they
assume <malloc.h> and memalign() are available.

gcc/testsuite/ChangeLog:

	PR testsuite/104021
	* gcc.dg/vect/tsvc/tsvc.h: Do not include malloc.h on dragonfly
	and use posix_memalign ().

Signed-off-by: Rimvydas Jasinskas <rimvydas.jas@gmail.com>
2022-01-19 07:47:07 +01:00
Rimvydas Jasinskas 32657045bd Add XFAIL parts of pr16855.C for dragonfly.
On DragonFly BSD profiling ends before these DTORs are invoked on dso cleanup.
The -static compilation works as expected.

gcc/testsuite/ChangeLog:

	PR testsuite/104022
	* g++.dg/gcov/pr16855.C: xfail the count lines for DTORs on dragonfly.
	* g++.dg/gcov/pr16855-priority.C: Ditto.  Adjust source layout so that
	dejagnu xfail expressions work.

Signed-off-by: Rimvydas Jasinskas <rimvydas.jas@gmail.com>
2022-01-19 07:45:46 +01:00
Martin Liska b01d2059c7 testsuite: fix pytest detection unsupported message.
PR testsuite/104109

gcc/testsuite/ChangeLog:

	* lib/gcov.exp: Fix pytest detection unsupported message.
2022-01-19 07:37:42 +01:00
Kewen Lin fc6cd798c0 testsuite: Adjust possibly fragile slp-perm-9.c [PR104015]
As Richard pointed out in PR104015, the test case slp-perm-9.c
can be fragile when vectorizer tries to use different
vectorisation strategies.

As suggested, this patch tries to make the check not sensitive
on the re-trying times by removing the times checking.  To still
retain the test coverage on unnecessary re-trying, for example
it exposes this PR104015 on Power9, I added two test cases to
powerpc testsuite.

gcc/testsuite/ChangeLog:

	PR tree-optimization/104015
	* gcc.dg/vect/slp-perm-9.c: Adjust.
	* gcc.target/powerpc/pr104015-1.c: New test.
	* gcc.target/powerpc/pr104015-2.c: New test.
2022-01-19 00:04:02 -06:00
Jason Merrill bd0ef35348 c++: fix PR104025 change
Somehow I pushed my earlier patch without it actually fixing the test; we
need input_location to be for the last consumed token, not the next one.

gcc/cp/ChangeLog:

	* parser.cc (saved_token_sentinel::rollback): Use
	cp_lexer_previous_token.
2022-01-18 23:06:56 -05:00
Jakub Jelinek ddce00dba2 i386: Fix GLC tuning with -masm=intel [PR104104]
> > On Sat, Jan 15, 2022 at 5:39 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
> > > Thanks for the suggestion, here is the updated patch that survived
> > > bootstrap/regtest.

Unfortunately the patch results in assembler failures with -masm=intel.

> > > > +  if (TARGET_DEST_FALSE_DEPENDENCY
> > > > +      && get_attr_dest_false_dep (insn) ==
> > > > +        DEST_FALSE_DEP_TRUE)
> > > > +    output_asm_insn ("vxorps\t{%x0, %x0, %x0}", operands);

All the vxorps insns were emitted like the above, which means for -masm=sysv
it looks like
        vxorps  %xmm3, %xmm3, %xmm3
but for -masm=intel like:
        vxorps
We want obviously
        vxorps  xmm3, xmm3, xmm3
so the following patch just drops the errorneous {}s.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR target/104104
	* config/i386/sse.md
	(<avx512>_<complexopname>_<mode><maskc_name><round_name>,
	avx512fp16_<complexopname>sh_v8hf<mask_scalarc_name><round_scalarcz_name>,
	avx512dq_mul<mode>3<mask_name>, <avx2_avx512>_permvar<mode><mask_name>,
	avx2_perm<mode>_1<mask_name>, avx512f_perm<mode>_1<mask_name>,
	avx512dq_rangep<mode><mask_name><round_saeonly_name>,
	avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>,
	<avx512>_getmant<mode><mask_name><round_saeonly_name>,
	avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>):
	Use vxorps\t%x0, %x0, %x0 instead of vxorps\t{%x0, %x0, %x0}.

	* gcc.target/i386/pr104104.c: New test.
2022-01-19 02:24:06 +01:00
Martin Sebor 6325041c2b Add test for bogus warning [PR104076].
Related:
PR middle-end/104076 - bogus -Wdangling-pointer on a conditional

gcc/testsuite/ChangeLog:
	PR middle-end/104076
	* g++.dg/warn/Wdangling-pointer-3.C: New test.
2022-01-18 18:04:08 -07:00
Martin Sebor 282110ae8b Suppress valid warning [PR104103].
gcc/testsuite/ChangeLog:
	PR middle-end/104103
	* gcc.dg/torture/pr57147-2.c: Prune out expected warning.
2022-01-18 18:04:08 -07:00
Martin Sebor 2f714642e5 Handle failure to determine pointer provenance conservatively [PR104069].
Partly resolves:
PR middle-end/104069 - -Werror=use-after-free false positive on elfutils-0.186

gcc/ChangeLog:
	PR middle-end/104069
	* gimple-ssa-warn-access.cc (pointers_related_p): Return false for
	an unknown result as documented.

gcc/testsuite/ChangeLog:
	PR middle-end/104069
	* gcc.dg/Wuse-after-free.c: New test.
2022-01-18 18:04:08 -07:00
Jonathan Wakely 9c186493a7 libstdc++: Update documentation for C++17 deprecations
libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document deprecations.
	* doc/xml/manual/status_cxx2017.xml: Update status.
	* doc/html/*: Regenerate.
2022-01-19 00:58:26 +00:00
Jonathan Wakely a68080a121 libstdc++: Fix deprecated attribute for std::get_temporary_buffer
This was deprecated in C++17, not C++14.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h (get_temporary_buffer): Change
	_GLIBCXX14_DEPRECATED to _GLIBCXX17_DEPRECATED.
2022-01-19 00:58:25 +00:00
Jonathan Wakely 72ce3fd2c7 libstdc++: Remove unused std::pair helper function
This function is no longer used since r12-6691 and can be removed.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (_PCC::_DeprConsPair): Remove unused
	function.
2022-01-19 00:58:25 +00:00
Jonathan Wakely c3861f7985 libstdc++: Fix std::atomic<std::shared_ptr<T>> for AIX [PR104101]
This fixes an on AIX.

The lock function currently just spins, which should be changed to use
back-off, and maybe then _M_val.wait(__current) when supported.

libstdc++-v3/ChangeLog:

	PR libstdc++/104101
	* include/bits/shared_ptr_atomic.h (_Sp_atomic::_Atomic_count::lock):
	Only use __thread_relax if __cpp_lib_atomic_wait is defined.
2022-01-19 00:58:21 +00:00
GCC Administrator 7a761ae658 Daily bump. 2022-01-19 00:16:32 +00:00
Andrew Pinski 5ce3c003df [COMMITTED] Improve coment for the newly added code in ipa-split.
It was pointed out to me by Jakub, that the comment in front of
the new code which handles warning/error attribute was not really
understandable. This fixes the comment to be understandable; I
don't know why I wrote the original comment that way even.

Committed as obvious after a quick build.

gcc/ChangeLog:

	* ipa-split.cc (visit_bb): Fix comment before the
	warning/error attribute checking code.
2022-01-18 15:45:20 -08:00
Jakub Jelinek 1a5145f1e3 c++: Fix handling of temporaries with consteval ctors and non-trivial dtors [PR104055]
The following testcase is miscompiled.  We see the constructor is immediate,
in build_over_call we trigger:
          if (obj_arg && is_dummy_object (obj_arg))
            {
              call = build_cplus_new (DECL_CONTEXT (fndecl), call, complain);
              obj_arg = NULL_TREE;
            }
which makes call a TARGET_EXPR with the dtor in TARGET_EXPR_CLEANUP,
but then call cxx_constant_value on it.  In cxx_eval_outermost_constant_expr
it triggers the:
      else if (TREE_CODE (t) != CONSTRUCTOR)
        {
          r = get_target_expr_sfinae (r, tf_warning_or_error | tf_no_cleanup);
          TREE_CONSTANT (r) = true;
        }
which wraps the CONSTRUCTOR r into a new TARGET_EXPR, but one without
dtors (I think we need e.g. the TREE_CONSTANT for the callers),
and finally build_over_call uses that.

The following patch fixes that by using get_target_expr instead
of get_target_expr_sfinae + TREE_CONSTANT (r) = true if t is
a TARGET_EXPR with non-NULL TARGET_EXPR_CLEANUP.

2022-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/104055
	* constexpr.cc (cxx_eval_outermost_constant_expr): If t is a
	TARGET_EXPR with TARGET_EXPR_CLEANUP, use get_target_expr rather
	than get_target_expr_sfinae with tf_no_cleanup, and don't set
	TREE_CONSTANT.

	* g++.dg/cpp2a/consteval27.C: New test.
2022-01-19 00:42:18 +01:00
Jason Merrill fdd6d85bd7 c++: Use -std=c++20 in testsuite default std list
C++20 has been official for a while now.

gcc/testsuite/ChangeLog:

	* lib/g++-dg.exp: Change 2a to 20.
2022-01-18 17:57:04 -05:00
Jason Merrill 2aa184458a c++: input_location and lookahead [PR104025]
Debug information was getting confused because input_location was different
depending on whether we had looked ahead to see if the next tokens look like
a template argument list.

I tried resetting input_location in cp_lexer_rollback_tokens itself, but
that caused regressions, so let's just do it here for now.

	PR c++/104025

gcc/cp/ChangeLog:

	* parser.cc (saved_token_sentinel::rollback): Call
	cp_lexer_set_source_position.
	(~saved_token_sentinel): Call rollback.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/pr104025.C: New test.

Co-authored-by: Jakub Jelinek  <jakub@redhat.com>
2022-01-18 17:57:04 -05:00
David Faust 7db42268ce bpf: ensure correct string offsets in BTF.ext
BPF CO-RE relocations contain offsets to strings buffered in the BTF
string table. These BTF-specific strings are stored in memory in the
CTF auxilliary strtab, which at output time is concatenated onto the end
of the standard strtab.

Previously, these string offsets were computed at the time the
relocations were created. But strings could be added to the standard
strtab after this point, causing the offsets to no longer be correct.

Compute the offsets just before output instead, when they are sure to no
longer change.

gcc/ChangeLog:

	* config/bpf/coreout.cc (bpf_core_reloc_add): Do not account
	for base strtab offset yet as it may change.
	(output_asm_btfext_core_reloc): Do so here instead.
	(output_btfext_core_sections): Likewise.
2022-01-18 13:20:49 -08:00
David Faust 43ec265213 bpf: write CO-RE relocation record size only once
The CO-RE relocation record size should be written only once in the
.BTF.ext section, not once for each section with relocations.

gcc/ChangeLog:

	* config/bpf/coreout.cc (output_btfext_header): Account for
	4-byte record size in core_relo_len.
	(output_btfext_core_sections): Only write record size once.
	* config/bpf/coreout.h (btf_ext_section_header): Delete unused
	member.

gcc/testsuite/ChangeLog:

	* gcc.target/bpf/core-section-1.c: Adjust expected record size
	occurrences.
2022-01-18 13:20:49 -08:00
David Malcolm 2aefe248aa analyzer: fix ICE on unary ops folding to casts of constants [PR104089]
gcc/analyzer/ChangeLog:
	PR analyzer/104089
	* region-model-manager.cc
	(region_model_manager::get_or_create_constant_svalue): Assert that
	we have a CONSTANT_CLASS_P.
	(region_model_manager::maybe_fold_unaryop): Only fold a constant
	when fold_unary's result is a constant or a cast of a constant.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/pr104089.c: New test.
	PR analyzer/104089

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-18 15:56:23 -05:00
David Malcolm 79e746bb05 analyzer: fix ICE on realloc of zeroed memory [PR104062]
gcc/analyzer/ChangeLog:
	PR analyzer/104062
	* region-model-manager.cc
	(region_model_manager::maybe_fold_sub_svalue): Avoid casting to
	NULL type when folding access to repeated svalue.

gcc/testsuite/ChangeLog:
	PR analyzer/104062
	* gcc.dg/analyzer/pr104062.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-18 15:55:12 -05:00
Jonathan Wakely fe3ed885cd libstdc++: Limit new basic_string(nullptr_t) constructor to C++23 [PR104099]
The new deleted constructors added by P2166R1 are a breaking change,
making previously valid code ill-formed in C++23. As a result, they
should only be defined for C++23 and not for C++11 and up.

libstdc++-v3/ChangeLog:

	PR libstdc++/104099
	* include/bits/basic_string.h (basic_string(nullptr_t)): Only
	define for C++23.
	(operator=(nullptr_t)): Likewise.
	* include/bits/cow_string.h: Likewise.
	* include/std/string_view (basic_string_view(nullptr_t)):
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/nullptr.cc: Adjust
	expected error. Add examples that become ill-formed in C++23.
	* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
	Adjust expected errors.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
	Likewise.
2022-01-18 20:41:46 +00:00
Patrick Palka 3c4a54adb2 c++: DEPENDENT_OPERATOR_TYPE as type of NTTP [PR104074]
We're incorrectly rejecting the below testcase during template argument
coercion because invalid_nontype_parm_type_p returns true for
DEPENDENT_OPERATOR_TYPE in C++17 mode.

This patch fixes this by partially rewriting invalid_nontype_parm_type_p
in terms of WILDCARD_TYPE_P, for which DEPENDENT_OPERATOR_TYPE is true,
so that the predicate handles wildcard types consistently.

	PR c++/104074

gcc/cp/ChangeLog:

	* pt.cc (invalid_nontype_parm_type_p): Use WILDCARD_TYPE_P so
	that we return false for DEPENDENT_OPERATOR_TYPE too.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype-auto20.C: New test.
2022-01-18 14:50:06 -05:00
Maciej W. Rozycki dad495e301 RISC-V: Fix use-after-free error in `parse_multiletter_ext'
Avoid undefined arithmetic involving a pointer to a heap allocation that
has been freed and move a problematic calculation ahead of the following
call to `free' in `riscv_subset_list::parse_multiletter_ext', removing a
compilation error:

.../gcc/common/config/riscv/riscv-common.cc: In member function 'const char* riscv_subset_list::parse_multiletter_ext(const char*, const char*, const char*)':
.../gcc/common/config/riscv/riscv-common.cc:905:27: error: pointer 'subset' used after 'void free(void*)' [-Werror=use-after-free]
  905 |       p += end_of_version - subset;
      |            ~~~~~~~~~~~~~~~^~~~~~~~
.../gcc/common/config/riscv/riscv-common.cc:904:12: note: call to 'void free(void*)' here
  904 |       free (subset);
      |       ~~~~~^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:2428: riscv-common.o] Error 1

and a build regression from commit 671a283636 ("Add -Wuse-after-free
[PR80532].").

	gcc/
	* common/config/riscv/riscv-common.cc
	(riscv_subset_list::parse_multiletter_ext): Move pointer
	arithmetic ahead of `free'.
2022-01-18 19:39:13 +00:00
Harald Anlauf 0d01a27226 Fortran: handle expansion of zero-sized array constructors
gcc/fortran/ChangeLog:

	PR fortran/103692
	* array.cc (gfc_expand_constructor): Handle zero-sized array
	constructors.

gcc/testsuite/ChangeLog:

	PR fortran/103692
	* gfortran.dg/pr102520.f90: Adjust error messages.
	* gfortran.dg/pr103692.f90: New test.
2022-01-18 20:02:11 +01:00
Jason Merrill 7ca2160170 c++: new (nothrow) array cleanup [PR104007]
For this testcase, the cleanup that is supposed to happen if initialization
throws was wrongly being run on the normal control path as well.  This turns
out to be because the EH-only handling in gimple_push_cleanup didn't apply
to conditional cleanups such as we have for nothrow new, since we check
whether the result is non-null before proceeding with the initialization.

	PR c++/104007

gcc/ChangeLog:

	* gimplify.cc (gimple_push_cleanup): Handle eh_only in conditional
	context.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/new2.C: New test.
2022-01-18 12:42:52 -05:00
Sandra Loosemore 3a0837b8fb middle-end: move initialization of stack_limit_rtx [PR103163]
stack_limit_rtx was being initialized before init_reg_modes_target (),
resulting in the REG expression being created incorrectly and an ICE
later in compilation.

2022-01-18  Sandra Loosemore  <sandra@codesourcery.com>

	PR middle-end/103163

	gcc/
	* emit-rtl.cc (init_emit_regs): Initialize stack_limit_rtx here...
	(init_emit_once): ...not here.
2022-01-18 09:27:36 -08:00
Jonathan Wakely e13e95bd27 libstdc++: Use __cpp_lib_concepts in std::reverse_iterator [PR104098]
We should not assume that std::iter_value_t etc. are defined
unconditionally for C++20 mode.

libstdc++-v3/ChangeLog:

	PR libstdc++/104098
	* include/bits/stl_iterator.h (reverse_iterator): Check
	__cpp_lib_concepts instead of __cplusplus.
2022-01-18 16:31:03 +00:00
Jonathan Wakely 302343d8dd libstdc++: Fix ambiguous std::pair constructors [PR101124]
The deprecated non-standard std::pair constructors that allow
constructing std::pair<move-only-type, pointer-type> from an rvalue and
a literal zero where not sufficiently constrained. They were viable when
constructing std::pair<copyable-type, pointer-type>, and that case
should work fine using the standard constructors.

Replace the constraints on the non-standard constructors so they are
only viable in cases that should actually be ill-formed according to the
standard.

Also rename __null_ptr_constant to __zero_as_null_pointer_constant so it
matches the name of the -Wzero-as-null-pointer-constant warning. Also
make the text of the deprecated warning describe the problem in more
detail.

libstdc++-v3/ChangeLog:

	PR libstdc++/101124
	* include/bits/stl_pair.h (pair): Adjust constraints on
	deprecated constructors accepting literal zero as null pointer
	constant. Improve wording of deprecated attribute.
	* testsuite/20_util/pair/cons/99957.cc: Check that deprecated
	constructors do not cause ambiguities for copyable types.
2022-01-18 16:31:03 +00:00
Jonathan Wakely 50bc6e463b libstdc++: Fix suggested alternative to std::ptr_fun
libstdc++-v3/ChangeLog:

	* include/bits/stl_function.h (ptr_fun): Fix suggestion for
	non-deprecated alternative.
2022-01-18 16:31:02 +00:00
Tom Honermann 0e4e4b37d9 libstdc++: Declare std::c8rtomb and std::mbrtoc8 if provided by the C library
This patch completes implementation of the C++20 proposal P0482R6 [1] by
adding declarations of std::c8rtomb() and std::mbrtoc8() in <cuchar> if
provided by the C library in <uchar.h>.

This patch addresses feedback provided in response to a previous patch
submission [2].

Autoconf changes determine if the C library declares c8rtomb and mbrtoc8
at global scope when uchar.h is included and compiled with either
-fchar8_t or -std=c++20. New _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T
and _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 configuration macros
reflect the probe results. The <cuchar> header declares these functions
in the std namespace only if available and the _GLIBCXX_USE_CHAR8_T
configuration macro is defined (by default it is defined if the C++20
__cpp_char8_t feature test macro is defined)

Patches to glibc to implement c8rtomb and mbrtoc8 have been submitted [3].

New tests validate the presence of these declarations. The tests pass
trivially if the C library does not provide these functions. Otherwise
they ensure that the functions are declared when <cuchar> is included
and either -fchar8_t or -std=c++20 is enabled.

1]: WG21 P0482R6
      "char8_t: A type for UTF-8 characters and strings (Revision 6)"
      https://wg21.link/p0482r6

[2]: [PATCH] C++ P0482R6 char8_t: declare std::c8rtomb and std::mbrtoc8
if provided by the C library
      https://gcc.gnu.org/pipermail/libstdc++/2021-June/052685.html

[3]: "C++20 P0482R6 and C2X N2653"
      [Patch 0/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135061.html
      [Patch 1/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135062.html
      [Patch 2/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135063.html
      [Patch 3/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135064.html

libstdc++-v3/ChangeLog:

	* acinclude.m4: Define config macros if uchar.h provides
	c8rtomb() and mbrtoc8().
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/c_compatibility/uchar.h (c8rtomb, mbrtoc8): Define.
	* include/c_global/cuchar (c8rtomb, mbrtoc8): Likewise.
	* include/c_std/cuchar (c8rtomb, mbrtoc8): Likewise.
	* testsuite/21_strings/headers/cuchar/functions_std_cxx20.cc:
	New test.
	* testsuite/21_strings/headers/cuchar/functions_std_fchar8_t.cc:
	New test.
2022-01-18 16:31:02 +00:00
Jonathan Wakely d7f2a09e98 libstdc++: Define <stdatomic.h> for C++23
This adds the C++23 <stdatomic.h> header, as proposed by P0943R6, for
compatibility with C code.

There are still some ABI differences between atomic_xxx in C and C++
std::atomic_xxx in C++, so this only provides source compatibility, not
binary compatibility.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Install new header.
	* include/Makefile.in: Regenerate.
	* include/c_compatibility/stdatomic.h: New file.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: New test.
2022-01-18 16:31:02 +00:00
Martin Liska 58385f6ace Fix -Wformat-diag in various targets.
gcc/ChangeLog:

	* collect2.cc (scan_libraries): Fix -Wformat-diag issues.
	* config/aarch64/aarch64-builtins.cc (aarch64_simd_expand_builtin): Likewise.
	* config/arc/arc.md: Likewise.
	* config/avr/avr.cc (avr_section_type_flags): Likewise.
	* config/bfin/bfin.cc (bfin_option_override): Likewise.
	(bfin_handle_longcall_attribute): Likewise.
	* config/cris/cris.h (FUNCTION_PROFILER): Likewise.
	* config/frv/frv.cc (frv_expand_builtin): Likewise.
	* config/ia64/ia64-c.cc (ia64_hpux_handle_builtin_pragma): Likewise.
	* config/iq2000/iq2000.cc (save_restore_insns): Likewise.
	(iq2000_print_operand_address): Likewise.
	(iq2000_print_operand): Likewise.
	* config/m32c/m32c-pragma.cc (m32c_pragma_memregs): Likewise.
	(m32c_pragma_address): Likewise.
	* config/m68k/m68k.cc (m68k_handle_fndecl_attribute): Likewise.
	* config/mips/mips.cc (mips_handle_interrupt_attr): Likewise.
	(mips_set_compression_mode): Likewise.
	* config/mmix/mmix.cc (mmix_function_profiler): Likewise.
	(mmix_print_operand): Likewise.
	(mmix_output_shiftvalue_op_from_str): Likewise.
	(mmix_output_shifted_value): Likewise.
	* config/msp430/driver-msp430.cc (msp430_select_hwmult_lib): Likewise.
	* config/msp430/msp430.cc (msp430_option_override): Likewise.
	(msp430_attr): Likewise.
	(msp430_expand_delay_cycles): Likewise.
	(msp430_expand_builtin): Likewise.
	* config/rs6000/aix73.h: Likewise.
	* config/rs6000/rtems.h (INVALID_64BIT): Likewise.
	* config/rx/rx.cc (rx_expand_builtin_mvtc): Likewise.
	(valid_psw_flag): Likewise.
	* config/sh/sh.cc (parse_validate_atomic_model_option): Likewise.
	* config/stormy16/stormy16.cc (xstormy16_function_profiler): Likewise.
	(xstormy16_expand_builtin_va_start): Likewise.
	(xstormy16_handle_below100_attribute): Likewise.
2022-01-18 17:25:37 +01:00
Martin Liska 88619b5b4c vms: fix -Wformat-diag warnings.
gcc/ChangeLog:

	* config/vms/vms-c.cc (vms_pragma_nostandard): Fix -Wformat-diag
	warning.
	(vms_pragma_standard): Likewise.
	(vms_pragma_extern_prefix): Likewise.
2022-01-18 17:25:37 +01:00
Martin Liska 7e5baa7e6f xtensa: fix -Wformat-diag warnings.
gcc/ChangeLog:

	* config/xtensa/xtensa.cc (print_operand): Fix warnings.
	(print_operand_address): Likewise.
	(xtensa_multibss_section_type_flags): Likewise.
2022-01-18 17:25:37 +01:00
Martin Liska 67d5e395b9 rs6000: fix last -Wformat-diag
gcc/ChangeLog:

	* config/rs6000/rs6000-call.cc (rs6000_invalid_builtin): Change
	wording of an error message.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/bfp/scalar-extract-exp-5.c: Update scanned
	pattern.
	* gcc.target/powerpc/bfp/scalar-extract-sig-5.c: Likewise.
	* gcc.target/powerpc/bfp/scalar-insert-exp-11.c: Likewise.
2022-01-18 17:25:37 +01:00
Martin Liska 62fcdefba1 v850: fix -Wformat-diag warnings.
gcc/ChangeLog:

	* config/v850/v850-c.cc (pop_data_area): Fix -Wformat-diag
	warning.
	(ghs_pragma_section): Likewise.
	(ghs_pragma_interrupt): Likewise.
	(ghs_pragma_starttda): Likewise.
	(ghs_pragma_startsda): Likewise.
	(ghs_pragma_startzda): Likewise.
	(ghs_pragma_endtda): Likewise.
	(ghs_pragma_endsda): Likewise.
	(ghs_pragma_endzda): Likewise.
2022-01-18 17:25:37 +01:00
Martin Liska 67f84a803f nds32: fix -Wformat-diag warning.
gcc/ChangeLog:

	* config/nds32/nds32-intrinsic.cc (nds32_expand_builtin_impl):
	Fix warnings.
	* config/nds32/nds32-intrinsic.md: Likewise.
	* config/nds32/nds32-isr.cc (nds32_check_isr_attrs_conflict): Likewise.
	* config/nds32/nds32.cc (nds32_print_operand): Likewise.
	(nds32_insert_attributes): Likewise.
2022-01-18 17:25:36 +01:00
Martin Liska b1f3640912 nvptx: fix -Wformat-diag warnings
gcc/ChangeLog:

	* config/nvptx/nvptx.cc (nvptx_goacc_validate_dims_1): Wrap
	keyword.
	* config/nvptx/nvptx.md: Remove trailing dot.

libgomp/ChangeLog:

	* testsuite/libgomp.oacc-c++/privatized-ref-2.C: Update keyword
	in dg-warning.
	* testsuite/libgomp.oacc-c++/privatized-ref-3.C: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/kernels-loop-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/pr85486.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-64-1.c: Likewise.
	* testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/kernels-loop-2.f95: Likewise.
	* testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: Likewise.
2022-01-18 17:25:36 +01:00