platform/upstream/gcc.git
2 years ago[Ada] arm-qnx-7.1: unwind goes wrong after regs restore
Doug Rupp [Fri, 6 May 2022 22:28:49 +0000 (15:28 -0700)]
[Ada] arm-qnx-7.1: unwind goes wrong after regs restore

Bump the pc +3 total for Thumb mode, the same calculation that as is
done for arm-linux.

gcc/ada/

* init.c (__gnat_adjust_context_for_raise) [QNX][__thumb2__]: Bump
the pc an extra byte.

2 years ago[Ada] Enable using absolute paths in -fdiagnostics-format=json output
Ghjuvan Lacambre [Fri, 6 May 2022 16:53:57 +0000 (18:53 +0200)]
[Ada] Enable using absolute paths in -fdiagnostics-format=json output

This commit makes GNAT use absolute paths in -fdiagnostics-format=json's
output when -gnatef is present on the command line. This makes life
easier for tools that ingest GNAT's output.

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new behavior.
* errout.adb (Write_JSON_Location): Output absolute paths when
needed.
* switch-c.adb (Scan_Front_End_Switches): Update -gnatef
comment.
* usage.adb (Usage): Update description of -gnatef.
* gnat_ugn.texi: Regenerate.

2 years ago[Ada] Fix bad interaction between Inline_Always and -gnateV + -gnata
Eric Botcazou [Fri, 6 May 2022 20:48:04 +0000 (22:48 +0200)]
[Ada] Fix bad interaction between Inline_Always and -gnateV + -gnata

The combination of pragma/aspect Inline_Always and -gnateV -gnata runs
afoul of the handling of inlining across units by gigi, which does not
inline a subprogram that calls nested subprograms if these subprograms
are not themselves inlined.

This condition does not apply to internally generated subprograms but
the special _postconditions procedure has Debug_Info_Needed set so it
is not considered as such and, as a consequence, triggers an error if
the enclosing subprogram requires inlining by means of Inline_Always.

The _postconditions procedure is already marked inlined when generating
C code so it makes sense to mark it inlined in the general case as well.

gcc/ada/

* contracts.adb (Build_Postconditions_Procedure): Set Is_Inlined
unconditionnally on the procedure entity.

2 years ago[Ada] Propagate null-exclusion to anonymous access types
Piotr Trojanek [Fri, 6 May 2022 15:23:25 +0000 (17:23 +0200)]
[Ada] Propagate null-exclusion to anonymous access types

When analyzing an array or record type declaration whose component has a
constrained access type, e.g.:

   type Buffer_Acc is not null access all String;

   type Buffer_Rec is record
      Data : Buffer_Acc (1 .. 10);
   end record;

   type Buffer_Arr is array (Boolean) of Buffer_Acc (1 .. 10);

we propagated various properties of the unconstrained access type (e.g.
the designated type, access-to-constant flag), but forgot to propagate
the null-exclusion.

For GNAT it didn't make a big difference, because the (anonymous)
component type was never subject to legality checks. The "value
tracking" optimisation machinery, which also deals with null values,
only works for entire objects and doesn't care about components.
However, GNATprove uses this flag when an access-to-component object is
dereferenced.

gcc/ada/

* sem_ch3.adb (Constrain_Access): Propagate null-exclusion flag
from parent type.

2 years ago[Ada] Add a comment about a finalization issue
Eric Botcazou [Fri, 6 May 2022 14:56:41 +0000 (16:56 +0200)]
[Ada] Add a comment about a finalization issue

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Statement): Add a comment about
a finalization issue.

2 years ago[Ada] Get rid of secondary stack for controlled components of limited types
Eric Botcazou [Thu, 5 May 2022 16:08:50 +0000 (18:08 +0200)]
[Ada] Get rid of secondary stack for controlled components of limited types

The initial work didn't change anything for limited types because they use
a specific return mechanism for functions called build-in-place where there
is no anonymous return object, so the secondary stack was used only for the
sake of consistency with the nonlimited case.

This change aligns the limited case with the nonlimited case, i.e. either
they both use the primary stack or they both use the secondary stack.

gcc/ada/

* exp_ch6.adb (Caller_Known_Size): Call Returns_On_Secondary_Stack
instead of Requires_Transient_Scope and tidy up.
(Needs_BIP_Alloc_Form): Likewise.
* exp_util.adb (Initialized_By_Aliased_BIP_Func_Call): Also return
true if the build-in-place function call has no BIPalloc parameter.
(Is_Finalizable_Transient): Remove redundant test.

2 years ago[Ada] Note that hardening features are experimental
Alexandre Oliva [Thu, 5 May 2022 03:45:38 +0000 (00:45 -0300)]
[Ada] Note that hardening features are experimental

Some features haven't got customer feedback or made upstream yet.

gcc/ada/

* doc/gnat_rm/security_hardening_features.rst: Note that hardening
features are experimental.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Another case where freezing incorrectly suppresses checks
Steve Baird [Wed, 4 May 2022 23:23:40 +0000 (16:23 -0700)]
[Ada] Another case where freezing incorrectly suppresses checks

Avoid improperly suppressing checks for the wrapper subprogram that is
built when a null type extension inherits (and does not override) a
function with a controlling result. This is a follow-up to other changes
already made on this ticket.

gcc/ada/

* exp_ch3.adb (Make_Controlling_Function_Wrappers): Set the
Corresponding_Spec field of a wrapper subprogram body before
analyzing the subprogram body; the field will be set (again)
during analysis, but we need it to be set earlier.
* exp_ch13.adb (Expand_N_Freeze_Entity): Add wrapper subprogram
bodies to the list of declarations for which we do not want to
suppress checks.

2 years ago[Ada] Adjust reference in comment
Eric Botcazou [Thu, 5 May 2022 09:02:07 +0000 (11:02 +0200)]
[Ada] Adjust reference in comment

This is needed after the creation of Returns_On_Secondary_Stack from the
original Requires_Transient_Scope.

gcc/ada/

* sem_util.adb (Indirect_Temp_Needed): Adjust reference in comment.

2 years ago[Ada] QNX shared libraries - arm-qnx build gnatlib .so's
Doug Rupp [Fri, 29 Apr 2022 21:15:17 +0000 (14:15 -0700)]
[Ada] QNX shared libraries - arm-qnx build gnatlib .so's

Shared libraries now fully supported on arm-qnx.

gcc/ada/

* Makefile.rtl (GNATLIB_SHARED): Revert disablement for arm-qnx.

2 years ago[Ada] Fix composability of return on the secondary stack
Eric Botcazou [Wed, 4 May 2022 10:31:14 +0000 (12:31 +0200)]
[Ada] Fix composability of return on the secondary stack

Having components that need to be returned on the secondary stack would
not always force a record type to be returned on the secondary stack
itself.

gcc/ada/

* sem_util.adb
(Returns_On_Secondary_Stack.Caller_Known_Size_Record): Directly
check the dependence on discriminants for the variant part, if
any, instead of calling the Is_Definite_Subtype predicate.

2 years ago[Ada] Fix "formal parameter & is not referenced" not being properly tagged
Ghjuvan Lacambre [Wed, 4 May 2022 11:31:07 +0000 (13:31 +0200)]
[Ada] Fix "formal parameter & is not referenced" not being properly tagged

gcc/ada/

* sem_warn.adb (Warn_On_Unreferenced_Entity): Fix warning tag.

2 years ago[Ada] Adjust warning switches
Ghjuvan Lacambre [Tue, 3 May 2022 14:00:46 +0000 (16:00 +0200)]
[Ada] Adjust warning switches

This makes tagging more accurate.

gcc/ada/

* sem_warn.adb (Check_References): Adjust conditions under which
warning messages should be emitted and their tags as well.

2 years ago[Ada] Minor tweaks to dispatching support code
Eric Botcazou [Mon, 2 May 2022 08:07:38 +0000 (10:07 +0200)]
[Ada] Minor tweaks to dispatching support code

No functional changes.

gcc/ada/

* exp_disp.ads (Expand_Interface_Thunk): Change type of Prim.
* exp_disp.adb (Expand_Interface_Thunk): Declare Is_Predef_Op
earlier, do not initialize Iface_Formal, use No idiom and tweaks
comments.
(Register_Primitive): Declare L earlier and tweak comments.
* sem_disp.adb (Check_Dispatching_Operation): Move tests out of
loop.

2 years ago[Ada] Missing discriminant checks when accessing variant field
Steve Baird [Fri, 29 Apr 2022 21:55:38 +0000 (14:55 -0700)]
[Ada] Missing discriminant checks when accessing variant field

In some cases, the compiler would incorrectly fail to generate
discriminant checks when accessing fields declared in a variant part.
Correct some such cases; detect the remaining cases and flag them as
unsupported. The formerly-problematic cases that are now handled
correctly involve component references occurring in a predicate
expression (e.g., the expression of a Dynamic_Predicate aspect
specification) for a type declaration (not for a subtype declaration).
The cases which are now flagged as unsupported involve expression
functions declared before the discriminated type in question has been
frozen.

gcc/ada/

* exp_ch3.ads: Replace visible Build_Discr_Checking_Funcs (which
did not need to be visible - it was not referenced outside this
package) with Build_Or_Copy_Discr_Checking_Funcs.
* exp_ch3.adb: Refactor existing code into 3 procedures -
Build_Discr_Checking_Funcs, Copy_Discr_Checking_Funcs, and
Build_Or_Copy_Discr_Checking_Funcs. This refactoring is intended
to be semantics-preserving.
* exp_ch4.adb (Expand_N_Selected_Component): Detect case where a
call should be generated to the Discriminant_Checking_Func for
the component in question, but that subprogram does not yet
exist.
* sem_ch13.adb (Freeze_Entity_Checks): Immediately before
calling Build_Predicate_Function, add a call to
Exp_Ch3.Build_Or_Copy_Discr_Checking_Funcs in order to ensure
that Discriminant_Checking_Func attributes are already set when
Build_Predicate_Function is called.
* sem_ch6.adb (Analyze_Expression_Function): If the expression
of a static expression function has been transformed into an
N_Raise_xxx_Error node, then we need to copy the original
expression in order to check the requirement that the expression
must be a potentially static expression. We also want to set
aside a copy the untransformed expression for later use in
checking calls to the expression function via
Inline_Static_Function_Call.  So introduce a new function,
Make_Expr_Copy, for use in these situations.
* sem_res.adb (Preanalyze_And_Resolve): When analyzing certain
expressions (e.g., a default parameter expression in a
subprogram declaration) we want to suppress checks. However, we
do not want to suppress checks for the expression of an
expression function.

2 years ago[Ada] Fix search for "for ... of" loop subprograms
Bob Duff [Mon, 2 May 2022 18:11:03 +0000 (14:11 -0400)]
[Ada] Fix search for "for ... of" loop subprograms

This patch makes the search for Get_Element_Access, Step (Next/Prev),
Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of"
loops) more robust.  In particular, we have a new Next procedure in Ada
2022, and we need to pick the right one.

We have not yet added the new Next and other subprograms.

gcc/ada/

* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): For each
subprogram found, assert that the variable is Empty, so we can
detect bugs where we find two or more things with the same name.
Without this patch, that bug would happen when we add the new
Next procedure.  For Step, make sure we pick the right one, by
checking name and number of parameters.  For Get_Element_Access,
check that we're picking a function.  That's not really
necessary, because there is no procedure with that name, but it
seems cleaner this way.
* rtsfind.ads: Minor comment improvement. It seems kind of odd
to say "under no circumstances", and then immediately contradict
that with "The one exception is...".

2 years ago[Ada] arm-qnx-7.1: unwind goes wrong after regs restore
Doug Rupp [Thu, 14 Apr 2022 17:59:37 +0000 (10:59 -0700)]
[Ada] arm-qnx-7.1: unwind goes wrong after regs restore

The usual increment of the pc to pc+2 for ARM is needed.

gcc/ada/

* init.c (QNX): __gnat_adjust_context_for_raise: New
implementation for arm-qnx.

2 years ago[Ada] Add reference counting in functional containers
Julien Bortolussi [Thu, 21 Apr 2022 09:11:26 +0000 (11:11 +0200)]
[Ada] Add reference counting in functional containers

This patch adds reference counting to dynamically allocated pointers
on arrays and elements used by the functional container. This is done
by making both the arrays and the elements controlled.

gcc/ada/

* libgnat/a-cofuba.ads, libgnat/a-cofuba.adb: Add reference
counting.

2 years ago[Ada] Issue a warning on entity hidden in use_clause with -gnatwh
Yannick Moy [Thu, 14 Apr 2022 06:38:29 +0000 (08:38 +0200)]
[Ada] Issue a warning on entity hidden in use_clause with -gnatwh

Augment the warnings issued with switch -gnatwh, so that a warning is
also issued when an entity from the package of a use_clause ends up
hidden due to an existing visible homonym.

gcc/ada/

* sem_ch8.adb (Use_One_Package): Possibly warn.
* sem_util.adb (Enter_Name): Factor out warning on hidden entity.
(Warn_On_Hiding_Entity): Extract warning logic from Enter_Name and
generalize it to be applied also on use_clause.
* sem_util.ads (Warn_On_Hiding_Entity): Add new procedure.

2 years ago[Ada] Issue better error message for out-of-order keywords in record def
Yannick Moy [Wed, 27 Apr 2022 07:52:55 +0000 (09:52 +0200)]
[Ada] Issue better error message for out-of-order keywords in record def

Various cases of out-of-order keywords in the definition of a record
were already detected. This adds a similar detection after NULL and
RECORD keywords.

gcc/ada/

* par-ch3.adb (P_Known_Discriminant_Part_Opt): Reword error
message to benefit from existing codefix.
(P_Record_Definition): Detect out-of-order keywords in record
definition and issue appropriate messages. Other cases are
already caught at appropriate places.

2 years ago[Ada] Use Actions field of freeze nodes for subprograms (continued)
Eric Botcazou [Mon, 2 May 2022 08:57:46 +0000 (10:57 +0200)]
[Ada] Use Actions field of freeze nodes for subprograms (continued)

This case was missed in the previous change.

gcc/ada/

* exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Put
the actions into the Actions field of the freeze node instead of
inserting them after it.

2 years ago[Ada] Add inline documentation for Is_{Parenthesis,Enum_Array}_Aggregate
Marc Poulhiès [Thu, 21 Apr 2022 09:10:22 +0000 (11:10 +0200)]
[Ada] Add inline documentation for Is_{Parenthesis,Enum_Array}_Aggregate

Both flags were added when square brackets for array/container
aggregates have been enabled with -gnat2022 without their corresponding
inline documentation. This change adds the missing documention.

gcc/ada/

* sinfo.ads: Add inline documention for Is_Parenthesis_Aggregate
and Is_Enum_Array_Aggregate.

2 years ago[Ada] Incorrect code for anonymous access-to-function with convention C
Bob Duff [Thu, 28 Apr 2022 14:22:42 +0000 (10:22 -0400)]
[Ada] Incorrect code for anonymous access-to-function with convention C

This patch fixes a bug where the compiler generates incorrect code for a
call via an object with convention C, whose type is an anonymous
access-to-function type.

gcc/ada/

* einfo-utils.adb (Set_Convention): Call Set_Convention
recursively, so that Set_Can_Use_Internal_Rep is called (if
appropriate) on the anonymous access type of the object, and its
designated subprogram type.
* sem_ch3.adb (Access_Definition): Remove redundant call to
Set_Can_Use_Internal_Rep.

2 years ago[Ada] Suppress warnings on membership test of ranges
Bob Duff [Fri, 29 Apr 2022 12:08:58 +0000 (08:08 -0400)]
[Ada] Suppress warnings on membership test of ranges

For a membership test "X in A .. B", the compiler used to warn if it
could prove that X is within one of the bounds.  For example, if we know
at compile time that X >= A, then the above could be replaced by "X <=
B".

This patch suppresses that warning, because there is really
nothing wrong with the membership test, and programmers sometimes
find it annoying.

gcc/ada/

* exp_ch4.adb (Expand_N_In): Do not warn in the above-mentioned
cases.
* fe.h (Assume_No_Invalid_Values): Remove from fe.h, because
this is not used in gigi.
* opt.ads (Assume_No_Invalid_Values): Improve the comment. We
don't need to "clearly prove"; we can just "prove". Remove the
comment about fe.h, which is no longer true.

2 years agotree-optimization/105763 - avoid abnormals with ranger queries
Richard Biener [Mon, 30 May 2022 11:19:38 +0000 (13:19 +0200)]
tree-optimization/105763 - avoid abnormals with ranger queries

In unswitching we use ranger to simplify switch statements so we
have to avoid doing anything for abnormals.

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

PR tree-optimization/105763
* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
Check gimple_range_ssa_p.

* gcc.dg/pr105763.c: New testcase.

2 years agoDaily bump.
GCC Administrator [Wed, 1 Jun 2022 00:16:34 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: non-dep call with empty TYPE_BINFO [PR105758]
Patrick Palka [Tue, 31 May 2022 20:49:08 +0000 (16:49 -0400)]
c++: non-dep call with empty TYPE_BINFO [PR105758]

Here the out-of-line definition of Z<T>::z causes duplicate_decls to
change z's type from using the primary template type Z<T> (which is also
the type of the injected class name) to the implicit instantiation Z<T>,
and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
set by a special case in lookup_template_class to point to the former).

Later, when processing the non-dependent call z->foo(0), build_over_call
relies on the object argument's TYPE_BINFO to build the templated form
for this call, which fails because the object argument type has empty
TYPE_BINFO due to the above.

It seems weird that the implicit instantiation Z<T> doesn't have the
same TYPE_BINFO as the primary template type Z<T>, despite them being
proclaimed equivalent via TYPE_CANONICAL.  So I tried also setting
TYPE_BINFO in the special case in lookup_template_class, but that led to
some problems with constrained partial specializations of the form Z<T>.
I'm not sure what, if anything, we ought to do about the subtle
differences between these two versions of the same type.

Fortunately it seems we don't need to rely on TYPE_BINFO at all in
build_over_call here -- the z_candidate struct already contains the
exact binfos we need to rebuild the BASELINK for the templated form.

PR c++/105758

gcc/cp/ChangeLog:

* call.cc (build_over_call): Use z_candidate::conversion_path
and ::access_path instead of TYPE_BINFO when building the
BASELINK for the templated form.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent24.C: New test.

2 years agoc++: use auto_timevar instead of timevar_push/pop
Patrick Palka [Tue, 31 May 2022 20:48:59 +0000 (16:48 -0400)]
c++: use auto_timevar instead of timevar_push/pop

r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with
auto_cond_timevar and removed now unnecessary wrapper functions.  This
patch does the same with timevar_push/pop and auto_timevar.

gcc/cp/ChangeLog:

* parser.cc: Use auto_timevar instead of timevar_push/pop.
Remove wrapper functions.
* pt.cc: Likewise.

2 years agoc++: squash cp_build_qualified_type/_real
Patrick Palka [Tue, 31 May 2022 20:48:56 +0000 (16:48 -0400)]
c++: squash cp_build_qualified_type/_real

This combines the two differently named versions of the same function
into a single function utilizing a default argument.

gcc/cp/ChangeLog:

* cp-tree.h (cp_build_qualified_type_real): Rename to ...
(cp_build_qualified_type): ... this.  Give its last parameter
a default argument.  Remove macro of the same name.
* decl.cc (grokdeclarator): Adjust accordingly.
* pt.cc (tsubst_aggr_type): Likewise.
(rebuild_function_or_method_type): Likewise.
(tsubst): Likewise.
(maybe_dependent_member_ref): Likewise.
(unify): Likewise.
* tree.cc (cp_build_qualified_type_real): Rename to ...
(cp_build_qualified_type): ... this.  Adjust accordingly.

2 years agobuild: TAGS and .cc transition
Jason Merrill [Fri, 27 May 2022 16:15:36 +0000 (12:15 -0400)]
build: TAGS and .cc transition

A few globs missed in the .c -> .cc transition.  Some targets were looking
at both *.c and *.cc, but there are no longer any .c files to scan.

gcc/ChangeLog:

* Makefile.in (TAGS): Look at libcpp/*.cc.

gcc/c/ChangeLog:

* Make-lang.in (c.tags): Look at *.cc.

gcc/cp/ChangeLog:

* Make-lang.in (c++.tags): Just look at *.cc.

gcc/d/ChangeLog:

* Make-lang.in (d.tags): Just look at *.cc.

gcc/fortran/ChangeLog:

* Make-lang.in (fortran.tags): Look at *.cc.

gcc/go/ChangeLog:

* Make-lang.in (go.tags): Look at *.cc.

gcc/objc/ChangeLog:

* Make-lang.in (objc.tags): Look at *.cc.

gcc/objcp/ChangeLog:

* Make-lang.in (obj-c++.tags): Look at *.cc.

2 years agod: Fix D lexer sometimes fails to compile code read from stdin
Iain Buclaw [Tue, 31 May 2022 12:45:02 +0000 (14:45 +0200)]
d: Fix D lexer sometimes fails to compile code read from stdin

As of gdc-12, the lexer expects there 4 bytes of zero padding at the end
of the source buffer to mark the end of input.  Sometimes when reading
from stdin, the data at the end of input is garbage rather than zeroes.
Fix that by explicitly calling memset past the end of the buffer.

PR d/105544

gcc/d/ChangeLog:

* d-lang.cc (d_parse_file): Zero padding past the end of the stdin
buffer so the D lexer has a sentinel to stop parsing at.

2 years agoaarch64: Fix build with gcc-4.8
Christophe Lyon [Tue, 31 May 2022 15:11:47 +0000 (16:11 +0100)]
aarch64: Fix build with gcc-4.8

My r13-680-g0dc8e1e7026d9b commit to add support for Decimal Floating
Point introduced:
      case SDmode:
      case DDmode:
      case TDmode:
which are rejected by gcc-4.8 as build compiler.

This patch replaces them with E_SDmode, E_DDmode and E_TD_mode.

Committed as obvious.

* config/aarch64/aarch64.cc (aarch64_gimplify_va_arg_expr):
Prefix mode names with E_.

2 years agoCorrect spelling of DW_AT_namelist_item
Alan Modra [Tue, 31 May 2022 06:13:36 +0000 (15:43 +0930)]
Correct spelling of DW_AT_namelist_item

include/
* dwarf2.def: Correct spelling of DW_AT_namelist_item.
gcc/
* dwarf2out.cc (gen_namelist_decl): Adjust to suit correct
spelling of DW_AT_namelist_item.

2 years agoc++: document comp_template_args's default args
Patrick Palka [Tue, 31 May 2022 12:17:27 +0000 (08:17 -0400)]
c++: document comp_template_args's default args

In passing, use bool for its return type.

gcc/cp/ChangeLog:

* cp-tree.h (comp_template_args): Change return type to bool.
* pt.cc (comp_template_args): Document default arguments.
Change return type to bool and adjust returns accordingly.

2 years agoc++: use current_template_constraints more
Patrick Palka [Tue, 31 May 2022 12:17:21 +0000 (08:17 -0400)]
c++: use current_template_constraints more

gcc/cp/ChangeLog:

* decl.cc (grokvardecl): Use current_template_constraints.
(grokdeclarator): Likewise.
(xref_tag): Likewise.
* semantics.cc (finish_template_template_parm): Likewise.

2 years agoopenmp: Add support for firstprivate and allocate clauses on scope construct
Jakub Jelinek [Tue, 31 May 2022 09:41:52 +0000 (11:41 +0200)]
openmp: Add support for firstprivate and allocate clauses on scope construct

OpenMP 5.2 adds support for firstprivate and allocate clauses on the scope
construct and this patch adds that support to GCC.
5.2 unfortunately (IMNSHO mistakenly) marked scope construct as worksharing,
which implies that it isn't possible to nest inside of it other scope,
worksharing loop, sections, explicit barriers, single etc. which would
make scope far less useful.  I'm not implementing that part, keeping the
5.1 behavior here, and will file an issue to revert that for OpenMP 6.0.
But, for firstprivate it keeps the restriction that is now implied from
worksharing construct that listed var can't be private in outer context,
where for reduction 5.1 had similar restriction explicit even for scope
and 5.2 has it implicitly through worksharing construct.

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

gcc/
* omp-low.cc (build_outer_var_ref): For code == OMP_CLAUSE_ALLOCATE
allow var to be private in the outer context.
(lower_private_allocate): Pass OMP_CLAUSE_ALLOCATE as last argument
to build_outer_var_ref.
gcc/c/
* c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
clauses.
gcc/cp/
* parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
clauses.
gcc/testsuite/
* c-c++-common/gomp/scope-5.c: New test.
* c-c++-common/gomp/scope-6.c: New test.
* g++.dg/gomp/attrs-1.C (bar): Add firstprivate and allocate clauses
to scope construct.
* g++.dg/gomp/attrs-2.C (bar): Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add testcase for
scope construct with allocate clause.
* testsuite/libgomp.c-c++-common/allocate-3.c (foo): Likewise.
* testsuite/libgomp.c-c++-common/scope-2.c: New test.

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

2 years agoc++: Add !TYPE_P assert to type_dependent_expression_p [PR99080]
Marek Polacek [Sat, 14 May 2022 00:09:53 +0000 (20:09 -0400)]
c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080]

As discussed here:
<https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564629.html>,
type_dependent_expression_p should not be called with a type argument.

I promised I'd add an assert so here it is.  One place needed adjusting.

PR c++/99080

gcc/cp/ChangeLog:

* pt.cc (type_dependent_expression_p): Assert !TYPE_P.
* semantics.cc (finish_id_expression_1): Handle UNBOUND_CLASS_TEMPLATE
specifically.

2 years agoAllow SCmode and DImode to be tieable with TARGET_64BIT on x86_64.
Roger Sayle [Mon, 30 May 2022 20:32:58 +0000 (21:32 +0100)]
Allow SCmode and DImode to be tieable with TARGET_64BIT on x86_64.

This patch is a form of insurance policy in case my patch for PR 7061 runs
into problems on non-x86 targets; the middle-end can add an extra check
that the backend is happy placing SCmode and DImode values in the same
register, before creating a SUBREG.  Unfortunately, ix86_modes_tieable_p
currently claims this is not allowed(?), even though the default target
hook for modes_tieable_p is to always return true [i.e. false can be
used to specifically prohibit bad combinations], and the x86_64 ABI
passes SCmode values in DImode registers!.  This makes the backend's
modes_tiable_p hook a little more forgiving, and additionally enables
interconversion between SCmode and V2SFmode, and between DCmode and
VD2Fmode, which opens interesting opporutunities in the future.

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

gcc/ChangeLog
* config/i386/i386.cc (ix86_modes_tieable_p): Allow SCmode to be
tieable with DImode on TARGET_64BIT, and SCmode tieable with
V2SFmode, and DCmode with V2DFmode.

2 years agoFortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300]
Harald Anlauf [Sat, 28 May 2022 20:02:20 +0000 (22:02 +0200)]
Fortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300]

ALLOCATE: generate different STAT,ERRMSG results for failures from
allocation of already allocated objects or insufficient virtual memory.

gcc/fortran/ChangeLog:

PR fortran/91300
* libgfortran.h: Define new error code LIBERROR_NO_MEMORY.
* trans-stmt.cc (gfc_trans_allocate): Generate code for setting
ERRMSG depending on result of STAT result of ALLOCATE.
* trans.cc (gfc_allocate_using_malloc): Use STAT value of
LIBERROR_NO_MEMORY in case of failed malloc.

gcc/testsuite/ChangeLog:

PR fortran/91300
* gfortran.dg/allocate_alloc_opt_15.f90: New test.

2 years agoPR rtl-optimization/101617: Use neg/sbb in ix86_expand_int_movcc.
Roger Sayle [Mon, 30 May 2022 20:26:37 +0000 (21:26 +0100)]
PR rtl-optimization/101617: Use neg/sbb in ix86_expand_int_movcc.

This patch resolves PR rtl-optimization/101617 where we should generate
the exact same code for (X ? -1 : 1) as we do for ((X ? -1 : 0) | 1).
The cause of the current difference on x86_64 is actually in
ix86_expand_int_movcc that doesn't know that negl;sbbl can be used
to create a -1/0 result depending on whether the input is zero/nonzero.

So for Andrew Pinski's test case:

int f1(int i)
{
  return i ? -1 : 1;
}

GCC currently generates:

f1:     cmpl    $1, %edi
        sbbl    %eax, %eax // x ? 0 : -1
        andl    $2, %eax // x ? 0 : 2
        subl    $1, %eax // x ? -1 : 1
        ret

but with the attached patch, now generates:

f1: negl    %edi
        sbbl    %eax, %eax // x ? -1 : 0
        orl     $1, %eax // x ? -1 : 1
        ret

To implement this I needed to add two expanders to i386.md to generate
the required instructions (in both SImode and DImode) matching the
pre-existing define_insns of the same name.

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

gcc/ChangeLog
PR rtl-optimization/101617
* config/i386/i386-expand.cc (ix86_expand_int_movcc): Add a
special case (indicated by negate_cc_compare_p) to generate a
-1/0 mask using neg;sbb.
* config/i386/i386.md (x86_neg<mode>_ccc): New define_expand
to generate an *x86_neg<mode>_ccc instruction.
(x86_mov<mode>cc_0_m1_neg): Likewise, a new define_expand to
generate a *x86_mov<mode>cc_0_m1_neg instruction.

gcc/testsuite/ChangeLog
PR rtl-optimization/101617
* gcc.target/i386/pr101617.c: New test case.

2 years agoMake the default rtx_costs of MULT/DIV variants consistent.
Roger Sayle [Mon, 30 May 2022 20:23:15 +0000 (21:23 +0100)]
Make the default rtx_costs of MULT/DIV variants consistent.

GCC's middle-end provides a default cost model for RTL expressions, for
backends that don't specify their own instruction timings, that can be
summarized as multiplications are COSTS_N_INSNS(4), divisions are
COSTS_N_INSNS(7) and all other operations are COSTS_N_INSNS(1).
This patch tweaks the above definition so that fused-multiply-add
(FMA) and high-part multiplications cost the same as regular multiplications,
or more importantly aren't (by default) considered less expensive.  Likewise
the saturating forms of multiplication and division cost the same as the
regular variants.  These values can always be changed by the target, but
the goal is to avoid RTL expansion substituting a suitable operation with
its saturating equivalent because it (accidentally) looks much cheaper.
For example, PR 89845 is about implementing division/modulus via highpart
multiply, which may accidentally look extremely cheap.

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

gcc/ChangeLog
* rtlanal.cc (rtx_cost) <MULT>: Treat FMA, SS_MULT, US_MULT,
SMUL_HIGHPART and UMUL_HIGHPART as having the same cost as MULT.
<DIV>: Likewise, SS_DIV and US_DIV have the same default as DIV.

2 years agoPR target/70321: Split double word equality/inequality after STV on x86.
Roger Sayle [Mon, 30 May 2022 20:20:09 +0000 (21:20 +0100)]
PR target/70321: Split double word equality/inequality after STV on x86.

This patch resolves the last piece of PR target/70321 a code quality
(P2 regression) affecting mainline.  Currently, for HJ's testcase:

void foo (long long ixi)
{
  if (ixi != 14348907)
    __builtin_abort ();
}

GCC with -m32 -O2 generates four instructions for the comparison:

        movl    16(%esp), %eax
        movl    20(%esp), %edx
        xorl    $14348907, %eax
        orl     %eax, %edx

but with this patch it now requires only three, making better use of
x86's addressing modes:

        movl    16(%esp), %eax
        xorl    $14348907, %eax
        orl     20(%esp), %eax

The solution is to expand "doubleword" equality/inequality expressions
using flag setting COMPARE instructions for the early RTL passes, and
then split them during split1, after STV and before reload.
Hence on x86_64, we now see/allow things like:

(insn 11 8 12 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg/v:TI 84 [ x ])
            (reg:TI 96))) "cmpti.c":2:43 30 {*cmpti_doubleword}

This allows the STV pass to decide whether it's preferrable to perform
this comparison using vector operations, i.e. a pxor/ptest sequence,
or as scalar integer operations, i.e. a xor/xor/or sequence.  Alas
this required tweaking of the STV pass to recognize the "new" form of
these comparisons and split out the pxor operation itself.  To confirm
this still works as expected I've added a new STV test case:

long long a[1024];
long long b[1024];

int foo()
{
  for (int i=0; i<1024; i++)
  {
    long long t = (a[i]<<8) | (b[i]<<24);
    if (t == 0)
      return 1;
  }
  return 0;
}

where with -m32 -O2 -msse4.1 the above comparison with zero should look
like:

        punpcklqdq      %xmm0, %xmm0
        ptest   %xmm0, %xmm0

Although this patch includes one or two minor tweaks to provide all the
necessary infrastructure to support conversion of TImode comparisons to
V1TImode (and SImode comparisons to V4SImode), STV doesn't yet implement
these transformations, but this is something that can be considered after
stage 4.  Indeed the new convert_compare functionality is split out
into a method to simplify its potential reuse by the timode_scalar_chain
class.

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

gcc/ChangeLog
PR target/70321
* config/i386/i386-expand.cc (ix86_expand_branch): Don't decompose
DI mode equality/inequality using XOR here.  Instead generate a
COMPARE for doubleword modes (DImode on !TARGET_64BIT or TImode).
* config/i386/i386-features.cc (gen_gpr_to_xmm_move_src): Use
gen_rtx_SUBREG when NUNITS is 1, i.e. for TImode to V1TImode.
(general_scalar_chain::convert_compare): New function to convert
scalar equality/inequality comparison into vector operations.
(general_scalar_chain::convert_insn) [COMPARE]: Refactor. Call
new convert_compare helper method.
(convertible_comparion_p): Update to match doubleword COMPARE
of two register, memory or integer constant operands.
* config/i386/i386-features.h (general_scalar_chain::convert_compare):
Prototype/declare member function here.
* config/i386/i386.md (cstore<mode>4): Change mode to SDWIM, but
only allow new doubleword modes for EQ and NE operators.
(*cmp<dwi>_doubleword): New define_insn_and_split, to split a
doubleword comparison into a pair of XORs followed by an IOR to
set the (zero) flags register, optimizing the XORs if possible.
* config/i386/sse.md (V_AVX): Include V1TI and V2TI in mode
iterator; V_AVX is (currently) only used by ptest.
(sse4_1 mode attribute): Update to support V1TI and V2TI.

gcc/testsuite/ChangeLog
PR target/70321
* gcc.target/i386/pr70321.c: New test case.
* gcc.target/i386/sse4_1-stv-1.c: New test case.

2 years agoi386: Remove constraints when used with constant integer predicates, take 2
Uros Bizjak [Mon, 30 May 2022 19:38:16 +0000 (21:38 +0200)]
i386: Remove constraints when used with constant integer predicates, take 2

const_int_operand and other const*_operand predicates do not need
constraints when the constraint is inherited from the range of
constant integer predicate.  Remove the constraint in case all
alternatives use the same inherited constraint.

However, when there are operands, commitative with a non-constant
operand, the operand effectively matches e.g.
nonimmediate_operand|const_int_operand rather than just
const_int_operand.  We should keep the constraint for
const_int_operand that are in a % pair. See PR 105624.

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

gcc/ChangeLog:

* 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:

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

2 years agox86: correct bmi2_umul<mode><dwi>3_1's MEM_P() uses
Jan Beulich [Mon, 30 May 2022 09:29:59 +0000 (11:29 +0200)]
x86: correct bmi2_umul<mode><dwi>3_1's MEM_P() uses

It's pretty clear that the operand numbers in the MEM_P() checks are
off by one, perhaps due to a copy-and-paste oversight (unlike in most
other places here we're dealing with two outputs).

gcc/

* config/i386/i386.md (bmi2_umul<mode><dwi>3_1): Correct MEM_P()
arguments.

2 years ago[Ada] Fix spurious options being inserted in -fdiagnostics-format=json output
Ghjuvan Lacambre [Fri, 29 Apr 2022 14:53:05 +0000 (16:53 +0200)]
[Ada] Fix spurious options being inserted in -fdiagnostics-format=json output

Without this patch, gnat would use `-gnatw?` as the default option for
some of the default warnings.

gcc/ada/

* erroutc.adb (Get_Warning_Option): Don't consider `?` as a
valid option switch.

2 years ago[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output
Ghjuvan Lacambre [Wed, 27 Apr 2022 13:01:28 +0000 (15:01 +0200)]
[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output

This enables better integration with tools that handle GNAT's output.

gcc/ada/

* erroutc.ads (Get_Warning_Option): New function returning the
option responsible for a warning if it exists.
* erroutc.adb (Get_Warning_Option): Likewise.
(Get_Warning_Tag): Rely on Get_Warning_Option when possible.
* errout.adb (Output_JSON_Message): Emit option field.

2 years ago[Ada] Remove contract duplication in formal doubly linked lists
Julien Bortolussi [Mon, 25 Apr 2022 08:53:15 +0000 (10:53 +0200)]
[Ada] Remove contract duplication in formal doubly linked lists

Remove a minor duplication in Post of a function of formal doubly linked
lists.

gcc/ada/

* libgnat/a-cfdlli.ads (Insert): Remove the duplication.

2 years ago[Ada] Fix expansion of structural subprogram variants
Piotr Trojanek [Wed, 27 Apr 2022 15:30:59 +0000 (17:30 +0200)]
[Ada] Fix expansion of structural subprogram variants

When implementing structural subprogram variants we ignored them in
expansion of the pragma itself, but not in expansion of a recursive
subprogram call. Now fixed.

gcc/ada/

* exp_ch6.adb (Check_Subprogram_Variant): Ignore structural
variants.

2 years ago[Ada] Simplify construction of a path to file
Piotr Trojanek [Fri, 25 Mar 2022 23:11:35 +0000 (00:11 +0100)]
[Ada] Simplify construction of a path to file

Code cleanup; semantics is unaffected.

gcc/ada/

* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.

2 years ago[Ada] Remove repeated description of support for Address clauses
Piotr Trojanek [Fri, 8 Apr 2022 21:27:24 +0000 (23:27 +0200)]
[Ada] Remove repeated description of support for Address clauses

The GNAT behaviour regarding the Ada RM requirement to support Address
clauses for imported subprograms was documented twice: in section about
packed types (which was a mistake) and in section about address clauses
(where it belongs).

Cleanup related to the use of packed arrays for bitset operations to
detect uses of uninitialized scalars in GNAT.

gcc/ada/

* doc/gnat_rm/implementation_advice.rst (Packed Types): Remove
duplicated and wrongly placed paragraph.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Add insertion character to Ineffective_Inline_Warnings messages
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:55:04 +0000 (09:55 +0200)]
[Ada] Add insertion character to Ineffective_Inline_Warnings messages

This enables tools that ingest GNAT's output to properly classify these
messages.

gcc/ada/

* inline.adb (Check_Package_Body_For_Inlining): Add insertion
character.

2 years ago[Ada] Add insertion character for overlay modification warnings
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:50:24 +0000 (09:50 +0200)]
[Ada] Add insertion character for overlay modification warnings

This enables tools that ingest GNAT's output to properly classify these
messages.

gcc/ada/

* freeze.adb (Warn_Overlay): Add 'o' insertion character.
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Likewise.
* sem_util.adb (Note_Possible_Modifications): Likewise.

2 years ago[Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:32:59 +0000 (09:32 +0200)]
[Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged

This caused tools ingesting GNAT's output to mislabel these messages.

gcc/ada/

* sem_warn.adb (Warn_On_Useless_Assignment): Fix insertion
character.

2 years ago[Ada] Fix Warn_On_Late_Primitives messages not being properly tagged
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:25:52 +0000 (09:25 +0200)]
[Ada] Fix Warn_On_Late_Primitives messages not being properly tagged

This caused tools ingesting GNAT's output to mislabel these messages.

gcc/ada/

* sem_disp.adb (Warn_On_Late_Primitive_After_Private_Extension):
Fix insertion character.

2 years ago[Ada] Fix -gnatw.f warnings not having the right insertion characters
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:21:01 +0000 (09:21 +0200)]
[Ada] Fix -gnatw.f warnings not having the right insertion characters

This caused these warnings not to be tagged with the switch causing
them, which is an issue for tools ingesting GNAT's output.

gcc/ada/

* sem_elab.adb (Process_Conditional_ABE_Access_Taken): Add '.f'
insertion characters.

2 years ago[Ada] Deconstruct deferred references
Piotr Trojanek [Tue, 26 Apr 2022 13:21:00 +0000 (15:21 +0200)]
[Ada] Deconstruct deferred references

While cleaning up and modifying code for unreferenced warnings we
removed all calls to Defer_Reference, which was the only routine that
populated the Deferred_References table. Consequently, all the code
related to this table became dead.

gcc/ada/

* lib-xref.ads (Deferred_Reference_Entry, Defer_Reference,
Process_Deferred_References, Has_Deferred_Reference): Remove
client API.
* lib-xref.adb (Deferred_References, Defer_Reference,
Has_Deferred_Reference, Process_Deferred_References): Remove
implementation.
* frontend.adb, sem_ch11.adb, sem_ch5.adb, sem_res.adb,
sem_util.adb, sem_warn.adb: Remove uses of Deferred_References.

2 years ago[Ada] Avoid creating a finalization wrapper block for functions
Bob Duff [Tue, 26 Apr 2022 11:16:20 +0000 (07:16 -0400)]
[Ada] Avoid creating a finalization wrapper block for functions

This patch fixes a bug whereby if a function body has local objects that
are finalizable, and has a return statement that requires generation of
transient finalizable temps, and there are dynamic-sized objects
requiring pushing/popping the (primary) stack at run time, and the
function body has exception handlers, then incorrect code is
generated. In particular, the transient objects are finalized after they
have been deallocated. This can cause seg faults, corrupted heap, and
the like.

Note that if there are no dynamic-sized objects, then the bug does
not occur, because the back end allocates objects of compile-time-known
size based on where they are referenced, rather than which local
block they are declared in.

This patch relies on the fact that an At_End handler and regular
exception handlers CAN coexist in the same handled statement sequence,
which was not true some years ago.

gcc/ada/

* exp_ch7.adb (Wrap_HSS_In_Block): Do not create a new block in
the case of function bodies. We include all subprogram bodies,
because it's harmless for procedures. We cannot easily avoid
creating this block in ALL cases, because some transformations
of (e.g.) task bodies end up moving some code such that the
wrong exception handlers apply to that code.
(Build_Finalizer_Call): Remove code for creating a new block.
This was unreachable code, given that Wrap_HSS_In_Block has
already done that, but with the above change to
Wrap_HSS_In_Block, this code becomes reachable, and triggers
essentially the same bug.
* exp_ch7.ads: Adjust comment.

2 years ago[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
Justin Squirek [Thu, 21 Apr 2022 20:35:20 +0000 (20:35 +0000)]
[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects

This patch corrects an error in the compiler whereby spurious
unreferenced warnings are generated on formal parameters of null generic
subprograms.

These changes also fix the parsing of aspects on formal parameters such
that the aspects now get properly set for all formal parameters in a
parameter list.

gcc/ada/

* par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
formals instead of just the last in a formal id list.
* sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
generic procedures as trivial in order to avoid spurious
unreferenced warnings.

2 years ago[Ada] Fix illegal Ada in s-dwalin.adb
Romain Beguet [Mon, 25 Apr 2022 13:57:25 +0000 (15:57 +0200)]
[Ada] Fix illegal Ada in s-dwalin.adb

Both the `System.Mmap` and `System.Object_Reader` packages are defining
entities named `Offset` and they are both `use`d at the top of
s-dwalin.adb.

Therefore, the references to `Offset` throughout this file are
ambiguous, and GNAT is supposed to complain. Since it does not for the
moment, we fix the ambiguity by declaring a subtype `Offset` at the top
of the file simply renames `System.Object_Reader.Offset`.

gcc/ada/

* libgnat/s-dwalin.adb: Add a subtype declaration to fix the
ambiguity.

2 years ago[Ada] Incorrect determination of whether an expression is predicate-static
Steve Baird [Wed, 20 Apr 2022 21:48:11 +0000 (14:48 -0700)]
[Ada] Incorrect determination of whether an expression is predicate-static

The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.

gcc/ada/

* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
about subexpressions of enclosing expressions. Generate warnings
for predicates that are known to be always true or always false,
except in the case where the predicate is expressed as a Boolean
literal. Deal with non-predicate-static expressions that have
been transformed into predicate-static expressions.  Add missing
Is_Type_Ref call to N_Membership_Test case.

2 years ago[Ada] Fix expansion of aggregate for discriminated limited extension
Eric Botcazou [Sat, 23 Apr 2022 10:28:28 +0000 (12:28 +0200)]
[Ada] Fix expansion of aggregate for discriminated limited extension

The presence of the discriminants prevents the values associated with the
components of the parent type from being put into the sub-aggregate built
for the _Parent component.

gcc/ada/

* exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
Skip the discriminants at the start of the component list before
looking for the components inherited from the parent in the case
of a tagged extension.

2 years ago[Ada] Do not freeze specifically for dispatch tables
Eric Botcazou [Fri, 22 Apr 2022 23:09:39 +0000 (01:09 +0200)]
[Ada] Do not freeze specifically for dispatch tables

The left-overs of the old freezing code in Make_DT are now redundant since
the semantic analyzer performs the same task for the 'Access attribute.

gcc/ada/

* exp_disp.adb (Make_DT): Remove remaining freezing code.

2 years ago[Ada] Do not analyze expression functions for dispatch tables
Eric Botcazou [Fri, 22 Apr 2022 20:27:22 +0000 (22:27 +0200)]
[Ada] Do not analyze expression functions for dispatch tables

There is no need to analyze expression functions that are primitives of a
tagged type for its dispatch table because they will be analyzed at the end
of the current scope.

gcc/ada/

* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Don't analyze
the body of an expression function in the case of a dispatch table.

2 years ago[Ada] Introduce Opt.CCG_Mode
Arnaud Charlet [Fri, 22 Apr 2022 08:32:37 +0000 (08:32 +0000)]
[Ada] Introduce Opt.CCG_Mode

To handle code common to the old and the new CCG code generator.

gcc/ada/

* gnat1drv.adb, opt.ads, sem_ch7.adb: Introduce CCG_Mode.

2 years ago[Ada] Update proofs of double arithmetic unit after prover changes
Yannick Moy [Tue, 19 Apr 2022 15:46:05 +0000 (15:46 +0000)]
[Ada] Update proofs of double arithmetic unit after prover changes

Changes in GNATprove (translation to Why3 and provers) result in proofs
being much less automatic, and requiring ghost code to detail
intermediate steps. In some cases, it is better to use the new By
mechanism to prove assertions in steps, as this avoids polluting the
proof context for other proofs. For that reason, add units s-spark.ads
and s-spcuop.ads/b to the runtime sources.

gcc/ada/

* Makefile.rtl: Add new units.
* libgnat/s-aridou.adb (Scaled_Divide): Add ghost code for provers.
* libgnat/s-spcuop.adb: New unit for ghost cut operations.
* libgnat/s-spcuop.ads: New unit for ghost cut operations.
* libgnat/s-spark.ads: New unit.

2 years ago[Ada] Tweaks to hardening docs
Alexandre Oliva [Thu, 21 Apr 2022 03:17:28 +0000 (00:17 -0300)]
[Ada] Tweaks to hardening docs

Mention when security hardening features are available in other
languages.

Expand the strub documentation a little, for clarity and completeness.

Add missing 'aliased' and attribute to variables in strub example.

gcc/ada/

* doc/gnat_rm/security_hardening_features.rst: Mention
availability in other languages when applicable.
(Stack Scrubbing): Associate the attribute with types, expand
some comments, fix the example involving access to variables.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Fix typo in comment for functional sets
Piotr Trojanek [Thu, 21 Apr 2022 19:36:15 +0000 (21:36 +0200)]
[Ada] Fix typo in comment for functional sets

Minor fix in a recently added comment.

gcc/ada/

* libgnat/a-cofuse.ads (Empty_Set): Fix typo in comment.

2 years ago[Ada] Restore hiding of predefined "=" operator through class-wide type
Eric Botcazou [Wed, 20 Apr 2022 22:03:59 +0000 (00:03 +0200)]
[Ada] Restore hiding of predefined "=" operator through class-wide type

The previous change introduced a backward incompatibility in the handling
of a user-defined "=" operator for a class-wide type of a tagged type: it
would previously hide the predefined "=" operator of the tagged type in
the private case, but it no longer does in this case, while it still does
in the nonprivate case.

This hiding is a non-portability, but is fundamentally what the compiler
implements, instead of the RM rule which requires homographs.  The reason
lies in the implementation of the "=" operator in GNAT: internally, there
is not a "=" predefined operator for every nonlimited type, but instead
there is a single, universal "=" predefined operator for all the nonlimited
types.  The consequence is that the hiding rule implemented in GNAT for "="
is effectively that a user-declared symmetrical "=" operator returning
boolean hides the predefined "=" operator of any type that is covered by
the user-declared operator.

Whether it is desirable to implement the exact RM rule in GNAT is to be
discussed, but existing code relies on the non-portability and would thus
need to be changed.

gcc/ada/

* sem_ch6.adb (New_Overloaded_Entity): Deal specifically with the
overriding of the "=" operator for tagged types.

2 years ago[Ada] Do not freeze profiles for dispatch tables
Eric Botcazou [Wed, 20 Apr 2022 07:54:49 +0000 (09:54 +0200)]
[Ada] Do not freeze profiles for dispatch tables

When static dispatch tables are built for library-level tagged types, the
primitives (the subprogram themselves) are frozen; that's necessary because
their address is taken.  However, their profile, i.e. all the types present
therein, is also frozen, which is not necessary after AI05-019 and is also
inconsistent with the handling of attribute references.

The change also removes a couple of pragma Inline on subprograms that are
too large for inlining to bring any benefit.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Adjust call to Make_DT.
* exp_disp.ads (Building_Static_DT): Remove pragma Inline.
(Building_Static_Secondary_DT): Likewise.
(Convert_Tag_To_Interface): Likewise.
(Make_DT): Remove second parameter.
* exp_disp.adb (Make_DT): Likewise.
(Check_Premature_Freezing): Delete.
Pass Do_Freeze_Profile as False in call to Freeze_Entity.
* freeze.ads (Freezing_Library_Level_Tagged_Type): Delete.
* freeze.adb (Freeze_Profile): Remove obsolete code.
(Freeze_Entity): Tweak comment.

2 years ago[Ada] Adapt proof of runtime unit s-arit32
Yannick Moy [Wed, 20 Apr 2022 09:39:11 +0000 (09:39 +0000)]
[Ada] Adapt proof of runtime unit s-arit32

After changes in GNATprove, adapt proof. Simply move an assertion up
before it is first needed here.

gcc/ada/

* libgnat/s-arit32.adb (Scaled_Divide32): Move assertion up.

2 years ago[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit
Yannick Moy [Tue, 19 Apr 2022 12:37:58 +0000 (14:37 +0200)]
[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit

The internal unit System.Generic_Array_Operations defines only generic
subprograms. Thus, pragma Assertion_Policy inside the spec has no
effect, as each instantiation is only subject to the assertion policy at
the program point of the instantiation. Remove this confusing pragma,
and add the pragma inside each generic body making use of additional
assertions or ghost code, so that running time of instantiations is not
impacted by assertions meant for formal verification.

gcc/ada/

PR ada/105303
* libgnat/s-gearop.adb: Add pragma Assertion_Policy in generic
bodies making use of additional assertions or ghost code.
* libgnat/s-gearop.ads: Remove confusing Assertion_Policy.

2 years ago[Ada] Delete no-longer-used Convert_To_Return_False flag
Steve Baird [Fri, 15 Apr 2022 20:30:34 +0000 (13:30 -0700)]
[Ada] Delete no-longer-used Convert_To_Return_False flag

As a result of other recent changes, the Convert_To_Return_False flag
is never set. The flag can be therefore be deleted.

gcc/ada/

* exp_ch11.adb (Expand_N_Raise_Expression): Remove
Convert_To_Return_False test.
* gen_il-fields.ads: Remove Convert_To_Return_False field.
* gen_il-gen-gen_nodes.adb: Remove use of
Convert_To_Return_False field.
* sinfo.ads: Remove comment describing Convert_To_Return_False
flag.

2 years ago[Ada] Add empty constructors to the functional containers
Julien Bortolussi [Thu, 14 Apr 2022 14:09:30 +0000 (16:09 +0200)]
[Ada] Add empty constructors to the functional containers

This patch adds empty constructors to the functional containers so that
we can use them in expression functions.

gcc/ada/

* libgnat/a-cofuma.ads, libgnat/a-cofuma.adb,
libgnat/a-cofuse.ads, libgnat/a-cofuse.adb,
libgnat/a-cofuve.ads, libgnat/a-cofuve.adb: Add empty
constructors.

2 years ago[Ada] Fix new CUDA kernel registration scheme
Ghjuvan Lacambre [Tue, 19 Apr 2022 08:01:49 +0000 (10:01 +0200)]
[Ada] Fix new CUDA kernel registration scheme

Removal of the previous kernel registration scheme unearthed mistakes in
the new one, which were:
- The new kernel registration code relied on the binder expansion phase,
  which didn't happen because the registration code was already
  generated by the binder.
- The kernel handle passed to CUDA_Register_Function was the first eight
  bytes of the code of the host-side procedure representing the kernel
  rather than its address.

gcc/ada/

* bindgen.adb (Gen_CUDA_Init): Remove code generating CUDA
definitions.
(Gen_CUDA_Defs): New function, generating definitions
initialized by Gen_CUDA_Init.
(Gen_Output_File_Ada): Call Gen_CUDA_Defs instead of
Gen_CUDA_Init.
(Gen_Adainit): Call Gen_CUDA_Init.

2 years ago[ARM] Fix prototype for vec_perm_const hook.
Prathamesh Kulkarni [Mon, 30 May 2022 07:53:50 +0000 (13:23 +0530)]
[ARM] Fix prototype for vec_perm_const hook.

gcc/ChangeLog:

* config/arm/arm.cc (arm_vectorize_vec_perm_const): Adjust prototype.

2 years agoRISC-V/testsuite: constraint some of tests to hard_float
Vineet Gupta [Fri, 27 May 2022 02:36:36 +0000 (19:36 -0700)]
RISC-V/testsuite: constraint some of tests to hard_float

Commit 9ddd44b58649d1d ("RISC-V: Provide `fmin'/`fmax' RTL pattern") added
tests which check for hard float instructions which obviously fails on
soft-float ABI builds.

And my recent commit b646d7d279ae ("RISC-V: Inhibit FP <--> int register
moves via tune param") is guilty of same crime.

So constraint with "dg-require-effective-target hard_float"

This reduces bunch of new RV failures.

|               ========= Summary of gcc testsuite =========
|                            | # of unexpected case / # of unique unexpected case
|                            |          gcc |          g++ |     gfortran |
|   rv64imac/   lp64/ medlow |  134 /    22 |    0 /     0 |            - |  BEFORE
|   rv64imac/   lp64/ medlow |   22 /     9 |    0 /     0 |            - |  AFTER
|

gcc/testsuite/Changelog:
* gcc.target/riscv/fmax.c: Add dg-require-effective-target hard_float.
* gcc.target/riscv/fmaxf.c: Ditto.
* gcc.target/riscv/fmin.c: Ditto.
* gcc.target/riscv/fminf.c: Ditto.
* gcc.target/riscv/smax-ieee.c: Ditto.
* gcc.target/riscv/smax.c: Ditto.
* gcc.target/riscv/smaxf-ieee.c: Ditto.
* gcc.target/riscv/smaxf.c: Ditto.
* gcc.target/riscv/smin-ieee.c: Ditto.
* gcc.target/riscv/smin.c: Ditto.
* gcc.target/riscv/sminf-ieee.c: Ditto.
* gcc.target/riscv/sminf.c: Ditto.
* gcc.target/riscv/pr105666.c: Ditto.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
2 years agoDaily bump.
GCC Administrator [Mon, 30 May 2022 00:16:21 +0000 (00:16 +0000)]
Daily bump.

2 years agolibcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]
Jakub Jelinek [Sun, 29 May 2022 19:57:51 +0000 (21:57 +0200)]
libcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]

The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).

In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.

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

PR preprocessor/105732
* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
token.

* c-c++-common/cpp/va-opt-10.c: New test.

2 years agoDarwin: Fix empty g++ command lines [PR105599].
Iain Sandoe [Sun, 29 May 2022 15:14:32 +0000 (16:14 +0100)]
Darwin: Fix empty g++ command lines [PR105599].

An empty g++ command line should produce a diagnostic that there are no
inputs.  The PR is that currently Darwin produces a dignostic about missing
link items instead - this is because (errnoeously), for this driver, we are
creating a link job for empty command lines.

The problem occurs in four stages:

 The g++ driver appends -shared-libgcc to the command line.

 The Darwin driver_init code in the backend does not see this (it sees an
 empty command line).

 When the back end driver code driver sees an empty command line, it does not
 add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
 avoid anything being claimed as an input_file and therefore triggering a link
 line.

 Since we do not have a value for asm-macosx-version-min when processing the
 driver specs, we unconditionally inject 'multiply_defined suppress' which is
 used with shared libgcc (but only intended on very old Darwin).  This then
 causes the generation of a link job.

The solution, for the present, is to move version-specific link params to the
LINK_SPEC so that they are only processed when a link job has already been
decided.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR target/105599

gcc/ChangeLog:

* config/darwin.h: Move versions-specific handling of multiply_defined
from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

2 years agosourcebuild.texi: Document toplevel directories
Eric Gallager [Sun, 29 May 2022 04:57:05 +0000 (00:57 -0400)]
sourcebuild.texi: Document toplevel directories

Fixes PR82383

gcc/ChangeLog:

PR other/82383
* doc/sourcebuild.texi: Add entries for the c++tools,
gotools, libbacktrace, libcc1, libcody, liboffloadmic,
and libsanitizer directories. Remove entry for boehm-gc.
Fix alphabetization for libquadmath.

2 years agoDaily bump.
GCC Administrator [Sun, 29 May 2022 00:16:31 +0000 (00:16 +0000)]
Daily bump.

2 years ago[PATCH 1/2] avr: Added AVR-DA and DB MCU series
Joel Holdsworth [Sat, 28 May 2022 19:16:01 +0000 (13:16 -0600)]
[PATCH 1/2] avr: Added AVR-DA and DB MCU series

gcc/
* config/avr/avr-mcus.def: Add device definitions.
* doc/avr-mmcu.texi: Corresponding changes.
* config/avr/gen-avr-mmcu-texi.cc: Added support for avr
device prefix.
* config/avr/gen-avr-mmcu-specs.cc: Prevent -mmcu=avr* flags
from leaking into cc1.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2 years agoOpenMP/Fortran: Add support for enter clause on declare target
Tobias Burnus [Sat, 28 May 2022 18:42:38 +0000 (20:42 +0200)]
OpenMP/Fortran: Add support for enter clause on declare target

Fortran version to C/C++ commit r13-797-g0ccba4ed8571c18c7015413441e971

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER.
* gfortran.h: Add OMP_LIST_ENTER.
* openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add
OMP_CLAUSE_ENTER.
(gfc_match_omp_clauses, gfc_match_omp_declare_target,
resolve_omp_clauses): Handle 'enter' clause.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported.
* testsuite/libgomp.fortran/declare-target-1.f90: Extend to test
explicit 'to' and 'enter' clause.
* testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-target-2.f90: Add 'enter' clause test.
* gfortran.dg/gomp/declare-target-4.f90: Likewise.

2 years agoFix ICE on sh
Vladimir Makarov [Sat, 28 May 2022 18:08:38 +0000 (12:08 -0600)]
Fix ICE on sh

gcc/
PR target/103722
* config/sh/sh.cc (sh_register_move_cost): Avoid cost "2" (which
is special) for various scenarios.

2 years agoVim swap files not ignored
Bruce Korb [Sat, 28 May 2022 15:36:10 +0000 (09:36 -0600)]
Vim swap files not ignored

ChangeLog:

* .gitignore: Ignore vim swap files

2 years agolibbacktrace: update README
Ian Lance Taylor [Sat, 28 May 2022 14:57:32 +0000 (07:57 -0700)]
libbacktrace: update README

PR libbacktrace/105721
* README: Update.

2 years agoDarwin: Amend REAL_LIBGCC_SPEC comment [NFC].
Iain Sandoe [Sat, 28 May 2022 10:55:00 +0000 (11:55 +0100)]
Darwin: Amend REAL_LIBGCC_SPEC comment [NFC].

This comment had got out of sync with reality, partly due to merging
of patches.  Updated to reflect the current implementation.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin.h (REAL_LIBGCC_SPEC): Update the comment block
describing this macro.

2 years agoRename OSCONS_CC to GCC_FOR_ADA_RTS
Alexandre Oliva [Sat, 28 May 2022 06:50:17 +0000 (03:50 -0300)]
Rename OSCONS_CC to GCC_FOR_ADA_RTS

Several gnatlib* targets perform, with a subshell and sed, the same
GCC_FOR_TARGET pathname transformation that OSCONS_CC performs with
make subst macros.  Rename OSCONS_CC to a more general name, and use
it for gnatlib as well.

for  gcc/ada/ChangeLog

* gcc-interface/Makefile.in (OSCONS_CC): Rename to...
(GCC_FOR_ADA_RTS): ... this.  Adjust users.
(gnatlib): Pass it down as CC.
(gnatlib-shared-default): Likewise.
(gnatlib-shared-win32, gnatlib-shared-darwin): Likewise.

2 years agolibgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
Jakub Jelinek [Sat, 28 May 2022 06:30:47 +0000 (08:30 +0200)]
libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]

since apparently _aligned_malloc requires freeing with _aligned_free and:
 /* Defined if gomp_aligned_alloc doesn't use fallback version
    and free can be used instead of gomp_aligned_free.  */
 #define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied.  For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.

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

PR libgomp/105745
* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
defined(HAVE__ALIGNED_MALLOC) case.
* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
handling as last option before fallback instead of first.
(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
_aligned_free.

2 years agoopenmp: Adjust diagnostics about same variable in link and to/enter clauses
Jakub Jelinek [Sat, 28 May 2022 06:26:57 +0000 (08:26 +0200)]
openmp: Adjust diagnostics about same variable in link and to/enter clauses

On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote:
> The 'TO'/'ENTER' usage is first stored in a linked list – and
> then as attribute to the symbol. I am not sure how to handle it best.

This reminds me I've left the C/C++ FE diagnostics about mixing link and
to/enter on the same variable in separate directives as is, so it always
talked about mixing link and to clauses.

This patch adjusts it, so that if link is first, it talks about the
clause actually used and if link is later, uses to or enter together
in the wording.

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

gcc/c/
* c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/cp/
* parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/testsuite/
* c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of
link and to/enter clauses on separate directives.

2 years agoc++: lambda in concept [PR105652]
Jason Merrill [Fri, 27 May 2022 02:43:05 +0000 (22:43 -0400)]
c++: lambda in concept [PR105652]

We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111).  When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output.  For the moment, let's work around all of this by overriding the
context of the closure.

PR c++/105652

gcc/cp/ChangeLog:

* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
instantiate into a class-scope lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda20.C: New test.

2 years agoDaily bump.
GCC Administrator [Sat, 28 May 2022 00:16:40 +0000 (00:16 +0000)]
Daily bump.

2 years agod: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.
Iain Buclaw [Fri, 27 May 2022 17:36:06 +0000 (19:36 +0200)]
d: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.

D front-end changes:

    - `scope' semantics are now enforced in `@safe' code on pointers to
      stack memory, but only as deprecation warnings.
    - Overriding virtual functions are now marked with the `override'
      and `final' in the generated headers of `-fdump-c++-spec='.
    - `-fpreview=fiximmmutableconv` has been added that disallows
      implicitly converting a return value with indirections to
      immutable if it determines the result must be unique.

D runtime changes:

    - Posix (excluding Darwin): Switch default GC signals from SIGUSR1/2
      to SIGRTMIN/SIGRTMIN+1

Phobos changes:

    - Import latest bug fixes to mainline.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4d07f22f2
* d-lang.cc (d_handle_option): Handle OPT_fpreview_fiximmutableconv.
* lang.opt (fpreview=fiximmutableconv): New option.
* runtime.def (ARRAYAPPENDT): Remove.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime f89da313.
* src/MERGE: Merge upstream phobos d46814c86.

Signed-off-by: Iain Buclaw <ibuclaw@gdcproject.org>
2 years agoc++: Fix ICE with -Wmismatched-tags [PR105725]
Marek Polacek [Fri, 27 May 2022 14:51:30 +0000 (10:51 -0400)]
c++: Fix ICE with -Wmismatched-tags [PR105725]

Here we ICE with -Wmismatched-tags on something like

  template <class T>
  bool B<T, enable_if_t<is_class_v<class T::foo>>>;

Specifically, the "class T::foo" bit.  There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash.  I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename').  In fact, every other compiler *requires* it.

PR c++/105725

gcc/cp/ChangeLog:

* parser.cc (class_decl_loc_t::add): Check CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-tags-10.C: New test.

2 years agoc-family: fix attribute constructor ICE [PR90658]
Marek Polacek [Thu, 26 May 2022 22:59:44 +0000 (18:59 -0400)]
c-family: fix attribute constructor ICE [PR90658]

Here the C compiler crashes because a FUNCTION_DECL got into
get_priority -> default_conversion, and the C FE's version of d_c
specifically asserts that it doesn't get a FUNCTION_DECL.  All uses
of default_conversion in c-attribs.cc are guarded by != IDENTIFIER_NODE
&& != FUNCTION_DECL, but get_priority was only checking IDENTIFIER_NODE.

PR c/90658

gcc/c-family/ChangeLog:

* c-attribs.cc (get_priority): Check FUNCTION_DECL.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-cdtor-1.c: New test.

2 years agolibstdc++: Mark non-exported function always_inline [PR105671]
Jonathan Wakely [Fri, 27 May 2022 11:43:18 +0000 (12:43 +0100)]
libstdc++: Mark non-exported function always_inline [PR105671]

This new function was added for gcc 11.1 but is not exported from the
shared library. Depending on inlining decisions, its callers might get
inlined but an external definition be needed for this function. That
then fails to link.

Since we can't add the export to the gcc-11 release branch now, mark it
always_inline. We can consider exporting it for gcc-13 if/when we bump
the shared library version (and maybe also for gcc-12 which is currently
at the same version as trunk). For now, the attribute will solve the
problem on all affected branches. The function is small enough that
force-inlining it shouldn't cause problems.

libstdc++-v3/ChangeLog:

PR libstdc++/105671
* include/std/sstream (basic_stringbuf::_M_high_mark): Add
always_inline attribute.

2 years agoFortran: Fix OpenMP clause name in error message
Tobias Burnus [Fri, 27 May 2022 11:12:45 +0000 (13:12 +0200)]
Fortran: Fix OpenMP clause name in error message

gcc/fortran/ChangeLog:

* openmp.cc (gfc_check_omp_requires): Fix clause name in error.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/requires-4.f90: Update dg-error.
* gfortran.dg/gomp/requires-8.f90: Update dg-error.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
2 years agoAvoid shift in get_ref_base_and_extent
Richard Biener [Fri, 27 May 2022 12:07:03 +0000 (14:07 +0200)]
Avoid shift in get_ref_base_and_extent

This avoids one instance of a shift from bytes to bits in
get_ref_base_and_extent by using TYPE_SIZE instead of TYPE_SIZE_UNIT.

* tree-dfa.cc (get_ref_base_and_extent): Avoid shift.

2 years agoipa: Check cst type when propagating controled uses info
Martin Jambor [Fri, 27 May 2022 11:05:40 +0000 (13:05 +0200)]
ipa: Check cst type when propagating controled uses info

PR 105639 shows that code with type-mismatches can trigger an assert
after runnning into a branch that was inteded only for references to
variables - as opposed to references to functions.  Fixed by moving
the condition from the assert to the guarding if statement.

gcc/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/105639
* ipa-prop.cc (propagate_controlled_uses): Check type of the
constant before adding a LOAD reference.

gcc/testsuite/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/105639
* gcc.dg/ipa/pr105639.c: New test.