]> gcc.gnu.org Git - gcc.git/log
gcc.git
2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 27 Sep 2021 12:48:23 +0000 (14:48 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9033-g654d1bd86a6d62e03530872d519a20bd06ae3a50 (Sept 27, 2021)

2 years agoFortran: Fix assumed-size to assumed-rank passing [PR94070]
Tobias Burnus [Mon, 27 Sep 2021 12:47:27 +0000 (14:47 +0200)]
Fortran: Fix assumed-size to assumed-rank passing [PR94070]

This code inlines the size0 and size1 libgfortran calls, the former is still
used by libgfortan itself (and by old code). Besides permitting more
optimizations, it also permits to handle assumed-rank dummies better: If the
dummy argument is a nonpointer/nonallocatable, an assumed-size actual arg is
repesented by having ubound == -1 for the last dimension. However, for
allocatable/pointers, this value can also exist. Hence, the dummy arg attr
has to be honored.

For that reason, when calling an assumed-rank procedure with nonpointer,
nonallocatable dummy arguments, the bounds have to be updated to avoid
the case ubound == -1 for the last dimension.

PR fortran/94070

gcc/fortran/ChangeLog:

* trans-array.c (gfc_tree_array_size): New function to
find size inline (whole array or one dimension).
(array_parameter_size): Use it, take stmt_block as arg.
(gfc_conv_array_parameter): Update call.
* trans-array.h (gfc_tree_array_size): Add prototype.
* trans-decl.c (gfor_fndecl_size0, gfor_fndecl_size1): Remove
these global vars.
(gfc_build_intrinsic_function_decls): Remove their initialization.
* trans-expr.c (gfc_conv_procedure_call): Update
bounds of pointer/allocatable actual args to nonallocatable/nonpointer
dummies to be one based.
* trans-intrinsic.c (gfc_conv_intrinsic_shape): Fix case for
assumed rank with allocatable/pointer dummy.
(gfc_conv_intrinsic_size): Update to use inline function.
* trans.h (gfor_fndecl_size0, gfor_fndecl_size1): Remove var decl.

libgfortran/ChangeLog:

* intrinsics/size.c (size0, size1): Comment that now not
used by newer compiler code.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Update
expected dg-note output.

gcc/testsuite/ChangeLog:

* gfortran.dg/c-interop/cf-out-descriptor-6.f90: Remove xfail.
* gfortran.dg/c-interop/size.f90: Remove xfail.
* gfortran.dg/intrinsic_size_3.f90: Update scan-tree-dump-times.
* gfortran.dg/transpose_optimization_2.f90: Likewise.
* gfortran.dg/size_optional_dim_1.f90: Add scan-tree-dump-not.
* gfortran.dg/assumed_rank_22.f90: New test.
* gfortran.dg/assumed_rank_22_aux.c: New test.

(cherry picked from commit 00f6de9c69119594f7dad3bd525937c94c8200d0)

2 years agoDaily bump.
GCC Administrator [Mon, 27 Sep 2021 00:18:02 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran: Fix associated intrinsic with assumed rank [PR101334]
Tobias Burnus [Sun, 26 Sep 2021 17:30:31 +0000 (19:30 +0200)]
Fortran: Fix associated intrinsic with assumed rank [PR101334]

ASSOCIATE (ptr, tgt) takes as first argument also an assumed-rank array;
however, using it together with a tgt (required to be non assumed rank)
had issues for both scalar and nonscalar tgt.

PR fortran/101334
gcc/fortran/ChangeLog:

* trans-intrinsic.c (gfc_conv_associated): Support assumed-rank
'pointer' with scalar/array 'target' argument.

libgfortran/ChangeLog:

* intrinsics/associated.c (associated): Also check for same rank.

gcc/testsuite/ChangeLog:

* gfortran.dg/associated_assumed_rank.f90: New test.

(cherry picked from commit fe2771b291c2c7c0ac37b75ec5b160937524b60c)

2 years agoDaily bump.
GCC Administrator [Sun, 26 Sep 2021 00:17:55 +0000 (00:17 +0000)]
Daily bump.

2 years agoDaily bump.
GCC Administrator [Sat, 25 Sep 2021 00:18:05 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran: Add missing diagnostic for F2018 C711 (TS29113 C407c)
Sandra Loosemore [Fri, 24 Sep 2021 17:53:53 +0000 (10:53 -0700)]
Fortran: Add missing diagnostic for F2018 C711 (TS29113 C407c)

2021-09-24  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/101333

gcc/fortran/
* interface.c (compare_parameter): Enforce F2018 C711.

gcc/testsuite/
* gfortran.dg/c-interop/c407c-1.f90: Remove xfails.

(cherry picked from commit 2364250eccc389a5f9820ac55f8260d34f229e73)

2 years agoFortran: Diagnose default-initialized pointer/allocatable dummies
Sandra Loosemore [Fri, 24 Sep 2021 17:50:54 +0000 (10:50 -0700)]
Fortran: Diagnose default-initialized pointer/allocatable dummies

TS29113 changed what was then C516 in the 2010 Fortran standard (now
C1557 in F2018) from disallowing all of pointer, allocatable, and
optional attributes on dummy arguments to BIND(C) functions, to
disallowing only pointer/allocatable with default-initialization.
gfortran was previously failing to diagnose violations of this
constraint.

2021-09-23  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/101320

gcc/fortran/
* decl.c (gfc_verify_c_interop_param): Handle F2018 C1557,
aka TS29113 C516.

gcc/testsuite/
* gfortran.dg/c-interop/c516.f90: Remove xfails.  Add more
tests.

(cherry picked from commit 2646d0e06b170569be1da28fce1d6e2f03a15f60)

2 years agoOpenMP: Fix target device ancestor tests according to reverse_offload.
Marcel Vollweiler [Fri, 24 Sep 2021 15:32:53 +0000 (08:32 -0700)]
OpenMP: Fix target device ancestor tests according to reverse_offload.

This patch removes the expectation that 'requires reverse_offload' is
unsupported from some 'target device ancester' tests which were introduced in
commit 03be3cfeef7b3811acb6c4a8da2fc5c1e25d3e4c. This is necessary since
commit f5bfc65f9a6e1f69b17d3740d043d2fbda339e05 changed the behaviour for
reverse_offload.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/target-device-ancestor-2.c: Remove message for
unsupported reverse offload.
* c-c++-common/gomp/target-device-ancestor-3.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.

2 years agoFix value uninitialization in vn_reference_insert_pieces [PR102400]
Feng Xue [Thu, 23 Sep 2021 01:14:33 +0000 (09:14 +0800)]
Fix value uninitialization in vn_reference_insert_pieces [PR102400]

2021-09-23  Feng Xue  <fxue@os.amperecomputing.com>

gcc/
PR tree-optimization/102400
* tree-ssa-sccvn.c (vn_reference_insert_pieces): Initialize
result_vdef to zero value.

2 years agoFix null-pointer dereference in delete_dead_or_redundant_call [PR102451]
Feng Xue [Thu, 23 Sep 2021 00:47:45 +0000 (08:47 +0800)]
Fix null-pointer dereference in delete_dead_or_redundant_call [PR102451]

2021-09-23  Feng Xue  <fxue@os.amperecomputing.com>

gcc/
PR tree-optimization/102451
* tree-ssa-dse.c (delete_dead_or_redundant_call): Record bb of stmt
before removal.

2 years agoDaily bump.
GCC Administrator [Fri, 24 Sep 2021 00:18:01 +0000 (00:18 +0000)]
Daily bump.

2 years agoopenmp: Diagnose omp::directive attribute without balanced token argument [PR102413]
Jakub Jelinek [Thu, 23 Sep 2021 09:23:33 +0000 (11:23 +0200)]
openmp: Diagnose omp::directive attribute without balanced token argument [PR102413]

If omp::directive attribute argument starting with the opening ( is not a balanced
token sequence, then cp_parser_skip_balanced_tokens (parser, 1) returns 1,
but the code was subtracting 2 from it and iterating until it was 0, so for the
non-balanced case it iterated from (size_t) -1 down to 0.

The following patch just diagnoses that as an error.

2021-09-23  Jakub Jelinek  <jakub@redhat.com>

PR c++/102413
* parser.c (cp_parser_omp_directive_args): Diagnose if omp::directive
is not followed by a balanced token sequence starting with open paren.

* g++.dg/gomp/attrs-14.C: New test.

(cherry picked from commit 0d39eb28fd2ab00306bd7c0a87b6c0ed615b5d12)

2 years agoc++: Fix up parsing of attributes for using-directive
Jakub Jelinek [Thu, 23 Sep 2021 07:36:01 +0000 (09:36 +0200)]
c++: Fix up parsing of attributes for using-directive

As I've said earlier and added xfails in gen-attrs-76.C test,
https://eel.is/c++draft/namespace.udir#nt:using-directive
has attribute-specifier-seq[opt] at the start, not at the end before ;
as gcc is expecting.
IMHO we should continue parsing at the end the GNU attributes
because using namespace N __attribute__((strong));, while not supported
anymore, used to be supported in the past, but my code searches for
using namespace N [[gnu::strong]]; didn't reveal anything at all.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

* parser.c (cp_parser_block_declaration): Call
cp_parser_using_directive for C++11 attributes followed by
using namespace tokens.
(cp_parser_using_directive): Parse C++11 attributes at the start
of the directive rather than at the end, only parse GNU attributes
at the end.

* g++.dg/lookup/strong-using.C: Add test using [[gnu::strong]]
as well.
* g++.dg/lookup/strong-using2.C: Likewise.
* g++.dg/cpp0x/gen-attrs-58.C: Move alignas(int) before
using namespace.
* g++.dg/cpp0x/gen-attrs-59.C: Move alignas(X) before
using namespace, add tests for alignas before semicolon.
* g++.dg/cpp0x/gen-attrs-76.C: Remove xfails.  Add test for
C++11 attributes on using directive before semicolon.

(cherry picked from commit 3890c28ac5bd03ba334a20fbf9518a37dcdbfe5d)

2 years agoFortran: diagnostic for argument w/type parameters for assumed-type dummy
Sandra Loosemore [Thu, 23 Sep 2021 00:32:22 +0000 (17:32 -0700)]
Fortran: diagnostic for argument w/type parameters for assumed-type dummy

2021-09-22  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/101319

gcc/fortran/
* interface.c (gfc_compare_actual_formal): Extend existing
assumed-type diagnostic to also check for argument with type
parameters.

gcc/testsuite/
* gfortran.dg/c-interop/assumed-type-dummy.f90: Remove xfail.

(cherry picked from commit 5098e7077bfcace3e80144e63c81be94546ced16)

2 years agoFortran: Fixes for F2018 C838 (PR fortran/101334)
Sandra Loosemore [Thu, 23 Sep 2021 00:28:25 +0000 (17:28 -0700)]
Fortran: Fixes for F2018 C838 (PR fortran/101334)

The compiler was failing to diagnose the error required by F2018 C838
when passing an assumed-rank array argument to a non-assumed-rank dummy.
It was also incorrectly giving an error for calls to the 2-argument form
of the ASSOCIATED intrinsic, which is supposed to be permitted by C838.

2021-09-19  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/101334

gcc/fortran/
* check.c (gfc_check_associated): Allow an assumed-rank
array for the pointer argument.
* interface.c (compare_parameter): Also give rank mismatch
error on assumed-rank array.

gcc/testsuite/
* gfortran.dg/c-interop/c535b-2.f90: Remove xfails.
* gfortran.dg/c-interop/c535b-3.f90: Likewise.

(cherry picked from commit 7a40f2e74815a926c5f47416c29efbc17aa1ef43)

2 years agoFortran: Fix testcases that violate C838, + revealed ICE
Sandra Loosemore [Thu, 23 Sep 2021 00:24:58 +0000 (17:24 -0700)]
Fortran: Fix testcases that violate C838, + revealed ICE

The three test cases fixed in this patch violated F2018 C838, which
only allows passing an assumed-rank argument to an assumed-rank dummy.
Wrapping the call in "select rank" revealed a null pointer dereference
which is fixed by guarding the use of the result of
GFC_DECL_SAVED_DESCRIPTOR similar to what is already done elsewhere.

2021-09-19  Sandra Loosemore  <sandra@codesourcery.com>

gcc/fortran/
* trans-stmt.c (trans_associate_var): Check that result of
GFC_DECL_SAVED_DESCRIPTOR is not null before using it.

gcc/testsuite/
* gfortran.dg/assumed_rank_18.f90 (g): Wrap call to h in
select rank.
* gfortran.dg/assumed_type_10.f90 (test_array): Likewise for
call to test_lib.
* gfortran.dg/assumed_type_11.f90 (test_array): Likewise.

(cherry picked from commit 8fa9e73e6db0ff05447f5547df925fdcb4733d05)

2 years agoDaily bump.
GCC Administrator [Thu, 23 Sep 2021 00:18:03 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran: Improve -Wmissing-include-dirs warnings [PR55534]
Tobias Burnus [Wed, 22 Sep 2021 22:10:00 +0000 (00:10 +0200)]
Fortran: Improve -Wmissing-include-dirs warnings [PR55534]

It turned out that enabling the -Wmissing-include-dirs for libcpp did output
too many warnings – at least as run with -B and similar options during the
GCC build and warning for internal include dirs like finclude, unlikely of
relevance to for a real-world user.
This patch now only warns for -I and -J by default but permits to get the
full warnings including libcpp ones with -Wmissing-include-dirs. It
additionally documents this in the manual.

With that change, the -Wno-missing-include-dirs could be removed
from libgfortran's configure and libgomp's testsuite always cflags.
This reverts those bits of the previous
commit r12-3722-g417ea5c02cef7f000e66d1af22b066c2c1cda047

Additionally, it turned out that all call to load_file called exit
explicitly - except for the main file via gfc_init -> gfc_new_file. The
latter also output a file not existing fatal error, such that two errors
where printed. Now exit is called in line with the other users of
load_file.

Finally, when compileing with "nonexisting/file.f90", first a warning that
"nonexisting" does not exist as include path was printed before the file
not found error was printed. Now the directory in which the physical file
is located is added silently, relying on the file-not-found diagnostic for
those.

PR fortran/55534
gcc/ChangeLog:

* doc/invoke.texi (-Wno-missing-include-dirs.): Document Fortran
behavior.

gcc/fortran/ChangeLog:

* cpp.c (gfc_cpp_register_include_paths, gfc_cpp_post_options):
Add new bool verbose_missing_dir_warn argument.
* cpp.h (gfc_cpp_post_options): Update prototype.
* f95-lang.c (gfc_init): Remove duplicated file-not found diag.
* gfortran.h (gfc_check_include_dirs): Takes bool
verbose_missing_dir_warn arg.
(gfc_new_file): Returns now void.
* options.c (gfc_post_options): Update to warn for -I and -J,
only, by default but for all when user requested.
* scanner.c (gfc_do_check_include_dir):
(gfc_do_check_include_dirs, gfc_check_include_dirs): Take bool
verbose warn arg and update to avoid printing the same message
twice or never.
(load_file): Fix indent.
(gfc_new_file): Return void and exit when load_file failed
as all other load_file users do.

libgfortran/ChangeLog:

* configure.ac (AM_FCFLAGS): Revert r12-3722 by removing
-Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/fortran.exp (ALWAYS_CFLAGS): Revert
r12-3722 by removing -Wno-missing-include-dirs.
* testsuite/libgomp.oacc-fortran/fortran.exp (ALWAYS_CFLAGS): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/include_14.f90: Add -J testcase and update dg-output.
* gfortran.dg/include_15.f90: Likewise.
* gfortran.dg/include_16.f90: Likewise.
* gfortran.dg/include_17.f90: Likewise.
* gfortran.dg/include_18.f90: Likewise.
* gfortran.dg/include_19.f90: Likewise.

(cherry picked from commit 83aac698835edcdb3e6d96b856bef1c5f92e5e24)

2 years agoIBM Z: TPF: Add cc clobber to profiling expanders
Andreas Krebbel [Wed, 22 Sep 2021 10:13:05 +0000 (12:13 +0200)]
IBM Z: TPF: Add cc clobber to profiling expanders

The code sequence emitted uses CC internally.

gcc/ChangeLog:

* config/s390/tpf.md (prologue_tpf, epilogue_tpf): Add cc clobber.

(cherry picked from commit e1223ea2f48e8588160b2948f8a1f8e47f9694fd)

2 years agoIBM Z: Fix PR102222
Andreas Krebbel [Wed, 22 Sep 2021 07:32:21 +0000 (09:32 +0200)]
IBM Z: Fix PR102222

Avoid emitting a strict low part move if the insv target actually
affects the whole target reg.

gcc/ChangeLog:

PR target/102222
* config/s390/s390.c (s390_expand_insv): Emit a normal move if it
is actually a full copy of the source operand into the target.
Don't emit a strict low part move if source and target mode match.

gcc/testsuite/ChangeLog:

* gcc.target/s390/pr102222.c: New test.

(cherry picked from commit a9b3c451be58f0fe660154323ace7ba72a4211ec)

2 years agoFortran: Add gfc_simple_for_loop aux function
Tobias Burnus [Wed, 22 Sep 2021 09:13:28 +0000 (11:13 +0200)]
Fortran: Add gfc_simple_for_loop aux function

Function to generate a simple loop (to be used internally).
Callers will be added in follow-up commits.

gcc/fortran/
* trans-expr.c (gfc_simple_for_loop): New.
* trans.h (gfc_simple_for_loop): New prototype.

(cherry picked from commit 424a4a463ac5932830a83560cf929f9c2f4564d8)

2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Wed, 22 Sep 2021 07:57:52 +0000 (09:57 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9024-gcc11a171eee059b645870f2e208c530f301239c9 (Sept 21, 2021)

2 years agoopenmp: Fix OpenMP expansion of scope with non-fallthrugh body [PR102415]
Jakub Jelinek [Wed, 22 Sep 2021 07:57:46 +0000 (09:57 +0200)]
openmp: Fix OpenMP expansion of scope with non-fallthrugh body [PR102415]

I've used function for omp single expansion also for omp scope.  That is
mostly ok, but as the testcase shows, there is one important difference.
The omp single expansion always has a fallthru body, because it during
omp lowering expands the body as if wrapped in an if to simulate that
one thread runs the body and others wait (unless nowait) until it completes
and continue.  omp scope is invoked by all threads and so if the body
is non-fallthru, the barrier (unless nowait) at the end will not be reached
by any of the threads.

The following patch fixes that by handling the case where cfg pass optimizes
away the exit bb of it gracefully.

2021-09-22  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/102415
* omp-expand.c (expand_omp_single): If region->exit is NULL,
assert region->entry is GIMPLE_OMP_SCOPE region and return.

* c-c++-common/gomp/scope-3.c: New test.

(cherry picked from commit c4432b2776aeeffee9125bf87ff937e4a8907bbd)

2 years agoopenmp: Add support for allocator and align modifiers on allocate clauses
Jakub Jelinek [Wed, 22 Sep 2021 07:52:32 +0000 (09:52 +0200)]
openmp: Add support for allocator and align modifiers on allocate clauses

As the allocate-2.c testcase shows, this change isn't 100% backwards compatible,
one could have allocate and/or align functions that return an OpenMP allocator
handle and previously it would call those functions and now would use those
names as keywords for the modifiers.  But it allows specify extra alignment
requirements for the allocations.

2021-09-22  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree.h (OMP_CLAUSE_ALLOCATE_ALIGN): Define.
* tree.c (omp_clause_num_ops): Change number of OMP_CLAUSE_ALLOCATE
arguments from 2 to 3.
* tree-pretty-print.c (dump_omp_clause): Print allocator() around
allocate clause allocator and print align if present.
* omp-low.c (scan_sharing_clauses): Force allocate_map entry even
for omp_default_mem_alloc if align modifier is present.  If align
modifier is present, use TREE_LIST to encode both allocator and
align.
(lower_private_allocate, lower_rec_input_clauses, create_task_copyfn):
Handle align modifier on allocator clause if present.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Copy over OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/c/
* c-parser.c (c_parser_omp_clause_allocate): Parse allocate clause
modifiers.
gcc/cp/
* parser.c (cp_parser_omp_clause_allocate): Parse allocate clause
modifiers.
* semantics.c (finish_omp_clauses) <OMP_CLAUSE_ALLOCATE>: Perform
semantic analysis of OMP_CLAUSE_ALLOCATE_ALIGN.
* pt.c (tsubst_omp_clauses) <case OMP_CLAUSE_ALLOCATE>: Handle
also OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/testsuite/
* c-c++-common/gomp/allocate-6.c: New test.
* c-c++-common/gomp/allocate-7.c: New test.
* g++.dg/gomp/allocate-4.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-2.c: New test.
* testsuite/libgomp.c-c++-common/allocate-3.c: New test.

(cherry picked from commit 059b819e3c94aae3dd0be55bd512ee6ee4e28798)

2 years agoipa-fnsummary: Remove inconsistent bp_pack_value
Kewen Lin [Wed, 22 Sep 2021 00:13:57 +0000 (19:13 -0500)]
ipa-fnsummary: Remove inconsistent bp_pack_value

There is one inconsistent bit-field streaming out and in.
On the side of streaming in:

    bp_pack_value (&bp, info->inlinable, 1);
    bp_pack_value (&bp, false, 1);
    bp_pack_value (&bp, info->fp_expressions, 1);

while on the side of the streaming out:

    info->inlinable = bp_unpack_value (&bp, 1);
    info->fp_expressions = bp_unpack_value (&bp, 1)

The removal of Cilk Plus support r8-4956 missed to remove
the streaming out of the bit, instead just change the value
for streaming out to be always false.

By hacking fp_expression_p to always return true, I can see
it reads the wrong fp_expressions value (false) out in wpa.

GCC12 adopts commit 63c6446f77b9001d26f973114450d790749f282b
which removes the inconsistent streaming out instead.

gcc/ChangeLog:

* ipa-fnsummary.c (inline_read_section): Unpack a dummy bit
to keep consistent with the side of streaming out.

2 years agoDaily bump.
GCC Administrator [Wed, 22 Sep 2021 00:18:00 +0000 (00:18 +0000)]
Daily bump.

2 years agors6000: Fix ELFv2 r12 use in epilogue
Segher Boessenkool [Wed, 8 Sep 2021 13:10:30 +0000 (13:10 +0000)]
rs6000: Fix ELFv2 r12 use in epilogue

We cannot use r12 here, it is already in use as the GEP (for sibling
calls).

2021-09-08  Segher Boessenkool  <segher@kernel.crashing.org>
PR target/102107
* config/rs6000/rs6000-logue.c (rs6000_emit_epilogue): For ELFv2 use
r11 instead of r12 for restoring CR.

(cherry picked from commit 86e6268cff328e27ee6f90e2afc35b6f437a25cd)

2 years agors6000: Don't use r12 for CR save on ELFv2 (PR102107)
Segher Boessenkool [Thu, 2 Sep 2021 16:38:24 +0000 (16:38 +0000)]
rs6000: Don't use r12 for CR save on ELFv2 (PR102107)

CR is saved and/or restored on some paths where GPR12 is already live
since it has a meaning in the calling convention in the ELFv2 ABI.

It is not completely clear to me that we can always use r11 here, but
it does seem save, there is checking code (to detect conflicts here),
and it is stage 1.  So here goes.

2021-09-03  Segher Boessenkool <segher@kernel.crashing.org>

PR target/102107
* config/rs6000/rs6000-logue.c (rs6000_emit_prologue): On ELFv2 use r11
instead of r12 for CR save, in all cases.

(cherry picked from commit 2484f7a4b0f52e6ed04754be336f1fa6fde47f6b)

2 years agoFortran - (large) arrays in the main shall be static
Harald Anlauf [Fri, 17 Sep 2021 19:45:33 +0000 (21:45 +0200)]
Fortran - (large) arrays in the main shall be static

gcc/fortran/ChangeLog:

PR fortran/102366
* trans-decl.c (gfc_finish_var_decl): Disable the warning message
for variables moved from stack to static storange if they are
declared in the main, but allow the move to happen.

gcc/testsuite/ChangeLog:

PR fortran/102366
* gfortran.dg/pr102366.f90: New test.

(cherry picked from commit 51166eb2c534692c3c7779def24f83c8c3811b98)

2 years agoFix no_fsanitize_address effective target
Eric Botcazou [Tue, 21 Sep 2021 07:25:47 +0000 (09:25 +0200)]
Fix no_fsanitize_address effective target

The implementation of the no_fsanitize_address effective target was copied
from asan-dg.exp without realizing that it does not work outside of this
context (there is a comment explaining why).  As a consequence, it always
returns 0, so for example the directive in gnat.dg/asan1.adb:

{ dg-skip-if "no address sanitizer" { no_fsanitize_address } }

does not work.  This led some people to add the nonsensical:

{ dg-require-effective-target no_fsanitize_address }

to sanitizer tests, e.g. g++.dg/warn/uninit-pr93100.C, thus disabling them
everywhere instead of just for the problematic targets.

gcc/testsuite/
* lib/target-supports.exp (no_fsanitize_address): Add missing bits.
* gcc.dg/pr91441.c: Likewise.
* gcc.dg/pr96260.c: Likewise.
* gcc.dg/pr96307.c: Likewise.
* gnat.dg/asan1.adb: Likewise.

* g++.dg/abi/anon4.C: Likewise.

2 years agoFortran: Fix -Wno-missing-include-dirs handling [PR55534]
Tobias Burnus [Tue, 21 Sep 2021 06:44:34 +0000 (08:44 +0200)]
Fortran: Fix -Wno-missing-include-dirs handling [PR55534]

gcc/fortran/ChangeLog:

PR fortran/55534
* cpp.c: Define GCC_C_COMMON_C for #include "options.h" to make
cpp_reason_option_codes available.
(gfc_cpp_register_include_paths): Make static, set pfile's
warn_missing_include_dirs and move before caller.
(gfc_cpp_init_cb): New, cb code moved from ...
(gfc_cpp_init_0): ... here.
(gfc_cpp_post_options): Call gfc_cpp_init_cb.
(cb_cpp_diagnostic_cpp_option): New. As implemented in c-family
to match CppReason flags to -W... names.
(cb_cpp_diagnostic): Use it to replace single special case.
* cpp.h (gfc_cpp_register_include_paths): Remove as now static.
* gfortran.h (gfc_check_include_dirs): New prototype.
(gfc_add_include_path): Add new bool arg.
* options.c (gfc_init_options): Don't set -Wmissing-include-dirs.
(gfc_post_options): Set it here after commandline processing. Call
gfc_add_include_path with defer_warn=false.
(gfc_handle_option): Call it with defer_warn=true.
* scanner.c (gfc_do_check_include_dir, gfc_do_check_include_dirs,
gfc_check_include_dirs): New. Diagnostic moved from ...
(add_path_to_list): ... here, which came before cmdline processing.
Take additional bool defer_warn argument.
(gfc_add_include_path): Take additional defer_warn arg.
* scanner.h (struct gfc_directorylist): Reorder for alignment issues,
add new 'bool warn'.

libgfortran/ChangeLog:
PR fortran/55534
* configure.ac (AM_FCFLAGS): Add -Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:
PR fortran/55534
* testsuite/libgomp.fortran/fortran.exp: Add -Wno-missing-include-dirs
to ALWAYS_CFLAGS.
* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.

gcc/testsuite/ChangeLog:
* gfortran.dg/include_6.f90: Change dg-error to
dg-warning and update pattern.
* gfortran.dg/include_14.f90: New test.
* gfortran.dg/include_15.f90: New test.
* gfortran.dg/include_16.f90: New test.
* gfortran.dg/include_17.f90: New test.
* gfortran.dg/include_18.f90: New test.
* gfortran.dg/include_19.f90: New test.
* gfortran.dg/include_20.f90: New test.
* gfortran.dg/include_21.f90: New test.

(cherry picked from commit 417ea5c02cef7f000e66d1af22b066c2c1cda047)

2 years agoDaily bump.
GCC Administrator [Tue, 21 Sep 2021 00:17:57 +0000 (00:17 +0000)]
Daily bump.

2 years agoFortran/OpenMP: unconstrained/reproducible ordered modifier
Tobias Burnus [Mon, 20 Sep 2021 15:31:45 +0000 (17:31 +0200)]
Fortran/OpenMP: unconstrained/reproducible ordered modifier

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_clauses): Add order_unconstrained.
* dump-parse-tree.c (show_omp_clauses): Dump it.
* openmp.c (gfc_match_omp_clauses): Match unconstrained/reproducible
modifiers to ordered(concurrent).
(OMP_DISTRIBUTE_CLAUSES): Accept ordered clause.
(resolve_omp_clauses): Reject ordered + order on same directive.
* trans-openmp.c (gfc_trans_omp_clauses, gfc_split_omp_clauses): Pass
on unconstrained modifier of ordered(concurrent).

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/order-5.f90: New test.
* gfortran.dg/gomp/order-6.f90: New test.
* gfortran.dg/gomp/order-7.f90: New test.
* gfortran.dg/gomp/order-8.f90: New test.
* gfortran.dg/gomp/order-9.f90: New test.

(cherry picked from commit 0de4184baca19cdd4ebc2d8aa2d538330cae51ee)

2 years agoRevert "GCC11 - Fortran: combined directives - order(concurrent) not on distribute"
Tobias Burnus [Mon, 20 Sep 2021 15:26:57 +0000 (17:26 +0200)]
Revert "GCC11 - Fortran: combined directives - order(concurrent) not on distribute"

This reverts commit b1dc26d3543d79805751c26ba5b142eeeb1f55b8.
Reason: This only applies to GCC 11 and is superceeded to a GCC 12 patch,
which will be cherry-picked in the next commit.

2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 20 Sep 2021 15:25:44 +0000 (17:25 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9017-gb1dc26d3543d79805751c26ba5b142eeeb1f55b8 (Sept 20, 2021)

2 years agoGCC11 - Fortran: combined directives - order(concurrent) not on distribute
Tobias Burnus [Mon, 20 Sep 2021 15:24:56 +0000 (17:24 +0200)]
GCC11 - Fortran: combined directives - order(concurrent) not on distribute

While OpenMP 5.1 and GCC 12 permits 'order(concurrent)' on distribute,
OpenMP 5.0 and GCC 11 don't. This patch for GCC 11 ensures the clause also
does not end up on 'distribute' when splitting combined directives.

gcc/fortran/ChangeLog:

* trans-openmp.c (gfc_split_omp_clauses): Don't put 'order(concurrent)'
on 'distribute' for combined directives, matching OpenMP 5.0

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/distribute-order-concurrent.f90: New test.

2 years agoopenmp: Support in_reduction for Fortran
Chung-Lin Tang [Mon, 20 Sep 2021 13:25:51 +0000 (21:25 +0800)]
openmp: Support in_reduction for Fortran

This patch is a merge of:
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579673.html

with some of the adjustments suggested by Jakub:
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579694.html

This patch does the required adjustments to let 'in_reduction' work for Fortran.
Task directive in_reduction now also works for Fortran after this patch.

gcc/fortran/ChangeLog:

* openmp.c (gfc_match_omp_clause_reduction): Add 'openmp_target' default
false parameter. Add 'always,tofrom' map for OMP_LIST_IN_REDUCTION case.
(gfc_match_omp_clauses): Add 'openmp_target' default false parameter,
adjust call to gfc_match_omp_clause_reduction.
(match_omp): Adjust call to gfc_match_omp_clauses
* trans-openmp.c (gfc_trans_omp_taskgroup): Add call to
gfc_match_omp_clause, create and return block.

gcc/ChangeLog:

* omp-low.c (scan_sharing_clauses): Place in_reduction copy of variable
in outer ctx if if exists. Check if non-existent in field_map before
installing OMP_CLAUSE_IN_REDUCTION decl.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/reduction4.f90: Adjust omp target in_reduction' scan
pattern.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-in-reduction-1.f90: New test.

2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 20 Sep 2021 06:53:26 +0000 (08:53 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9016-g79c523d40de1b7ce1dd0f4865c0855ab2bf6744b (Sept 20, 2021).

2 years agoopenmp: Handle unconstrained and reproducible modifiers on order(concurrent)
Jakub Jelinek [Mon, 20 Sep 2021 06:52:39 +0000 (08:52 +0200)]
openmp: Handle unconstrained and reproducible modifiers on order(concurrent)

This patch adds handling for unconstrained and reproducible modifiers on
order(concurrent) clause.  For all static schedules (including auto and
no schedule or dist_schedule clauses) I believe what we implement is
reproducible, so the patch doesn't do much beyond recognizing those.
Note, there is an OpenMP/spec issue that needs resolution on what
should happen with the dynamic schedules (whether it should be an error
to mix such clauses, or silently make it non-reproducible, and in which
exact cases), so it might need some follow-up.

Besides that, this patch allows order(concurrent) clause on the distribute
construct which is something also added in OpenMP 5.1, and finally
check the newly added restriction that at most one order clause
can appear on a construct.

The allowing of order clause on distribute has a side-effect that
order(concurrent) copyin(thrpriv) is no longer allowed on combined/composite
constructs with distribute parallel for{, simd} in it, previously the
order applied only to for/simd and so a threadprivate var could be seen
in the construct, but now it also applies to distribute and so on the parallel
we shouldn't refer to a threadprivate var.

2021-09-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree.h (OMP_CLAUSE_ORDER_UNCONSTRAINED): Define.
* tree-pretty-print.c (dump_omp_clause): Print unconstrained:
for OMP_CLAUSE_ORDER_UNCONSTRAINED.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Split order clause also to
distribute construct.  Copy over OMP_CLAUSE_ORDER_UNCONSTRAINED.
gcc/c/
* c-parser.c (c_parser_omp_clause_order): Parse unconstrained
and reproducible modifiers.
(OMP_DISTRIBUTE_CLAUSE_MASK): Add order clause.
gcc/cp/
* parser.c (cp_parser_omp_clause_order): Parse unconstrained
and reproducible modifiers.
(OMP_DISTRIBUTE_CLAUSE_MASK): Add order clause.
gcc/testsuite/
* c-c++-common/gomp/order-1.c (f2): Add tests for distribute
with order clause.
(f3): Remove.
* c-c++-common/gomp/order-2.c: Don't expect error for distribute
with order clause.
* c-c++-common/gomp/order-5.c: New test.
* c-c++-common/gomp/order-6.c: New test.
* c-c++-common/gomp/clause-dups-1.c (f1): Add tests for
duplicated order clause.
(f9): New function.
* c-c++-common/gomp/clauses-1.c (baz, bar): Don't mix copyin and
order(concurrent) clauses on the same composite construct combined
with distribute, instead split it into two tests, one without
copyin and one without order(concurrent).  Add order(concurrent)
clauses to {,{,target} teams} distribute.
* g++.dg/gomp/attrs-1.C (baz, bar): Likewise.
* g++.dg/gomp/attrs-2.C (baz, bar): Likewise.

(cherry picked from commit e9d8fcabd032b873bf3fe14ae8afd8970827c0cb)

2 years agoopenmp: Allow private or firstprivate arguments to default clause even for C/C++
Jakub Jelinek [Mon, 20 Sep 2021 06:49:26 +0000 (08:49 +0200)]
openmp: Allow private or firstprivate arguments to default clause even for C/C++

OpenMP 5.1 allows default(private) or default(firstprivate) even in C/C++,
but it behaves the same way as in Fortran only for variables not declared at
namespace or file scope.  For the namespace/file scope variables it instead
behaves as default(none).

2021-09-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* gimplify.c (omp_default_clause): For C/C++ default({,first}private),
if file/namespace scope variable doesn't have predetermined sharing,
treat it as if there was default(none).
gcc/c/
* c-parser.c (c_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
gcc/cp/
* parser.c (cp_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
* cp-gimplify.c (cxx_omp_finish_clause): Handle OMP_CLAUSE_PRIVATE.
gcc/testsuite/
* c-c++-common/gomp/default-2.c: New test.
* c-c++-common/gomp/default-3.c: New test.
* g++.dg/gomp/default-1.C: New test.
libgomp/
* testsuite/libgomp.c++/default-1.C: New test.
* testsuite/libgomp.c-c++-common/default-1.c: New test.
* libgomp.texi (OpenMP 5.1): Mark "private and firstprivate argument
to default clause in C and C++" as implemented.

(cherry picked from commit e5597f2ad55219092929dc12ea15e1edba06df18)

2 years agoDaily bump.
GCC Administrator [Mon, 20 Sep 2021 00:17:58 +0000 (00:17 +0000)]
Daily bump.

2 years agoFortran - fix handling of optional allocatable DT arguments with INTENT(OUT)
Harald Anlauf [Thu, 16 Sep 2021 18:12:21 +0000 (20:12 +0200)]
Fortran - fix handling of optional allocatable DT arguments with INTENT(OUT)

gcc/fortran/ChangeLog:

PR fortran/102287
* trans-expr.c (gfc_conv_procedure_call): Wrap deallocation of
allocatable components of optional allocatable derived type
procedure arguments with INTENT(OUT) into a presence check.

gcc/testsuite/ChangeLog:

PR fortran/102287
* gfortran.dg/intent_out_14.f90: New test.

(cherry picked from commit cfea7b86f2430b9cb8018379b071f4004233119c)

2 years agoFortran - fix ICE during error recovery checking entry characteristics
Harald Anlauf [Tue, 14 Sep 2021 18:23:27 +0000 (20:23 +0200)]
Fortran - fix ICE during error recovery checking entry characteristics

gcc/fortran/ChangeLog:

PR fortran/102311
* resolve.c (resolve_entries): Attempt to recover cleanly after
rejecting mismatched function entries.

gcc/testsuite/ChangeLog:

PR fortran/102311
* gfortran.dg/entry_25.f90: New test.

(cherry picked from commit b305ec979d9dfc8153859a62a8ab9dd43c3bfc73)

2 years agoDaily bump.
GCC Administrator [Sun, 19 Sep 2021 00:17:58 +0000 (00:17 +0000)]
Daily bump.

2 years agoFortran: Fix some issues with pointers to character.
José Rui Faustino de Sousa [Sat, 5 Jun 2021 11:12:50 +0000 (11:12 +0000)]
Fortran: Fix some issues with pointers to character.

gcc/fortran/ChangeLog:

PR fortran/100120
PR fortran/100816
PR fortran/100818
PR fortran/100819
PR fortran/100821
* trans-array.c (gfc_get_array_span): rework the way character
array "span" was calculated.
(gfc_conv_expr_descriptor): improve handling of character sections
and unlimited polymorphic objects.
* trans-expr.c (gfc_get_character_len): new function to calculate
character string length.
(gfc_get_character_len_in_bytes): new function to calculate
character string length in bytes.
(gfc_conv_scalar_to_descriptor): add call to set the "span".
(gfc_trans_pointer_assignment): set "_len" and antecipate the
initialization of the deferred character length hidden argument.
* trans-intrinsic.c (gfc_conv_associated): set "force_no_tmp" to
avoid the creation of a temporary.
* trans-types.c (gfc_get_dtype_rank_type): rework type detection
so that unlimited polymorphic objects get proper type infomation,
also important for bind(c).
(gfc_get_dtype): add argument to pass the rank if necessary.
(gfc_get_array_type_bounds): cosmetic change to have character
arrays called character instead of unknown.
* trans-types.h (gfc_get_dtype): modify prototype.
* trans.c (get_array_span): rework the way character array "span"
was calculated.
* trans.h (gfc_get_character_len): new prototype.
(gfc_get_character_len_in_bytes): new prototype.
Add "unlimited_polymorphic" flag to "gfc_se" type to signal when
expression carries an unlimited polymorphic object.

libgfortran/ChangeLog:

PR fortran/100120
* intrinsics/associated.c (associated): have associated verify if
the "span" matches insted of the "elem_len".
* libgfortran.h (GFC_DESCRIPTOR_SPAN): add macro to retrive the
descriptor "span".

gcc/testsuite/ChangeLog:

PR fortran/100120
* gfortran.dg/PR100120.f90: New test.
PR fortran/100816
PR fortran/100818
PR fortran/100819
PR fortran/100821
* gfortran.dg/character_workout_1.f90: New test.
* gfortran.dg/character_workout_4.f90: New test.

(cherry picked from commit d514626ee2566c68b8a79c7b99aaf791d69e1b2f)

2 years agoDaily bump.
GCC Administrator [Sat, 18 Sep 2021 00:18:17 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran: Use _Float128 rather than __float128 for c_float128 kind.
Sandra Loosemore [Fri, 17 Sep 2021 17:15:42 +0000 (10:15 -0700)]
Fortran: Use _Float128 rather than __float128 for c_float128 kind.

The GNU Fortran manual documents that the c_float128 kind corresponds
to __float128, but in fact the implementation uses float128_type_node,
which is _Float128.  Both refer to the 128-bit IEEE/ISO encoding, but
some targets including aarch64 only define _Float128 and not __float128,
and do not provide quadmath.h.  This caused errors in some test cases
referring to __float128.

This patch changes the documentation (including code comments) and
test cases to use _Float128 to match the implementation.

2021-09-16  Sandra Loosemore  <sandra@codesourcery.com>

gcc/fortran/

* intrinsic.texi (ISO_C_BINDING): Change C_FLOAT128 to correspond
to _Float128 rather than __float128.
* iso-c-binding.def (c_float128): Update comments.
* trans-intrinsic.c (gfc_builtin_decl_for_float_kind): Likewise.
(build_round_expr): Likewise.
(gfc_build_intrinsic_lib_fndcecls): Likewise.
* trans-types.h (gfc_real16_is_float128): Likewise.

gcc/testsuite/
* gfortran.dg/PR100914.c: Do not include quadmath.h.  Use
_Float128 _Complex instead of __complex128.
* gfortran.dg/PR100914.f90: Add -Wno-pedantic to suppress error
about use of _Float128.
* gfortran.dg/c-interop/typecodes-array-float128-c.c: Use
_Float128 instead of __float128.
* gfortran.dg/c-interop/typecodes-sanity-c.c: Likewise.
* gfortran.dg/c-interop/typecodes-scalar-float128-c.c: Likewise.
* lib/target-supports.exp
(check_effective_target_fortran_real_c_float128): Update comments.

libgfortran/
* ISO_Fortran_binding.h: Update comments.
* runtime/ISO_Fortran_binding.c: Likewise.

(cherry picked from commit 00b1324f9285f49a6f9516f408f6be5bc6545219)

2 years agoFortran: TS 29113 testsuite
Sandra Loosemore [Fri, 17 Sep 2021 17:08:45 +0000 (10:08 -0700)]
Fortran: TS 29113 testsuite

Add tests to exercise features added to Fortran via TS 29113, "Further
Interoperability of Fortran with C":

https://wg5-fortran.org/N1901-N1950/N1942.pdf

2021-09-01  Sandra Loosemore  <sandra@codesourcery.com>

gcc/testsuite/
* gfortran.dg/c-interop/allocatable-dummy-c.c: New file.
* gfortran.dg/c-interop/allocatable-dummy.f90: New file.
* gfortran.dg/c-interop/allocatable-optional-pointer.f90: New file.
* gfortran.dg/c-interop/allocate-c.c: New file.
* gfortran.dg/c-interop/allocate-errors-c.c: New file.
* gfortran.dg/c-interop/allocate-errors.f90: New file.
* gfortran.dg/c-interop/allocate.f90: New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-1.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-2.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-3.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-4.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-5.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-6.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-7.f90:
New file.
* gfortran.dg/c-interop/argument-association-assumed-rank-8.f90:
New file.
* gfortran.dg/c-interop/assumed-type-dummy.f90: New file.
* gfortran.dg/c-interop/c-interop.exp: New file.
* gfortran.dg/c-interop/c1255-1.f90: New file.
* gfortran.dg/c-interop/c1255-2.f90: New file.
* gfortran.dg/c-interop/c1255a.f90: New file.
* gfortran.dg/c-interop/c407a-1.f90: New file.
* gfortran.dg/c-interop/c407a-2.f90: New file.
* gfortran.dg/c-interop/c407b-1.f90: New file.
* gfortran.dg/c-interop/c407b-2.f90: New file.
* gfortran.dg/c-interop/c407c-1.f90: New file.
* gfortran.dg/c-interop/c516.f90: New file.
* gfortran.dg/c-interop/c524a.f90: New file.
* gfortran.dg/c-interop/c535a-1.f90: New file.
* gfortran.dg/c-interop/c535a-2.f90: New file.
* gfortran.dg/c-interop/c535b-1.f90: New file.
* gfortran.dg/c-interop/c535b-2.f90: New file.
* gfortran.dg/c-interop/c535b-3.f90: New file.
* gfortran.dg/c-interop/c535c-1.f90: New file.
* gfortran.dg/c-interop/c535c-2.f90: New file.
* gfortran.dg/c-interop/c535c-3.f90: New file.
* gfortran.dg/c-interop/c535c-4.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-1.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-2.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-3.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-4.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-5.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-6.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-7.f90: New file.
* gfortran.dg/c-interop/cf-descriptor-8-c.c: New file.
* gfortran.dg/c-interop/cf-descriptor-8.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-1.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-2.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-3.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-4.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-5.f90: New file.
* gfortran.dg/c-interop/cf-out-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/cf-out-descriptor-6.f90: New file.
* gfortran.dg/c-interop/contiguous-1-c.c: New file.
* gfortran.dg/c-interop/contiguous-1.f90: New file.
* gfortran.dg/c-interop/contiguous-2-c.c: New file.
* gfortran.dg/c-interop/contiguous-2.f90: New file.
* gfortran.dg/c-interop/contiguous-3-c.c: New file.
* gfortran.dg/c-interop/contiguous-3.f90: New file.
* gfortran.dg/c-interop/deferred-character-1.f90: New file.
* gfortran.dg/c-interop/deferred-character-2.f90: New file.
* gfortran.dg/c-interop/dump-descriptors.c: New file.
* gfortran.dg/c-interop/dump-descriptors.h: New file.
* gfortran.dg/c-interop/establish-c.c: New file.
* gfortran.dg/c-interop/establish-errors-c.c: New file.
* gfortran.dg/c-interop/establish-errors.f90: New file.
* gfortran.dg/c-interop/establish.f90: New file.
* gfortran.dg/c-interop/explicit-interface.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-1.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-2.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-3.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-4.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-5.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-6.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-7.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-8-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-8.f90: New file.
* gfortran.dg/c-interop/fc-descriptor-9-c.c: New file.
* gfortran.dg/c-interop/fc-descriptor-9.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-1-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-1.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-2-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-2.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-3-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-3.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-4-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-4.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-5-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-5.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-6-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-6.f90: New file.
* gfortran.dg/c-interop/fc-out-descriptor-7-c.c: New file.
* gfortran.dg/c-interop/fc-out-descriptor-7.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-1.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-2.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-3.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-4.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-5.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-6.f90: New file.
* gfortran.dg/c-interop/ff-descriptor-7.f90: New file.
* gfortran.dg/c-interop/note-5-3.f90: New file.
* gfortran.dg/c-interop/note-5-4-c.c: New file.
* gfortran.dg/c-interop/note-5-4.f90: New file.
* gfortran.dg/c-interop/optional-c.c: New file.
* gfortran.dg/c-interop/optional.f90: New file.
* gfortran.dg/c-interop/rank-class.f90: New file.
* gfortran.dg/c-interop/rank.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-1.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-2.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-3.f90: New file.
* gfortran.dg/c-interop/removed-restrictions-4.f90: New file.
* gfortran.dg/c-interop/section-1-c.c: New file.
* gfortran.dg/c-interop/section-1.f90: New file.
* gfortran.dg/c-interop/section-1p.f90: New file.
* gfortran.dg/c-interop/section-2-c.c: New file.
* gfortran.dg/c-interop/section-2.f90: New file.
* gfortran.dg/c-interop/section-2p.f90: New file.
* gfortran.dg/c-interop/section-3-c.c: New file.
* gfortran.dg/c-interop/section-3.f90: New file.
* gfortran.dg/c-interop/section-3p.f90: New file.
* gfortran.dg/c-interop/section-4-c.c: New file.
* gfortran.dg/c-interop/section-4.f90: New file.
* gfortran.dg/c-interop/section-errors-c.c: New file.
* gfortran.dg/c-interop/section-errors.f90: New file.
* gfortran.dg/c-interop/select-c.c: New file.
* gfortran.dg/c-interop/select-errors-c.c: New file.
* gfortran.dg/c-interop/select-errors.f90: New file.
* gfortran.dg/c-interop/select.f90: New file.
* gfortran.dg/c-interop/setpointer-c.c: New file.
* gfortran.dg/c-interop/setpointer-errors-c.c: New file.
* gfortran.dg/c-interop/setpointer-errors.f90: New file.
* gfortran.dg/c-interop/setpointer.f90: New file.
* gfortran.dg/c-interop/shape.f90: New file.
* gfortran.dg/c-interop/size.f90: New file.
* gfortran.dg/c-interop/tkr.f90: New file.
* gfortran.dg/c-interop/typecodes-array-basic-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-basic.f90: New file.
* gfortran.dg/c-interop/typecodes-array-char-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-char.f90: New file.
* gfortran.dg/c-interop/typecodes-array-float128-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-float128.f90: New file.
* gfortran.dg/c-interop/typecodes-array-int128-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-int128.f90: New file.
* gfortran.dg/c-interop/typecodes-array-longdouble-c.c: New file.
* gfortran.dg/c-interop/typecodes-array-longdouble.f90: New file.
* gfortran.dg/c-interop/typecodes-sanity-c.c: New file.
* gfortran.dg/c-interop/typecodes-sanity.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-basic-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-basic.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-float128-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-float128.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-int128-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-int128.f90: New file.
* gfortran.dg/c-interop/typecodes-scalar-longdouble-c.c: New file.
* gfortran.dg/c-interop/typecodes-scalar-longdouble.f90: New file.
* gfortran.dg/c-interop/ubound.f90: New file.
* lib/target-supports.exp
(check_effective_target_fortran_real_c_float128): New function.

(cherry picked from commit cb17b5054118ec0f727956fd6e034b577b5e261c)

2 years agoFortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h.
Sandra Loosemore [Fri, 17 Sep 2021 14:13:29 +0000 (16:13 +0200)]
Fortran: Prefer GCC internal macros to float.h in ISO_Fortran_binding.h.

2021-09-17  Sandra Loosemore  <sandra@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

libgfortran/
* ISO_Fortran_binding.h: Only include float.h if the C compiler
doesn't have predefined __LDBL_* and __DBL_* macros. Handle
LDBL_MANT_DIG == 53 for FreeBSD.

(cherry picked from commit 654187d05376f08667c8ba88309073e0345431c2)

2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Fri, 17 Sep 2021 13:22:20 +0000 (15:22 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-9011-g469aad8b5d787c728fbe8b4ec6537385d7815d5a (Sept 17, 2021).

2 years agolibgomp: Spelling error fix in OpenMP 5.1 conformance section
Jakub Jelinek [Fri, 17 Sep 2021 13:21:24 +0000 (15:21 +0200)]
libgomp: Spelling error fix in OpenMP 5.1 conformance section

Fix spelling of OpenMP directive declare variant.

2021-09-17  Jakub Jelinek  <jakub@redhat.com>

* libgomp.texi (OpenMP 5.1): Spelling fix,
declare variante -> declare variant.

(cherry picked from commit 4a7842bb99249295bfbdfaa6a3030414e4d9eb9d)

2 years agoopenmp: Add support for OpenMP 5.1 atomics for C++
Jakub Jelinek [Fri, 17 Sep 2021 13:20:20 +0000 (15:20 +0200)]
openmp: Add support for OpenMP 5.1 atomics for C++

Besides the C++ FE changes, I've noticed that the C FE didn't reject
  #pragma omp atomic capture compare
  { v = x; x = y; }
and other forms of atomic swap, this patch fixes that too.  And the
c-family/ routine needed quite a few changes so that the new code
in it works fine with both FEs.

2021-09-17  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
* c-omp.c (c_finish_omp_atomic): Avoid creating
TARGET_EXPR if test is true, use create_tmp_var_raw instead of
create_tmp_var and add a zero initializer to TARGET_EXPRs that
had NULL initializer.  When omitting operands after v = x,
use type of v rather than type of x.  Fix type of vtmp
TARGET_EXPR.
gcc/c/
* c-parser.c (c_parser_omp_atomic): Reject atomic swap if capture
is true.
gcc/cp/
* cp-tree.h (finish_omp_atomic): Add r and weak arguments.
* parser.c (cp_parser_omp_atomic): Update function comment for
OpenMP 5.1 atomics, parse OpenMP 5.1 atomics and fail, compare and
weak clauses.
* semantics.c (finish_omp_atomic): Add r and weak arguments, handle
them, handle COND_EXPRs.
* pt.c (tsubst_expr): Adjust for COND_EXPR forms that
finish_omp_atomic can now produce.
gcc/testsuite/
* c-c++-common/gomp/atomic-18.c: Expect same diagnostics in C++ as in
C.
* c-c++-common/gomp/atomic-25.c: Drop c effective target.
* c-c++-common/gomp/atomic-26.c: Likewise.
* c-c++-common/gomp/atomic-27.c: Likewise.
* c-c++-common/gomp/atomic-28.c: Likewise.
* c-c++-common/gomp/atomic-29.c: Likewise.
* c-c++-common/gomp/atomic-30.c: Likewise.  Adjust expected diagnostics
for C++ when it differs from C.
(foo): Change return type from double to void.
* g++.dg/gomp/atomic-5.C: Adjust expected diagnostics wording.
* g++.dg/gomp/atomic-20.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/atomic-19.c: Drop c effective target.
Use /* */ comments instead of //.
* testsuite/libgomp.c-c++-common/atomic-20.c: Likewise.
* testsuite/libgomp.c-c++-common/atomic-21.c: Likewise.
* testsuite/libgomp.c++/atomic-16.C: New test.
* testsuite/libgomp.c++/atomic-17.C: New test.

(cherry picked from commit 3a2bcffac602f5de56537a77db1062984bcefd45)

2 years agoAdd OpenACC 'host_data' testing to 'gfortran.dg/goacc/unexpected-end.f90'
Thomas Schwinge [Fri, 17 Sep 2021 13:16:02 +0000 (15:16 +0200)]
Add OpenACC 'host_data' testing to 'gfortran.dg/goacc/unexpected-end.f90'

Use underscore instead of space in 'host_data'.

Follow-up to recent commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec
"Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]".

gcc/testsuite/
* gfortran.dg/goacc/unexpected-end.f90: Add OpenACC 'host_data'
testing.

(cherry picked from commit 8b69c481fc86e04c6c83f3a49eef2760c175a8f2)

2 years agoFix PR rtl-optimization/102306
Eric Botcazou [Fri, 17 Sep 2021 08:12:12 +0000 (10:12 +0200)]
Fix PR rtl-optimization/102306

This is a duplication of volatile loads introduced during GCC 9 development
by the 2->2 mechanism of the RTL combiner.  There is already a substantial
checking for volatile references in can_combine_p but it implicitly assumes
that the combination reduces the number of instructions, which is of course
not the case here.  So the fix teaches try_combine to abort the combination
when it is about to make a copy of volatile references to preserve them.

gcc/
PR rtl-optimization/102306
* combine.c (try_combine): Abort the combination if we are about to
duplicate volatile references.

gcc/testsuite/
* gcc.target/sparc/20210917-1.c: New test.

2 years agoDaily bump.
GCC Administrator [Fri, 17 Sep 2021 00:18:02 +0000 (00:18 +0000)]
Daily bump.

2 years agoFortran - fix handling of substring start and end indices
Harald Anlauf [Mon, 13 Sep 2021 17:26:35 +0000 (19:26 +0200)]
Fortran - fix handling of substring start and end indices

gcc/fortran/ChangeLog:

PR fortran/85130
* expr.c (find_substring_ref): Handle given substring start and
end indices as signed integers, not unsigned.

gcc/testsuite/ChangeLog:

PR fortran/85130
* gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again
test that was erroneously considered as illegal.

(cherry picked from commit 8d93ba93d3b13ac3d3c34404cad87732c809605b)

2 years agoFortran - ensure simplification of bounds of array-valued named constants
Harald Anlauf [Mon, 13 Sep 2021 17:28:10 +0000 (19:28 +0200)]
Fortran - ensure simplification of bounds of array-valued named constants

gcc/fortran/ChangeLog:

PR fortran/82314
* decl.c (add_init_expr_to_sym): For proper initialization of
array-valued named constants the array bounds need to be
simplified before adding the initializer.

gcc/testsuite/ChangeLog:

PR fortran/82314
* gfortran.dg/pr82314.f90: New test.

(cherry picked from commit 104c05c5284b7822d770ee51a7d91946c7e56d50)

2 years agosparc: Add scheduling information for LEON5
Daniel Cederman [Mon, 25 Mar 2019 08:12:17 +0000 (09:12 +0100)]
sparc: Add scheduling information for LEON5

The LEON5 can often dual issue instructions from the same 64-bit aligned
double word if there are no data dependencies. Add scheduling information
to avoid scheduling unpairable instructions back-to-back.

gcc/ChangeLog:

* config/sparc/sparc-opts.h (enum sparc_processor_type): Add LEON5
* config/sparc/sparc.c (struct processor_costs): Add LEON5 costs
(leon5_adjust_cost): Increase cost of store with data dependency
on ALU instruction and FPU anti-dependencies.
(sparc_option_override): Add LEON5 costs
(sparc_adjust_cost): Add LEON5 cost adjustments
* config/sparc/sparc.h: Add LEON5
* config/sparc/sparc.md: Include LEON5 scheduling information
* config/sparc/sparc.opt: Add LEON5
* doc/invoke.texi: Add LEON5
* config/sparc/leon5.md: New file.

2 years agosparc: Add NOP in stack_protect_setsi if sparc_fix_b2bst enabled
Daniel Cederman [Thu, 1 Oct 2020 07:11:38 +0000 (09:11 +0200)]
sparc: Add NOP in stack_protect_setsi if sparc_fix_b2bst enabled

This is needed to prevent the Store -> (Non-store or load) -> Store
sequence.

gcc/ChangeLog:

* config/sparc/sparc.md (stack_protect_setsi): Add NOP to prevent
sensitive sequence for B2BST errata workaround.

2 years agosparc: Prevent atomic instructions in beginning of functions for UT700
Daniel Cederman [Mon, 12 Oct 2020 06:50:35 +0000 (08:50 +0200)]
sparc: Prevent atomic instructions in beginning of functions for UT700

A call to the function might have a load instruction in the delay slot
and a load followed by an atomic function could cause a deadlock.

gcc/ChangeLog:

* config/sparc/sparc.c (sparc_do_work_around_errata): Do not begin
functions with atomic instruction in the UT700 errata workaround.

2 years agosparc: Skip all empty assembly statements
Daniel Cederman [Fri, 16 Oct 2020 07:12:30 +0000 (09:12 +0200)]
sparc: Skip all empty assembly statements

This version detects multiple empty assembly statements in a row and also
detects non-memory barrier empty assembly statements (__asm__("")). It
can be used instead of next_active_insn().

gcc/ChangeLog:

* config/sparc/sparc.c (next_active_non_empty_insn): New function
that returns next active non empty assembly instruction.
(sparc_do_work_around_errata): Use new function.

2 years agosparc: Treat more instructions as load or store in errata workarounds
Daniel Cederman [Fri, 25 Sep 2020 11:17:46 +0000 (13:17 +0200)]
sparc: Treat more instructions as load or store in errata workarounds

Check the attribute of instruction to determine if it performs a store
or load operation. This more generic approach sees the last instruction
in the GOTdata_op model as a potential load and treats the memory barrier
as a potential store instruction.

gcc/ChangeLog:

* config/sparc/sparc.c (store_insn_p): Add predicate for store
attributes.
(load_insn_p): Add predicate for load attributes.
(sparc_do_work_around_errata): Use new predicates.

2 years agosparc: Print out bit names for LEON and LEON3 with -mdebug
Andreas Larsson [Wed, 5 Jul 2017 11:36:31 +0000 (13:36 +0200)]
sparc: Print out bit names for LEON and LEON3 with -mdebug

gcc/ChangeLog:

* config/sparc/sparc.c (dump_target_flag_bits): Print bit names for
LEON and LEON3.

2 years agoFix target/101934: aarch64 memset code creates unaligned stores for -mstrict-align
Andrew Pinski [Tue, 31 Aug 2021 04:41:14 +0000 (04:41 +0000)]
Fix target/101934: aarch64 memset code creates unaligned stores for -mstrict-align

The problem here is the aarch64_expand_setmem code did not check
STRICT_ALIGNMENT if it is creating an overlapping store.
This patch adds that check and the testcase works.

gcc/ChangeLog:

PR target/101934
* config/aarch64/aarch64.c (aarch64_expand_setmem):
Check STRICT_ALIGNMENT before creating an overlapping
store.

gcc/testsuite/ChangeLog:

PR target/101934
* gcc.target/aarch64/memset-strict-align-1.c: New test.

(cherry picked from commit a45786e9a31f995087d8cb42bc3a4fe06911e588)

2 years agoDaily bump.
GCC Administrator [Thu, 16 Sep 2021 00:17:54 +0000 (00:17 +0000)]
Daily bump.

2 years agoc++: Fix handling of decls with flexible array members initialized with side-effects...
Jakub Jelinek [Wed, 15 Sep 2021 20:21:17 +0000 (22:21 +0200)]
c++: Fix handling of decls with flexible array members initialized with side-effects [PR88578]

> > Note, if the flexible array member is initialized only with non-constant
> > initializers, we have a worse bug that this patch doesn't solve, the
> > splitting of initializers into constant and dynamic initialization removes
> > the initializer and we don't have just wrong DECL_*SIZE, but nothing is
> > emitted when emitting those vars into assembly either and so the dynamic
> > initialization clobbers other vars that may overlap the variable.
> > I think we need keep an empty CONSTRUCTOR elt in DECL_INITIAL for the
> > flexible array member in that case.
>
> Makes sense.

So, the following patch fixes that.

The typeck2.c change makes sure we keep those CONSTRUCTORs around (although
they should be empty because all their elts had side-effects/was
non-constant if it was removed earlier), and the varasm.c change is to avoid
ICEs on those as well as ICEs on other flex array members that had some
initializers without side-effects, but not on the last array element.

The code was already asserting that the (index of the last elt in the
CONSTRUCTOR + 1) times elt size is equal to TYPE_SIZE_UNIT of the local->val
type, which is true for C flex arrays or for C++ if they don't have any
side-effects or the last elt doesn't have side-effects, this patch changes
that to assertion that the TYPE_SIZE_UNIT is greater than equal to the
offset of the end of last element in the CONSTRUCTOR and uses TYPE_SIZE_UNIT
(int_size_in_bytes) in the code later on.

2021-09-15  Jakub Jelinek  <jakub@redhat.com>

PR c++/88578
PR c++/102295
gcc/
* varasm.c (output_constructor_regular_field): Instead of assertion
that array_size_for_constructor result is equal to size of
TREE_TYPE (local->val) in bytes, assert that the type size is greater
or equal to array_size_for_constructor result and use type size as
fieldsize.
gcc/cp/
* typeck2.c (split_nonconstant_init_1): Don't throw away empty
initializers of flexible array members if they have non-zero type
size.
gcc/testsuite/
* g++.dg/ext/flexary39.C: New test.
* g++.dg/ext/flexary40.C: New test.

(cherry picked from commit e5d1af8a07ae9fcc40ea5c781c3ad46d20ea12a6)

2 years agoc++: Update DECL_*SIZE for objects with flexible array members with initializers...
Jakub Jelinek [Tue, 14 Sep 2021 14:56:30 +0000 (16:56 +0200)]
c++: Update DECL_*SIZE for objects with flexible array members with initializers [PR102295]

The C FE updates DECL_*SIZE for vars which have initializers for flexible
array members for many years, but C++ FE kept DECL_*SIZE the same as the
type size (i.e. as if there were zero elements in the flexible array
member).  This results e.g. in ELF symbol sizes being too small.

Note, if the flexible array member is initialized only with non-constant
initializers, we have a worse bug that this patch doesn't solve, the
splitting of initializers into constant and dynamic initialization removes
the initializer and we don't have just wrong DECL_*SIZE, but nothing is
emitted when emitting those vars into assembly either and so the dynamic
initialization clobbers other vars that may overlap the variable.
I think we need keep an empty CONSTRUCTOR elt in DECL_INITIAL for the
flexible array member in that case.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/102295
* decl.c (layout_var_decl): For aggregates ending with a flexible
array member, add the size of the initializer for that member to
DECL_SIZE and DECL_SIZE_UNIT.

* g++.target/i386/pr102295.C: New test.

(cherry picked from commit 818c505188ff5cd8eb048eb0e614c4ef732225bd)

2 years agoc++: Fix __is_*constructible/assignable for templates [PR102305]
Jakub Jelinek [Tue, 14 Sep 2021 14:55:04 +0000 (16:55 +0200)]
c++: Fix __is_*constructible/assignable for templates [PR102305]

is_xible_helper returns error_mark_node (i.e. false from the traits)
for abstract classes by testing ABSTRACT_CLASS_TYPE_P (to) early.
Unfortunately, as the testcase shows, that doesn't work on class templates
that haven't been instantiated yet, ABSTRACT_CLASS_TYPE_P for them is false
until it is instantiated, which is done when the routine later constructs
a dummy object with that type.

The following patch fixes this by calling complete_type first, so that
ABSTRACT_CLASS_TYPE_P test will work properly, while keeping the handling
of arrays with unknown bounds, or incomplete types where it is done
currently.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/102305
* method.c (is_xible_helper): Call complete_type on to.

* g++.dg/cpp0x/pr102305.C: New test.

(cherry picked from commit f008fd3a480e3718436156697ebe7eeb47841457)

2 years agoEnable store fusion on Power10.
Pat Haugen [Mon, 30 Aug 2021 15:58:21 +0000 (10:58 -0500)]
Enable store fusion on Power10.

gcc/ChangeLog:

* config/rs6000/rs6000-cpus.def (ISA_3_1_MASKS_SERVER): Add
OPTION_MASK_P10_FUSION_2STORE.
(POWERPC_MASKS): Likewise.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Enable
store fusion for Power10.
(is_fusable_store): New.
(power10_sched_reorder): Likewise.
(rs6000_sched_reorder): Do Power10 specific reordering.
(rs6000_sched_reorder2): Likewise.
* config/rs6000/rs6000.opt: Add new option.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/fusion-p10-stst.c: New test.
* gcc.target/powerpc/fusion-p10-stst2.c: New test.

2 years agors6000: Generate an lxvp instead of two adjacent lxv instructions
Peter Bergner [Wed, 14 Jul 2021 23:27:02 +0000 (18:27 -0500)]
rs6000: Generate an lxvp instead of two adjacent lxv instructions

The MMA build built-ins currently use individual lxv instructions to
load up the registers of a __vector_pair or __vector_quad.  If the
memory addresses of the built-in operands are to adjacent locations,
then we can use an lxvp in some cases to load up two registers at once.
The patch below adds support for checking whether memory addresses are
adjacent and emitting an lxvp instead of two lxv instructions.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (adjacent_mem_locations): Return the lower
addressed memory rtx, if any.
(rs6000_split_multireg_move): Fix code formatting.
Handle MMA build built-ins with operands in adjacent memory locations.

gcc/testsuite/
* gcc.target/powerpc/mma-builtin-9.c: New test.

(cherry picked from commit 69feb7601e86274fa9abbfb420b00c8adf947e7b)

2 years agors6000: Move rs6000_split_multireg_move to later in file
Peter Bergner [Wed, 14 Jul 2021 23:23:31 +0000 (18:23 -0500)]
rs6000: Move rs6000_split_multireg_move to later in file

An upcoming change to rs6000_split_multireg_move requires it to be
moved later in the file to fix a declaration issue.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_split_multireg_move): Move to later
in the file.

(cherry picked from commit 7d914777fc6c6151f430d798fc97bae927a430f7)

2 years agoDaily bump.
GCC Administrator [Wed, 15 Sep 2021 00:18:10 +0000 (00:18 +0000)]
Daily bump.

2 years agoVerify destination[source] of a load[store] instruction is a register.
Pat Haugen [Tue, 14 Sep 2021 20:02:09 +0000 (15:02 -0500)]
Verify destination[source] of a load[store] instruction is a register.

Backported from master:
2021-08-09  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/ChangeLog:

* config/rs6000/rs6000.c (is_load_insn1): Verify destination is a
register.
(is_store_insn1): Verify source is a register.

2 years agoFortran: Add missing ST_OMP_END_SCOPE handling [PR102313]
Tobias Burnus [Tue, 14 Sep 2021 14:50:11 +0000 (16:50 +0200)]
Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]

PR fortran/102313

gcc/fortran/ChangeLog:

* parse.c (gfc_ascii_statement): Add missing ST_OMP_END_SCOPE.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/unexpected-end.f90: New test.
* gfortran.dg/gomp/unexpected-end.f90: New test.

(cherry picked from commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec)

2 years agoFix PR ada/101970
Eric Botcazou [Tue, 14 Sep 2021 09:33:05 +0000 (11:33 +0200)]
Fix PR ada/101970

This is a regression present on the mainline and 11 branch in the form of an
ICE for an enumeration type with a full signed representation for its size.

gcc/ada/
PR ada/101970
* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Enum_Rep>:
Use an unchecked conversion instead of a regular conversion in the
enumeration case and remove Conversion_OK flag in the integer case.
<Attribute_Pos>: Remove superfluous test.

gcc/testsuite/
* gnat.dg/enum_rep2.adb: New test.

2 years agotestsuite: Use sync_long_long instead of sync_int_long for atomic-29.c test
Jakub Jelinek [Tue, 14 Sep 2021 09:32:46 +0000 (11:32 +0200)]
testsuite: Use sync_long_long instead of sync_int_long for atomic-29.c test

As discussed, the test tests atomics on doubles which are 64-bit and so we
should use sync_long_long effective target instead of sync_int_long that
covers 64-bit atomics only on 64-bit arches.  I've added -march=pentium
to follow what is documented for sync_long_long, I guess -march=zarch should
be added for s390* too, but haven't tested that.

And using sync_long_long found a syntax error in that effective target
implementation, so I've fixed that too.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

* c-c++-common/gomp/atomic-29.c: Add -march=pentium
dg-additional-options for ia32.  Use sync_long_long effective target
instead of sync_int_long.
* lib/target-supports.exp (check_effective_target_sync_long_long): Fix
a syntax error.

(cherry picked from commit b29fc21482c0e203136eb5d44bdc1495de3918c6)

2 years agoopenmp: Add testing checks (whether lhs appears in operands at all) to more trees
Jakub Jelinek [Tue, 14 Sep 2021 09:31:17 +0000 (11:31 +0200)]
openmp: Add testing checks (whether lhs appears in operands at all) to more trees

This patch adds testing checks (goa_stabilize_expr with NULL pre_p) for more
tree codes, so that we don't gimplify their operands individually unless lhs
appears in them.  Also, so that we don't have exponential compile time complexity
with the added checks, I've added a depth computation, we don't expect lhs
to be found in depth 8 or above as all the atomic forms must have x expression
in specific places in the expressions.

2021-09-14  Jakub Jelinek  <jakub@redhat.com>

* gimplify.c (goa_stabilize_expr): Add depth argument, propagate
it to recursive calls, for depth above 7 just gimplify or return.
Perform a test even for MODIFY_EXPR, ADDR_EXPR, COMPOUND_EXPR with
__builtin_clear_padding and TARGET_EXPR.
(gimplify_omp_atomic): Adjust goa_stabilize_expr callers.

(cherry picked from commit 3f89d5ebcca8ea8c363db39cd3946db12b11adcc)

2 years agoDo not issue size error for too large array type
Eric Botcazou [Tue, 14 Sep 2021 09:14:37 +0000 (11:14 +0200)]
Do not issue size error for too large array type

The error is to be issued when objects of the type are declared instead.

gcc/ada/
* gcc-interface/decl.c (validate_size): Do not issue an error if the
old size has overflowed.

2 years agoFix inaccurate bounds in debug info for vector array types
Eric Botcazou [Tue, 14 Sep 2021 09:10:17 +0000 (11:10 +0200)]
Fix inaccurate bounds in debug info for vector array types

They should not be 0-based, unless the array type itself is.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity): For vector types, make
the representative array the debug type.

2 years agoFix internal error on pointer-to-pointer binding in LTO mode
Eric Botcazou [Tue, 14 Sep 2021 08:44:34 +0000 (10:44 +0200)]
Fix internal error on pointer-to-pointer binding in LTO mode

gcc/ada/
* gcc-interface/utils.c (update_pointer_to): Set TYPE_CANONICAL on
pointer and reference types.

2 years agoRemove superfluous call to UI_Is_In_Int_Range
Eric Botcazou [Tue, 14 Sep 2021 08:21:20 +0000 (10:21 +0200)]
Remove superfluous call to UI_Is_In_Int_Range

gcc/ada/
* gcc-interface/utils.c (can_materialize_object_renaming_p): Do not
call UI_Is_In_Int_Range on the result of Normalized_First_Bit.

2 years agoGive more informative error message for by-reference types
Eric Botcazou [Tue, 14 Sep 2021 07:41:36 +0000 (09:41 +0200)]
Give more informative error message for by-reference types

Recent compilers enforce more strictly the RM C.6(18) clause, which says
that volatile record types are by-reference types.  This changes the typical
error message now given in these cases.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <is_type>: Declare new
constant.  Adjust error message issued by validate_size in the case
of by-reference types.
(validate_size): Always use the error strings passed by the caller.

2 years agors6000: Expand fmod and remainder when built with fast-math [PR97142]
Xionghu Luo [Tue, 7 Sep 2021 01:22:50 +0000 (20:22 -0500)]
rs6000: Expand fmod and remainder when built with fast-math [PR97142]

fmod/fmodf and remainder/remainderf could be expanded instead of library
call when fast-math build, which is much faster.

fmodf:
     fdivs   f0,f1,f2
     friz    f0,f0
     fnmsubs f1,f2,f0,f1

remainderf:
     fdivs   f0,f1,f2
     frin    f0,f0
     fnmsubs f1,f2,f0,f1

SPEC2017 Ofast P8LE: 511.povray_r +1.14%,  526.blender_r +1.72%

gcc/ChangeLog:

2021-09-07  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/97142
* config/rs6000/rs6000.md (fmod<mode>3): New define_expand.
(remainder<mode>3): Likewise.

gcc/testsuite/ChangeLog:

2021-09-07  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/97142
* gcc.target/powerpc/pr97142.c: New test.

(cherry-picked from 546ecb0054af302acf0839c7f3eb78598f8c0672)

2 years agoDaily bump.
GCC Administrator [Tue, 14 Sep 2021 00:18:11 +0000 (00:18 +0000)]
Daily bump.

2 years agolibgfortran: Handle m68k extended real format in ISO_Fortran_binding.h
Andreas Schwab [Mon, 13 Sep 2021 08:30:16 +0000 (10:30 +0200)]
libgfortran: Handle m68k extended real format in ISO_Fortran_binding.h

libgfortran/
* ISO_Fortran_binding.h (CFI_type_long_double)
(CFI_type_long_double_Complex) [LDBL_MANT_DIG == 64 &&
LDBL_MIN_EXP == -16382 && LDBL_MAX_EXP == 16384]: Define.

(cherry picked from commit fc4a29c0781186269dc5f668e76ecea82030dde3)

2 years agoMerge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11
Tobias Burnus [Mon, 13 Sep 2021 06:59:27 +0000 (08:59 +0200)]
Merge remote-tracking branch 'origin/releases/gcc-11' into devel/omp/gcc-11

Merge up to r11-8983-gb79f0b99fde48e33ab9b01e1e2d3c184ee60cb93 (Sept 13, 2021)

2 years agolibgfortran: Makefile fix for ISO_Fortran_binding.h
Tobias Burnus [Mon, 13 Sep 2021 06:58:54 +0000 (08:58 +0200)]
libgfortran: Makefile fix for ISO_Fortran_binding.h

libgfortran/ChangeLog:

* Makefile.am (gfor_built_src): Depend on
include/ISO_Fortran_binding.h not on ISO_Fortran_binding.h.
(ISO_Fortran_binding.h): Rename make target to ...
(include/ISO_Fortran_binding.h): ... this.
* Makefile.in: Regenerate.

(cherry picked from commit fc4f0631de806c89a383fd02428a16e91068b9f6)

2 years agoFortran: Revert to non-multilib-specific ISO_Fortran_binding.h
Sandra Loosemore [Mon, 13 Sep 2021 06:57:32 +0000 (08:57 +0200)]
Fortran: Revert to non-multilib-specific ISO_Fortran_binding.h

Commit fef67987cf502fe322e92ddce22eea7ac46b4d75 changed the
libgfortran build process to generate multilib-specific versions of
ISO_Fortran_binding.h from a template, by running gfortran to identify
the values of the Fortran kind constants C_LONG_DOUBLE, C_FLOAT128,
and C_INT128_T.  This caused multiple problems with search paths, both
for build-tree testing and installed-tree use, not all of which have
been fixed.

This patch reverts to a non-multilib-specific .h file that uses GCC's
predefined preprocessor symbols to detect the supported types and map
them to kind values in the same way as the Fortran front end.

2021-09-06  Sandra Loosemore  <sandra@codesourcery.com>

libgfortran/
* ISO_Fortran_binding-1-tmpl.h: Deleted.
* ISO_Fortran_binding-2-tmpl.h: Deleted.
* ISO_Fortran_binding-3-tmpl.h: Deleted.
* ISO_Fortran_binding.h: New file to replace the above.
* Makefile.am (gfor_cdir): Remove MULTISUBDIR.
(ISO_Fortran_binding.h): Simplify to just copy the file.
* Makefile.in: Regenerated.
* mk-kinds-h.sh: Revert pieces no longer needed for
ISO_Fortran_binding.h.

(cherry picked from commit 13beaf9e8d2d8264c0ad8f6504793fdcf26f3f73)

2 years agolibgfortran: Further fixes for GFC/CFI descriptor conversions.
Sandra Loosemore [Mon, 13 Sep 2021 06:55:52 +0000 (08:55 +0200)]
libgfortran: Further fixes for GFC/CFI descriptor conversions.

This patch is for:
PR100907 - Bind(c): failure handling wide character
PR100911 - Bind(c): failure handling C_PTR
PR100914 - Bind(c): errors handling complex
PR100915 - Bind(c): failure handling C_FUNPTR
PR100917 - Bind(c): errors handling long double real

All of these problems are related to the GFC descriptors constructed
by the Fortran front end containing ambigous or incomplete
information.  This patch does not attempt to change the GFC data
structure or the front end, and only makes the runtime interpret it in
more reasonable ways.  It's not a complete fix for any of the listed
issues.

The Fortran front end does not distinguish between C_PTR and
C_FUNPTR, mapping both onto BT_VOID.  That is what this patch does also.

The other bugs are related to GFC descriptors only containing elem_len
and not kind.  For complex types, the elem_len needs to be divided by
2 and then mapped onto a real kind.  On x86 targets, the kind
corresponding to C long double is different than its elem_len; since
we cannot accurately disambiguate between a 16-byte kind 10 long
double from __float128, this patch arbitrarily prefers to interpret that as
the standard long double type rather than the GNU extension.

Similarly, for character types, the GFC descriptor cannot distinguish
between character(kind=c_char, len=4) and character(kind=ucs4, len=1).
But since the front end currently rejects anything other than len=1
(PR92482) this patch uses the latter interpretation.

2021-09-01  Sandra Loosemore  <sandra@codesourcery.com>
    José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/testsuite/
PR fortran/100911
PR fortran/100915
PR fortran/100916
* gfortran.dg/PR100911.c: New file.
* gfortran.dg/PR100911.f90: New file.
* gfortran.dg/PR100914.c: New file.
* gfortran.dg/PR100914.f90: New file.
* gfortran.dg/PR100915.c: New file.
* gfortran.dg/PR100915.f90: New file.

libgfortran/
PR fortran/100907
PR fortran/100911
PR fortran/100914
PR fortran/100915
PR fortran/100917
* ISO_Fortran_binding-1-tmpl.h (CFI_type_cfunptr): Make equivalent
to CFI_type_cptr.
* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Fix
handling of CFI_type_cptr and CFI_type_cfunptr.  Additional error
checking and code cleanup.
(gfc_desc_to_cfi_desc): Likewise.  Also correct kind mapping
for character, complex, and long double types.

(cherry picked from commit 93b6b2f614eb692d1d8126ec6cb946984a9d01d7)

2 years agoopenmp: Implement OpenMP 5.1 atomics, so far for C only
Jakub Jelinek [Mon, 13 Sep 2021 06:50:43 +0000 (08:50 +0200)]
openmp: Implement OpenMP 5.1 atomics, so far for C only

This patch implements OpenMP 5.1 atomics (with clarifications from upcoming 5.2).
The most important changes are that it is now possible to write (for C/C++,
for Fortran it was possible before already) min/max atomics and more importantly
compare and exchange in various forms.
Also, acq_rel is now allowed on read/write and acq_rel/acquire are allowed on
update, and there are new compare, weak and fail clauses.

2021-09-10  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree-core.h (enum omp_memory_order): Add OMP_MEMORY_ORDER_MASK,
OMP_FAIL_MEMORY_ORDER_UNSPECIFIED, OMP_FAIL_MEMORY_ORDER_RELAXED,
OMP_FAIL_MEMORY_ORDER_ACQUIRE, OMP_FAIL_MEMORY_ORDER_RELEASE,
OMP_FAIL_MEMORY_ORDER_ACQ_REL, OMP_FAIL_MEMORY_ORDER_SEQ_CST and
OMP_FAIL_MEMORY_ORDER_MASK enumerators.
(OMP_FAIL_MEMORY_ORDER_SHIFT): Define.
* gimple-pretty-print.c (dump_gimple_omp_atomic_load,
dump_gimple_omp_atomic_store): Print [weak] for weak atomic
load/store.
* gimple.h (enum gf_mask): Change GF_OMP_ATOMIC_MEMORY_ORDER
to 6-bit mask, adjust GF_OMP_ATOMIC_NEED_VALUE value and add
GF_OMP_ATOMIC_WEAK.
(gimple_omp_atomic_weak_p, gimple_omp_atomic_set_weak): New inline
functions.
* tree.h (OMP_ATOMIC_WEAK): Define.
* tree-pretty-print.c (dump_omp_atomic_memory_order): Adjust for
fail memory order being encoded in the same enum and also print
fail clause if present.
(dump_generic_node): Print weak clause if OMP_ATOMIC_WEAK.
* gimplify.c (goa_stabilize_expr): Add target_expr and rhs arguments,
handle pre_p == NULL case as a test mode that only returns value
but doesn't change gimplify nor change anything otherwise, adjust
recursive calls, add MODIFY_EXPR, ADDR_EXPR, COND_EXPR, TARGET_EXPR
and CALL_EXPR handling, adjust COMPOUND_EXPR handling for
__builtin_clear_padding calls, for !rhs gimplify as lvalue rather
than rvalue.
(gimplify_omp_atomic): Adjust goa_stabilize_expr caller.  Handle
COND_EXPR rhs.  Set weak flag on gimple load/store for
OMP_ATOMIC_WEAK.
* omp-expand.c (omp_memory_order_to_fail_memmodel): New function.
(omp_memory_order_to_memmodel): Adjust for fail clause encoded
in the same enum.
(expand_omp_atomic_cas): New function.
(expand_omp_atomic_pipeline): Use omp_memory_order_to_fail_memmodel
function.
(expand_omp_atomic): Attempt to optimize atomic compare and exchange
using expand_omp_atomic_cas.
gcc/c-family/
* c-common.h (c_finish_omp_atomic): Add r and weak arguments.
* c-omp.c: Include gimple-fold.h.
(c_finish_omp_atomic): Add r and weak arguments.  Add support for
OpenMP 5.1 atomics.
gcc/c/
* c-parser.c (c_parser_conditional_expression): If omp_atomic_lhs and
cond.value is >, < or == with omp_atomic_lhs as one of the operands,
don't call build_conditional_expr, instead build a COND_EXPR directly.
(c_parser_binary_expression): Avoid calling parser_build_binary_op
if omp_atomic_lhs even in more cases for >, < or ==.
(c_parser_omp_atomic): Update function comment for OpenMP 5.1 atomics,
parse OpenMP 5.1 atomics and fail, compare and weak clauses, allow
acq_rel on atomic read/write and acq_rel/acquire clauses on update.
* c-typeck.c (build_binary_op): For flag_openmp only handle
MIN_EXPR/MAX_EXPR.
gcc/cp/
* parser.c (cp_parser_omp_atomic): Allow acq_rel on atomic read/write
and acq_rel/acquire clauses on update.
* semantics.c (finish_omp_atomic): Adjust c_finish_omp_atomic caller.
gcc/testsuite/
* c-c++-common/gomp/atomic-17.c (foo): Add tests for atomic read,
write or update with acq_rel clause and atomic update with acquire clause.
* c-c++-common/gomp/atomic-18.c (foo): Adjust expected diagnostics
wording, remove tests moved to atomic-17.c.
* c-c++-common/gomp/atomic-21.c: Expect only 2 omp atomic release and
2 omp atomic acq_rel directives instead of 4 omp atomic release.
* c-c++-common/gomp/atomic-25.c: New test.
* c-c++-common/gomp/atomic-26.c: New test.
* c-c++-common/gomp/atomic-27.c: New test.
* c-c++-common/gomp/atomic-28.c: New test.
* c-c++-common/gomp/atomic-29.c: New test.
* c-c++-common/gomp/atomic-30.c: New test.
* c-c++-common/goacc-gomp/atomic.c: Expect 1 omp atomic release and
1 omp atomic_acq_rel instead of 2 omp atomic release directives.
* gcc.dg/gomp/atomic-5.c: Adjust expected error diagnostic wording.
* g++.dg/gomp/atomic-18.C:Expect 4 omp atomic release and
1 omp atomic_acq_rel instead of 5 omp atomic release directives.
libgomp/
* testsuite/libgomp.c-c++-common/atomic-19.c: New test.
* testsuite/libgomp.c-c++-common/atomic-20.c: New test.
* testsuite/libgomp.c-c++-common/atomic-21.c: New test.

(cherry picked from commit 8122fbff770bcff183a9c3c72e8092c0ca32150b)

2 years agolibgomp.texi: Extend OpenMP 5.0 Implementation Status
Tobias Burnus [Mon, 13 Sep 2021 06:40:35 +0000 (08:40 +0200)]
libgomp.texi: Extend OpenMP 5.0 Implementation Status

libgomp/
* libgomp.texi (OpenMP Implementation Status): Extend
OpenMP 5.0 section.
(OpenACC Profiling Interface): Fix typo.

(cherry picked from commit ff7bc505b17e67ba244ca284aa7514a4f0fc27b6)

2 years agolibgomp.texi: Add OpenMP Implementation Status
Tobias Burnus [Mon, 13 Sep 2021 06:39:23 +0000 (08:39 +0200)]
libgomp.texi: Add OpenMP Implementation Status

libgomp/
* libgomp.texi (Enabling OpenMP): Refer to OMP spec in general
not to 4.5; link to new section.
(OpenMP Implementation Status): New.

(cherry picked from commit cff72ef4e2ff8d5775470a8a01a6d9760d2c70be)

2 years agoinvoke.texi: Fix @opindex for -foffload-options
Tobias Burnus [Mon, 13 Sep 2021 06:36:17 +0000 (08:36 +0200)]
invoke.texi: Fix @opindex for -foffload-options

gcc/
* doc/invoke.texi (-foffload-options): Fix @opindex.

(cherry picked from commit 1bc66017c118229a101f0a2c097a9c209f777883)

2 years agoFortran: Fix Bind(C) char-len check, add ptr-contiguous check
Tobias Burnus [Mon, 13 Sep 2021 06:34:33 +0000 (08:34 +0200)]
Fortran: Fix Bind(C) char-len check, add ptr-contiguous check

Add F2018, 18.3.6 (5), pointer + contiguous is not permitted
check for dummies in BIND(C) procs.

Fix misreading of F2018, 18.3.4/18.3.5 + 18.3.6 (5) regarding
character dummies passed as byte stream to a bind(C) dummy arg:
Per F2018, 18.3.1 only len=1 is interoperable (since F2003).
F2008 added 'constant expression' for vars (F2018, 18.3.4/18.3.5),
applicable to dummy args per F2018, C1554. I misread this such
that len > 1 is permitted if len is a constant expr.

While the latter would work as character len=1 a(10) and len=2 a(5)
have the same storage sequence and len is fixed, it is still invalid.
Hence, it is now rejected again.

gcc/fortran/ChangeLog:

* decl.c (gfc_verify_c_interop_param): Reject pointer with
CONTIGUOUS attributes as dummy arg. Reject character len > 1
when passed as byte stream.

gcc/testsuite/ChangeLog:

* gfortran.dg/bind_c_char_6.f90: Update dg-error.
* gfortran.dg/bind_c_char_7.f90: Likewise.
* gfortran.dg/bind_c_char_8.f90: Likewise.
* gfortran.dg/iso_c_binding_char_1.f90: Likewise.
* gfortran.dg/pr32599.f03: Likewise.
* gfortran.dg/bind_c_char_9.f90: Comment testcase bits which are
implementable but not valid F2018.
* gfortran.dg/bind_c_contiguous.f90: New test.

(cherry picked from commit 943c65c4494145e993af43c821c82000013c6375)

2 years agoDaily bump.
GCC Administrator [Mon, 13 Sep 2021 00:18:13 +0000 (00:18 +0000)]
Daily bump.

2 years agod: Don't include terminating null pointer in string expression conversion (PR102185)
Iain Buclaw [Fri, 3 Sep 2021 07:34:00 +0000 (09:34 +0200)]
d: Don't include terminating null pointer in string expression conversion (PR102185)

This gets re-added by the ExprVisitor when lowering StringExp back into a
STRING_CST during the code generator pass.

PR d/102185

gcc/d/ChangeLog:

* d-builtins.cc (d_eval_constant_expression): Don't include
terminating null pointer in string expression conversion.

gcc/testsuite/ChangeLog:

* gdc.dg/pr102185.d: New test.

(cherry picked from commit 53a4def0dc1aac39d592a0d20e9ec16e8b5574ac)

2 years agoDaily bump.
GCC Administrator [Sun, 12 Sep 2021 00:17:52 +0000 (00:17 +0000)]
Daily bump.

2 years agoFortran - out of bounds in array constructor with implied do loop
Harald Anlauf [Thu, 9 Sep 2021 19:34:01 +0000 (21:34 +0200)]
Fortran - out of bounds in array constructor with implied do loop

gcc/fortran/ChangeLog:

PR fortran/98490
* trans-expr.c (gfc_conv_substring): Do not generate substring
bounds check for implied do loop index variable before it actually
becomes defined.

gcc/testsuite/ChangeLog:

PR fortran/98490
* gfortran.dg/bounds_check_23.f90: New test.

(cherry picked from commit 5fe0865ab788bdc387b284a3ad57e5a95a767b18)

2 years agoFortran - improve error recovery determining array element from constructor
Harald Anlauf [Tue, 7 Sep 2021 18:51:49 +0000 (20:51 +0200)]
Fortran - improve error recovery determining array element from constructor

gcc/fortran/ChangeLog:

PR fortran/101327
* expr.c (find_array_element): When bounds cannot be determined as
constant, return error instead of aborting.

gcc/testsuite/ChangeLog:

PR fortran/101327
* gfortran.dg/pr101327.f90: New test.

(cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3)

This page took 0.11751 seconds and 5 git commands to generate.