platform/upstream/gcc.git
2 years ago[Ada] Fix for internal error on semi-circular record aggregate
Eric Botcazou [Thu, 10 Feb 2022 11:37:56 +0000 (12:37 +0100)]
[Ada] Fix for internal error on semi-circular record aggregate

This creates a couple of record subtypes pointing to each other through
access subtypes, and we break the circularity at the latter subtypes.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: If
it is a special subtype designated by an access subtype, then defer
the completion of incomplete types.

2 years ago[Ada] Adjust copyright line
Eric Botcazou [Tue, 8 Feb 2022 20:18:58 +0000 (21:18 +0100)]
[Ada] Adjust copyright line

gcc/ada/

* gcc-interface/ada-tree.h, gcc-interface/ada.h,
gcc-interface/gadaint.h, gcc-interface/targtyps.cc: Adjust
copyright line.

2 years ago[Ada] Preserve unchecked conversion of string constant
Eric Botcazou [Sun, 16 Jan 2022 13:09:20 +0000 (14:09 +0100)]
[Ada] Preserve unchecked conversion of string constant

This makes it possible to pass the result to a C function directly.

gcc/ada/

* gcc-interface/utils.cc (unchecked_convert): Do not fold a string
constant if the target type is pointer to character.

2 years ago[Ada] Remove redundant marking of illegal pragma with error posted
Piotr Trojanek [Sat, 16 Apr 2022 12:38:54 +0000 (14:38 +0200)]
[Ada] Remove redundant marking of illegal pragma with error posted

We flag illegal pragma Elaborate with a call to Error_Msg on the pragma
argument, which in turn calls Set_Error_Posted on the enclosing
statement, i.e. on the pragma itself. The explicit call to
Set_Error_Posted on the pragma itself was redundant.

Cleanup related to handling of illegal code when detecting uninitialized
scalar objects.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Remove redundant call to
Set_Error_Posted.

2 years ago[Ada] Fix continuation message without a prior error
Piotr Trojanek [Fri, 15 Apr 2022 08:44:37 +0000 (10:44 +0200)]
[Ada] Fix continuation message without a prior error

When resolution of an expanded name fails, we call routine
Error_Missing_With_Of_Known_Unit which emits an error continuation
message (i.e. an error string starting with \\). However, for error
continuations to work properly there must be some prior error, because
continuation itself doesn't set flags like Serious_Errors_Detected.

Without these flags the problematic statement is not marked with
Error_Posted, which in turn is needed to prevent cascaded errors.

In particular, when unresolved procedure call uses a direct name or an
extended name with an unknown prefix, e.g.:

  Unknown (1, 2, 3);
  Unknown.Call (1, 2, 3);

then the N_Procedure_Call statements are marked with Error_Posted. But
when a call uses an extended name with a known prefix we failed to flag
the N_Procedure_Call with Error_Posted.

Found while improving the robustness of a feature that detects
uninitialized scalar objects.

gcc/ada/

* sem_ch8.adb (Find_Expanded_Name): Emit a main error message
before adding a continuation with the call to
Error_Missing_With_Of_Known_Unit.

2 years ago[Ada] Mark Requires_Transient_Scope as Inline
Eric Botcazou [Fri, 15 Apr 2022 06:48:30 +0000 (08:48 +0200)]
[Ada] Mark Requires_Transient_Scope as Inline

The predicate is now a simple disjunction of two other predicates.

gcc/ada/

* sem_util.ads (Requires_Transient_Scope): Add pragma Inline.

2 years ago[Ada] Avoid internal compiler error for illegal Predicate_Failure aspect spec
Steve Baird [Thu, 14 Apr 2022 20:24:15 +0000 (13:24 -0700)]
[Ada] Avoid internal compiler error for illegal Predicate_Failure aspect spec

gcc/ada/

* sem_ch13.adb (Build_Predicate_Functions): If a semantic error
has been detected then ignore Predicate_Failure aspect
specifications in the same way as is done for CodePeer and
SPARK. This avoids an internal compiler error if
Ancestor_Predicate_Function_Called is True but Result_Expr is
not an N_And_Then node (and is therefore unsuitable as an
argument in a call to Left_Opnd).

2 years ago[Ada] Fix spurious violations of No_Secondary_Stack restriction
Eric Botcazou [Thu, 14 Apr 2022 15:31:44 +0000 (17:31 +0200)]
[Ada] Fix spurious violations of No_Secondary_Stack restriction

Now that finalization and return on the secondary stack are decoupled, the
transient scopes created because of the former need not necessarily manage
the secondary stack and trigger a violation of the associated restriction.

gcc/ada/

* exp_ch7.adb (Wrap_Transient_Declaration): Propagate Uses_Sec_Stack
to enclosing function if it does not return on the secondary stack.
* exp_ch6.adb (Expand_Call_Helper): Call Establish_Transient_Scope
with Manage_Sec_Stack set to True only when necessary.
* sem_res.adb (Resolve_Call): Likewise.
(Resolve_Entry_Call): Likewise.

2 years ago[Ada] Ignore Predicate_Failure in CodePeer mode
Daniel Mercier [Thu, 14 Apr 2022 15:36:17 +0000 (17:36 +0200)]
[Ada] Ignore Predicate_Failure in CodePeer mode

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function): Ignore predicate
failure in CodePeer mode.

2 years ago[Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows
Arnaud Charlet [Thu, 14 Apr 2022 11:13:39 +0000 (11:13 +0000)]
[Ada] Fix compilation of raise-gcc.c with -DSTANDALONE under windows

This is needed in particular by GNAT LLVM builds.

gcc/ada/

* raise-gcc.c: Fix compilation with -DSTANDALONE under windows.

2 years ago[Ada] Preserve and reuse original type in Narrow_Large_Operation
Eric Botcazou [Thu, 14 Apr 2022 11:08:38 +0000 (13:08 +0200)]
[Ada] Preserve and reuse original type in Narrow_Large_Operation

Instead of using that of Original_Node (N) after rewriting, which does not
work if N had previously been rewritten.

gcc/ada/

* exp_ch4.adb (Narrow_Large_Operation): Preserve and reuse Etype.

2 years ago[Ada] Wrong interface dynamic dispatch via access parameter
Javier Miranda [Wed, 13 Apr 2022 16:27:59 +0000 (16:27 +0000)]
[Ada] Wrong interface dynamic dispatch via access parameter

When the prefix of an Access attribute is an explicit dereference of an
access parameter (or a renaming of such a dereference, or a subcomponent
of such a dereference), the context is a general access type to a
class-wide interface type, and an accessibility check must be generated,
the frontend silently skips generating an implicit type conversion to
force the displacement of the pointer to reference the secondary
dispatch table.

gcc/ada/

* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): New
subprogram which factorizes code.
(Expand_N_Attribute_Reference): Call the new subprogram to add
the missing implicit interface type conversion.

2 years ago[Ada] Ignore Predicate_Failure in GNATprove mode
Piotr Trojanek [Wed, 13 Apr 2022 19:39:38 +0000 (21:39 +0200)]
[Ada] Ignore Predicate_Failure in GNATprove mode

In GNATprove mode we are don't want predicate failure to pollute the
predicate expression extracted from the predicate function.

gcc/ada/

* sem_ch13.adb (Build_Predicate_Function): Ignore predicate
failure in GNATprove mode.

2 years ago[Ada] Fix bug in handling of Predicate_Failure aspect
Steve Baird [Tue, 5 Apr 2022 00:52:11 +0000 (17:52 -0700)]
[Ada] Fix bug in handling of Predicate_Failure aspect

The run-time behavior of the Ada 2022 Predicate_Failure aspect was
incorrectly implemented. This could cause incorrect exception messages
at execution time in the case of a predicate check failure, as
demonstrated by ACATS test C324006. In addition, a new attribute
(Predicate_Expression) is defined in order to improve the FE/SPARK
interface.

gcc/ada/

* einfo-utils.ads, einfo-utils.adb: Delete Predicate_Function_M
function and Set_Predicate_Function_M procedure.
* einfo.ads: Delete comments for Is_Predicate_Function_M and
Predicate_Function_M functions. Add comment for new
Predicate_Expression function. Update comment describing
predicate functions.
* exp_util.ads, exp_util.adb (Make_Predicate_Call): Replace Mem
formal parameter with Static_Mem and Dynamic_Mem formals.
(Make_Predicate_Check): Delete Add_Failure_Expression and call
to it.
* exp_ch4.adb (Expand_N_In.Predicate_Check): Update
Make_Predicate_Call call to match profile change.
* gen_il-fields.ads: Delete Is_Predicate_Function_M field, add
Predicate_Expression field.
* gen_il-gen-gen_entities.adb: Delete Is_Predicate_Function_M
use, add Predicate_Expression use.
* sem_ch13.adb (Build_Predicate_Functions): Rename as singular,
not plural; we no longer build a Predicate_M function. Delete
Predicate_M references. Add new Boolean parameter for predicate
functions when needed. Restructure body of generated predicate
functions to implement required Predicate_Failure behavior and
to set new Predicate_Expression attribute. Remove special
treatment of raise expressions within predicate expressions.
* sem_util.ads (Predicate_Failure_Expression,
Predicate_Function_Needs_Membership_Parameter): New functions.
* sem_util.adb (Is_Current_Instance): Fix bugs which caused
wrong result.
(Is_Current_Instance_Reference_In_Type_Aspect): Delete
Is_Predicate_Function_M reference.
(Predicate_Failure_Expression): New function.
(Propagate_Predicate_Attributes): Delete Is_Predicate_Function_M
references.

2 years ago[Ada] Avoid copy operation for returns involving function calls
Eric Botcazou [Tue, 12 Apr 2022 19:56:35 +0000 (21:56 +0200)]
[Ada] Avoid copy operation for returns involving function calls

The underlying issue is that the front-end does not create transient scopes
for return statements, so objects copied for these statements can never be
finalized properly.

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Adjust comment.
(Expand_Simple_Function_Return): For the case of a type which needs
finalization and is returned on the primary stack, do not create a
copy if the expression originates from a function call.
* exp_ch7.adb (Transient Scope Management): Adjust comment.
* exp_util.ads (Is_Related_To_Func_Return): Add WARNING line.
* fe.h (Is_Related_To_Func_Return): Declare.

2 years ago[Ada] Fix invalid expanded code for entry families
Piotr Trojanek [Tue, 12 Apr 2022 20:22:40 +0000 (22:22 +0200)]
[Ada] Fix invalid expanded code for entry families

Expansion of entry families created a slightly illegal AST with
Elsif_Parts being an empty list. Cleanup uncovered by the work on
detection of uninitialized scalars.

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove empty Elsif_Parts
from the constructed IF statement.

2 years ago[Ada] Cleanup expansion of protected entry families
Piotr Trojanek [Tue, 12 Apr 2022 19:46:36 +0000 (21:46 +0200)]
[Ada] Cleanup expansion of protected entry families

Expansion of entry families contained a condition that was always true.
Cleanup related to detection of uninitialized scalar objects (which
uncovered that expansion of entry families creates a slightly illegal
AST with Elsif_Parts being an empty list).

gcc/ada/

* exp_ch9.adb (Build_Find_Body_Index): Remove IF statement whose
condition was true-by-construction; remove excessive assertion
(since the call to Elsif_Parts will check that Nod is present
and it is an if-statement).

2 years ago[Ada] Remove remaining references to gnatfind/gnatxref
Arnaud Charlet [Tue, 12 Apr 2022 09:29:31 +0000 (09:29 +0000)]
[Ada] Remove remaining references to gnatfind/gnatxref

gcc/ada/

* gnat1drv.adb, gnatcmd.adb: Remove references to gnatfind/xref.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst,
doc/gnat_ugn/the_gnat_compilation_model.rst: Ditto.
* gnat_ugn.texi: Regenerate.
* gnatfind.adb, gnatxref.adb, xr_tabls.adb, xr_tabls.ads,
xref_lib.adb, xref_lib.ads: Removed, no longer used.

2 years ago[Ada] Fix proof of runtime unit a-strfix and a-strsup
Claire Dross [Tue, 12 Apr 2022 08:57:31 +0000 (10:57 +0200)]
[Ada] Fix proof of runtime unit a-strfix and a-strsup

Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

* libgnat/a-strfix.adb: Add assertions.
* libgnat/a-strsup.adb: Idem.

2 years ago[Ada] Support Ada 2022 null array aggregates
Ed Schonberg [Fri, 8 Apr 2022 17:48:10 +0000 (10:48 -0700)]
[Ada] Support Ada 2022 null array aggregates

Add support for Ada 2022's "[]" null array aggregates (thanks to Ed
Schonberg for producing most of this patch).

gcc/ada/

* erroutc.ads: Fix a single-character typo in a comment.
* exp_aggr.adb: Fix a single-character typo in a comment.
Replace several pairs of calls to Low_Bound and
High_Bound (which do not handle an identifier that denotes a
scalar subtype) with corresponding calls to Get_Index_Bounds
(which does handle that case).
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Set the
Component_Associations attribute of a null array aggregate to
New_List.
* sem_aggr.ads: New visible function
Is_Null_Array_Aggregate_High_Bound.
* sem_aggr.adb (Is_Null_Array_Aggregate_High_Bound,
Is_Null_Aggregate, Resolve_Null_Array_Aggregate): New functions.
(Resolve_Aggregate): Recognize null array aggregates (using
Is_Null_Aggregate) and, when one is recognized, resolve
it (using Resolve_Null_Array_Aggregate).  Avoid calling
Array_Aggr_Subtype for a null array aggregate; the needed
subtype is built in Resolve_Null_Array_Aggregate. Do not
incorrectly flag a null aggregate (after it is transformed by
expansion) as being both positional and named.
* sem_attr.adb (Eval_Attribute): Special treatment for null
array aggregate high bounds to avoid incorrectly flagging
something like Integer'Pred (Integer'First) as an illegal static
expression.
* sem_eval.adb (Out_Of_Range): Special treatment for null array
aggregate high bounds to avoid incorrectly flagging something
like Integer'Pred (Integer'First) as an illegal static
expression.

2 years ago[Ada] Further adapt proof of double arithmetic runtime unit
Yannick Moy [Mon, 11 Apr 2022 15:56:01 +0000 (15:56 +0000)]
[Ada] Further adapt proof of double arithmetic runtime unit

After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

* libgnat/s-aridou.adb (Lemma_Abs_Range,
Lemma_Double_Shift_Left, Lemma_Shift_Left): New lemmas.
(Double_Divide): Add ghost code.
(Lemma_Concat_Definition, Lemma_Double_Shift_Left,
Lemma_Shift_Left, Lemma_Shift_Right): Define or complete lemmas.
(Scaled_Divide): Add ghost code.

2 years ago[Ada] Improve optimization of "=" on bit-packed arrays
Bob Duff [Thu, 7 Apr 2022 17:23:20 +0000 (13:23 -0400)]
[Ada] Improve optimization of "=" on bit-packed arrays

This patch fixes a performance regression, introduced by a previous bug
fix.  That fix had the unintended side effect of removing the
optimization in cases where the two operands are of two different
compiler-generated modular types.

gcc/ada/

* exp_pakd.adb (Expand_Packed_Eq): Replace the check for *same*
modular type, with a check for any modular type, and assert that
the two types have the same modulus and so on.
* exp_pakd.ads: Minor comment improvements.

2 years ago[Ada] Casing style on record components
Bob Duff [Thu, 7 Apr 2022 14:59:32 +0000 (10:59 -0400)]
[Ada] Casing style on record components

This patch fixes a bug where the -gnatyr switch fails to detect
incorrect casing of record components.

gcc/ada/

* style.adb (Check_Identifier): Deal with the case where a
record component definition has been transformed; we want to
warn if the original came from source.
* libgnat/s-objrea.ads, libgnat/s-objrea.adb: Fix casing of MF
to be consistent.
* uname.adb: Fix casing of Chars to be consistent.
* sem_util.ads: Minor comment fix.

2 years ago[Ada] Get rid of secondary stack for controlled components
Eric Botcazou [Sat, 9 Apr 2022 22:47:48 +0000 (00:47 +0200)]
[Ada] Get rid of secondary stack for controlled components

This eliminates the use of the secondary stack to return composite types
with controlled components from functions, by exposing the return slot of
these functions through the support interface of memory pools, much like
for the secondary stack itself.  This is piggybacked on the support of a
specific intrinsic function by the code generator, and can be disabled if
this support is not available, as well with the -gnatd_r debug switch.

The change also streamlines a bit the implementation by consistently using
the Needs_Finalization predicate, or its derivatives, in various places.

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-retsta.
* debug.adb (d_r): Document usage.
* exp_ch4.adb (Expand_N_Allocato): Deal with the return stack pool.
* exp_ch6.adb (Expand_Simple_Function_Return): Replace calls to
Requires_Transient_Scope with Returns_On_Secondary_Stack.  Deal
with types that need finalization returned on the primary stack,
use CW_Or_Needs_Finalization for those returned on the secondary.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Return early
for the return stack pool.
(Remove_Side_Effects): Call CW_Or_Needs_Finalization.
* fe.h (Requires_Transient_Scope): Delete.
(Returns_On_Secondary_Stack): Declare.
* gnat1drv.adb (Adjust_Global_Switches): Set Back_End_Return_Slot
to False when generating C code or if -gnatd_r is specified.
* opt.ads (Back_End_Return_Slot): New boolean variable.
* rtsfind.ads (RTU_Id): Add System_Return_Stack.
(RE_Id): Add RE_RS_Allocate and RE_RS_Pool.
(RE_Unit_Table): Add entries for RE_RS_Allocate and RE_RS_Pool.
* sem_util.ads (CW_Or_Has_Controlled_Part): Delete.
(CW_Or_Needs_Finalization): Declare.
(Requires_Transient_Scope): Adjust description.
(Returns_On_Secondary_Stack): Declare.
* sem_util.adb (Compute_Returns_By_Ref): Set Returns_By_Ref on types
which need finalization if they are returned on the secondary stack.
(CW_Or_Has_Controlled_Part): Rename to...
(CW_Or_Needs_Finalization): ...this.
(Requires_Transient_Scope): Move bulk of implementation to...
(Returns_On_Secondary_Stack): ...here.  Return true for types which
need finalization only if the back-end return slot is not supported.
* libgnat/s-retsta.ads: New file.
* gcc-interface/ada-builtin-types.def (BT_FN_PTR_SSIZE): Define.
* gcc-interface/ada-builtins.def (return_slot): Likewise.
* gcc-interface/ada-tree.h (BUILT_IN_RETURN_SLOT): Likewise.
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Replace call to
Requires_Transient_Scope with Returns_On_Secondary_Stack.
* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return by invisible reference, skip the copy if the source
is the same as the destination.
* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Deal with
the return stack pool.

2 years ago[Ada] Small housekeeping work continued
Eric Botcazou [Sat, 2 Apr 2022 21:26:57 +0000 (23:26 +0200)]
[Ada] Small housekeeping work continued

No functional changes.

gcc/ada/

* gcc-interface/trans.cc: Fix formatting issues in comments.
(Subprogram_Body_to_gnu): Tidy up.
(Exception_Handler_to_gnu_gcc): Rename into...
(Exception_Handler_to_gnu): ...this.
(gnat_to_gnu) <N_Exception_Handler>: Adjust to above renaming.

2 years ago[Ada] Small housekeeping work
Eric Botcazou [Thu, 31 Mar 2022 20:38:54 +0000 (22:38 +0200)]
[Ada] Small housekeeping work

No functional changes.

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Rename a couple
of local variables and use Is_Generic_Subprogram predicate.
(process_decls): Likewise.

2 years ago[Ada] Do not override inlining heuristics for expression functions at -Os
Eric Botcazou [Thu, 27 Jan 2022 16:18:28 +0000 (17:18 +0100)]
[Ada] Do not override inlining heuristics for expression functions at -Os

gcc/ada/

* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Do not deal with
inlining heuristics for expression functions here but...
* gcc-interface/decl.cc (inline_status_for_subprog): ...here instead
and do not override them at -Os.

2 years ago[Ada] Remove dead code for scope entity having E_Subprogram_Body kind
Piotr Trojanek [Thu, 3 Feb 2022 14:11:26 +0000 (15:11 +0100)]
[Ada] Remove dead code for scope entity having E_Subprogram_Body kind

In GNAT AST the Scope field always points to the semantic scope (e.g.
subprogram) and never to syntactic scope (e.g. subprogram body).

Cleanup related to handling of circular access-to-record types.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity): Remove dead code
which expected Scope to return E_Subprogram_Body entity.

2 years agoPR105647 Update pr105169* so it does not fail on powerpc64le
Giuliano Belinassi [Wed, 18 May 2022 19:16:48 +0000 (16:16 -0300)]
PR105647 Update pr105169* so it does not fail on powerpc64le

On powerpc64le, the tests related to pr105169 failed because the
.localentry was not on a power of two address due to the extra nop
instruction taking one byte and thus moving its position one byte
further. Generating two nops instead moves .localentry to a valid
position.

gcc/testsuite/ChangeLog
2022-05-18  Giuliano Belinassi  <gbelinassi@suse.de>

PR target/105647
* g++.dg/modules/pr105169_a.C: Change -fpatchable-function-entry to 2.
* g++.dg/modules/pr105169_b.C: Likewise.

2 years agoanalyzer: update docs about -fanalyzer-checker=taint
David Malcolm [Thu, 19 May 2022 12:50:54 +0000 (08:50 -0400)]
analyzer: update docs about -fanalyzer-checker=taint

gcc/ChangeLog:
* doc/invoke.texi (-fanalyzer-checker=): Add
-Wanalyzer-va-list-leak and -Wanalyzer-va-list-use-after-va-end to
the list of analyzer warnings disabled by
-fanalyzer-checker=taint.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agocfgexpand: Yet another spot with debug insns references to global vars without varpoo...
Jakub Jelinek [Thu, 19 May 2022 09:58:15 +0000 (11:58 +0200)]
cfgexpand: Yet another spot with debug insns references to global vars without varpool nodes [PR105630]

This is similar to the earlier patch to avoid having MEM_EXPRs
referencing global vars without varpool nodes, but this time
the difference is that during gimplification some hashing
actually created DECL_RTLs for the n VAR_DECL and the previous
change was in the if above this when DECL_RTL is NULL and we are
considering creating it.

The following patch drops on the floor references to vars where
we've optimized away the varpool node even when it has DECL_RTL.

Bootstrapped/regtested on x86_64-linux and i686-linux, plus
bootstrapped on those without the cfgexpand.cc change, reapplied
it and rebuilt stage3 cc1/cc1plus, the resulting cc1/cc1plus
binaries on both targets were identical except for the 16-byte
executable_checksum (I've done the second bootstraps in the same
directory as the first one after moving the previous one elsewhere,
so pathnames were the same, just checksum hasn't been regenerated).
So, at least on those binaries this patch doesn't affect debug info
at all.

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

PR debug/105630
* cfgexpand.cc (expand_debug_expr): For VAR_DECL, punt for
global vars without symtab node even when they have DECL_RTL
set.

* gcc.dg/pr105630.c: New test.

2 years agopointer-query: Fix ICE with non-pointer param [PR105635]
Jakub Jelinek [Thu, 19 May 2022 09:56:21 +0000 (11:56 +0200)]
pointer-query: Fix ICE with non-pointer param [PR105635]

The gimple_parm_array_size function comment talks about pointe parameters
but doesn't actually verify it, it checks whether an attribute is present
on the function and then just uses TREE_TYPE (TREE_TYPE (var)) which
assumes a pointer type (or in theory could work for ARRAY_TYPE but
c-family languages which only have that attribute will never have ARRAY_TYPE
parameters; and for VECTOR_TYPE/COMPLEX_TYPE it would mean something quite
different).

So, this patch punts early if var doesn't have pointer/reference type.

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

PR c/105635
* pointer-query.cc (gimple_parm_array_size): Return NULL if var
doesn't have pointer or reference type.

* gcc.dg/pr105635.c: New test.

2 years agocompiler: traverse expressions when exporting constants
Julia Lapenko [Mon, 16 May 2022 07:37:49 +0000 (10:37 +0300)]
compiler: traverse expressions when exporting constants

When exporting a constant A that is expressed through a constant
B from another package, it is necessary to traverse an expression
representing the constant A to generate a sequence of type casts
from the constant B. Current implementation doesn't collect types
of constants contained in such expressions. This change fetches
these types.

Fixes golang/go#51291

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405976

2 years agoDaily bump.
GCC Administrator [Thu, 19 May 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.

2 years agoc: Implement new -Wenum-int-mismatch warning [PR105131]
Marek Polacek [Fri, 1 Apr 2022 20:55:58 +0000 (16:55 -0400)]
c: Implement new -Wenum-int-mismatch warning [PR105131]

In C, an enumerated type is compatible with char, a signed integer type,
or an unsigned integer type (6.7.2.2/5).  Therefore this code compiles:

  enum E { l = -1, z = 0, g = 1 };
  int foo(void);
  enum E foo(void) { return z; }

if the underlying type of 'enum E' is 'int' (if not, we emit an error).
This is different for typedefs, where C11 permits typedefs to be
redeclared to the same type, but not to compatible types.  In C++, the
code above is invalid.

It seems desirable to emit a warning in the C case, because it is
probably a mistake and definitely a portability error, given that the
choice of the underlying type is implementation-defined.

To that end, this patch implements a new -Wenum-int-mismatch warning.
Conveniently, we already have comptypes_check_enum_int to detect such
mismatches.  This warning is enabled by either -Wall or -Wc++-compat.

PR c/105131

gcc/c-family/ChangeLog:

* c.opt (Wenum-int-mismatch): New.

gcc/c/ChangeLog:

* c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type
mismatches.
* c-tree.h (comptypes_check_enum_int): Declare.
* c-typeck.cc (comptypes): No longer static.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wenum-int-mismatch.

gcc/testsuite/ChangeLog:

* gcc.dg/Wenum-int-mismatch-1.c: New test.
* gcc.dg/Wenum-int-mismatch-2.c: New test.
* gcc.dg/Wenum-int-mismatch-3.c: New test.
* gcc.dg/Wenum-int-mismatch-4.c: New test.
* gcc.dg/Wenum-int-mismatch-5.c: New test.

2 years agoRevert move of g++.dg/pr69667.C
Paul A. Clarke [Wed, 18 May 2022 20:45:56 +0000 (15:45 -0500)]
Revert move of g++.dg/pr69667.C

Commit eccbd7fcee5bbfc47731e8de83c44eee2e3dcc4b moved the subject file to
g++.target/powerpc.  Unfortunately, test g++.dg/tsan/pr88018.C includes
"../pr69667.C".

Revert the move of this file.

Commit 14e678a2c4a76433fd4029568d28530c921e11ee relaxed some DejaGnu
directives in g++.dg/tsan/pr88018.C, given its more restrictive environment
within g++.target/powerpc.  Revert these changes in that file as well.

2022-05-18  Paul A. Clarke  <pc@us.ibm.com>

gcc/testsuite
PR target/105620
* g++.target/powerpc/pr69667.C: Move to ...
* g++.dg/pr69667.C: here. Also, revert recent dg directives changes.

2 years agox86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK
Uros Bizjak [Wed, 18 May 2022 18:03:26 +0000 (20:03 +0200)]
x86: Fix -fsplit-stack feature detection via  TARGET_CAN_SPLIT_STACK

Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack
is only supported on glibc targets. However, this original commit
required some fixups. As part of the fixup, the changes to the
gnu-user-common.h and gnu.h were partially reverted in commit
60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK
to be defined for non-glibc targets even though -fsplit-stack is
actually not supported and attempting to use it causes a runtime error.

This causes gcc internal code, such as ./gcc/go/gospec.c to not
correctly detect that -fsplit-stack is not supported and thus causes
gccgo to fail compilation on non-glibc targets.

This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the
default libc is glibc. It is presently unclear to me if there is a
better way to detect glibc at pre-processor time.

The proposed changes have been tested on x86 and x86_64 Alpine Linux
(which uses musl libc) and fix compilation of gccgo for this target.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
gcc/ChangeLog:

* config/i386/gnu-user-common.h (defined): Only define
TARGET_CAN_SPLIT_STACK for glibc targets.
* config/i386/gnu.h (defined): Ditto.

2 years agoCorrect ix86_rtx_cost for multi-word multiplication.
Roger Sayle [Wed, 18 May 2022 15:23:01 +0000 (16:23 +0100)]
Correct ix86_rtx_cost for multi-word multiplication.

This is the i386 backend specific piece of my revised patch for
PR middle-end/98865, where Richard Biener has suggested that I perform
the desired transformation during RTL expansion where the backend can
control whether it is profitable to convert a multiplication into a
bit-wise AND and a negation.  This works well for x86_64, but alas
exposes a latent bug with -m32, where a DImode multiplication incorrectly
appears to be cheaper than negdi2+anddi3(!?).  The fix to ix86_rtx_costs
is to report that a DImode (multi-word) multiplication actually requires
three SImode multiplications and two SImode additions.  This also corrects
the cost of TImode multiplication on TARGET_64BIT.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.cc (ix86_rtx_costs) [MULT]: When mode size
is wider than word_mode, a multiplication costs three word_mode
multiplications and two word_mode additions.

2 years agoAvoid andn and generate shorter not;and with -Oz on x86.
Roger Sayle [Wed, 18 May 2022 15:13:17 +0000 (16:13 +0100)]
Avoid andn and generate shorter not;and with -Oz on x86.

The x86 instruction encoding for SImode andn is longer than the
equivalent notl/andl sequence when the source for the not operand
is the same register as the destination.  This patch adds post_reload
splitters to i386.md to avoid "-mbmi" (which enables andn) increasing
code size with "-Oz".

One minor subtlety with this patch is that the splitter for
*andn_si_ccno swaps the order of operands (match_dup 2 and match_dup 3)
as memory operands need to appear first in *test<mode>_1 patterns.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.md (define_split):  Split *andsi_1
and *andn_si_ccno after reload with -Oz.

gcc/testsuite/ChangeLog
* gcc.target/i386/bmi-andn-3.c: New test case.

2 years agoc, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]
Marek Polacek [Sat, 7 May 2022 20:15:49 +0000 (16:15 -0400)]
c, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]

This PR complains that we emit the "enumeration value not handled in
switch" warning even though the enumerator was marked with the
[[maybe_unused]] attribute.

I couldn't just check TREE_USED, because the enumerator could have been
used earlier in the function, which doesn't play well with the
c_do_switch_warnings warning.  Instead, I had to check the attributes on
the CONST_DECL.  This is easy since the TYPE_VALUES of an enum type are
now consistent between C and C++, both of which store the CONST_DECL in
its TREE_VALUE.

PR c++/105497

gcc/c-family/ChangeLog:

* c-warn.cc (c_do_switch_warnings): Don't warn about unhandled
enumerator when it was marked with attribute unused.

gcc/testsuite/ChangeLog:

* c-c++-common/Wswitch-1.c: New test.
* g++.dg/warn/Wswitch-4.C: New test.

2 years agoc++: fix SIGFPE with -Wclass-memaccess [PR105634]
Marek Polacek [Tue, 17 May 2022 19:13:58 +0000 (15:13 -0400)]
c++: fix SIGFPE with -Wclass-memaccess [PR105634]

Here we crash because we attempt to % by 0.  Thus fixed.
While at it, I've moved the -Wclass-memaccess tests into warn/.
I've checked that the # of expected passes is the same before/after
the move.

PR c++/105634

gcc/cp/ChangeLog:

* call.cc (maybe_warn_class_memaccess): Avoid % by zero.

gcc/testsuite/ChangeLog:

* g++.dg/Wclass-memaccess-2.C: Moved to...
* g++.dg/warn/Wclass-memaccess-2.C: ...here.
* g++.dg/Wclass-memaccess-3.C: Moved to...
* g++.dg/warn/Wclass-memaccess-3.C: ...here.
* g++.dg/Wclass-memaccess-4.C: Moved to...
* g++.dg/warn/Wclass-memaccess-4.C: ...here.
* g++.dg/Wclass-memaccess-5.C: Moved to...
* g++.dg/warn/Wclass-memaccess-5.C: ...here.
* g++.dg/Wclass-memaccess-6.C: Moved to...
* g++.dg/warn/Wclass-memaccess-6.C: ...here.
* g++.dg/Wclass-memaccess.C: Moved to...
* g++.dg/warn/Wclass-memaccess.C: ...here.
* g++.dg/warn/Wclass-memaccess-7.C: New test.

2 years agoReduce usage of limited_with clauses with -fdump-ada-spec
Eric Botcazou [Wed, 18 May 2022 14:27:55 +0000 (16:27 +0200)]
Reduce usage of limited_with clauses with -fdump-ada-spec

The problem is that subtypes are not part of the limited view of a package
so we need to use types in conjunction with limited_with clauses, which is
not always desirable as this yields less portable Ada bindings.  The patch
also contains a small enhancement for complex floating-point types.

gcc/c-family/
* c-ada-spec.cc (dump_ada_node) <COMPLEX_TYPE>: Deal with usual
floating-point complex types.
<POINTER_TYPE>: Do not use limited_with clause if the designated
type is a scalar type.

2 years agotestsuite/rs6000: Move pr83660.C to g++.target
Kewen Lin [Wed, 18 May 2022 14:08:10 +0000 (09:08 -0500)]
testsuite/rs6000: Move pr83660.C to g++.target

Move pr83660.C to g++.target.  As comment #3 of PR83660,
rename it to c isn't one option.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr83660.C: Moved to...
* g++.target/powerpc/pr83660.C: ...here.

2 years agographite: Extend SCoP detection dump output
Frederik Harwath [Wed, 18 May 2022 05:59:42 +0000 (07:59 +0200)]
graphite: Extend SCoP detection dump output

Extend dump output to make understanding why Graphite rejects to
include a loop in a SCoP easier (for GCC developers).

gcc/ChangeLog:

* graphite-scop-detection.cc (scop_detection::can_represent_loop):
Output reason for failure to dump file.
(scop_detection::harmful_loop_in_region): Likewise.
(scop_detection::graphite_can_represent_expr): Likewise.
(scop_detection::stmt_has_simple_data_refs_p): Likewise.
(scop_detection::stmt_simple_for_scop_p): Likewise.
(print_sese_loop_numbers): New function.
(scop_detection::add_scop): Use from here.

gcc/testsuite/ChangeLog:

* gcc.dg/graphite/scop-22a.c: New test.

2 years agodemangler: Reorganize for module demangling
Nathan Sidwell [Tue, 8 Mar 2022 18:53:39 +0000 (10:53 -0800)]
demangler: Reorganize for module demangling

Module demangling requires some changes in how substitutions are
handled.  This adjusts things to make that possible.

libiberty/
* cp-demangle.c (d_name): Add SUBSTABLE parameter,
push substitution if requested. Adjust unscoped name handling.
(d_prefix): Reorder main loop. Adjust all calls.
(d_unqualified_name): Add SCOPE parameter, create qualified
name here. Adjust all calls.
(cplus_demangle_type): Do not handle 'S' here, leave all
to d_class_enum_type.
(d_class_enum_type): Add SUBSTABLE parameter.

2 years ago'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'
Thomas Schwinge [Fri, 29 Apr 2022 08:44:12 +0000 (10:44 +0200)]
'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'

include/
* cuda/cuda.h (enum CUjit_option): Add
'CU_JIT_GENERATE_DEBUG_INFO', 'CU_JIT_GENERATE_LINE_INFO'.
(enum CUlimit): Add 'CU_LIMIT_STACK_SIZE',
'CU_LIMIT_MALLOC_HEAP_SIZE'.
(cuCtxSetLimit, cuGetErrorName): Add.

2 years ago'include/cuda/cuda.h': For C++, wrap in 'extern "C"'
Thomas Schwinge [Fri, 29 Apr 2022 08:33:15 +0000 (10:33 +0200)]
'include/cuda/cuda.h': For C++, wrap in 'extern "C"'

include/
* cuda/cuda.h: For C++, wrap in 'extern "C"'.

2 years agoOpenMP: Add Fortran support for inoutset depend-kind
Tobias Burnus [Wed, 18 May 2022 10:04:21 +0000 (12:04 +0200)]
OpenMP: Add Fortran support for inoutset depend-kind

Fortran additions to the C/C++ + ME/libgomp commit
r13-556-g2c16eb3157f86ae561468c540caf8eb326106b5f

gcc/fortran/ChangeLog:

* gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET.
(gfc_omp_clauses): Enlarge ENUM_BITFIELD.
* dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle
'inoutset' depend modifier.
* openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj):
Likewise.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1): Set 'inoutset' to Y.
(OpenMP Context Selectors): Add missing comma.
* testsuite/libgomp.fortran/depend-5.f90: Add inoutset test.
* testsuite/libgomp.fortran/depend-6.f90: Likewise.
* testsuite/libgomp.fortran/depend-7.f90: Likewise.
* testsuite/libgomp.fortran/depend-inoutset-1.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/all-memory-1.f90: Add inoutset test.
* gfortran.dg/gomp/all-memory-2.f90: Likewise.
* gfortran.dg/gomp/depobj-1.f90: Likewise.
* gfortran.dg/gomp/depobj-2.f90: Likewise.

2 years ago[Ada] Fix proof of runtime unit s-imageu
Claire Dross [Mon, 11 Apr 2022 12:10:49 +0000 (14:10 +0200)]
[Ada] Fix proof of runtime unit s-imageu

Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

* libgnat/s-imageu.adb (Set_Image_Unsigned): Change assertion.

2 years ago[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp
Doug Rupp [Fri, 8 Apr 2022 21:12:24 +0000 (14:12 -0700)]
[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtramp

Fix compilation warning. The code was using a cast to struct sigcontext
*, which doesn't exist. It worked by accident.

gcc/ada/

* sigtramp-qnx.c: Change struct sigcontext * to mcontext_t *.

2 years ago[Ada] arm-qnx-7.1: stack-checking and sigtramp implementation
Doug Rupp [Fri, 8 Apr 2022 18:28:48 +0000 (11:28 -0700)]
[Ada] arm-qnx-7.1: stack-checking and sigtramp implementation

Rewrite and base on VxWorks RTP implementation.

gcc/ada/

* sigtramp-arm-qnx.c: Rewrite.

2 years ago[Ada] Adapt proof of double arithmetic runtime unit
Yannick Moy [Fri, 8 Apr 2022 15:24:49 +0000 (15:24 +0000)]
[Ada] Adapt proof of double arithmetic runtime unit

After changes in Why3 and generation of VCs, ghost code needs to be
adapted for proofs to remain automatic.

gcc/ada/

* libgnat/s-aridou.adb (Big3): Change return type.
(Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive): Reorder
alphabetically.
(Lemma_Concat_Definition, Lemma_Double_Big_2xxsingle): New
lemmas.
(Double_Divide, Scaled_Divide): Add assertions.

2 years ago[Ada] Fix proof of runtime unit s-valeu
Claire Dross [Fri, 8 Apr 2022 14:38:47 +0000 (16:38 +0200)]
[Ada] Fix proof of runtime unit s-valeu

Update to provers caused some proof regressions.  Fix the proof by
changing ghost code.

gcc/ada/

* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.

2 years ago[Ada] Make sure output variable is always initialized
Kévin Le Gouguec [Thu, 7 Apr 2022 15:43:34 +0000 (17:43 +0200)]
[Ada] Make sure output variable is always initialized

gcc/ada/

* libgnat/s-dwalin.adb (Read_Aranges_Header): Initialize output
parameter in case we return early.

2 years ago[Ada] Disable Vet calls when container checks are disabled
Bob Duff [Thu, 7 Apr 2022 16:58:56 +0000 (12:58 -0400)]
[Ada] Disable Vet calls when container checks are disabled

Calls to various Vet functions are used throughout the containers
packages to check internal consistency. This patch improves efficiency
by disabling these calls when Container_Checks are suppressed.

gcc/ada/

* libgnat/a-crbtgo.ads, libgnat/a-rbtgbo.ads,
libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
libgnat/a-cbhase.adb, libgnat/a-cdlili.adb,
libgnat/a-cfdlli.adb, libgnat/a-cfhama.adb,
libgnat/a-cfhase.adb, libgnat/a-cidlli.adb,
libgnat/a-cihama.adb, libgnat/a-cihase.adb,
libgnat/a-cohama.adb, libgnat/a-cohase.adb,
libgnat/a-crbtgo.adb, libgnat/a-crdlli.adb, libgnat/a-rbtgbo.adb
(Vet): Make the Vet functions do nothing when
Container_Checks'Enabled is False, and inline them, so the calls
disappear when optimizing.

2 years ago[Ada] arm-qnx-7.1: undefined reference to fma* symbols
Doug Rupp [Thu, 7 Apr 2022 18:08:56 +0000 (11:08 -0700)]
[Ada] arm-qnx-7.1: undefined reference to fma* symbols

Configure the arm-qnx runtime packages to avoid generating these
symbols.

gcc/ada/

* Makefile.rtl (arm-qnx): Use default (non-fma) target pair.

2 years ago[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts
Kévin Le Gouguec [Thu, 7 Apr 2022 08:51:51 +0000 (10:51 +0200)]
[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hosts

Currently, a 64-bit gnatsymbolize fails to output line numbers and
accurate symbol names when run on 32-bit executables (and vice-versa).
This is because a couple of spots in System.Dwarf_Lines expect the
Address_Size found in the DWARF data to match the host Address'Size.

This patch corrects that assumption.

gcc/ada/

* libgnat/s-dwalin.adb (Aranges_Lookup, Enable_Cache): Adapt to
changes in the signature of Read_Aranges_*.
(Debug_Info_Lookup): Do not control address size read from
DWARF.
(Read_Aranges_Header): Do not control address size read from
DWARF; return this size.
(Read_Aranges_Entry): Use the size returned by
Read_Aranges_Header.

2 years ago[Ada] Improve error messages for occurrence of GNAT extensions without -gnatX
Gary Dismukes [Wed, 6 Apr 2022 00:20:10 +0000 (20:20 -0400)]
[Ada] Improve error messages for occurrence of GNAT extensions without -gnatX

The error message issued for use of GNAT extension features without
specifying -gnatX (or pragma Extensions_Allowed) was confusing in the
presence of a pragma specifying a language version (such as "pragma
Ada_2022;"), because the pragma supersedes the switch.  The message is
improved by testing for use of such a pragma, plus use of pragma
Extensions_Allowed is now suggested, and several cases are changed to
call the common error procedure for flagging uses of extension features.

gcc/ada/

* errout.ads (Error_Msg_GNAT_Extension): Add formal Loc and
revise comment.
* errout.adb (Error_Msg_GNAT_Extension): Condition message on
the flag Ada_Version_Pragma, and add suggestion to use of pragma
Extensions_Allowed in messages.
* par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch11.adb,
par-ch12.adb: Add actual Token_Ptr on calls to
Error_Msg_GNAT_Extension.
* par-ch4.adb: Change Error_Msg to Error_Msg_GNAT_Extension for
error calls related to use of extension features.
* sem_ch13.adb: Likewise.

2 years ago[Ada] Fix Ada-QNX task priority conversion
Johannes Kliemann [Tue, 5 Apr 2022 16:25:43 +0000 (16:25 +0000)]
[Ada] Fix Ada-QNX task priority conversion

The conversion between OS and Ada priorties should be done in the wider
Interfaces.C.int type rather than Any_Priority otherwise
Constraint_Error will be raised when coverting Any_Priority'Last to int.

gcc/ada/

* libgnarl/s-osinte__qnx.adb (To_Target_Priority): Perform
arithmetic in int.

2 years ago[Ada] Use specific predicate before manipulating BIP_Alloc_Form
Eric Botcazou [Mon, 28 Mar 2022 19:16:24 +0000 (21:16 +0200)]
[Ada] Use specific predicate before manipulating BIP_Alloc_Form

For the sake of consistency with other similar manipulations.

gcc/ada/

* exp_ch7.adb (Build_BIP_Cleanup_Stmts): Use Needs_BIP_Alloc_Form.

2 years ago[Ada] Crash building VSS with compiler built with assertions
Javier Miranda [Fri, 1 Apr 2022 22:12:05 +0000 (22:12 +0000)]
[Ada] Crash building VSS with compiler built with assertions

When a tagged type T has aspect String_Literal, a derived type defines a
null extension T2, and the context to resolve the use of an object of
type T2 where the string literal is applicable is a class-wide type the
frontend crashes trying to evaluate if the object is a null extension.
This problem does not reproduce when the compiler is built with
assertions disabled.

gcc/ada/

* sem_ch6.adb (Find_Corresponding_Spec): Avoid calling
Is_Null_Extension with a class-wide type entity.
(Overrides_Visible_Function): Handle alias entities.
* sem_res.adb (Has_Applicable_User_Defined_Literal): Conversion
not needed if the result type of the call is class-wide or if
the result type matches the context type.
* sem_util.ads (Is_Null_Extension): Adding documentation.
(Is_Null_Extension_Of): Adding documentation.
* sem_util.adb (Is_Null_Extension): Adding assertion.
(Is_Null_Extension_Of): Adding assertions.

2 years ago[Ada] Ada2022: AI12-0143 Index attribute for entry families
Javier Miranda [Fri, 1 Apr 2022 20:06:27 +0000 (20:06 +0000)]
[Ada] Ada2022: AI12-0143 Index attribute for entry families

gcc/ada/

* snames.ads-tmpl (Name_Index): New attribute name.
(Attribute_Id): Adding Attribute_Index as regular attribute.
* sem_attr.adb (Attribute_22): Adding Attribute_Index as Ada
2022 attribute.
(Analyze_Index_Attribute): Check that 'Index appears in a
pre-/postcondition aspect or pragma associated with an entry
family.
(Analyze_Attribute): Adding semantic analysis for 'Index.
(Eval_Attribute): Register 'Index as can never be folded.
(Resolve_Attribute): Resolve attribute 'Index.
* sem_ch9.adb (Check_Wrong_Attribute_In_Postconditions): New
subprogram.
(Analyze_Requeue): Check that the requeue target shall not have
an applicable specific or class-wide postcondition which
includes an Index attribute reference.
* exp_attr.adb (Expand_N_Attribute_Reference): Transform
attribute Index into a renaming of the second formal of the
wrapper built for an entry family that has contract cases.
* einfo.ads (Is_Entry_Wrapper): Complete documentation.

2 years ago[Ada] Fix proof of runtime units
Yannick Moy [Mon, 4 Apr 2022 15:38:57 +0000 (17:38 +0200)]
[Ada] Fix proof of runtime units

Update to latest version of Why3 caused some proof regressions.
Fix the proof by changing ghost code.

gcc/ada/

* libgnat/s-imagei.adb (Set_Digits): Add assertion.
* libgnat/s-imgboo.adb (Image_Boolean): Add assertions.
* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertion.

2 years ago[Ada] Errors missed on ACATS test B650007
Arnaud Charlet [Sat, 2 Apr 2022 17:29:09 +0000 (17:29 +0000)]
[Ada] Errors missed on ACATS test B650007

This ACATS test shows that we need to call Is_Immutably_Limited_Type
in Analyze_Function_Return and also that we have a latent bug in
Is_Immutably_Limited_Type which shouldn't look through private types.

gcc/ada/

* sem_aux.adb (Is_Immutably_Limited_Type): Do not look through
private types as per RM 7.5(8.1).
* sem_ch6.adb (Analyze_Function_Return): Use
Is_Immutably_Limited_Type as per RM 6.5(5.10).

2 years ago[Ada] Fix the parsing for delta aggregate
Marc Poulhiès [Mon, 4 Apr 2022 12:09:45 +0000 (14:09 +0200)]
[Ada] Fix the parsing for delta aggregate

In Ada 2022, delta aggregate must use parentheses not square brackets
except array delta aggregates.

gcc/ada/

* gen_il-gen-gen_nodes.adb (Gen_IL.Gen.Gen_Nodes): Add
Is_Homogeneous_Aggregate field for N_Delta_Aggregate nodes.
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Minor reformatting.
* sem_aggr.adb (Resolve_Delta_Aggregate): Reject square brackets
for record aggregate.
(Resolve_Record_Aggregate): Uniformise error message.

2 years ago[Ada] Secondary stack and a-tags
Arnaud Charlet [Sun, 3 Apr 2022 08:08:48 +0000 (08:08 +0000)]
[Ada] Secondary stack and a-tags

The simple use of Ada.Tags triggers a dependency on the secondary stack
mechanism, which is unwanted on small embedded targets. To avoid this
dependency, we special case a-tags.ali in ALI.Scan_ALI to not set
Sec_Stack_Used. If some other code calls one of the functions returning
a string, this code will also be marked as requiring the secondary
stack. We also remove the need to import and set __gnat_binder_ss_count
in this case by ensuring this variable defaults to 0.

gcc/ada/

* ali.adb (Scan_ALI): Special case a-tags.ali when setting
Sec_Stack_Used.
* bindgen.adb (Gen_Adainit): Simplify handling of secondary
stack related code, and only import __gnat_binder_ss_count when
needed.
* libgnat/s-secsta.adb (Binder_SS_Count): Default initialize to
0.

2 years ago[Ada] Fix problematic underflow for Float_Type'Value
Eric Botcazou [Mon, 4 Apr 2022 21:16:53 +0000 (23:16 +0200)]
[Ada] Fix problematic underflow for Float_Type'Value

We need a couple of guards for boundary conditions in the support code.

gcc/ada/

* libgnat/s-dourea.adb ("/"): Add guard for zero and infinite
divisor.
* libgnat/s-valuer.adb (Scan_Raw_Real): Add guard for very large
exponent values.

2 years ago[Ada] Spurious error on freezing of tagged types in SPARK
Yannick Moy [Fri, 1 Apr 2022 14:58:19 +0000 (16:58 +0200)]
[Ada] Spurious error on freezing of tagged types in SPARK

SPARK RM 7.7(8) mandates that the freezing point of a tagged type must
occur within the so-called early call region of all its primitives.
This check may lead to spurious errors due to generated constructs being
considered in the search for the start of the early call region.

gcc/ada/

* sem_elab.adb (Is_Suitable_Construct): Fix for generated
constructs.

2 years ago[Ada] Rework optimization skipping pragma check in object declaration
Marc Poulhiès [Fri, 18 Mar 2022 09:32:41 +0000 (10:32 +0100)]
[Ada] Rework optimization skipping pragma check in object declaration

When an object declaration is initialized with a type conversion:

 Var : Typ := Typ (Value);

we skip the check for Typ's predicate as it is already checked
during the type conversion.

This is not correct when Var's subtype and the target subtype of the
conversion do not statically match:

 Var : Typ := OtherTyp (Value);

In such case, we can't skip the check of Typ's predicate.

Fix minor typos in comment.

gcc/ada/

* sem_ch3.adb (Analyze_Object_Declaration): Skip predicate check
for type conversion if object's subtype and expression's subtype
statically match.
* exp_prag.adb (Expand_Pragma_Check): Typo fix in comment.

2 years ago[Ada] Fix internal error on subprogram instantiation
Eric Botcazou [Fri, 1 Apr 2022 23:21:36 +0000 (01:21 +0200)]
[Ada] Fix internal error on subprogram instantiation

The compiler builds renamings for actuals of formal objects for debugging
purposes in this case, but it must not generate them for temporaries.

gcc/ada/

* exp_dbug.ads (Build_Subprogram_Instance_Renamings): Fix typo.
* exp_dbug.adb (Build_Subprogram_Instance_Renamings): Build the
renaming only for actuals of formal objects.

2 years ago[Ada] Overriding error on type derived from discriminated untagged private type
Gary Dismukes [Thu, 31 Mar 2022 20:33:01 +0000 (16:33 -0400)]
[Ada] Overriding error on type derived from discriminated untagged private type

When a derived type DT has an untagged private parent type PT with a
discriminant, where the full type of PT is tagged, and DT inherits a
function F with an anonymous access result that designates the type, the
compiler wrongly reports an error saying that DT must be declared
abstract or F overridden. A test is added to exclude checking the
abstract overriding rules that should only apply to inherited
subprograms of tagged derived types.

gcc/ada/

* sem_ch3.adb (Check_Abstract_Overriding): If the type is
derived from an untagged type, then don't perform any of the
abstract overriding error checks.

2 years ago[Ada] Prevent overflow in computation of aggregate size
Piotr Trojanek [Thu, 31 Mar 2022 18:56:58 +0000 (20:56 +0200)]
[Ada] Prevent overflow in computation of aggregate size

When computing size of a static aggregate to decide if it should be
transformed into assignments and loops we could have an overflow check.
This is mostly harmless, because colossal aggregates will likely crash
the application anyway, no matter how we transform them.

This was not detected because compiler was built with -gnatg switch that
suppresses overflow checks (they are only enabled by an explicit -gnato
switch).

gcc/ada/

* exp_aggr.adb (Component_Count): Calculate size as an Uint and
only then check if it is in the range of Int, as otherwise the
multiplication of Int values can overflow.

2 years ago[Ada] Fast implementation of floating-point mathematical functions
Eric Botcazou [Mon, 28 Mar 2022 07:30:16 +0000 (09:30 +0200)]
[Ada] Fast implementation of floating-point mathematical functions

This adds a package renaming unit to the GNAT hierarchy so as to expose
the underlying implementation of floating-point mathematical functions,
thus also making it possible to use their vector implementation, if any.

The change also contains a small improvement to the Hide_Public_Entities
mechanism in Sem_Ch7 that makes it possible to clear the Is_Public flag
within instances of generic packages that do not have a body.

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-gfmafu$(objext).
(SIMD_PATH_TARGET_PAIRS): New variable.
(TRASYM_DWARF_COMMON_OBJS): Minor tweak.
(x86-64/Linux): Use SIMD_PATH_TARGET_PAIRS.
(x32/Linux): Likewise.
* doc/gnat_rm/the_gnat_library.rst (Generic_Fast_Math_Functions):
New entry.
* gnat_rm.texi: Regenerate.
* impunit.adb (Non_Imp_File_Names_95): Add g-gfmafu.
* sem_ch7.adb (Has_Referencer): Do not set In_Nested_Instance for
instances of generic packages that do not have a body.
* libgnat/a-nalofl__simd.ads: New SIMD-enabled version.
* libgnat/a-nuaufl__simd.ads: Likewise.
* libgnat/g-gfmafu.ads: New package renaming unit.

2 years ago[Ada] Freezing too strict in instances
Arnaud Charlet [Wed, 30 Mar 2022 19:00:27 +0000 (19:00 +0000)]
[Ada] Freezing too strict in instances

Should_Freeze_Type is relaxed to only take the relevant case into
account (entities denoted by generic actual parameters as per
13.14(5/3), as well as profile of any subprograms named as per
13.14(10.2/4)), instead of being overly conservative wrt instances and
as a result, wrongly rejecting some legal code.

In practice this means we only need to worry about profile of
subprograms named as part of instances.

gcc/ada/

* freeze.adb (Should_Freeze_Type): Fix handling of freezing in
instances.

2 years ago[Ada] Fix incorrect freezing with generic child unit
Marc Poulhiès [Mon, 28 Mar 2022 14:03:48 +0000 (16:03 +0200)]
[Ada] Fix incorrect freezing with generic child unit

The Analyze_Associations.Check_Generic_Parent function was using an
incorrect node as the instanciation node for the actual, possibly
leading to incorrect freeze node being created (and later crashing in
gigi). Using Get_Unit_Instantiation_Node fixes the issue.

gcc/ada/

* sem_ch12.adb (Check_Generic_Parent): Use
Get_Unit_Instantiation_Node instead of Next.

2 years ago[Ada] Ada.Numerics.Aux.*: Mention more Intrinsic and less C Math Library
Alexandre Oliva [Wed, 30 Mar 2022 08:45:17 +0000 (05:45 -0300)]
[Ada] Ada.Numerics.Aux.*: Mention more Intrinsic and less C Math Library

Since we import the elemental math functions as intrinsics, it's not
accurate to state we're drawing them in from the C math library.

gcc/ada/

* libgnat/a-nagefl.ads: Replace mentions of C/unix math library
with intrinsics.
* libgnat/a-nallfl.ads: Likewise.  State compatibility
requirements.
* libgnat/a-nalofl.ads: Likewise.
* libgnat/a-nuaufl.ads: Likewise.

2 years ago[Ada] Small performance tweak in recent change
Eric Botcazou [Wed, 30 Mar 2022 10:59:23 +0000 (12:59 +0200)]
[Ada] Small performance tweak in recent change

This avoids a useless walk of the prefix chain in instances.

gcc/ada/

* sem_ch8.adb (Analyze_Subprogram_Renaming): Move final test on
In_Instance to outer condition.

2 years ago[Ada] New port arm-qnx
Doug Rupp [Tue, 29 Mar 2022 16:22:31 +0000 (09:22 -0700)]
[Ada] New port arm-qnx

The QNX system specs for ARM and AARCH64 are identical. It makes more
sense to have it named for the base architecture.

gcc/ada/

* Makefile.rtl: Rename system-qnx-aarch64.ads to
system-qnx-arm.ads.
(AARCH64 QNX section): Modify to handle both arm and arch64.
* tracebak.c (__QNX__): Add new __ARMEL__ section.
* sigtramp-arm-qnx.c: New file.
* libgnat/system-qnx-aarch64.ads: Renamed to ...
* libgnat/system-qnx-arm.ads: this.

2 years agoEnhance final_value_replacement_loop to handle bitwise induction.
liuhongt [Tue, 7 Dec 2021 07:41:52 +0000 (15:41 +0800)]
Enhance final_value_replacement_loop to handle bitwise induction.

This patch will enable below optimization:

 {
-  int bit;
-  long long unsigned int _1;
-  long long unsigned int _2;
-
   <bb 2> [local count: 46707768]:
-
-  <bb 3> [local count: 1027034057]:
-  # tmp_11 = PHI <tmp_8(3), tmp_6(D)(2)>
-  # bit_13 = PHI <bit_9(3), 63(2)>
-  _1 = 1 << bit_13;
-  _2 = ~_1;
-  tmp_8 = _2 & tmp_11;
-  bit_9 = bit_13 + -3;
-  if (bit_9 != -3(OVF))
-    goto <bb 3>; [95.65%]
-  else
-    goto <bb 4>; [4.35%]
-
-  <bb 4> [local count: 46707768]:
-  return tmp_8;
+  tmp_12 = tmp_6(D) & 7905747460161236406;
+  return tmp_12;

 }

gcc/ChangeLog:

PR middle-end/103462
* match.pd (bitwise_induction_p): New match.
* tree-scalar-evolution.cc (gimple_bitwise_induction_p):
Declare.
(analyze_and_compute_bitwise_induction_effect): New function.
(enum bit_op_kind): New enum.
(final_value_replacement_loop): Enhanced to handle bitwise
induction.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr103462-1.c: New test.
* gcc.target/i386/pr103462-2.c: New test.
* gcc.target/i386/pr103462-3.c: New test.
* gcc.target/i386/pr103462-4.c: New test.
* gcc.target/i386/pr103462-5.c: New test.
* gcc.target/i386/pr103462-6.c: New test.

2 years agoThis patch adds a combine pattern for "CA minus one". The SImode "CA minus one" can...
Haochen Gui [Wed, 11 May 2022 01:19:52 +0000 (09:19 +0800)]
This patch adds a combine pattern for "CA minus one". The SImode "CA minus one" can be converted to DImode as CA only has two values (0 or 1).

gcc/
PR target/95737
* config/rs6000/rs6000.md (*subfsi3_carry_in_xx_64): New.

gcc/testsuite/
PR target/95737
* gcc.target/powerpc/pr95737.c: New.

2 years agorecognize bzhi pattern when there's zero_extendsidi.
liuhongt [Thu, 28 Apr 2022 07:30:06 +0000 (15:30 +0800)]
recognize bzhi pattern when there's zero_extendsidi.

backend has

16550(define_insn "*bmi2_bzhi_<mode>3_2"
16551  [(set (match_operand:SWI48 0 "register_operand" "=r")
16552        (and:SWI48
16553          (plus:SWI48
16554            (ashift:SWI48 (const_int 1)
16555                          (match_operand:QI 2 "register_operand" "r"))
16556            (const_int -1))
16557          (match_operand:SWI48 1 "nonimmediate_operand" "rm")))
16558   (clobber (reg:CC FLAGS_REG))]
16559  "TARGET_BMI2"
16560  "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
16561  [(set_attr "type" "bitmanip")
16562   (set_attr "prefix" "vex")
16563   (set_attr "mode" "<MODE>")])

But there's extra zero_extend in pattern match.

424Failed to match this instruction:
425(parallel [
426        (set (reg:DI 90)
427            (zero_extend:DI (and:SI (plus:SI (ashift:SI (const_int 1 [0x1])
428                            (subreg:QI (reg:SI 98) 0))
429                        (const_int -1 [0xffffffffffffffff]))
430                    (subreg:SI (reg:DI 95) 0))))
431        (clobber (reg:CC 17 flags))
432    ])

Add new define_insn for it.

gcc/ChangeLog:

PR target/104375
* config/i386/i386.md (*bmi2_bzhi_zero_extendsidi_4): New
define_insn.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr104375.c: New test.

2 years agoExpand __builtin_memcmp_eq with ptest for OImode.
liuhongt [Tue, 1 Mar 2022 05:41:52 +0000 (13:41 +0800)]
Expand __builtin_memcmp_eq with ptest for OImode.

gcc/ChangeLog:

PR target/104610
* config/i386/i386-expand.cc (ix86_expand_branch): Use ptest
for QImode when code is EQ or NE.
* config/i386/i386.md (cbranchoi4): New expander.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr104610.c: New test.

2 years agors6000: Prefer assigning the MMA vector operands to altivec registers [PR105556]
Peter Bergner [Wed, 18 May 2022 02:09:29 +0000 (21:09 -0500)]
rs6000: Prefer assigning the MMA vector operands to altivec registers [PR105556]

When optimizing the DGEMM kernel in OpenBLAS to use MMA, the MMA code
uses all 8 accumulators, which overlap all vs0-vs31 vector registers.
Current trunk assigns one of the normal vector inputs to one of the MMA
instructions, which forces us to spill one of the accumulators to memory,
leading to poor performance.  The solution here is to replace the "wa"
constraints for the vector input operands in the MMA instruction patterns
with "v,?wa" so that we prefer using the altivec registers vs32-vs63
over the vs0-vs31 registers.

2022-05-17  Peter Bergner  <bergner@linux.ibm.com>
    Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
PR target/105556
* config/rs6000/mma.md (mma_<vv>, mma_<avv>, mma_<pv>, mma_<apv>,
mma_<vvi4i4i8>, mma_<avvi4i4i8>, mma_<vvi4i4i2>, mma_<avvi4i4i2>,
mma_<vvi4i4>, mma_<avvi4i4>, mma_<pvi4i2>, mma_<apvi4i2>,
mma_<vvi4i4i4>, mma_<avvi4i4i4>): Replace "wa" constraints with "v,?wa".
Update other operands accordingly.

2 years agoDaily bump.
GCC Administrator [Wed, 18 May 2022 00:16:36 +0000 (00:16 +0000)]
Daily bump.

2 years agocompiler: load LHS subexpressions of op= assignment only once
Ian Lance Taylor [Wed, 11 May 2022 00:05:08 +0000 (17:05 -0700)]
compiler: load LHS subexpressions of op= assignment only once

Fixes golang/go#52811

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405617

2 years agoc++: constexpr ref to array of array [PR102307]
Jason Merrill [Tue, 26 Apr 2022 15:15:04 +0000 (11:15 -0400)]
c++: constexpr ref to array of array [PR102307]

The problem here is that first check_initializer calls
build_aggr_init_full_exprs, which does overload resolution, but then in the
case of failed constexpr throws away the result and does it again in
build_functional_cast.  But in the first overload resolution,
reshape_init_array_1 decided to reuse the inner CONSTRUCTORs because
tf_error is set, so we know we're committed.  But the second pass gets
confused by the CONSTRUCTORs with non-init-list types.

Fixed by avoiding a second pass: instead, pass the call from build_aggr_init
to build_cplus_new, which will turn it into a TARGET_EXPR.  I don't bother
to change the object argument because it will be replaced later in
simplify_aggr_init_expr.

PR c++/102307

gcc/cp/ChangeLog:

* decl.cc (check_initializer): Use build_cplus_new in case of
constexpr failure.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/constexpr-array2.C: New test.

2 years agoc: use CONST_DECL for enumerators in TYPE_VALUES
Marek Polacek [Tue, 17 May 2022 17:41:56 +0000 (13:41 -0400)]
c: use CONST_DECL for enumerators in TYPE_VALUES

The C and C++ FEs differ in TYPE_VALUES for an enum type: an entry in
the list in the C++ FE has a CONST_DECL in the TREE_VALUE, but the C FE
has only the numerical value of the CONST_DECL there.  This has caused
me some trouble in my PR105497 patch.  Using a CONST_DECL is preferable
because a CONST_DECL can track more information (e.g., attributes), and
you can always get the value simply by looking at its DECL_INITIAL.

This turned out to be a trivial change.  One place in godump.cc had to be
adjusted.  I'm not changing the CONST_DECL check in c_do_switch_warnings
because I'll be changing it soon in my next patch.  I didn't see any other
checks that this patch makes redundant.

gcc/c/ChangeLog:

* c-decl.cc (finish_enum): Store the CONST_DECL into TREE_VALUE, not
its value.

gcc/ChangeLog:

* godump.cc (go_output_typedef): Use the DECL_INITIAL of the TREE_VALUE.

2 years agoFix register count when not splitting Complex IEEE 128-bit args.
Pat Haugen [Tue, 17 May 2022 20:53:24 +0000 (15:53 -0500)]
Fix register count when not splitting Complex IEEE 128-bit args.

For ABI_V4, we do not split complex args. This created a problem because
even though an arg would be passed in two VSX regs, we were only advancing the
function arg counter by one VSX register. Fixed with this patch.

PR target/99685

gcc/
* config/rs6000/rs6000-call.cc (rs6000_function_arg_advance_1): Bump
register count when not splitting IEEE 128-bit Complex.

2 years agoOpenMP: Skip target-nesting warning for reverse offload
Tobias Burnus [Tue, 17 May 2022 20:09:16 +0000 (22:09 +0200)]
OpenMP: Skip target-nesting warning for reverse offload

gcc/ChangeLog:

* omp-low.cc (check_omp_nesting_restrictions): Skip warning for
target inside target if inner is reverse offload.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/target-device-ancestor-5.c: New test.

2 years agolibstdc++: Relax memory ordering for default memory resource object
Jonathan Wakely [Tue, 17 May 2022 15:17:21 +0000 (16:17 +0100)]
libstdc++: Relax memory ordering for default memory resource object

Currently pmr::set_default_resource and pmr::get_default_resource both
use sequentially consistent memory ordering. This is overkill. The
standard only requires that a call to set_default_resource synchronizes
with subsequent calls to set_default_resource and get_default_resource.

Using acquire-release for the setter and acquire for the getter is
sufficient to meet the requirement.

Reviewed-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:

* src/c++17/memory_resource.cc (set_default_resource): Use
memory_order_acq_rel.
(get_default_resource): Use memory_order_acquire.

2 years agolibstdc++: Add attributes to functions in <memory_resource>
Jonathan Wakely [Tue, 17 May 2022 14:14:39 +0000 (15:14 +0100)]
libstdc++: Add attributes to functions in <memory_resource>

Add attributes to the accessors for the global memory resource objects,
to allow the compiler to eliminate redundant calls to them. For example,
multiple calls to std::pmr::new_delete_resource() will always return the
same object, and so the compiler can replace them with a single call.

Ideally we would like adjacent calls to std::pmr::get_default_resource()
to be combined into a single call by the CSE pass. The 'pure' attribute
would permit that. However, the standard requires that calls to
std::pmr::set_default_resource() synchronize with subsequent calls to
std::pmr::get_default_resource().  With 'pure' the DCE pass might
eliminate seemingly redundant calls to std::pmr::get_default_resource().
That might be unsafe, because the caller might be relying on the
associated synchronization. We could use a hypothetical attribute that
allows CSE but not DCE, but we don't have one. So it can't be 'pure'.

Also add [[nodiscard]] to equality operators.

libstdc++-v3/ChangeLog:

* include/std/memory_resource (new_delete_resource): Add
nodiscard, returns_nonnull and const attributes.
(null_memory_resource): Likewise.
(set_default_resource, get_default_resource): Add returns_nonnull
attribute.
(memory_resource::is_equal): Add nodiscard attribute.
(operator==, operator!=): Likewise.

2 years agolibstdc++: Add attributes to <system_error> and related
Jonathan Wakely [Tue, 17 May 2022 13:50:32 +0000 (14:50 +0100)]
libstdc++: Add attributes to <system_error> and related

Add the const attribute to std::future_category() and
std::iostream_category(), to match the existing attributes on
std::generic_category() and std::system_category().

Also add [[nodiscard]] to those functions and to the comparison
operators for std::error_code and std::error_condition, and to
std::make_error_code and std::make_error_condition overloads.

libstdc++-v3/ChangeLog:

* include/bits/ios_base.h (io_category): Add const and nodiscard
attributes.
(make_error_code, make_error_condition): Add nodiscard.
* include/std/future (future_category): Add const and nodiscard.
(make_error_code, make_error_condition): Add nodiscard.
* include/std/system_error (generic_category system_category):
Add nodiscard. Replace _GLIBCXX_CONST with C++11 attribute.
(error_code::value, error_code::category, error_code::operator bool)
(error_condition::value, error_condition::category)
(error_condition::operator bool, make_error_code)
(make_error_condition, operator==, operator!=, operator<=>): Add
nodiscard.

2 years agoRevert 'Use more ARRAY_SIZE.' for mkoffload
Tobias Burnus [Tue, 17 May 2022 18:46:29 +0000 (20:46 +0200)]
Revert 'Use more ARRAY_SIZE.' for mkoffload

Revert commit r13-472-gca32b29ec3e92dcf8dda5c2501d0baf9dd1cb09d partially;
namely for {gcn,nvptx}/mkoffload.cc, only.

The patch changed 'sizeof(...)/sizeof(...[0])' to the 'ARRAY_SIZE' macro,
which is in principle a good idea – except that in the two mkoffload.cc,
the change happened inside a string that is used to generate plain C code.

With offlading to nvptx or gcn, the mkoffload genenates then the C file
and compilation of the latter fails with
"warning: implicit declaration of function 'ARRAY_SIZE'" followed by
"error: initializer element is not constant"

gcc/
* config/gcn/mkoffload.cc (process_obj): Revert: Use ARRAY_SIZE.
* config/nvptx/mkoffload.cc (process): Likewise.

2 years agoAdd side effect infrastructure.
Andrew MacLeod [Mon, 9 May 2022 19:35:14 +0000 (15:35 -0400)]
Add side effect infrastructure.

Replace the non-null procesing with a generic side effect implementation that
can handle arbitrary side effects.

* Makefile.in (OBJS): Add gimple-range-side-effect.o.
* gimple-range-cache.cc (non_null_ref::non_null_ref): Delete.
(non_null_ref::~non_null_ref): Delete.
(non_null_ref::set_nonnull): Delete.
(non_null_ref::non_null_deref_p): Delete.
(non_null_ref::process_name): Delete.
(ranger_cache::ranger_cache): Initialize m_exit object.
(ranger_cache::fill_block_cache): Use m_exit object intead of nonnull.
(ranger_cache::range_from_dom): Use side_effect class and m_exit object.
(ranger_cache::update_to_nonnull): Delete.
(non_null_loadstore): Delete.
(ranger_cache::block_apply_nonnull): Delete.
(ranger_cache::apply_side_effects): New.
* gimple-range-cache.h (class non_null_ref): Delete.
(non_null_ref::adjust_range): Delete.
(class ranger_cache): Adjust prototypes, add side effect manager.
* gimple-range-path.cc (path_range_query::range_defined_in_block): Use
side effect manager for queries.
(path_range_query::adjust_for_non_null_uses): Ditto.
* gimple-range-path.h (class path_range_query): Delete non_null_ref.
* gimple-range-side-effect.cc: New.
* gimple-range-side-effect.h: New.
* gimple-range.cc (gimple_ranger::gimple_ranger): Update contructor.
(gimple_ranger::range_of_expr): Check def block for override value.
(gimple_ranger::range_on_entry): Don't scan dominators for non-null.
(gimple_ranger::range_on_edge): Check for outgoing side-effects.
(gimple_ranger::register_side_effects): Call apply_side_effects.
(enable_ranger): Update contructor.
* gimple-range.h (class gimple_ranger): Update prototype.
(enable_ranger): Update prototype.
* tree-vrp.cc (execute_ranger_vrp): Invoke without immediate-use flag.

2 years agodemangler: Structured Bindings
Nathan Sidwell [Tue, 8 Mar 2022 21:00:35 +0000 (13:00 -0800)]
demangler: Structured Bindings

C++ Structured bindings have a mangling that has yet to be formally
documented.  However, it's been around for a while and shows up for
module support.

include/
* demangle.h (enum demangle_component_type): Add
DEMANGLE_COMPONENT_STRUCTURED_BINDING.
libiberty/
* cp-demangle.c (d_make_comp): Adjust.
(d_unqualified_name): Add 'DC' support.
(d_count_template_scopes): Adjust.
(d_print_comp_inner): Add structured binding.
* testsuite/demangle-expected: Add testcases.

2 years agoPR105169 Fix references to discarded sections
Giuliano Belinassi [Sat, 7 May 2022 02:37:52 +0000 (23:37 -0300)]
PR105169 Fix references to discarded sections

When -fpatchable-function-entry= is enabled, certain C++ codes fails to
link because of generated references to discarded sections in
__patchable_function_entry section. This commit fixes this problem by
puting those references in a COMDAT section.

2022-05-06  Giuliano Belinassi  <gbelinassi@suse.de>

gcc/ChangeLog
PR c++/105169
* targhooks.cc (default_print_patchable_function_entry_1): Handle COMDAT case.
* varasm.cc (switch_to_comdat_section): New
(handle_vtv_comdat_section): Call switch_to_comdat_section.
* varasm.h: Declare switch_to_comdat_section.

gcc/testsuite/ChangeLog
2022-05-06  Giuliano Belinassi  <gbelinassi@suse.de>

PR c++/105169
* g++.dg/modules/pr105169.h: New file.
* g++.dg/modules/pr105169_a.C: New test.
* g++.dg/modules/pr105169_b.C: New file.

2 years agoDo not clear bb->aux in duplicate_loop_body_to_header_edge
Richard Biener [Tue, 17 May 2022 15:18:06 +0000 (17:18 +0200)]
Do not clear bb->aux in duplicate_loop_body_to_header_edge

duplicate_loop_body_to_header_edge clears bb->aux which is not wanted
by a new use in loop unswitching.  The clearing was introduced with
r0-69110-g6580ee7781f903 and it seems accidentially so.

2022-05-17  Richard Biener  <rguenther@suse.de>

* cfgloopmanip.cc (duplicate_loop_body_to_header_edge): Do
not clear bb->aux of the copied blocks.

2 years agoCheck for equivalence after merging relations.
Andrew MacLeod [Tue, 17 May 2022 01:39:30 +0000 (21:39 -0400)]
Check for equivalence after merging relations.

When registering a relation, we need to merge with any existing relation
before checking if it was an equivalence... otherwise it was not being
handled properly.

gcc/
PR tree-optimization/105458
* value-relation.cc (path_oracle::register_relation): Merge, then check
for equivalence.

gcc/testsuite/
* gcc.dg/pr105458.c: New.

2 years agoi386: Fix ICE in final_scan_insn_1 [PR105624]
Uros Bizjak [Tue, 17 May 2022 15:22:26 +0000 (17:22 +0200)]
i386: Fix ICE in final_scan_insn_1 [PR105624]

Apparently const_int_operand and other const*_operand predicates
do need constraints.  Revert the offending patch that caused ICE.

2022-05-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/105624
Revert:

* config/i386/i386.md: Remove constraints when used with
const_int_operand, const0_operand, const_1_operand, constm1_operand,
const8_operand, const128_operand, const248_operand, const123_operand,
const2367_operand, const1248_operand, const359_operand,
const_4_or_8_to_11_operand, const48_operand, const_0_to_1_operand,
const_0_to_3_operand, const_0_to_4_operand, const_0_to_5_operand,
const_0_to_7_operand, const_0_to_15_operand, const_0_to_31_operand,
const_0_to_63_operand, const_0_to_127_operand, const_0_to_255_operand,
const_0_to_255_mul_8_operand, const_1_to_31_operand,
const_1_to_63_operand, const_2_to_3_operand, const_4_to_5_operand,
const_4_to_7_operand, const_6_to_7_operand, const_8_to_9_operand,
const_8_to_11_operand, const_8_to_15_operand, const_10_to_11_operand,
const_12_to_13_operand, const_12_to_15_operand, const_14_to_15_operand,
const_16_to_19_operand, const_16_to_31_operand, const_20_to_23_operand,
const_24_to_27_operand and const_28_to_31_operand.
* config/i386/mmx.md: Ditto.
* config/i386/sse.md: Ditto.
* config/i386/subst.md: Ditto.
* config/i386/sync.md: Ditto.

gcc/testsuite/ChangeLog:

PR target/105624
* gcc.target/i386/pr105624.c: New test.

2 years agolibgomp: Clarify that omp_display_env is fully implemented
Jakub Jelinek [Tue, 17 May 2022 14:58:26 +0000 (16:58 +0200)]
libgomp: Clarify that omp_display_env is fully implemented

OpenMP 5.2 added
"When called from within a target region the effect is unspecified."
restriction to omp_display_env, so it is ok not to support it in
target regions (worst case we could add an empty implementation
or one with __builtin_trap in there).

2022-05-17  Jakub Jelinek  <jakub@redhat.com>

* libgomp.texi (OpenMP 5.1): Remove "Not inside target regions"
comment for omp_display_env feature.