Commit graph

188477 commits

Author SHA1 Message Date
Andrew MacLeod
fe4e6c824a Look for a relation between operands only when possible.
Do not look for a relation between 2 operands if there is no range-ops handler.

	gcc/
	PR tree-optimization/102463
	* gimple-range-fold.cc (fold_using_range::relation_fold_and_or): If
	there is no range-ops handler, don't look for a relation.

	gcc/testsuite/
	* gcc.dg/pr102463.c: New.
2021-09-23 12:56:43 -04:00
Andrew MacLeod
053e1d6421 Create a ranger-local flag for non-executable edges.
Instead of repurposing EDGE_EXECUTABLE, ranger creates a local flag and
ultizes it throughout.

	* gimple-range-cache.cc (ranger_cache::ranger_cache): Take
	non-executable_edge flag as parameter.
	* gimple-range-cache.h (ranger_cache): Adjust prototype.
	* gimple-range-gori.cc (gori_compute::gori_compute): Take
	non-executable_edge flag as parameter.
	(gori_compute::outgoing_edge_range_p): Check new flag.
	* gimple-range-gori.h (gori_compute): Adjust prototype.
	* gimple-range.cc (gimple_ranger::gimple_ranger): Create new flag.
	(gimple_ranger::range_on_edge): Check new flag.
	* gimple-range.h (gimple_ranger::non_executable_edge_flag): New.
	* gimple-ssa-evrp.c (rvrp_folder): Pass ranger flag to simplifer.
	(hybrid_folder::hybrid_folder): Set ranger non-executable flag value.
	(hybrid_folder::fold_stmt): Set flag value in the simplifer.
	* vr-values.c (simplify_using_ranges::set_and_propagate_unexecutable):
	Use not_executable flag if provided inmstead of EDGE_EXECUTABLE.
	(simplify_using_ranges::simplify_switch_using_ranges): Clear
	EDGE_EXECUTABLE like it originally did.
	(simplify_using_ranges::cleanup_edges_and_switches): Clear any
	NON_EXECUTABLE flags.
	(simplify_using_ranges::simplify_using_ranges): Adjust.
	* vr-values.h (class simplify_using_ranges): Adjust.
	(simplify_using_ranges::set_range_query): Add non-executable flag param.
2021-09-23 12:56:43 -04:00
Tobias Burnus
1b07d9dce6 Fortran: Handle allocated() with coindexed scalars [PR93834]
While for an allocatable 'array', 'array(:)' and 'array(:)[1]' are
not allocatable, it is believed that not only 'scalar' but also
'scalar[1]' is allocatable.  However, coarrays are collectively
established/allocated; thus, 'allocated(scalar[i])' is equivalent
to 'allocated(scalar)'. [At least when assuming that 'i' does not
refer to a failed image.]

2021-09-23  Harald Anlauf  <anlauf@gmx.de>
	    Tobias Burnus  <tobias@codesourcery.com>

	PR fortran/93834
gcc/fortran/ChangeLog:

	* trans-intrinsic.c (gfc_conv_allocated): Cleanup. Handle
	coindexed scalar coarrays.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/coarray_allocated.f90: New test.
2021-09-23 18:48:48 +02:00
Luís Ferreira
b3585c0836 libiberty: prevent null dereferencing on dlang_type
libiberty/
	* d-demangle.c (dlang_Type): Validate MANGLED is nonnull.

	* testsuite/d-demangle-expected: New test.
2021-09-23 11:54:00 -04:00
Luís Ferreira
5481040197 libiberty: prevent buffer overflow when decoding user input
libiberty/
	* d-demangle.c (dlang_symbol_backref): Ensure strlen of
	string is less than length computed by dlang_number.
2021-09-23 11:48:45 -04:00
Jonathan Wakely
43358e91bd libstdc++: Remove c++20-specific dg-error directives in test
I added extra dg-error directives for C++20 to match the extra errors
caused by some of the call stack being constexpr in C++20. Since Jason's
changes to reduce those errors, those dg-error lines no longer match.
This removes them again.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc:
	Remove dg-error lines for C++20-only errors.
2021-09-23 16:07:39 +01:00
Jonathan Wakely
8fa90926e0 libstdc++: Disable PCH for test that depends on a macro being defined
This test tries to ensure that <system_error> can be included after
defining _XOPEN_SOURCE=600, which doesn't test anything if that header
is already included via the <bits/stdc++.h> PCH before the macro
definition. Disable PCH so that it behaves as intended.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/19_diagnostics/headers/system_error/93151.cc:
	Disable PCH.
2021-09-23 16:07:39 +01:00
Jonathan Wakely
477897451e libstdc++: Make std::system_category() recognize Windows error codes
The std::system_category error category should be used for
system-specific error codes, which means on Windows it should be used
for Windows error codes.  Currently that category assumes that the error
numbers it deals with are errno numbers, which means that
ERROR_ACCESS_DENIED (which has value 0x5) gets treated as whichever
errno number happens to have that value (EIO on mingw32-w64).

This adds a mapping from known Windows error codes to generic errno
ones. This means we correctly treat ERROR_ACCESS_DENIED as corresponding
to EACCES.

Also make std::system_category().message(int) return the right message
for Windows errors, by using FormatMessage instead of strerror. The
output of FormatMessage includes ".\r\n" at the end, so we strip that
off to allow the message to be used in contexts where that would be
problematic.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* src/c++11/system_error.cc (system_error_category) [_WIN32]:
	Map Windows error codes to generic POSIX error numbers. Use
	FormatMessage instead of strerror.
	* testsuite/19_diagnostics/error_category/system_category.cc:
	Adjust for new behaviour on Windows.
2021-09-23 16:07:39 +01:00
Jonathan Wakely
dd396a321b libstdc++: Improvements to standard error category objects
This ensures that the objects returned by std::generic_category() and
std::system_category() are initialized before any code starts executing,
and are not destroyed at the end of the program. This means it is always
safe to access them, even during startup and termination. See LWG 2992
and P1195R0 for further discussion of this.

Additionally, make the types of those objects final, which might
potentially allow additional devirtualization opportunities. The types
are not visible to users, so there is no way they can derive from them,
so making them final has no semantic change.

Finally, add overrides for equivalent(int, const error_condition&) to
those types, to avoid the second virtual call that would be performed by
the base class definition of the function. Because we know what
default_error_condition(int) does for the derived type, we don't need to
make a virtual call.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* src/c++11/system_error.cc (generic_error_category): Define
	class and virtual functions as 'final'.
	(generic_error_category::equivalent(int, const error_condition&)):
	Override.
	(system_error_category): Define class and virtual functions as
	'final'.
	(system_error_category::equivalent(int, const error_condition&)):
	Override.
	(generic_category_instance, system_category_instance): Use
	constinit union to make the objects immortal.
2021-09-23 16:07:38 +01:00
Jonathan Wakely
ce01e2e64c libstdc++: std::system_category should know meaning of zero [PR102425]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102425
	* src/c++11/system_error.cc
	(system_error_category::default_error_condition): Add 0 to
	switch.
	* testsuite/19_diagnostics/error_category/102425.cc: New test.
2021-09-23 16:07:38 +01:00
Patrick Palka
f6a05b23cc c++: improve tree dump for templated decls
gcc/cp/ChangeLog:

	* ptree.c (cxx_print_decl): Dump the DECL_TEMPLATE_RESULT of
	a TEMPLATE_DECL.  Dump the DECL_TEMPLATE_INFO rather than just
	printing its pointer value.
2021-09-23 09:36:14 -04:00
Eric Botcazou
96783caedc [Ada] Fix obsolete comment mentioning girder discriminants
gcc/ada/

	* gcc-interface/decl.c (gnat_to_gnu_entity): Fix comment.
2021-09-23 13:06:17 +00:00
Richard Kenner
c20222ed49 [Ada] Add Subprogram_Body_Or_Type
gcc/ada/

	* gen_il-gen-gen_entities.adb (Subprogram_Body_Or_Type): Add.
	* gen_il-types.ads (Subprogram_Body_Or_Type): Likewise.
2021-09-23 13:06:17 +00:00
Richard Kenner
faa396c4ee [Ada] Add N_Has_Bounds and N_Is_Index
gcc/ada/

	* einfo-utils.adb (Next_Index): Verify input and output are
	N_Is_Index.
	* gen_il-gen-gen_nodes.adb (N_Has_Bounds, N_Is_Index): Add.
	* gen_il-types.ads (N_Has_Bounds, N_Is_Index): Likewise.
	* sem_ch3.adb (Array_Type_Declaration): Use Next, not
	Next_Index.
	* sem_ch12.adb (Formal_Dimensions): Likewise.
	* sem_util.adb (Is_Valid_Renaming): Likewise.
2021-09-23 13:06:16 +00:00
Eric Botcazou
ead89f5f14 [Ada] Adjust documentation of gnatsymbolize
gcc/ada/

	* doc/gnat_ugn/gnat_utility_programs.rst (gnatsymbolize):
	Document new --load option and -g1 as minimal compilation
	requirement.
2021-09-23 13:06:16 +00:00
Piotr Trojanek
f7d1b4a7e0 [Ada] Tune detection of internally generated positional aggregates
gcc/ada/

	* sem_aggr.adb (Resolve_Array_Aggregate): Only keep the bounds
	for internally generated attributes; otherwise, compute them
		anew.
2021-09-23 13:06:16 +00:00
Javier Miranda
abf3f4f309 [Ada] Wrappers of access-to-subprograms with pre/post conditions
gcc/ada/

	* sem_ch3.adb (Build_Access_Subprogram_Wrapper): Decorate the
	wrapper with attribute Is_Wrapper, and move its declaration to
	the freezing actions of its type declaration; done to facilitate
	identifying it at later stages to avoid handling it as a
	primitive operation of a tagged type; otherwise it may be
	handled as a dispatching operation and erroneously registered in
	a dispatch table.
	(Make_Index): Add missing decoration of field Parent.
	* sem_disp.adb (Check_Dispatching_Operation): Complete
	decoration of late-overriding dispatching primitives.
	(Is_Access_To_Subprogram_Wrapper): New subprogram.
	(Inherited_Subprograms): Prevent cascaded errors; adding missing
	support for private types.
	* sem_type.adb (Add_One_Interp): Add missing support for the
	first interpretation of a primitive of an inmediate ancestor
	interface.
	* sem_util.adb (Check_Result_And_Post_State_In_Pragma): Do not
	report missing reference in postcondition placed in internally
	built wrappers.
	* exp_disp.adb (Expand_Dispatching_Call): Adding assertion.
2021-09-23 13:06:15 +00:00
Ed Schonberg
fe43084ca3 [Ada] Ada2022: implementation of AI12-0212 : iterator specs in array aggregates
gcc/ada/

	* sem_aggr.adb (Resolve_Array_Aggregate): Check the validity of
	an array aggregate all of whose components are iterated
	component associations.
	* exp_aggr.adb (Expand_Array_Aggregate,
	Two_Pass_Aggregate_Expansion): implement two-pass algorithm and
	replace original aggregate with resulting temporary, to ensure
	that a proper length check is performed if context is
	constrained. Use attributes Pos and Val to handle index types of
	any discrete type.
2021-09-23 13:06:15 +00:00
Bob Duff
c06539752d [Ada] Follow-on efficiency improvements
gcc/ada/

	* gen_il-gen.adb: Set the number of concrete nodes that have the
	Homonym field to a higher number than any other field. This
	isn't true, but it forces Homonym's offset to be chosen first,
	so it will be at offset zero and hence slot zero.
2021-09-23 13:06:14 +00:00
Richard Kenner
fb3f21a3df [Ada] If unnesting and relocating subprogram call, make new Parameter_Associations
gcc/ada/

	* atree.adb (Relocate_Node): If relocating a subprgram call and
	we're doing unnesting, make a new Parameter_Associations, if
	any.
2021-09-23 13:06:14 +00:00
Piotr Trojanek
e2b2f629da [Ada] Remove Initializes contracts from Ada.Strings.Bounded
gcc/ada/

	* libgnat/a-strbou.ads (Generic_Bounded_Length): Remove explicit
	Initializes contract.
2021-09-23 13:06:14 +00:00
Bob Duff
99e30ba8c0 [Ada] Cleanup and efficiency improvements
gcc/ada/

	* gen_il-gen.adb: Generate getters and setters with much of the
	code inlined. Generate code for storing a few fields in the node
	header, to avoid the extra level of indirection for those
	fields. We generate the header type, so we don't have to
	duplicate hand-written Ada and C code to depend on the number of
	header fields.  Declare constants for slot size. Use short names
	because these are used all over.  Remove
	Put_Low_Level_Accessor_Instantiations, Put_Low_Level_C_Getter,
	which are no longer needed.  Rename
	Put_High_Level_C_Getter-->Put_C_Getter.
	* atree.ads, atree.adb: Take into account the header slots.
	Take into account the single Node_Or_Entity_Field type.  Remove
	"pragma Assertion_Policy (Ignore);", because the routines in
	this package are no longer efficiency critical.
	* atree.h: Remove low-level getters, which are no longer used by
	sinfo.h and einfo.h.
	* einfo-utils.adb: Avoid crash in Known_Alignment.
	* live.adb, sem_eval.adb: Remove code that prevents Node_Id from
	having a predicate.  We don't actually add a predicate to
	Node_Id, but we want to be able to for temporary debugging.
	* sinfo-utils.adb: Remove code that prevents Node_Id from having
	a predicate.  Take into account the single Node_Or_Entity_Field
	type.
	* sinfo-utils.ads: Minor.
	* table.ads (Table_Type): Make the components aliased, because
	low-level setters in Atree need to take 'Access.
	* treepr.adb: Take into account the single Node_Or_Entity_Field
	type.  Make some code more robust, so we can print out
	half-baked nodes.
	* types.ads: Move types here for visibility purposes.
	* gcc-interface/gigi.h, gcc-interface/trans.c: Take into account
	the Node_Header change in the GNAT front end.
	* gcc-interface/cuintp.c, gcc-interface/targtyps.c: Add because
	gigi.h now refers to type Node_Header, which is in sinfo.h.
2021-09-23 13:06:14 +00:00
Yannick Moy
7165704bfa [Ada] Minimize parts of Ada.Strings.Fixed marked SPARK_Mode => Off
gcc/ada/

	* libgnat/a-strfix.adb (Delete, Insert, Overwrite,
	Replace_Slice): Remove SPARK_Mode Off.
	* libgnat/a-strfix.ads (Insert, Overwrite, Replace_Slice):
	Strengthen precondition.
2021-09-23 13:06:13 +00:00
Piotr Trojanek
37a3df0d9a [Ada] Remove global parameter in Global contracts of Ada.Strings.Bounded
gcc/ada/

	* libgnat/a-strbou.ads (Generic_Bounded_Length): Remove non-null
	Global contracts.
2021-09-23 13:06:13 +00:00
Steve Baird
62e66ee5bf [Ada] Update "Implementation Defined Characteristics" documentation.
gcc/ada/

	* doc/gnat_rm/implementation_defined_characteristics.rst: Update
	this section to reflect the current version of Ada RM M.2.
	* gnat_rm.texi: Regenerate.
2021-09-23 13:06:13 +00:00
Bill Schmidt
16e3d6b8b2 rs6000: Add psabi diagnostic for C++ zero-width bit field ABI change
Previously zero-width bit fields were removed from structs, so that otherwise
homogeneous aggregates were treated as such and	passed in FPRs and VSRs.
This was incorrect behavior per	the ELFv2 ABI.	Now that these fields are no
longer being removed, we generate the correct parameter	passing	code.  Alert
the unwary user	in the rare cases where	this behavior changes.

2021-09-23  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	PR target/102024
	* config/rs6000/rs6000-call.c (rs6000_aggregate_candidate): Detect
	zero-width bit fields and return indicator.
	(rs6000_discover_homogeneous_aggregate): Diagnose when the
	presence of a zero-width bit field changes parameter passing in
	GCC 12.

gcc/testsuite/
	PR target/102024
	* g++.target/powerpc/pr102024.C: New.
2021-09-23 07:40:34 -05:00
Aldy Hernandez
0044691620 Remove dominator check in fold_using_range::range_of_phi.
Revert the following patch, as it was an artifact of diagnostic code
being run with improper IL.

commit 64b80b8819
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Sep 21 08:28:28 2021 +0200

    Do not query SCEV in range_of_phi unless dominators are available.

    SCEV won't work without dominators and we can get called without
    dominators from debug_ranger.

gcc/ChangeLog:

	* gimple-range-fold.cc (fold_using_range::range_of_phi):
	Remove dominator check.
2021-09-23 13:08:27 +02:00
Aldy Hernandez
f3d357bab3 Hoist edge calculations in precompute_relations.
Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-path.cc (path_range_query::precompute_relations):
	Hoist edge calculations before using EDGE_SUCC.
2021-09-23 13:08:27 +02:00
Jonathan Wakely
d917742fe2 configure: Update --help output for --with-multilib-list
The list of architectures that support the option is incomplete.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jim Wilson <jimw@sifive.com>

gcc/ChangeLog:

	* configure.ac: Fix --with-multilib-list description.
	* configure: Regenerate.
2021-09-23 11:30:27 +01:00
Richard Biener
c0cc62b32d tree-optimization/102448 - clear copied alignment info from vect
This fixes the previous change which removed setting alignment info
from the vectorizers idea of how a pointer is being used but left
in place the copied info from DR_PTR_INFO without realizing that this
is in fact _not_ the alignment of the access but the alignment of
a base pointer contained in it.

The following makes sure to not use that info.

2021-09-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/102448
	* tree-vect-data-refs.c (vect_duplicate_ssa_name_ptr_info):
	Clear alignment info copied from DR_PTR_INFO.
2021-09-23 11:17:33 +02:00
Hongyu Wang
9ce500289a AVX512FP16: Enable vec_cmpmn/vcondmn expanders for HF modes.
gcc/ChangeLog:

	* config/i386/i386-expand.c (ix86_use_mask_cmp_p): Enable
	HFmode mask_cmp.
	* config/i386/sse.md (sseintvecmodelower): Add HF vector modes.
	(<avx512>_store<mode>_mask): Extend to support HF vector modes.
	(vec_cmp<mode><avx512fmaskmodelower>): Likewise.
	(vcond_mask_<mode><avx512fmaskmodelower>): Likewise.
	(vcond<mode><mode>): New expander.
	(vcond<mode><sseintvecmodelower>): Likewise.
	(vcond<sseintvecmodelower><mode>): Likewise.
	(vcondu<mode><sseintvecmodelower>): Likewise.

gcc/testsuite/ChangeLog:

	* g++.target/i386/avx512fp16-vcondmn-vec.C: New test.
	* g++.target/i386/avx512fp16-vcondmn-minmax.C: Ditto.
	* gcc.target/i386/avx512fp16-vcondmn-loop-1.c: Ditto.
	* gcc.target/i386/avx512fp16-vcondmn-loop-2.c: Ditto.
	* gcc.target/i386/avx512fp16-vec_cmpmn.c: Ditto.
2021-09-23 17:05:02 +08:00
Hongyu Wang
3829793c50 AVX512FP16: add truncmn2/extendmn2 expanders
gcc/ChangeLog:

	* config/i386/sse.md (extend<ssePHmodelower><mode>2):
	New expander.
	(extendv4hf<mode>2): Likewise.
	(extendv2hfv2df2): Likewise.
	(trunc<mode><ssePHmodelower>2): Likewise.
	(avx512fp16_vcvt<castmode>2ph_<mode>): Rename to ...
	(trunc<mode>v4hf2): ... this, and drop constraints.
	(avx512fp16_vcvtpd2ph_v2df): Rename to ...
	(truncv2dfv2hf2): ... this, and likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-trunc-extendvnhf.c: New test.
2021-09-23 17:05:02 +08:00
Hongyu Wang
25faed6f37 AVX512FP16: Add float(uns)?mn2 expander
gcc/ChangeLog:

	* config/i386/sse.md (float<floatunssuffix><mode><ssePHmodelower>2):
	New expander.
	(avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode>):
	Rename to ...
	(float<floatunssuffix><mode>v4hf2): ... this, and drop constraints.
	(avx512fp16_vcvt<floatsuffix>qq2ph_v2di): Rename to ...
	(float<floatunssuffix>v2div2hf2): ... this, and likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-floatvnhf.c: New test.
2021-09-23 17:05:02 +08:00
Hongyu Wang
60698a19c7 AVX512FP16: Add fix(uns)?_truncmn2 for HF scalar and vector modes
NB: 64bit/32bit vectorize for HFmode is not supported for now, will
adjust this patch when V2HF/V4HF operations supported.

gcc/ChangeLog:

	* config/i386/i386.md (fix<fixunssuffix>_trunchf<mode>2): New expander.
	(fixuns_trunchfhi2): Likewise.
	(*fixuns_trunchfsi2zext): New define_insn.
	* config/i386/sse.md (ssePHmodelower): New mode_attr.
	(fix<fixunssuffix>_trunc<ssePHmodelower><mode>2):
	New expander for same element vector fix_truncate.
	(fix<fixunssuffix>_trunc<ssePHmodelower><mode>2):
	Likewise for V4HF to V4SI/V4DI fix_truncate.
	(fix<fixunssuffix>_truncv2hfv2di2):
	Likeise for V2HF to V2DI fix_truncate.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-trunchf.c: New test.
	* gcc.target/i386/avx512fp16-truncvnhf.c: Ditto.
2021-09-23 17:05:02 +08:00
Hongyu Wang
fccd8855ed AVX512FP16: Add expander for smin/maxhf3.
gcc/ChangeLog:

	* config/i386/i386.md (<code>hf3): New expander.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-builtin-minmax-1.c: New test.
2021-09-23 17:05:02 +08:00
liuhongt
1041111f19 AVX512FP16: Add expander for fmahf4
gcc/ChangeLog:

	* config/i386/sse.md (FMAMODEM): extend to handle FP16.
	(VFH_SF_AVX512VL): Extend to handle HFmode.
	(VF_SF_AVX512VL): Deleted.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-fma-1.c: New test.
	* gcc.target/i386/avx512fp16vl-fma-1.c: New test.
	* gcc.target/i386/avx512fp16vl-fma-vectorize-1.c: New test.
2021-09-23 17:05:02 +08:00
liuhongt
cb8d916eef AVX512FP16: Add expander for rint/nearbyinthf2.
gcc/ChangeLog:

	* config/i386/i386.md (rinthf2): New expander.
	(nearbyinthf2): New expander.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-builtin-round-1.c: Add new testcase.
2021-09-23 17:05:01 +08:00
Jakub Jelinek
0d39eb28fd 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.
2021-09-23 10:10:58 +02:00
Aldy Hernandez
4c0c43623e Overhaul jump thread state in forward threader.
I've been pulling state from across the forward jump threader into the
jt_state class, but it it still didn't feel right.  The ultimate goal
was to keep track of candidate threading paths so that the simplifier
could simplify statements with the path as context.  This patch completes
the transition, while cleaning up a lot of things in the process.

I've revamped both state and the simplifier such that a base state class
contains only the blocks as they're registered, and any pass specific
knowledge is where it belongs... in the pass.  This allows VRP to keep
its const and copies business, and DOM to keep this as well as its evrp
client.  This makes the threader cleaner, as it will now have no knowledge
of either const/copies or evrp.

This also paves the wave for the upcoming hybrid threader, which will
just derive the state class and provide almost nothing, since the ranger
doesn't need to register any equivalences or ranges as it folds.

There is some code duplication in the simplifier, since both the DOM and
VRP clients use a vr_values based simplifier, but this is temporary as
the VRP client is about to be replaced with a hybrid ranger.

For a better view of what this patch achieves, here are the base
classes:

class jt_state
{
public:
  virtual ~jt_state () { }
  virtual void push (edge);
  virtual void pop ();
  virtual void register_equiv (tree dest, tree src, bool update_range =
false);
  virtual void register_equivs_edge (edge e);
  virtual void register_equivs_stmt (gimple *, basic_block,
				     class jt_simplifier *);
  virtual void record_ranges_from_stmt (gimple *stmt, bool temporary);
  void get_path (vec<basic_block> &);
  void append_path (basic_block);
  void dump (FILE *);
  void debug ();
private:
  auto_vec<basic_block> m_blocks;
};

class jt_simplifier
{
public:
  virtual ~jt_simplifier () { }
  virtual tree simplify (gimple *, gimple *, basic_block, jt_state *) =
0;
};

There are no functional changes.

gcc/ChangeLog:

	* tree-ssa-dom.c (class dom_jump_threader_simplifier): Rename...
	(class dom_jt_state): ...this and provide virtual overrides.
	(dom_jt_state::register_equiv): New.
	(class dom_jt_simplifier): Rename from
	dom_jump_threader_simplifier.
	(dom_jump_threader_simplifier::simplify): Rename...
	(dom_jt_simplifier::simplify): ...to this.
	(pass_dominator::execute): Use dom_jt_simplifier and
	dom_jt_state.
	* tree-ssa-threadedge.c (jump_threader::jump_threader):
	Clean-up.
	(jt_state::register_equivs_stmt): Abstract out...
	(jump_threader::record_temporary_equivalences_from_stmts_at_dest):
	...from here.
	(jump_threader::thread_around_empty_blocks): Update state.
	(jump_threader::thread_through_normal_block): Same.
	(jt_state::jt_state): Remove.
	(jt_state::push): Remove pass specific bits.  Keep block vector
	updated.
	(jt_state::append_path): New.
	(jt_state::pop): Remove pass specific bits.
	(jt_state::register_equiv): Same.
	(jt_state::record_ranges_from_stmt): Same.
	(jt_state::register_equivs_on_edge): Same.  Rename...
	(jt_state::register_equivs_edge):  ...to this.
	(jt_state::dump): New.
	(jt_state::debug): New.
	(jump_threader_simplifier::simplify): Remove.
	(jt_state::get_path): New.
	* tree-ssa-threadedge.h (class jt_simplifier): Make into a base
	class.  Expose common functionality as virtual methods.
	(class jump_threader_simplifier): Same.  Rename...
	(class jt_simplifier): ...to this.
	* tree-vrp.c (class vrp_jump_threader_simplifier): Rename...
	(class vrp_jt_simplifier): ...to this. Provide pass specific
	overrides.
	(class vrp_jt_state): New.
	(vrp_jump_threader_simplifier::simplify): Rename...
	(vrp_jt_simplifier::simplify): ...to this.  Inline code from
	what used to be the base class.
	(vrp_jump_threader::vrp_jump_threader): Use vrp_jt_state and
	vrp_jt_simplifier.
2021-09-23 08:05:48 +02:00
GCC Administrator
e4777439fc Daily bump. 2021-09-23 00:16:29 +00:00
Sandra Loosemore
5098e7077b 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.
2021-09-22 17:11:08 -07:00
Sandra Loosemore
7a40f2e748 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.
2021-09-22 17:10:57 -07:00
Sandra Loosemore
8fa9e73e6d 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.
2021-09-22 17:09:29 -07:00
Tobias Burnus
83aac69883 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.
2021-09-22 20:58:35 +02:00
Roger Sayle
8f571e6471 More NEGATE_EXPR folding in match.pd
As observed by Jakub in comment #2 of PR 98865, the expression -(a>>63)
is optimized in GENERIC but not in GIMPLE.  Investigating further it
turns out that this is one of a few transformations performed by
fold_negate_expr in fold-const.c that aren't yet performed by match.pd.
This patch moves/duplicates them there, and should be relatively safe
as these transformations are already performed by the compiler, but
just in different passes.

This revised patch adds a Boolean simplify argument to tree-ssa-sccvn.c's
vn_nary_build_or_lookup_1 to control whether simplification should be
performed before value numbering, updating the callers, but then
avoiding simplification when constructing/value-numbering NEGATE_EXPR.
This avoids the regression of gcc.dg/tree-ssa/ssa-free-88.c, and enables
the new test case(s) to pass.

2021-09-22  Roger Sayle  <roger@nextmovesoftware.com>
	    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
	* match.pd (negation simplifications): Implement some negation
	folding transformations from fold-const.c's fold_negate_expr.
	* tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Add a SIMPLIFY
	argument, to control whether the op should be simplified prior
	to looking up/assigning a value number.
	(vn_nary_build_or_lookup): Update call to vn_nary_build_or_lookup_1.
	(vn_nary_simplify): Likewise.
	(visit_nary_op): Likewise, but when constructing a NEGATE_EXPR
	now call vn_nary_build_or_lookup_1 disabling simplification.

gcc/testsuite/ChangeLog
	* gcc.dg/fold-negate-1.c: New test case.
2021-09-22 19:17:49 +01:00
H.J. Lu
2f2dcbe471 x86: Clean up gcc.target/i386/auto-init-* tests
1. Replace ia32 with { ! lp64 } to enable ILP32 tests for -mx32.
2. Replace lp64 with { ! ia32 } to enable x86-64 ISA tests for -mx32.
3. For auto-init-3.c, add -msse and -mfpmath=387 for ia32.

	* gcc.target/i386/auto-init-2.c: Replace ia32 with { ! lp64 }.
	* gcc.target/i386/auto-init-3.c (dg-options): Add -msse.
	(dg-additional-options): Add -mfpmath=387 for ia32.
	Replace lp64 with { ! ia32 }. Add a space after ia32.
	* gcc.target/i386/auto-init-4.c: Replace lp64 with { ! ia32 }.
	* gcc.target/i386/auto-init-5.c: Likewise.
	* gcc.target/i386/auto-init-padding-3.c: Likewise.
	* gcc.target/i386/auto-init-padding-7.c: Likewise.
	* gcc.target/i386/auto-init-padding-8.c: Likewise.
	* gcc.target/i386/auto-init-padding-9.c: Likewise.
2021-09-22 10:00:02 -07:00
Patrick Palka
9329344a6d c++: concept-ids and value-dependence [PR102412]
The problem here is that uses_template_parms returns true for all
concept-ids (even those with non-dependent arguments), so when a concept-id
is used as a default template argument then during deduction the default
argument is considered dependent even after substituting into it, which
leads to deduction failure (from type_unification_real).

This patch fixes this by implementing the resolution of CWG 2446 which
says a concept-id is dependent only if its arguments are.

	DR 2446
	PR c++/102412

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_constant_expression)
	<case TEMPLATE_ID_EXPR>: Check value_dependent_expression_p
	instead of processing_template_decl.
	* pt.c (value_dependent_expression_p) <case TEMPLATE_ID_EXPR>:
	Return true only if any_dependent_template_arguments_p.
	(instantiation_dependent_r) <case CALL_EXPR>: Remove this case.
	<case TEMPLATE_ID_EXPR>: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-nondep2.C: New test.
	* g++.dg/cpp2a/concepts-nondep3.C: New test.
2021-09-22 11:16:53 -04:00
Yannick Moy
0988829edd [Ada] Simplify contract of Ada.Strings.Fixed.Trim for proof
gcc/ada/

	* libgnat/a-strfix.ads (Trim): Simplify contracts.
	* libgnat/a-strfix.adb (Trim): Remove white space.
2021-09-22 15:01:51 +00:00
Piotr Trojanek
dfe93fd5f5 [Ada] Reuse routines for detecting attributes Old and Result
gcc/ada/

	* exp_ch4.adb (Expand_N_Op_Eq): Reuse Is_Attribute_Result.
	* exp_prag.adb (Expand_Attributes): Reuse Is_Attribute_Old.
2021-09-22 15:01:50 +00:00
Yannick Moy
03b6cc3b3e [Ada] Spurious error on deferred constant with predicate
gcc/ada/

	* sem_ch3.adb (Analyze_Object_Declaration): Do not insert a
	predicate check after a deferred constant declaration.
2021-09-22 15:01:50 +00:00