Commit graph

195756 commits

Author SHA1 Message Date
Jonathan Wakely
03cb9ed8dd libstdc++: Update std::pointer_traits to match new LWG 3545 wording
It was pointed out in recent LWG 3545 discussion that having a
constrained partial specialization of std::pointer_traits can cause
ambiguities with program-defined specializations. For example, the
addition to the testcase has:

template<typename P> requires std::derived_from<P, base_type
struct std::pointer_traits<P>;

This would be ambiguous with the library's own constrained partial
specialization:

template<typename Ptr> requires requires { typename Ptr::element_type; }
struct std::pointer_traits<Ptr>;

Neither specialization is more specialized than the other for a type
that is derived from base_type and also has an element_type member.

The solution is to remove the library's partial specialization, and do
the check for Ptr::element_type in the __ptr_traits_elem helper (which
is what we already do for !__cpp_concepts anyway).

libstdc++-v3/ChangeLog:

	* include/bits/ptr_traits.h (__ptr_traits_elem) [__cpp_concepts]:
	Also define the __ptr_traits_elem class template for the
	concepts case.
	(pointer_traits<Ptr>): Remove constrained partial
	specialization.
	* testsuite/20_util/pointer_traits/lwg3545.cc: Check for
	ambiguitiy with program-defined partial specialization.
2022-09-26 23:47:37 +01:00
Jonathan Wakely
af85ad8917 libstdc++: Use new built-ins for std::is_convertible traits
libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_convertible, is_convertible_v):
	Define using new built-in.
	(is_nothrow_convertible is_nothrow_convertible_v): Likewise.
2022-09-26 23:47:37 +01:00
Martin Liska
7701ea4a70 docs: add missing dash in option name
gcc/ChangeLog:

	* doc/invoke.texi: Add missing dash for
	  Wanalyzer-exposure-through-uninit-copy.
2022-09-26 21:04:11 +02:00
Marek Polacek
567329fdd9 c++: P2513R4, char8_t Compatibility and Portability Fix [PR106656]
P0482R6, which added char8_t, didn't allow

  const char arr[] = u8"howdy";

because it said "Declarations of arrays of char may currently be initialized
with UTF-8 string literals. Under this proposal, such initializations would
become ill-formed."  This caused too many issues, so P2513R4 alleviates some
of those compatibility problems.  In particular, "Arrays of char or unsigned
char may now be initialized with a UTF-8 string literal."  This restriction
has been lifted for initialization only, not implicit conversions.  Also,
my reading is that 'signed char' was excluded from the allowable conversions.

This is supposed to be treated as a DR in C++20.

	PR c++/106656

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Update value of __cpp_char8_t
	for C++20.

gcc/cp/ChangeLog:

	* typeck2.cc (array_string_literal_compatible_p): Allow
	initializing arrays of char or unsigned char by a UTF-8 string literal.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/feat-cxx2b.C: Adjust.
	* g++.dg/cpp2a/feat-cxx2a.C: Likewise.
	* g++.dg/ext/char8_t-feature-test-macro-2.C: Likewise.
	* g++.dg/ext/char8_t-init-2.C: Likewise.
	* g++.dg/cpp2a/char8_t3.C: New test.
	* g++.dg/cpp2a/char8_t4.C: New test.
2022-09-26 13:34:04 -04:00
Aldy Hernandez
5e77d4082f Optimize [0 = x & MASK] in range-ops.
For [0 = x & MASK], we can determine that x is ~MASK.  This is
something we're picking up in DOM thanks to maybe_set_nonzero_bits,
but is something we should handle natively.

This is a good example of how much easier to maintain the range-ops
entries are versus the ad-hoc pattern matching stuff we had to do
before.  For the curious, compare the changes to range-op here,
versus maybe_set_nonzero_bits.

I'm leaving the call to maybe_set_nonzero_bits until I can properly
audit it to make sure we're catching it all in range-ops.  It won't
hurt, since both set_range_info() and set_nonzero_bits() are
intersect operations, so we'll never lose information if we do both.

	PR tree-optimization/107009

gcc/ChangeLog:

	* range-op.cc (operator_bitwise_and::op1_range): Optimize 0 = x & MASK.
	(range_op_bitwise_and_tests): New test.
2022-09-26 19:24:58 +02:00
Marek Polacek
be4b32b9ef c++: Instantiate less when evaluating __is_convertible
Jon reported that evaluating __is_convertible in a test led to
instantiating something ill-formed and so we failed to compile the test.
__is_convertible doesn't and shouldn't need to instantiate so much, so
let's limit it with a cp_unevaluated guard.  Use a helper function to
implement both built-ins.

	PR c++/106784

gcc/cp/ChangeLog:

	* method.cc (is_convertible_helper): New.
	(is_convertible): Use it.
	(is_nothrow_convertible): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/is_convertible3.C: New test.
	* g++.dg/ext/is_nothrow_convertible3.C: New test.
2022-09-26 12:20:38 -04:00
Patrick Palka
099a66498b c++ modules: variable template partial spec fixes [PR107033]
In r13-2775-g32d8123cd6ce87 I missed that we need to adjust the call to
add_mergeable_specialization in the MK_partial case to correctly handle
variable template partial specializations (it currently assumes we're
always dealing with one for a class template).  This fixes an ICE when
converting the testcase from that commit to use an importable header
instead of a named module.

	PR c++/107033

gcc/cp/ChangeLog:

	* module.cc (trees_in::decl_value): In the MK_partial case for
	a variable template partial specialization, pass decl_p=true to
	add_mergeable_specialization, and set spec to the VAR_DECL not
	the TEMPLATE_DECL.
	* pt.cc (add_mergeable_specialization): For a variable template
	partial specialization, set the TREE_TYPE of the new
	DECL_TEMPLATE_SPECIALIZATIONS node to the TREE_TYPE of the
	VAR_DECL not the VAR_DECL itself.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/partial-2.cc, g++.dg/modules/partial-2.h: New
	files, factored out from ...
	* g++.dg/modules/partial-2_a.C, g++.dg/modules/partial-2_b.C: ...
	these.
	* g++.dg/modules/partial-2_c.H: New test.
	* g++.dg/modules/partial-2_d.C: New test.
2022-09-26 11:30:17 -04:00
Jeff Law
1b5432b401 Update my address and DCO entry in MAINTAINERS file
/
	* MAINTAINERS: Update my email address and DCO entry.
2022-09-26 09:14:55 -06:00
Aldy Hernandez
2460f7cdef Set ranges from unreachable edges for all known ranges.
In the conversion of DOM+evrp to DOM+ranger, we missed that evrp was
exporting ranges for unreachable edges for all SSA names for which we
have ranges for.  Instead we have only been exporting ranges for the
SSA name in the final conditional to the BB involving the unreachable
edge.

This patch adjusts adjusts DOM to iterate over the exports, similarly
to what evrp was doing.

Note that I also noticed that we don't calculate the nonzero bit mask
for op1, when 0 = op1 & MASK.  This isn't needed for this PR,
since maybe_set_nonzero_bits() is chasing the definition and
parsing the bitwise and on its own.  However, I'll be adding the
functionality for completeness sake, plus we could probably drop the
maybe_set_nonzero_bits legacy call entirely.

	PR tree-optimization/107009

gcc/ChangeLog:

	* tree-ssa-dom.cc
	(dom_opt_dom_walker::set_global_ranges_from_unreachable_edges):
	Iterate over exports.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr107009.c: New test.
2022-09-26 16:39:29 +02:00
Thomas Schwinge
e9019085e1 nvptx: Allow '--with-arch' to override the default '-misa'
gcc/
	* config.gcc (with_arch) [nvptx]: Allow '--with-arch' to override
	the default.
	* config/nvptx/gen-multilib-matches.sh: New.
	* config/nvptx/t-nvptx (MULTILIB_OPTIONS, MULTILIB_MATCHES)
	(MULTILIB_EXCEPTIONS): Handle this.
	* doc/install.texi (Specific) <nvptx-*-none>: Document this.
	* doc/invoke.texi (Nvidia PTX Options): Likewise.
2022-09-26 16:06:01 +02:00
Thomas Schwinge
4d94582e0d nvptx: Introduce dummy multilib option for default '-misa=sm_30'
... primarily in preparation for later changes.

	gcc/
	* config.gcc (TM_MULTILIB_CONFIG) [nvptx]: Set to '$with_arch'.
	* config/nvptx/t-nvptx (MULTILIB_OPTIONS, MULTILIB_MATCHES)
	(MULTILIB_EXCEPTIONS): Handle it.
2022-09-26 16:03:36 +02:00
Thomas Schwinge
108b99b6c4 nvptx: Make default '-misa=sm_30' explicit
... primarily in preparation for later changes.

	gcc/
	* config.gcc (with_arch) [nvptx]: Set to 'sm_30'.
	* config/nvptx/nvptx.cc (nvptx_option_override): Assert that
	'-misa' appeared.
	* config/nvptx/nvptx.h (OPTION_DEFAULT_SPECS): Define.
	* config/nvptx/nvptx.opt (misa=): Remove 'Init'.
2022-09-26 16:00:38 +02:00
Thomas Schwinge
84072a2615 nvptx: forward '-v' command-line option to assembler
For example, for offloading compilation with '-save-temps -v', before vs. after
word-diff then looks like:

    [...]
     [...]/build-gcc-offload-nvptx-none/gcc/as {+-v -v+} -o ./a.xnvptx-none.mkoffload.o ./a.xnvptx-none.mkoffload.s
    {+Verifying sm_30 code with sm_35 code generation.+}
    {+ ptxas -c -o /dev/null ./a.xnvptx-none.mkoffload.o --gpu-name sm_35 -O0+}
    [...]

(This depends on <https://github.com/MentorEmbedded/nvptx-tools/pull/37>
"Put '-v' verbose output onto stderr instead of stdout".)

	gcc/
	* config/nvptx/nvptx.h (ASM_SPEC): Define.
2022-09-26 16:00:09 +02:00
Jeff Law
1b74b5cb4e [RFA] Minor improvement to coremark, avoid unconditional jump to return
gcc/
	* cfgcleanup.cc (bb_is_just_return): No longer static.
	* cfgcleanup.h (bb_is_just_return): Add prototype.
	* cfgrtl.cc (fixup_reorder_chain): Do not create an
	unconditional jump to a return block.  Conditionally
	remove unreachable blocks.

gcc/testsuite/

	* gcc.target/riscv/ret-1.c: New test.
2022-09-26 09:40:41 -04:00
Thomas Neumann
386ebf75f4 fix assert in __deregister_frame_info_bases
When using the atomic fast path deregistering can fail during
program shutdown if the lookup structures are already destroyed.
The assert in __deregister_frame_info_bases takes that into
account. In the non-fast-path case however is not aware of
program shutdown, which caused a compiler error on such platforms.
We fix that by introducing a constant for in_shutdown in
non-fast-path builds.
We also drop the destructor priority, as it is not supported on
all platforms and we no longer rely upon the priority anyway.

libgcc/ChangeLog:
	* unwind-dw2-fde.c: Introduce a constant for in_shutdown
	for the non-fast-path case. Drop destructor priority.
2022-09-26 15:12:02 +02:00
Jonathan Wakely
6904ed80a2 libstdc++: Add #if around non-C++03 code in std::bitset [PR107037]
libstdc++-v3/ChangeLog:

	PR libstdc++/107037
	* include/std/bitset (_Base_bitset::_M_do_reset): Use
	preprocessor conditional around non-C++03 code.
	* testsuite/20_util/bitset/107037.cc: New test.
2022-09-26 12:00:07 +01:00
Tobias Burnus
d3df98807b OpenACC: Fix reduction tree-sharing issue [PR106982]
The tree for var == incoming == outgound was
'MEM <double[5]> [(double *)&reduced]' which caused the ICE
"incorrect sharing of tree nodes".

	PR middle-end/106982

gcc/ChangeLog:

	* omp-low.cc (lower_oacc_reductions): Add some unshare_expr.

gcc/testsuite/ChangeLog:

	* c-c++-common/goacc/reduction-7.c: New test.
	* c-c++-common/goacc/reduction-8.c: New test.
2022-09-26 12:45:28 +02:00
Martin Liska
2387cfc7f6 s390: fix wrong refactoring
Since r13-2251-g1930c5d05ceff2, the refactoring is not 1:1 and we end
up with a wrong rtx type.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_rtx_costs): Remove dest variable
	and use only dst.
2022-09-26 12:08:13 +02:00
Kyrylo Tkachov
c33e12fa47 aarch64: Add -march support for Armv9.1-A, Armv9.2-A, Armv9.3-A
This is a straightforward patch that allows targeting the architecture revisions mentioned in the subject
through -march. These are already supported in binutils.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

	* config/aarch64/aarch64-arches.def (armv9.1-a): Define.
	(armv9.2-a): Likewise.
	(armv9.3-a): Likewise.
	* config/aarch64/aarch64.h (AARCH64_FL_V9_1): Likewise.
	(AARCH64_FL_V9_2): Likewise.
	(AARCH64_FL_V9_3): Likewise.
	(AARCH64_FL_FOR_ARCH9_1): Likewise.
	(AARCH64_FL_FOR_ARCH9_2): Likewise.
	(AARCH64_FL_FOR_ARCH9_3): Likewise.
	(AARCH64_ISA_V9_1): Likewise.
	(AARCH64_ISA_V9_2): Likewise.
	(AARCH64_ISA_V9_3): Likewise.
	* doc/invoke.texi (AArch64 Options): Document armv9.1-a, armv9.2-a,
	armv9.3-a values to -march.
2022-09-26 10:14:30 +01:00
Ghjuvan Lacambre
3a2ae05208 ada: Doc: rename Valid_Image to Valid_Value
This renaming happened some time ago in the code, but the documentation
was not updated.

gcc/ada/

	* doc/gnat_rm/implementation_defined_attributes.rst: Rename Valid_Image.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
a490e7da3a ada: Fix location of pragmas coming from aspects in top-level instances
This patch fixes an AST anomaly where pragmas that correspond to aspects
of a generic package declaration appeared as the auxiliary declarations
of the compilation unit for the instantiated package body.

In particular, this anomaly happened for aspect Annotate and affected
GNATprove, which didn't pick pragma corresponding to this aspect.

gcc/ada/

	* sem_ch12.adb (Build_Instance_Compilation_Unit_Nodes): Relocate
	auxiliary declarations from the original compilation unit to the
	newly created compilation unit for the spec.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
756efb7484 ada: Remove unreferenced Rtsfind entries
Remove unreferenced entries for finding runtime units and runtime
entities by the compiler. Code cleanup using basic grep scripting.

gcc/ada/

	* rtsfind.ads
	(RTU_Id): Remove unreferenced packages; fix whitespace.
	(RE_Id): Remove unreferenced entities; add comment about entity
	that is only used by GNATprove and not by GNAT.
2022-09-26 11:02:31 +02:00
Piotr Trojanek
dda025c9ce ada: Remove unreferenced C macro from OS constants template
The STR/STR1 macros in OS constants template has been unreferenced since
2005, so we can safely remove them.

gcc/ada/

	* s-oscons-tmplt.c (STR, STR1): Remove.
2022-09-26 11:02:31 +02:00
Eric Botcazou
c381ccdf06 ada: Document Long_Long_Long_Size parameter for -gnateT
This was overlooked when the new parameter was created.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(-gnateT): Document new parameter Long_Long_Long_Size.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:30 +02:00
Steve Baird
37645e2cd7 ada: Improve CUDA host-side and device-side binder support
Binder-generated code is not allowed to use Ada2012 syntax. In order to
specify an aspect, a pragma must be used.

gcc/ada/

	* bindgen.adb: When the binder is invoked for the device, specify
	the CUDA_Global aspect for the adainit and adafinal procedures via
	a pragma instead of via an aspect_specification.
2022-09-26 11:02:30 +02:00
Kévin Le Gouguec
6b8e3ee10f ada: Document support for the mold linker
gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Linker Switches): Document support for mold along with gold; add some
	advice regarding OpenSSL in the Pro version.
	* gnat_ugn.texi: Regenerate.
2022-09-26 11:02:30 +02:00
Tucker Taft
91c706565f ada: Make Original_Aspect_Pragma_Name more precise
This commit makes Original_Aspect_Pragma_Name more precise in cases
where there is a second level of indirection caused by pragmas being
turned into Check pragmas.

gcc/ada/

	* sem_util.adb (Original_Aspect_Pragma_Name): Check for Check
	pragmas.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
4450567167 ada: Delay expansion of iterator specification in preanalysis
When preanalysing spec expression (e.g. expression of an expression
function), the name of iterator specification should not be expanded.

This patch simplifies a complicated condition for delaying expansion
within quantified expressions and iterated component associations.

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Delay expansion
	based on Full_Analysis flag.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
2ef56cae72 ada: Delay expansion of iterated component association
When preanalysing spec expression (e.g. expression of an expression
function), the name of iterator specification within an iterated
component association should not be expanded, especially in GNATprove
mode.

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Delay expansion of
	for iterated component association just like it is done within
	quantified expression.
2022-09-26 11:02:30 +02:00
Piotr Trojanek
5549d2695a ada: Only reject volatile ghost objects when SPARK_Mode is On
SPARK rule that forbids ghost volatile objects is only affecting proof
and not generation of object code. It is now only applied where SPARK_Mode
is On. This flexibility is needed to compile code automatically instrumented
by GNATcoverage.

gcc/ada/

	* contracts.adb (Analyze_Object_Contract): Check SPARK_Mode before
	applying SPARK rule.
2022-09-26 11:02:30 +02:00
Justin Squirek
6305563579 ada: Improve accessibility check generation
Improve accessibility check generation by more precisely identifying cases in
which an Original_Node call is needed.

Instead of grabbing the Original_Node of a prefix in all cases (since this
can cause issues where unanalyzed instance names get referenced) we only
obtain the original node when said prefix comes as a result of expanding
function calls.

gcc/ada/

	* sem_util.adb
	(Accessibility_Level): Modify indexed and selected components case
	by reducing the scope where Original_Node gets used.
2022-09-26 11:02:30 +02:00
Boris Yakobowski
9677984d7b ada: Remove GNATmetric's documentation from GNAT's documentation
gcc/ada/

	* doc/gnat_ugn/gnat_utility_programs.rst: Remove documentation for
	gnatmetric.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
092d7509db ada: Remove socket definitions for ancient MinGW
Modern MinGW defines _WIN32_WINNT as 0xa00, so there is no need go guard
against it being lower than 0x0600 or setting it to 0x0501.

gcc/ada/

	* gsocket.h: Remove redefinition of _WIN32_WINNT.
	* mingw32.h: Remove conditional definition of _WIN32_WINNT.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
af61dc3ffd ada: Remove definition of MAXPATHLEN for ancient MinGW
Modern MinGW defines MAXPATHLEN in sys/param.h, so better to use it
directly.

gcc/ada/

	* mingw32.h: Remove condition definition of MAXPATHLEN; the include
	directive for stdlib.h was most likely intended to provide the
	MAX_PATH.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
09b91bbcdd ada: Deconstruct build support for ancient MinGW
Remove conditional C code for building GNAT with MinGW earlier than 2.0,
which was released in 2007.

gcc/ada/

	* adaint.c: Remove conditional #include directives for old MinGW.
	* cal.c: Always include winsock.h, since it is part of modern
	MinGW.
	* cstreams.c: Remove workaround for old MinGW.
	* expect.c: Remove conditional #include directive for old MinGW.
	* mingw32.h: Remove STD_MINGW and OLD_MINGW declarations.
	* sysdep.c: Remove conditional #include directive for old MinGW.
2022-09-26 11:02:29 +02:00
Piotr Trojanek
fb95fb2125 ada: Tune comment of routine for detecting junk names
Reword comment to avoid repetition between spec and body.

gcc/ada/

	* sem_warn.ads (Has_Junk_Name): Reword comment.
2022-09-26 11:02:29 +02:00
Eric Botcazou
6c37375640 Small tweaks. 2022-09-26 10:44:43 +02:00
Martin Liska
7ed1a816ba ranger: remove unused function
gcc/ChangeLog:

	* value-range.cc (tree_compare): Remove unused function.
2022-09-26 09:30:44 +02:00
Kewen Lin
5be0950d22 rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
makes one assumption that we have emitted one insn which
restores the frame pointer previously.  That part of code
was guarded with flag frame_pointer_needed before, it was
consistent, but it was replaced with flag
frame_pointer_needed_indeed since commit r10-7981.  It
caused ICE due to unexpected NULL insn.

	PR target/96072

gcc/ChangeLog:

	* config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
	condition for adding REG_CFA_DEF_CFA reg note with
	frame_pointer_needed_indeed.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr96072.c: New test.
2022-09-26 00:33:18 -05:00
Hu, Lin1
9c9cf4f087 testsuite: Fix up avx256-unaligned-store-3.c test.
gcc/testsuite/ChangeLog:

	PR target/94962
	* gcc.target/i386/avx256-unaligned-store-3.c: Add -mno-avx512f
2022-09-26 13:30:26 +08:00
Kewen Lin
bfad7069b7 rs6000: Fix condition of define_expand vec_shr_<mode> [PR100645]
PR100645 exposes one latent bug in define_expand vec_shr_<mode>
that the current condition TARGET_ALTIVEC is too loose.  The
mode iterator VEC_L contains a few modes, they are not always
supported as vector mode, VECTOR_UNIT_ALTIVEC_OR_VSX_P should
be used like some other VEC_L usages.

	PR target/100645

gcc/ChangeLog:

	* config/rs6000/vector.md (vec_shr_<mode>): Replace condition
	TARGET_ALTIVEC with VECTOR_UNIT_ALTIVEC_OR_VSX_P.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr100645.c: New test.
2022-09-25 22:23:44 -05:00
liuhongt
3db8e9c242 Support 2-instruction vector shuffle for V4SI/V4SF in ix86_expand_vec_perm_const_1.
2022-09-23  Hongtao Liu  <hongtao.liu@intel.com>
	    Liwei Xu  <liwei.xu@intel.com>

gcc/ChangeLog:

	PR target/53346
	* config/i386/i386-expand.cc (expand_vec_perm_shufps_shufps):
	New function.
	(ix86_expand_vec_perm_const_1): Insert
	expand_vec_perm_shufps_shufps at the end of 2-instruction
	expand sequence.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr53346-1.c: New test.
	* gcc.target/i386/pr53346-2.c: New test.
	* gcc.target/i386/pr53346-3.c: New test.
	* gcc.target/i386/pr53346-4.c: New test.
2022-09-26 11:20:46 +08:00
GCC Administrator
de613c6295 Daily bump. 2022-09-26 00:18:09 +00:00
Mikael Morin
77bbf69d29 fortran: Support clobbering of derived types [PR41453]
This adds support for clobbering of non-polymorphic derived type
variables, when they are passed as actual argument whose associated
dummy has the INTENT(OUT) attribute.

We avoid to play with non-constant type sizes or class descriptors by
requiring that the types are derived (not class) and strictly matching,
and by excluding parameterized derived types.

Types that are used in the callee are also excluded: they are types with
allocatable components (the components will be deallocated), and
finalizable types or types with finalizable components (they will be
passed to finalization routines).

	PR fortran/41453

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Allow strictly
	matching derived types.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_10.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
95375ffb3d fortran: Support clobbering of allocatables and pointers [PR41453]
This adds support for clobbering of allocatable and pointer scalar
variables passed as actual argument to a subroutine when the associated
dummy has the INTENT(OUT) attribute.
Support was explicitly disabled (since the beginning for pointers, since
r11-7315-g2df374b337a5f6cf5528e91718e4e12e4006b7ae for allocatables),
but the clobber generation code seems to support it well, as
demonstrated by the newly added testcase.

	PR fortran/41453
	PR fortran/99169

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove conditions
	on ALLOCATABLE and POINTER attributes guarding clobber
	generation.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_9.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
d5e1935b09 fortran: Support clobbering of ASSOCIATE variables [PR41453]
This is in spirit a revert of:
r9-3051-gc109362313623d83fe0a5194bceaf994cf0c6ce0

That commit added a condition to avoid generating ICE with clobbers
of ASSOCIATE variables.
The test added at that point continues to pass if we remove that
condition now.

	PR fortran/41453
	PR fortran/87401

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove condition
	disabling clobber generation for ASSOCIATE variables.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_8.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
467ef2c40d fortran: Support clobbering of SAVE variables [PR41453]
This removes a condition added in:
r9-3032-gee7fb0588c6361b4d77337ab0f7527be64fcdde2.

That commit added a condition to avoid generating ICE with clobbers
of variables with the SAVE attribute.
The test added at that point continues to pass if we remove that
condition now.

	PR fortran/41453
	PR fortran/87395

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove condition
	on SAVE attribute guarding clobber generation.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_7.f90: New test.
2022-09-25 14:44:54 +02:00
Mikael Morin
51c9480f9f fortran: Support clobbering of reference variables [PR41453]
This adds support for clobbering of variables passed by reference,
when the reference is forwarded to a subroutine as actual argument
whose associated dummy has the INTENT(OUT) attribute.
This was explicitly disabled by a condition added with
r9-3032-gee7fb0588c6361b4d77337ab0f7527be64fcdde2 and removing that
condition seems to work, as demonstrated by the new testcase.

	PR fortran/41453
	PR fortran/87395

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Remove condition
	disabling clobber generation for dummy variables.  Remove
	obsolete comment.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_6.f90: New test.
2022-09-25 14:44:54 +02:00
Harald Anlauf
20aa1eb6cb fortran: Support clobbering with implicit interfaces [PR105012]
Before procedure calls, we clobber actual arguments whose associated
dummy is INTENT(OUT).  This only applies to procedures with explicit
interfaces, as the knowledge of the interface is necessary to know
whether an argument has the INTENT(OUT) attribute.

This change also enables clobber generation for procedure calls without
explicit interface, when the procedure has been defined in the same
file because we can use the dummy arguments' characteristics from the
procedure definition in that case.

The knowledge of the dummy characteristics is directly available through
gfc_actual_arglist’s associated_dummy pointers which have been populated
as a side effect of calling gfc_check_externals.

	PR fortran/105012

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Use dummy
	information from associated_dummy if there is no information
	from the procedure interface.

gcc/testsuite/ChangeLog:

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

Co-Authored-By: Mikael Morin <mikael@gcc.gnu.org>
2022-09-25 14:44:53 +02:00
Mikael Morin
29919bf3b6 fortran: Move clobbers after evaluation of all arguments [PR106817]
For actual arguments whose dummy is INTENT(OUT), we used to generate
clobbers on them at the same time we generated the argument reference
for the function call.  This was wrong if for an argument coming
later, the value expression was depending on the value of the just-
clobbered argument, and we passed an undefined value in that case.

With this change, clobbers are collected separatedly and appended
to the procedure call preliminary code after all the arguments have been
evaluated.

	PR fortran/106817

gcc/fortran/ChangeLog:

	* trans-expr.cc (gfc_conv_procedure_call): Collect all clobbers
	to their own separate block.  Append the block of clobbers to
	the procedure preliminary block after the argument evaluation
	codes for all the arguments.

gcc/testsuite/ChangeLog:

	* gfortran.dg/intent_optimize_4.f90: New test.
2022-09-25 14:44:53 +02:00