platform/upstream/gcc.git
3 years ago[Ada] Detect unchecked union components with fully qualified names
Piotr Trojanek [Wed, 13 Jan 2021 11:53:21 +0000 (12:53 +0100)]
[Ada] Detect unchecked union components with fully qualified names

gcc/ada/

* exp_ch4.adb (Component_Is_Unconstrained_UU): Detect both
qualified and unqualified names of unchecked union components.

3 years ago[Ada] Remove redundant checks for empty lists
Piotr Trojanek [Tue, 12 Jan 2021 20:37:26 +0000 (21:37 +0100)]
[Ada] Remove redundant checks for empty lists

gcc/ada/

* exp_ch4.adb (Variant_Is_Unconstrained_UU): Remove redundant
check for empty list.
* exp_disp.adb (Find_Entry_Index): Simplify by removing
redundant check and counting from zero; fix type of a local
variable.
* sem_ch12.adb (Save_Global_Descendant): Remove an unnecessary
special-case for empty lists.

3 years ago[Ada] Cleanup a statically true condition in expanded raise statement
Piotr Trojanek [Tue, 12 Jan 2021 20:16:28 +0000 (21:16 +0100)]
[Ada] Cleanup a statically true condition in expanded raise statement

gcc/ada/

* exp_ch4.adb (Apply_Accessibility_Check): Skip a statically
true condition in expanded raise statement.

3 years ago[Ada] Fix s-os_lib.adb so vectorizing compilation works
Bob Duff [Tue, 12 Jan 2021 18:25:07 +0000 (13:25 -0500)]
[Ada] Fix s-os_lib.adb so vectorizing compilation works

gcc/ada/

* libgnat/s-os_lib.adb (Missed_Drive_Letter): Simplify the code.

3 years ago[Ada] Spurious warning on useless assignment with target name
Ed Schonberg [Tue, 12 Jan 2021 15:46:26 +0000 (10:46 -0500)]
[Ada] Spurious warning on useless assignment with target name

gcc/ada/

* sem_ch5.adb (Analyze_Assignment): Do not emit the warning that
a previous value of the target object is useless if the
right-hand side of the assignment includes target names.

3 years ago[Ada] Do not use hash function for enumeration Value with trampolines
Eric Botcazou [Tue, 12 Jan 2021 15:01:15 +0000 (16:01 +0100)]
[Ada] Do not use hash function for enumeration Value with trampolines

gcc/ada/

* exp_imgv.adb: Add with/use clauses for Targparm.
(Build_Enumeration_Image_Tables): Set type of Threshold to Nat and
initialize it to Nat'Last if the type is local and the target does
not support descriptors.  Adjust Threshold_For_Size similarly.
(Expand_Value_Attribute): Minor tweaks.

3 years ago[Ada] Move Build_And_Insert_CUDA_Initialization to expansion phase
Ghjuvan Lacambre [Tue, 12 Jan 2021 12:57:59 +0000 (13:57 +0100)]
[Ada] Move Build_And_Insert_CUDA_Initialization to expansion phase

gcc/ada/

* exp_ch7.adb (Expand_N_Package_Body): Add CUDA init call.
* sem_ch7.adb (Analyze_Package_Body_Helper): Remove CUDA init
call.

3 years ago[Ada] Don't emit style errors when parens are required
Ghjuvan Lacambre [Mon, 11 Jan 2021 15:26:45 +0000 (16:26 +0100)]
[Ada] Don't emit style errors when parens are required

gcc/ada/

* par-ch5.adb (P_Condition): Check if expression is declare
expression.

3 years ago[Ada] Simplify GNATmake by reusing GNAT.Ctrl_C
Piotr Trojanek [Tue, 12 Jan 2021 10:24:23 +0000 (11:24 +0100)]
[Ada] Simplify GNATmake by reusing GNAT.Ctrl_C

gcc/ada/

* make.adb (Make): Use GNAT.Ctrl_C.Install_Handler instead of a
custom imported procedure.

3 years ago[Ada] Small cleanup in the Expand_Image_Attribute procedure
Eric Botcazou [Tue, 12 Jan 2021 09:38:53 +0000 (10:38 +0100)]
[Ada] Small cleanup in the Expand_Image_Attribute procedure

gcc/ada/

* exp_imgv.adb (Is_User_Defined_Enumeration_Type): Delete.
(Expand_Image_Attribute): Move inline expansion into normal flow of
control, move down declarations and remove superfluous processing.

3 years ago[Ada] Qualify internal access-to-subprogram types as not null
Piotr Trojanek [Mon, 11 Jan 2021 17:06:35 +0000 (18:06 +0100)]
[Ada] Qualify internal access-to-subprogram types as not null

gcc/ada/

* libgnat/g-alleve.adb (Bit_Operation): Now a not-null type.
* libgnat/g-sechas.adb (Fill_Buffer_Access): Likewise.
* libgnat/s-dwalin.adb (Callback): Likewise.

3 years ago[Ada] Remove commented code
Ghjuvan Lacambre [Tue, 12 Jan 2021 08:15:13 +0000 (09:15 +0100)]
[Ada] Remove commented code

gcc/ada/

* exp_util.adb (Is_Possibly_Unaligned_Object): Remove commented
code.

3 years ago[Ada] Handle defaults in declare_expressions in postconditions
Ed Schonberg [Sat, 9 Jan 2021 21:57:21 +0000 (16:57 -0500)]
[Ada] Handle defaults in declare_expressions in postconditions

gcc/ada/

* sem_ch3.adb (Find_Type_Of_Object):  When In_Spec_Expression is
set and the object declaration generates a subtype indication,
build the corresponding subtype declaration and place it in tree
without the use of Insert_Actions, which is disabled in this
context.

3 years ago[Ada] Use inline expansion of Image for standard boolean by default
Eric Botcazou [Tue, 12 Jan 2021 12:25:24 +0000 (13:25 +0100)]
[Ada] Use inline expansion of Image for standard boolean by default

gcc/ada/

* debug.adb (d_x): Document extended usage.
* exp_imgv.adb (Expand_Standard_Boolean_Image): New procedure.
(Expand_Image_Attribute): Call it to expand in line the attribute
for standard boolean by default.

3 years ago[Ada] Use inline expansion of Image for enumeration types by default
Eric Botcazou [Mon, 11 Jan 2021 07:51:16 +0000 (08:51 +0100)]
[Ada] Use inline expansion of Image for enumeration types by default

gcc/ada/

* debug.adb (d_x): Document new usage.
* exp_imgv.adb (Expand_User_Defined_Enumeration_Image): Add Typ
parameter and use it throughout the processing.
(Expand_Image_Attribute): Retrieve the underlying type of the
prefix and use the inline expansion for user-defined enumeration
types with a literal string by default.

3 years ago[Ada] Tweak implementation of System.Double_Real.Split
Eric Botcazou [Mon, 11 Jan 2021 10:15:46 +0000 (11:15 +0100)]
[Ada] Tweak implementation of System.Double_Real.Split

gcc/ada/

* libgnat/s-dorepr.adb (Split): Declare a per-size temporary.
Add pragma Annotate.

3 years ago[Ada] Remove redundant explicit calls to UI_From_Int in comparisons
Piotr Trojanek [Fri, 8 Jan 2021 19:48:58 +0000 (20:48 +0100)]
[Ada] Remove redundant explicit calls to UI_From_Int in comparisons

gcc/ada/

* exp_ch4.adb, sem_ch13.adb, sem_eval.adb, sem_res.adb: Remove
redundant calls to UI_From_Int.

3 years ago[Ada] Adjust expansion of perfect hash function for Value
Eric Botcazou [Sun, 10 Jan 2021 17:28:35 +0000 (18:28 +0100)]
[Ada] Adjust expansion of perfect hash function for Value

gcc/ada/

* exp_imgv.ads (Build_Enumeration_Image_Tables): Adjust comment.
* exp_imgv.adb (Build_Enumeration_Image_Tables): Add the
declaration nodes of the 4 tables to the declaration list of the
function body.

3 years ago[Ada] Speed up enumeration'Value with perfect hash function
Piotr Trojanek [Fri, 8 Jan 2021 18:53:41 +0000 (19:53 +0100)]
[Ada] Speed up enumeration'Value with perfect hash function

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imagen, s-imen16,
s-imen32, s-imenu8, s-pehage, s-valuen, s-vaen16, s-vaen32 and
s-vaenu8.  Remove s-imenne, s-imgenu and s-valenu.
* debug.adb (d_h): Document new usage.
* einfo.ads (Lit_Hash): New attribute for enumeration types.
(Set_Lit_Hash): Declare.
* einfo.adb (Lit_Hash): New function.
(Set_Lit_Hash): New procedure.
(Write_Field21_Name): Print Lit_Hash for Enumeration_Kind.
* exp_imgv.ads (Build_Enumeration_Image_Tables): Fix description
and document the hash function and its tables.
* exp_imgv.adb: Add with/use clauses for Debug.  Add with clause
for System.Perfect_Hash_Generators.
(Append_Table_To): New helper routine.
(Build_Enumeration_Image_Tables): Call it to build the tables.
In the main unit, register the literals with the hash generator.
If they are sufficiently many and -gnatd_h is not passed, generate
a perfect hash function and its tables; otherwise, generate a dummy
hash function.  For the other units, generate only the declaration.
In all cases, set Lit_Hash to the entity of the function, if any.
(Expand_Value_Attribute): Pass the 'Unrestricted_Access of Lit_Hash,
if any, as third argument to the Value_Enumeration_NN function.
* gnat1drv.adb (Adjust_Global_Switches): force simpler implementation
of 'Value in CodePeer_Mode.
* lib.ads (Synchronize_Serial_Number): Add SN parameter.
* lib.adb (Synchronize_Serial_Number): Assert that it is larger than
the serial number of the current unit and set the latter to it only
in this case.
* rtsfind.ads (RTU_Id): Add System_Img_Enum_8, System_Img_Enum_16,
System_Img_Enum_32, System_Val_Enum_8, System_Val_Enum_16 and
System_Val_Enum_32.  Remove System_Img_Enum, System_Img_Enum_New
and System_Val_Enum.
* sem_attr.adb (Analyze_Access_Attribute): Do not flag a compiler
generated Unrestricted_Access attribute as illegal in a declare
expression.
(RE_Unit_Table): Adjust to above changes.
* libgnat/g-heasor.ads: Add pragma Compiler_Unit_Warning.
* libgnat/g-table.ads: Likewise.
* libgnat/g-pehage.ads: Add with clause and local renaming for
System.Perfect_Hash_Generators.
(Optimization): Turn into derived type.
(Verbose): Turn into renaming.
(Too_Many_Tries): Likewise.
(Table_Name): Move to System.Perfect_Hash_Generators.
(Define): Likewise.
(Value): Likewise.
* libgnat/g-pehage.adb: Remove with clause for Ada.Directories,
GNAT.Heap_Sort_G and GNAT.Table.  Move bulk of implementation
to System.Perfect_Hash_Generators, only keep the output part.
* libgnat/s-imagen.ads: New generic unit.
* libgnat/s-imagen.adb: New body.
* libgnat/s-imen16.ads: New unit.
* libgnat/s-imen32.ads: Likewise.
* libgnat/s-imenu8.ads: Likewise.
* libgnat/s-imenne.ads: Adjust description.
* libgnat/s-imgenu.ads: Delete.
* libgnat/s-imgenu.adb: Likewise.
* libgnat/s-pehage.ads: New unit from GNAT.Perfect_Hash_Generators.
* libgnat/s-pehage.adb: New body from GNAT.Perfect_Hash_Generators.
* libgnat/s-valuen.ads: New generic unit.
* libgnat/s-valuen.adb: New body.
* libgnat/s-vaen16.ads: New unit.
* libgnat/s-vaen32.ads: Likewise.
* libgnat/s-vaenu8.ads: Likewise.
* libgnat/s-valenu.ads: Delete.
* libgnat/s-valenu.adb: Likewise.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-pehage.o.
(GNATBIND_OBJS): Remove s-imgenu.o.

3 years ago[Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error
Piotr Trojanek [Fri, 8 Jan 2021 18:53:41 +0000 (19:53 +0100)]
[Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error

gcc/ada/

* sem_util.ads (Apply_Compile_Time_Constraint_Error): Remove
parameter Rep from the function spec and "and if the flag Rep is
set" from the comment.
* sem_util.adb (Apply_Compile_Time_Constraint_Error): Remove
parameter Rep.

3 years ago[Ada] Ongoing work for AI12-0212: container aggregates
Ed Schonberg [Fri, 8 Jan 2021 01:12:34 +0000 (20:12 -0500)]
[Ada] Ongoing work for AI12-0212: container aggregates

gcc/ada/

* sem_aggr.adb (Resolve_Indexed_Aggregate): For indexed
aggregates with component associations verify that if there is
more than one component association then all the choices are
static, that the set of choices define a continuous sequence of
values, and that if loop specfications appear, they do not
include iterator filters or key expressions.

3 years ago[Ada] Implement tiered support for floating-point output operations
Eric Botcazou [Wed, 6 Jan 2021 14:27:15 +0000 (15:27 +0100)]
[Ada] Implement tiered support for floating-point output operations

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-dourea, s-imager,
s-imgflt, s-imglfl and s-imgllf.
(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorks]: Use s-dorepr__fma.adb.
(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorksAE]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/VxWorks]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/QNX]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/FreeBSD]: Likewise.
(LIBGNAT_TARGET_PAIRS) [PowerPC/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [IA-64/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [IA-64/HP-UX]: Likewise.
(LIBGNAT_TARGET_PAIRS) [RISC-V/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [PowerPC/Darwin]: Likewise.
* exp_attr.adb (Expand_N_Attribute_Reference) [Attribute_Fore]: Use
Fixed suffix and Long_Float type.
* exp_imgv.adb (Expand_Image_Attribute): For floating-point types,
use the routine of the corresponding root type.  For ordinary fixed
point types, use Fixed suffix and Long_Float type.
(Expand_Value_Attribute): Revert latest change for Long_Long_Float.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Remove libgnat units
g-hesora.o and s-imgenu.o, add g-heasor.o, g-table.o and s-pehage.o.
(GNATBIND_OBJS): Remove libgnat unit s-imgenu.o.
* rtsfind.ads (RTU_Id): Add System_Img_Flt, System_Img_LFlt and
System_Img_LLF.  Remove System_Img_Real.
(RE_Id): Rename RE_Fore_Real to RE_Fore_Fixed.  Add RE_Image_Float,
RE_Image_Long_Float and RE_Image_Long_Long_Float.  Rename
RE_Image_Ordinary_Fixed_Point to RE_Image_Fixed.
(RE_Unit_Table): Adjust to above changes.
* libgnat/a-nbnbre.adb (Fixed_Conversions): Use Long_Float instead
of Long_Long_Float.
* libgnat/a-textio.ads (Field): Remove obsolete comment.
* libgnat/a-ticoau.ads (Aux): Adjust ancestor package.
* libgnat/a-ticoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-ticoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-tifiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-tifiio__128.adb: Likewise.
* libgnat/a-tiflau.ads: Add Set_Image formal parameter.
* libgnat/a-tiflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-tiflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/a-witeio.ads (Field): Remove obsolete comment.
* libgnat/a-wtcoau.ads (Aux): Adjust ancestor package.
* libgnat/a-wtcoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-wtcoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-wtfiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-wtfiio__128.adb: Likewise.
* libgnat/a-wtflau.ads: Add Set_Image formal parameter.
* libgnat/a-wtflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-wtflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/a-ztexio.ads (Field): Remove obsolete comment.
* libgnat/a-ztcoau.ads (Aux): Adjust ancestor package.
* libgnat/a-ztcoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-ztcoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-ztfiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt.  Remove the one for System.Val_LLF.  Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-ztfiio__128.adb: Likewise.
* libgnat/a-ztflau.ads: Add Set_Image formal parameter.
* libgnat/a-ztflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-ztflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/s-dorepr.adb: New file.
* libgnat/s-dorepr__fma.adb: Likewise.
* libgnat/s-dourea.ads: Likewise.
* libgnat/s-dourea.adb: Likewise.
* libgnat/s-forrea.ads (Fore_Real): Rename into...
(Fore_Fixed): ...this and take Long_Float parameters.
* libgnat/s-forrea.adb (Fore_Real): Likewise.
(Fore_Fixed): Likewise.
* libgnat/s-imgrea.ads: Move to...
(Set_Image_Real): Turn into mere renaming.
* libgnat/s-imager.ads: ...here.
(Image_Ordinary_Fixed_Point): Turn into...
(Image_Fixed_Point): ...this.
* libgnat/s-imgrea.adb: Add pragma No_Body.  Move to...
* libgnat/s-imager.adb: ...here.
(Image_Ordinary_Fixed_Point): Turn into...
(Image_Fixed_Point): ...this.
(Is_Negative): Replace Long_Long_Float with Num.
(Set_Image_Real): Likewise.  Use Double_T instead of single Num
throughout the algorithm.
* libgnat/s-imgflt.ads: New file.
* libgnat/s-imglfl.ads: Likewise.
* libgnat/s-imgllf.ads: Likewise.
* libgnat/s-imagef.ads: Adjust comment.
* libgnat/s-imguti.ads (Max_Real_Image_Length): New named number.
* libgnat/s-powflt.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Float.
* libgnat/s-powlfl.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Long_Float.
* libgnat/s-powllf.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Long_Long_Float.
* libgnat/s-valrea.ads: Change order of formal parameters.
* libgnat/s-valrea.adb: Add with clause for System.Double_Real.
(Double_Real): New instantiation.
(Fast2Sum): Delete.
(Large_Powten): New function.
(Integer_to_Real): Use Quick_Two_Sum instead of Fast2Sum.  Convert
the value to Double_T.  Do the scaling in Double_T for base 10.
* libgnat/s-valflt.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types.  Use Unsigned.
* libgnat/s-vallfl.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types.  Use Long_Unsigned.
* libgnat/s-valllf.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types.  Use Long_Long_Unsigned.

3 years ago[Ada] Set constraint error on real division just like on integer division
Piotr Trojanek [Fri, 8 Jan 2021 13:31:25 +0000 (14:31 +0100)]
[Ada] Set constraint error on real division just like on integer division

gcc/ada/

* sem_eval.adb (Eval_Arithmetic_Op): Call
Set_Raises_Constraint_Error on real division by zero just like
it is called for integer division by zero earlier in this
routine.

3 years ago[Ada] Remove redundant check in iteration over formal parameters
Piotr Trojanek [Fri, 8 Jan 2021 16:01:27 +0000 (17:01 +0100)]
[Ada] Remove redundant check in iteration over formal parameters

gcc/ada/

* freeze.adb (Build_Renamed_Body): Simplify IF and WHILE
statements with the same condition.

3 years ago[Ada] Refactor repeated call to Next when pretty-printing if-expressions
Piotr Trojanek [Fri, 8 Jan 2021 12:07:30 +0000 (13:07 +0100)]
[Ada] Refactor repeated call to Next when pretty-printing if-expressions

gcc/ada/

* pprint.adb (Expr_Name): Introduce local constants to make the
code more readable and avoid repeated calls to Next to reach the
ELSE part of an if-expression.

3 years agog++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]
Tobias Burnus [Wed, 5 May 2021 06:50:15 +0000 (08:50 +0200)]
g++.dg/gomp/clause-3.C: Fix - missing in r12-438-g1580fc7 [PR100422]

gcc/testsuite/
PR testsuite/100422
* g++.dg/gomp/clause-3.C: Use 'reduction(&:..)' instead of '...(&&:..)'.

3 years agotree-optimization/79333 - fold stmts following SSA edges in VN
Richard Biener [Tue, 4 May 2021 13:51:20 +0000 (15:51 +0200)]
tree-optimization/79333 - fold stmts following SSA edges in VN

This makes sure to follow SSA edges when folding eliminated stmts.
This reaps the same benefit as forwprop folding all stmts, not
waiting for one to produce copysign in the new testcase.

2021-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79333
* tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt):
Fold stmt following SSA edges.

* gcc.dg/tree-ssa/ssa-fre-94.c: New testcase.
* gcc.dg/graphite/fuse-1.c: Adjust.
* gcc.dg/pr43864-4.c: Likewise.

3 years agomiddle-end/100394 - avoid DSE/DCE of pure call that throws
Richard Biener [Mon, 3 May 2021 13:11:28 +0000 (15:11 +0200)]
middle-end/100394 - avoid DSE/DCE of pure call that throws

There is -fdelete-dead-exceptions now and we're tracking
nothrow and const/pure bits separately and I do remember that
const or pure does _not_ imply nothrow.

Now, in the light of the PR100382 fix which added a
stmt_unremovable_because_of_non_call_eh_p guard to DSEs "DCE"
I wondered how -fdelete-dead-exceptions applies to calls and
whether stmt_unremovable_because_of_non_call_eh_p doing

  return (fun->can_throw_non_call_exceptions
          && !fun->can_delete_dead_exceptions
          && stmt_could_throw_p (fun, stmt));

really should conditionalize itself on
fun->can_throw_non_call_exceptions.  In fact DCE happily elides
pure function calls that throw without a LHS (probably a
consistency bug).  The following testcase shows this:

int x, y;
int __attribute__((pure,noinline)) foo () { if (x) throw 1; return y; }

int main()
{
  int a[2];
  x = 1;
  try {
    int res = foo ();
    a[0] = res;
  } catch (...) {
      return 0;
  }
  return 1;
}

note that if you wrap foo () into another noinline
wrap_foo () { foo (); return 1; } function then we need to make
sure to not DCE this call either even though it only throws
externally.

2021-05-03  Richard Biener  <rguenther@suse.de>

PR middle-end/100394
* calls.c (expand_call): Preserve possibly throwing calls.
* cfgexpand.c (expand_call_stmt): When a call can throw signal
RTL expansion there are side-effects.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Simplify,
mark all possibly throwing stmts necessary unless we can elide
dead EH.
* tree-ssa-dse.c (pass_dse::execute): Preserve exceptions unless
-fdelete-dead-exceptions.
* tree.h (DECL_PURE_P): Add note about exceptions.

* g++.dg/torture/pr100382.C: New testcase.

3 years agolibcc1: avoid a call to c_str
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: avoid a call to c_str

This is a trivial change to libcc1 to avoid an explicit call to c_str.
Passing by const reference is slightly less wordy.

libcc1

* compiler.cc (make_regexp): Take const std::string.
(cc1_plugin::compiler_triplet_regexp::find): Update.

3 years agolibcc1: avoid extra string copies
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: avoid extra string copies

PR c/94669 points out that a couple of spots in libcc1 take a
std::string where a reference would do.  This changes these spots to
take a const char *, to reduce the number of copies.

libcc1

PR c/94669
* compiler.hh (compiler_driver_filename): Take const char *.
(compiler_triplet_regexp): Likewise.

3 years agolibcc1: use variadic templates for callbacks
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use variadic templates for callbacks

This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions.  This is how I had wanted it to work from the very
beginning, and is possible now with C++11.

I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.

libcc1

* rpc.hh (argument_wrapper) <get>: Replace cast operator.
(argument_wrapper<T *>) <get>: Likewise.
(unmarshall): Add std::tuple overloads.
(callback): Remove.
(class invoker): New.
* libcp1plugin.cc (plugin_init): Update.
* libcp1.cc (libcp1::add_callbacks): Update.
* libcc1plugin.cc (plugin_init): Update.
* libcc1.cc (libcc1::add_callbacks): Update.
* connection.cc (cc1_plugin::connection::do_wait): Update.

3 years agolibcc1: fix a memory leak
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: fix a memory leak

libcc1 has a memory leak when calling fork_exec -- it allocates a new
vector of arguments, but then does not free it anywhere.  This patch
changes this code to use std::vector instead.

Note that the previous code tried to avoid bad_alloc.  I don't believe
this is very important.  For one thing, plenty of other allocations do
not bother with this.

libcc1

* gdbctx.hh (do_compile): Use std::vector.

3 years agolibcc1: share the GCC interface code
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: share the GCC interface code

Both the C and C++ side of the GDB plugin in libcc1 share a lot of
code relating to the base GCC interface.  It was all copy-and-pasted,
but is essentially identical between the two.  This is by design, as
the base GCC API is intended to be shared.

This patch merges the implementations into base_gdb_plugin, which was
introduced earlier for this purpose.

libcc1

* libcp1.cc (libcp1): Change parameters.  Update.
(libcp1_set_verbose, libcp1_set_arguments)
(libcp1_set_triplet_regexp, libcp1_set_driver_filename)
(libcp1_set_source_file, libcp1_set_print_callback, fork_exec)
(libcp1_compile, libcp1_destroy, vtable): Remove.
(libcp1::add_callbacks): New method, extracted from
libcp1_compile.
(gcc_c_fe_context): Update.
* libcc1.cc (libcc1): Change parameters.  Update.
(libcc1_set_verbose, libcc1_set_arguments)
(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
(libcc1_set_source_file, libcc1_set_print_callback, fork_exec)
(libcc1_compile, libcc1_destroy, vtable): Remove.
(libcc1::add_callbacks): New method, extracted from
libcc1_compile.
(gcc_c_fe_context): Update.
* gdbctx.hh (base_gdb_plugin): Change parameters.
(~base_gdb_plugin): New.
<add_callbacks>: New virtual method.
<plugin_name, fe_version, compiler_name, vtable>: New members.
(get_self, do_set_verbose, do_set_arguments)
(do_set_triplet_regexp, do_set_driver_filename)
(do_set_arguments_v0, do_set_source_file, do_set_print_callback)
(fork_exec, do_compile, do_compile_v0, do_destroy): New methods.

3 years agolibcc1: use GCC_FE_VERSION_1 in C++ plugin
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use GCC_FE_VERSION_1 in C++ plugin

The C++ plugin defaults to version 0 of the base compiler API.
However, this is a mistake -- version 1 was introduced before the C++
API was even implemented.  This switches the default to version 1.
Note that the compiler-side plugin will accept this version, so it
should remain compatible.

libcc1

* libcp1.cc (vtable): Use GCC_FE_VERSION_1.

3 years agolibcc1: share GDB plugin code
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: share GDB plugin code

The two GDB plugins in libcc1 share a fair amount of code.  This was
done by copy-and-paste, though in reality the underlying code is
nearly identical.

libcc1

* libcp1.cc (struct libcp1): Derive from base_gdb_plugin.  Remove
shared code.
(class libcp1_connection): Remove.
(rpc): Remove.
(libcp1_set_verbose, libcp1_compile): Update.
(cp_call_binding_oracle, cp_call_symbol_address)
(cp_call_enter_scope, cp_call_leave_scope): Update.
* libcc1.cc (struct libcc1): Derive from base_gdb_plugin.  Remove
shared code.
(class libcc1_connection): Remove.
(c_call_binding_oracle, c_call_symbol_address): Update.
(rpc): Remove.
(libcc1_set_verbose, libcc1_compile): Update.
* gdbctx.hh: New file.

3 years agolibcc1: share basic context code
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: share basic context code

Both plugins in libcc1 share a fair amount of boilerplate.  They both
share error-emission code, context management code, and tree GC code.
This patch unifies these two bodies of code, avoiding needless
duplication.

libcc1

* libcc1plugin.cc: Move code to context.cc.
* libcp1plugin.cc: Move code to context.cc.
* context.hh: New file.
* context.cc: New file.
* Makefile.in: Rebuild.
* Makefile.am (AM_CPPFLAGS): Add more gcc flags.
(CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): Update.
(libcc1plugin_la_SOURCES): Add context.hh, context.cc.
(libcp1plugin_la_SOURCES): Likewise.

3 years agolibcc1: use static_assert
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use static_assert

This changes one spot in libcc1 to use static_assert rather than the
old-style array declaration.

libcc1

* libcp1plugin.cc: Use static assert.

3 years agolibcc1: use foreach
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use foreach

This changes libcc1 to ues foreach in a couple of spots.

libcc1

* libcp1plugin.cc (plugin_context::mark): Use foreach.
* libcc1plugin.cc (plugin_context::mark): Use foreach.

3 years agolibcc1: unify compiler handling
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: unify compiler handling

Both libcc1 plugins have nearly identical copies of code to find the
underlying compiler.  This seemed wasteful to me, so this patch
unifies the copies.

Two minor API changes were needed.

First, the old code used a back-link from the compiler object to the
plugin object to check the 'verbose' setting.  This patch adds a
'verbose' setting directly to the compiler object instead.

Second, the 'find' method implicitly knew which compiler base name
("gcc" or "g++") to use.  This patch makes this a parameter that is
passed in by the plugin.

libcc1

* libcp1.cc (compiler, compiler_triplet_regexp)
(compiler_driver_filename): Remove.
(libcp1::libcp1): Update.
(make_regexp, libcp1::compiler::find)
(libcp1::compiler_triplet_regexp::find)
(libcp1::compiler_driver_filename::find): Remove.
(libcp1_set_verbose, libcp1_set_arguments)
(libcp1_set_triplet_regexp, libcp1_set_driver_filename): Update.
* libcc1.cc (compiler, compiler_triplet_regexp)
(compiler_driver_filename): Remove.
(libcc1::libcc1): Update.
(make_regexp, libcc1::compiler::find)
(libcc1::compiler_triplet_regexp::find)
(libcc1::compiler_driver_filename::find): Remove.
(libcc1_set_verbose, libcc1_set_arguments)
(libcc1_set_triplet_regexp, libcc1_set_driver_filename): Update.
* compiler.cc: New file.
* compiler.hh: New file.
* Makefile.in: Rebuild.
* Makefile.am (libcc1_la_SOURCES): Add compiler.hh, compiler.cc.

3 years agolibcc1: use unique_ptr more
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use unique_ptr more

This changes libcc1 to use unique_ptr in a few more places, removing
some manual memory management.

libcc1

* libcp1.cc (struct libcp1) <connection, compilerp>: Use
unique_ptr.
(~libcp1): Remove.
(libcp1_compile, libcp1_set_triplet_regexp)
(libcp1_set_driver_filename): Update.
* libcc1.cc (struct libcc1) <connection, compilerp>: Use
unique_ptr.
(~libcc1): Remove.
(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
(libcc1_compile): Update.

3 years agolibcc1: add more uses of 'deleter'
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: add more uses of 'deleter'

This changes libcc1 to use the 'deleter' template in a few more
places.  The template and basic specializations are moved to a new
header, then some unmarshall functions are changed to use this code.
This change avoids the need to repeat cleanup code in the
unmarshallers.

libcc1

* rpc.hh (deleter): Move template and some specializations to
deleter.hh.
(argument_wrapper<const T *>): Use cc1_plugin::unique_ptr.
* marshall.cc (cc1_plugin::unmarshall): Use
cc1_plugin::unique_ptr.
* marshall-cp.hh (deleter): New specializations.
(unmarshall): Use cc1_plugin::unique_ptr.
* deleter.hh: New file.

3 years agolibcc1: add deleter objects
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: add deleter objects

This adds deleter objects for various kinds of protocol pointers to
libcc1.  Existing specializations of argument_wrapper are then
replaced with a single specialization that handles all pointer types
via the appropriate deleter.  The result here is a bit nicer because
the argument_wrapper boilerplate code is completely shared, leaving
just the memory-management detail to the particular specializations.

libcc1

* rpc.hh (struct deleter): New template class and
specializations.
(argument_wrapper): Remove specializations.  Add specialization
for any pointer type.

3 years agolibcc1: use std::vector when building function types
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use std::vector when building function types

This changes libcc1 to use std::vector in the code that builds
function types.  This avoids some explicit memory management.

libcc1

* libcp1plugin.cc (plugin_build_function_type): Use std::vector.
* libcc1plugin.cc (plugin_build_function_type): Use std::vector.

3 years agolibcc1: use variadic templates for "rpc"
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use variadic templates for "rpc"

This changes libcc1 to use variadic templates for the "rpc" functions.
This simplifies the code and removes some possibility for mistakes.

libcc1

* libcp1.cc (rpc): Use variadic template.  Remove overloads.
* libcc1.cc (rpc): Use variadic template.  Remove overloads.

3 years agolibcc1: use variadic templates for "call"
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use variadic templates for "call"

This changes libcc1 to use variadic templates for the "call"
functions.  The primary benefit is that this simplifies the code.

libcc1

* rpc.hh (call): Use variadic template.  Remove overloads.
* marshall.hh (marshall): Add base overload.  Use variadic
template.

3 years agolibcc1: delete copy constructor and assignment operators
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: delete copy constructor and assignment operators

Change libcc1 to use "= delete" for the copy constructor and
assignment operator, rather than the old approach of private methods
that are nowhere defined.

libcc1

* rpc.hh (argument_wrapper): Use delete for copy constructor.
* connection.hh (class connection): Use delete for copy
constructor.
* callbacks.hh (class callbacks): Use delete for copy constructor.

3 years agolibcc1: inline some simple methods
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: inline some simple methods

This changes libcc1 to inline a trivial method and to use the default
constructor.

libcc1

* connection.hh (~connection): Use default.
(print): Inline.
* connection.cc (cc1_plugin::connection::~connection)
(cc1_plugin::connection::print): Remove definitions.

3 years agolibcc1: use "override"
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use "override"

This changes libcc1 to use "override" where appropriate.

libcc1

* libcp1.cc (class compiler_triplet_regexp)
(class compiler_driver_filename, class libcp1_connection): Use
"override".
* libcc1.cc (class compiler_triplet_regexp)
(class compiler_driver_filename, class libcc1_connection): Use
"override".

3 years agolibcc1: use templates to unmarshall enums
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use templates to unmarshall enums

Now that C++11 can be used in GCC, libcc1 can be changed to use
templates and type traits to handle unmarshalling all kinds of enums.

libcc1

* marshall.hh (cc1_plugin::unmarshall): Use type traits.
* marshall-cp.hh (cc1_plugin::unmarshall): Remove overloads.
* marshall-c.hh: Remove.
* libcc1plugin.cc: Update includes.
* libcc1.cc: Update includes.

3 years agoctype support for libstdc++ on VxWorks
Corentin Gay [Wed, 5 May 2021 00:49:43 +0000 (21:49 -0300)]
ctype support for libstdc++ on VxWorks

for  libstdc++-v3/ChangeLog

* acinclude.m4: Add VxWorks-specific case for the
configuration of ctypes.
* configure: Regenerate.
* config/locale/vxworks/ctype_members.cc: Add VxWorks-specific
version.
* config/os/vxworks/ctype_base.h: Adjust for VxWorks7+.
* config/os/vxworks/ctype_configure_char.cc: Likewise.
* config/os/vxworks/ctype_inline.h: Likewise.
* testsuite/28_regex/traits/char/isctype.cc: Defines
NEWLINE_IN_CLASS_BLANK if the target is VxWorks.
* testsuite/28_regex/traits/wchar_t/isctype.cc: Likewise.

3 years agorestore EH on x86-vx7r2
Alexandre Oliva [Wed, 5 May 2021 00:49:41 +0000 (21:49 -0300)]
restore EH on x86-vx7r2

x86-vx7r2 needs svr4_dbx_register_map, but the default in i386/i386.h
was dbx_register_map, partially swapping ebp and esp in unwind info.

i386/vxworks.h had a correct overrider, but it was conditional for
vxworks < 7.  This patch reenables the overrider unconditionally.

for  gcc/ChangeLog

* config/i386/vxworks.h (DBX_REGISTER_NUMBER): Make it
unconditional.

3 years agoDaily bump.
GCC Administrator [Wed, 5 May 2021 00:16:54 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Fix null dereferences in std::promise
Jonathan Wakely [Tue, 4 May 2021 15:28:57 +0000 (16:28 +0100)]
libstdc++: Fix null dereferences in std::promise

This fixes some ubsan errors in std::promise:

future:1153:34: runtime error: member call on null pointer of type 'struct element_type'
future:1153:34: runtime error: member access within null pointer of type 'struct element_type'

The problem is that the check for a null pointer is done inside the
_State::__Setter function, which is only evaluated after evaluating the
_M_future->_M_set_result postfix-expression.

This change adds a new promise::_M_state() helper for accessing
_M_future, and moves the check for no shared state into there, instead
of inside the __setter functions. The __setter functions are made
always_inline, to avoid the situation where the linker selects the old
version of set_value (without the _S_check call) and the new version of
__setter (without the _S_check call) and so there is no check. With the
always_inline attribute the old version of set_value will either inline
the old __setter or call an extern definition of it, and the new
set_value will do the check itself, so both versions do the check.

libstdc++-v3/ChangeLog:

* include/std/future (promise::set_value): Check for existence
of shared state before dereferncing it.
(promise::set_exception, promise::set_value_at_thread_exit)
(promise::set_exception_at_thread_exit): Likewise.
(promise<R&>::set_value, promise<R&>::set_exception)
(promise<R&>::set_value_at_thread_exit)
(promise<R&>::set_exception_at_thread_exit): Likewise.
(promise<void>::set_value, promise<void>::set_exception)
(promise<void>::set_value_at_thread_exit)
(promise<void>::set_exception_at_thread_exit): Likewise.
* testsuite/30_threads/promise/members/at_thread_exit2.cc:
Remove unused variable.

3 years agolibstdc++: Fix undefined behaviour in std::string
Jonathan Wakely [Tue, 4 May 2021 14:49:38 +0000 (15:49 +0100)]
libstdc++: Fix undefined behaviour in std::string

This fixes a ubsan error when constructing a string with a null pointer:

bits/basic_string.h:534:21: runtime error: applying non-zero offset 18446744073709551615 to null pointer

The _M_construct function only cares whether the second pointer is
non-null, so create a non-null value without undefined arithmetic.

We can also pass the random_access_iterator_tag directly to the
_M_construct function, to avoid going via the tag dispatching
_M_construct_aux, because we know we have pointers not integers here.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string(const CharT*, const A&)):
Do not do arithmetic on null pointer.

3 years agolibstdc++: Fix null dereference in pb_ds containers
Jonathan Wakely [Tue, 4 May 2021 14:46:28 +0000 (15:46 +0100)]
libstdc++: Fix null dereference in pb_ds containers

This fixes ubsan errors:

ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp:533:15: runtime error: member access within null pointer of type 'struct entry'

libstdc++-v3/ChangeLog:

* include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp
(find_key_pointer(key_const_reference, false_type))
(find_key_pointer(key_const_reference, true_type)): Do not
dereference null pointer.

3 years agolibstdc++ Fix undefined behaviour in testsuite
Jonathan Wakely [Tue, 4 May 2021 14:28:39 +0000 (15:28 +0100)]
libstdc++ Fix undefined behaviour in testsuite

Fix some test bugs found by ubsan.

libstdc++-v3/ChangeLog:

* testsuite/20_util/from_chars/3.cc: Use unsigned type to avoid
overflow.
* testsuite/24_iterators/reverse_iterator/2.cc: Do not add
non-zero value to null pointer.
* testsuite/25_algorithms/copy_backward/move_iterators/69478.cc:
Use past-the-end iterator for result.
* testsuite/25_algorithms/move_backward/69478.cc: Likewise.
* testsuite/25_algorithms/move_backward/93872.cc: Likewise.

3 years agoaix: encode function section
David Edelsohn [Tue, 4 May 2021 13:43:40 +0000 (09:43 -0400)]
aix: encode function section

AIX XCOFF symbols can be labels or qualnames (names with an appended
mapping class).  CSECTs must be declared with a mapping class.
Within an assembler file, the symbol names with and without the mapping
class are unique.  An object file symbol table only presents the symbol
name without the mapping class, but the section of the symbol depends on
the mapping class.

The AIX XCOFF assembly language does not support first class aliases.
GCC implements symbol aliases by emitting additional labels for the function
or object.  When GCC encodes sections for a DECL, it must distinguish
between the primary definition and the aliases, which don't have a
mapping class encoding.

.globl foo[DS]
.globl .foo
.globl foo1
.globl .foo1
.csect foo[DS]
foo:
foo1:
.long .foo, TOC[tc0] 0
.csect .foo[PR]
.foo:
.foo1:

The CSECT foo[DS] and label foo are distinct.  foo1 is another label (alias)
for foo, and .foo1 is another label (alias) for .foo.  foo is the function
descriptor and .foo is the code.

This patch adds the [DS] mapping class to the encoding of FUNCTION_DECL
but ensures that mapping class is not added to function aliases.

rs6000_output_mi_thunk is updated to emit the function name that matches
the behavior of GCC final.c for normal functions: get_fnname_from_decl based
on the RTL name, not the DECL name.

* config/rs6000/rs6000-call.c (rs6000_output_mi_thunk): Use
get_fnname_from_decl for name of thunk.
* config/rs6000/rs6000.c (rs6000_declare_alias): Use assemble_name
and ASM_OUTPUT_LABEL.
(rs6000_xcoff_declare_function_name): Use assemble_name and
ASM_OUTPUT_LABEL.
(rs6000_xcoff_declare_object_name): Use ASM_OUTPUT_LABEL.
(rs6000_xcoff_encode_section_info): Don't add mapping class
for aliases.  Always add [DS] mapping class to primary
FUNCTION_DECL.
(rs6000_asm_weaken_decl): Don't explicitly add [DS].

3 years agoPR middle-end/100307 - spurious -Wplacement-new with negative pointer offset
Martin Sebor [Tue, 4 May 2021 19:46:37 +0000 (13:46 -0600)]
PR middle-end/100307 - spurious -Wplacement-new with negative pointer offset

gcc/ChangeLog:

PR middle-end/100307
* builtins.c (compute_objsize_r): Clear base0 for pointers.

gcc/testsuite/ChangeLog:

PR middle-end/100307
* g++.dg/warn/Wplacement-new-size-9.C: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-26.c: New test.

3 years agoAdjust strings in dg-warning directives (PR testsuite/100412).
Martin Sebor [Tue, 4 May 2021 17:10:40 +0000 (11:10 -0600)]
Adjust strings in dg-warning directives (PR testsuite/100412).

gcc/testsuite/ChangeLog:
* gcc.dg/Wvla-parameter-3.c: Use unique strings in directive names.

3 years agoAdjust strings in dg-warning directives (PR testsuite/100412).
Martin Sebor [Tue, 4 May 2021 16:21:20 +0000 (10:21 -0600)]
Adjust strings in dg-warning directives (PR testsuite/100412).

gcc/testsuite/ChangeLog:
* gcc.dg/Wvla-parameter-2.c: Use unique strings in directive names.

3 years agoMake bfin-elf build again
Jeff Law [Tue, 4 May 2021 14:56:28 +0000 (08:56 -0600)]
Make bfin-elf build again

gcc/
* config/bfin/bfin.h (NOTICE_UPDATE_CC): Remove.

3 years agos390/testsuite: Fix oscbreak-1.c.
Robin Dapp [Mon, 15 Mar 2021 17:06:05 +0000 (18:06 +0100)]
s390/testsuite: Fix oscbreak-1.c.

Checking for an osc break is somewhat brittle especially with many
passes potentially introducing new insns and moving them around.
Therefore, only compile the test with -O1 -fschedule-insns in order
to limit the influence of other passes.

gcc/testsuite/ChangeLog:

* gcc.target/s390/oscbreak-1.c: Compile with -O1
-fschedule-insns

3 years agoRemove CC0
Segher Boessenkool [Fri, 23 Apr 2021 19:59:00 +0000 (19:59 +0000)]
Remove CC0

This removes CC0 and all directly related infrastructure.

CC_STATUS, CC_STATUS_MDEP, CC_STATUS_MDEP_INIT, and NOTICE_UPDATE_CC
are deleted and poisoned.  CC0 is only deleted (some targets use that
name for something else).  HAVE_cc0 is automatically generated, and we
no longer will do that after this patch.

CC_STATUS_INIT is suggested in final.c to also be useful for ports that
are not CC0, and at least arm seems to use it for something.  So I am
leaving that alone, but most targets that have it could remove it.

2021-05-04  Segher Boessenkool  <segher@kernel.crashing.org>

* caller-save.c: Remove CC0.
* cfgcleanup.c: Remove CC0.
* cfgrtl.c: Remove CC0.
* combine.c: Remove CC0.
* compare-elim.c: Remove CC0.
* conditions.h: Remove CC0.
* config/h8300/h8300.h: Remove CC0.
* config/h8300/h8300-protos.h: Remove CC0.
* config/h8300/peepholes.md: Remove CC0.
* config/i386/x86-tune-sched.c: Remove CC0.
* config/m68k/m68k.c: Remove CC0.
* config/rl78/rl78.c: Remove CC0.
* config/sparc/sparc.c: Remove CC0.
* config/xtensa/xtensa.c: Remove CC0.
(gen_conditional_move):  Use pc_rtx instead of cc0_rtx in a piece of
RTL where that is used as a placeholder only.
* cprop.c: Remove CC0.
* cse.c: Remove CC0.
* cselib.c: Remove CC0.
* df-problems.c: Remove CC0.
* df-scan.c: Remove CC0.
* doc/md.texi: Remove CC0.  Adjust an example.
* doc/rtl.texi: Remove CC0.  Adjust an example.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Remove CC0.
* emit-rtl.c: Remove CC0.
* final.c: Remove CC0.
* fwprop.c: Remove CC0.
* gcse-common.c: Remove CC0.
* gcse.c: Remove CC0.
* genattrtab.c: Remove CC0.
* genconfig.c: Remove CC0.
* genemit.c: Remove CC0.
* genextract.c: Remove CC0.
* gengenrtl.c: Remove CC0.
* genrecog.c: Remove CC0.
* haifa-sched.c: Remove CC0.
* ifcvt.c: Remove CC0.
* ira-costs.c: Remove CC0.
* ira.c: Remove CC0.
* jump.c: Remove CC0.
* loop-invariant.c: Remove CC0.
* lra-constraints.c: Remove CC0.
* lra-eliminations.c: Remove CC0.
* optabs.c: Remove CC0.
* postreload-gcse.c: Remove CC0.
* postreload.c: Remove CC0.
* print-rtl.c: Remove CC0.
* read-rtl-function.c: Remove CC0.
* reg-notes.def: Remove CC0.
* reg-stack.c: Remove CC0.
* reginfo.c: Remove CC0.
* regrename.c: Remove CC0.
* reload.c: Remove CC0.
* reload1.c: Remove CC0.
* reorg.c: Remove CC0.
* resource.c: Remove CC0.
* rtl.c: Remove CC0.
* rtl.def: Remove CC0.
* rtl.h: Remove CC0.
* rtlanal.c: Remove CC0.
* sched-deps.c: Remove CC0.
* sched-rgn.c: Remove CC0.
* shrink-wrap.c: Remove CC0.
* simplify-rtx.c: Remove CC0.
* system.h: Remove CC0.  Poison NOTICE_UPDATE_CC, CC_STATUS_MDEP_INIT,
CC_STATUS_MDEP, and CC_STATUS.
* target.def: Remove CC0.
* valtrack.c: Remove CC0.
* var-tracking.c: Remove CC0.

3 years agotree-optimization/100414 - compute dominance info in phiopt
Richard Biener [Tue, 4 May 2021 11:39:14 +0000 (13:39 +0200)]
tree-optimization/100414 - compute dominance info in phiopt

phiopt now has dominator queries but fails to compute dominance
info.

2021-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100414
* tree-ssa-phiopt.c (get_non_trapping): Do not compute dominance
info here.
(tree_ssa_phiopt_worker): But unconditionally here.

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

3 years agoOpenMP: Support complex/float in && and || reduction
Tobias Burnus [Tue, 4 May 2021 11:38:03 +0000 (13:38 +0200)]
OpenMP: Support complex/float in && and || reduction

C/C++ permit logical AND and logical OR also with floating-point or complex
arguments by doing an unequal zero comparison; the result is an 'int' with
value one or zero.  Hence, those are also permitted as reduction variable,
even though it is not the most sensible thing to do.

gcc/c/ChangeLog:

* c-typeck.c (c_finish_omp_clauses): Accept float + complex
for || and && reductions.

gcc/cp/ChangeLog:

* semantics.c (finish_omp_reduction_clause): Accept float + complex
for || and && reductions.

gcc/ChangeLog:

* omp-low.c (lower_rec_input_clauses, lower_reduction_clauses): Handle
&& and || with floating-point and complex arguments.

gcc/testsuite/ChangeLog:

* gcc.dg/gomp/clause-1.c: Use 'reduction(&:..)' instead of '...(&&:..)'.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/reduction-1.c: New test.
* testsuite/libgomp.c-c++-common/reduction-2.c: New test.
* testsuite/libgomp.c-c++-common/reduction-3.c: New test.

3 years agoReplace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file.
Nick Clifton [Tue, 4 May 2021 12:35:17 +0000 (13:35 +0100)]
Replace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file.

2021-05-04  Nick Clifton  <nickc@redhat.com>

* configure.ac (AC_PROG_CC): Replace with AC_PROG_CC_C99.
* configure: Regenerate.

3 years agolibstdc++: Do not use deduced return type for std::visit [PR 100384]
Jonathan Wakely [Tue, 4 May 2021 11:16:46 +0000 (12:16 +0100)]
libstdc++: Do not use deduced return type for std::visit [PR 100384]

This avoids errors outside the immediate context when std::visit is an
overload candidate because of ADL, but not actually viable.

The solution is to give std::visit a non-deduced return type. New
helpers are introduced for that, and existing ones refactored slightly.

libstdc++-v3/ChangeLog:

PR libstdc++/100384
* include/std/variant (__get_t): New alias template yielding the
return type of std::get<N> on a variant.
(__visit_result_t): New alias template yielding the result of
std::visit.
(__same_types): Move into namespace __detail::__variant.
(__check_visitor_results): Likewise. Use __invoke_result_t and
__get_t.
(__check_visitor_result): Remove.
(visit): Use __visit_result_t for return type.
* testsuite/20_util/variant/100384.cc: New test.

3 years agolibstdc++: Remove _GLIBCXX_USE_INT128 autoconf macro
Jonathan Wakely [Tue, 4 May 2021 11:07:09 +0000 (12:07 +0100)]
libstdc++: Remove _GLIBCXX_USE_INT128 autoconf macro

We don't need to decide whether to use __int128 when running configure,
we can do so at compilation time by seeing if __SIZEOF_INT128__ is
defined and if it's greater than __SIZEOF_LONG_LONG__.

This removes another unnecessary architecture-specific config macro in
<bits/c++config.h>, so the same header can work for 32-bit or 64-bit
compilation on AIX.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_INT128_FLOAT128): Remove
checks for __int128 and rename to GLIBCXX_ENABLE_FLOAT128.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Adjust to use GLIBCXX_ENABLE_FLOAT128.
* include/bits/random.h (_Select_uint_least_t<s, 1>):
Use __SIZEOF_INT128__ to decide whether to use __int128.
* include/std/charconv (__to_chars_unsigned_type): Likewise.

3 years agoReuse non-gimple_reg variable for inlining
Eric Botcazou [Tue, 4 May 2021 10:47:11 +0000 (12:47 +0200)]
Reuse non-gimple_reg variable for inlining

When a call to a function is inlined and takes a parameter whose type is not
gimple_reg, a local variable is created in the caller to hold a copy of the
argument passed in the call with the following comment:

      /* We may produce non-gimple trees by adding NOPs or introduce
         invalid sharing when operand is not really constant.
         It is not big deal to prohibit constant propagation here as
         we will constant propagate in DOM1 pass anyway.  *

Of course the second sentence of the comment does not apply to non-gimple_reg
values, unless they get SRAed later, because we don't do constant propagation
for them.  This for example prevents two identical calls to a pure function
from being merged in the attached Ada testcase.

Therefore the attached patch attempts to reuse a read-only or non-addressable
local DECL of the caller, the hitch being that expand_call_inline needs to be
prevented from creating a CLOBBER for the case where it ends uo being reused.

gcc/
* tree-inline.c (insert_debug_decl_map): Delete.
(copy_debug_stmt): Minor tweak.
(setup_one_parameter): Do not use a variable if the value is either
a read-only DECL or a non-addressable local variable in the caller.
In this case, insert the debug-only variable in the map manually.
(expand_call_inline): Do not generate a CLOBBER for these values.
* tree-inline.h (debug_map): Minor tweak.

3 years agoFix libiberty link failures in LTO mode for MinGW
Eric Botcazou [Tue, 4 May 2021 10:40:42 +0000 (12:40 +0200)]
Fix libiberty link failures in LTO mode for MinGW

The test for the presence of variables (really symbols) does not work
when you add -Ox -flto to CFLAGS:

  for v in $vars; do
    AC_MSG_CHECKING([for $v])
    AC_CACHE_VAL(libiberty_cv_var_$v,
      [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int *p;]],[[extern int $v [];
                                         p = $v;]])],
                      [eval "libiberty_cv_var_$v=yes"],
                      [eval "libiberty_cv_var_$v=no"])])
    if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
      AC_MSG_RESULT(yes)
      AC_DEFINE_UNQUOTED($n)
    else
      AC_MSG_RESULT(no)
    fi
  done

because the assignment to 'p' is optimized away by LTO.  This is visible
on MinGW platforms in the form of a link failure for sys_siglist.

There is another link failures for stpcpy: the symbol is both referenced
by libiberty's pex-win32.c and provided by libiberty's stpcpy.c, so it
needs to have a linkage to be resolved in LTO mode.

libiberty/
* configure.ac: Make test for variables more robust.
* configure: Regenerate.
gcc/
* builtins.c (builtin_with_linkage_p): Return true for stp[n]cpy.
* symtab.c (symtab_node::output_to_lto_symbol_table_p): Tidy up.

3 years agoRestrict gcc.dg/tree-ssa/ssa-dse-26.c
Richard Biener [Tue, 4 May 2021 09:35:24 +0000 (11:35 +0200)]
Restrict gcc.dg/tree-ssa/ssa-dse-26.c

This restricts the testcase to the target where it exposes the
situation fixed with g:e9d297a15d68121ba5bdd5a76ea71c1916180622
which targets BIT_FIELD_REFs created by fold_truth_andor.

This avoids strange dejagnu limits with overly long target lists
and simplifies the tests.

2021-05-04  Richard Biener  <rguenther@suse.de>

* gcc.dg/tree-ssa/ssa-dse-26.c: Skip on !lp64 targets,
simplify dump scanning down to one case.

3 years agotree-optimization/100329 - avoid reassociating asm goto defs
Richard Biener [Tue, 4 May 2021 08:07:35 +0000 (10:07 +0200)]
tree-optimization/100329 - avoid reassociating asm goto defs

This avoids reassociating asm goto defs because we have no idea
on which outgoing edge to insert defs.

2021-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100329
* tree-ssa-reassoc.c (can_reassociate_p): Do not reassociate
asm goto defs.
(insert_stmt_after): Assert we're not running into asm goto.

* gcc.dg/torture/pr100329.c: New testcase.

3 years agotree-optimization/100398 - avoid DSE of control flow stmt
Richard Biener [Tue, 4 May 2021 07:18:11 +0000 (09:18 +0200)]
tree-optimization/100398 - avoid DSE of control flow stmt

The following makes sure to preserve control altering stmts
when removing trivially dead stmts in DSE.

2021-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100398
* tree-ssa-dse.c (pass_dse::execute): Preserve control
altering stmts.

* gcc.dg/torture/pr100398.c: New testcase.

3 years ago[Ada] Remove arbitrary and redundant qualification with Sinfo
Piotr Trojanek [Fri, 8 Jan 2021 12:04:06 +0000 (13:04 +0100)]
[Ada] Remove arbitrary and redundant qualification with Sinfo

gcc/ada/

* pprint.adb: Remove qualification of arbitrary calls to
Sinfo.Expressions and Sinfo.Parameter_Associations.

3 years ago[Ada] Use function and not procedure UI_Image in pretty-printing
Piotr Trojanek [Fri, 8 Jan 2021 12:02:12 +0000 (13:02 +0100)]
[Ada] Use function and not procedure UI_Image in pretty-printing

gcc/ada/

* pprint.adb (Expr_Name): Simplify with functional variant of
UI_Image.

3 years ago[Ada] Reuse existing To_Mixed routine in pretty-printer
Piotr Trojanek [Fri, 8 Jan 2021 11:50:24 +0000 (12:50 +0100)]
[Ada] Reuse existing To_Mixed routine in pretty-printer

gcc/ada/

* pprint.adb (To_Mixed): Removed.

3 years ago[Ada] Refine type of a counter variable from Integer to Natural
Piotr Trojanek [Fri, 8 Jan 2021 11:10:51 +0000 (12:10 +0100)]
[Ada] Refine type of a counter variable from Integer to Natural

gcc/ada/

* pprint.adb (List_Name_Count): Change type from Integer to
Natural.

3 years ago[Ada] Minor tweak in pretty-printing of expressions
Yannick Moy [Fri, 8 Jan 2021 08:38:59 +0000 (09:38 +0100)]
[Ada] Minor tweak in pretty-printing of expressions

gcc/ada/

* pprint.adb (Expression_Image): Special case for
expression-with-actions.

3 years ago[Ada] Do not "optimize" by converting Positive to Unsigned
Bob Duff [Thu, 7 Jan 2021 19:16:21 +0000 (14:16 -0500)]
[Ada] Do not "optimize" by converting Positive to Unsigned

gcc/ada/

* exp_ch4.adb (Expand_Concatenate): Remove the non-optimization.

3 years ago[Ada] Reuse First_Formal for generic subprograms
Piotr Trojanek [Thu, 7 Jan 2021 11:17:49 +0000 (12:17 +0100)]
[Ada] Reuse First_Formal for generic subprograms

gcc/ada/

* lib-xref.adb (Generate_Reference_To_Formals): Remove dedicated
branch for generic subprograms (they are now handled together
with non-generic subprograms in the ELSE branch); replace a
low-level Ekind membership test with a high-level call to
Is_Access_Subprogram_Type.

3 years ago[Ada] Fix inconsistent iteration with First_Formal and Next_Entity
Piotr Trojanek [Thu, 7 Jan 2021 11:14:42 +0000 (12:14 +0100)]
[Ada] Fix inconsistent iteration with First_Formal and Next_Entity

gcc/ada/

* sem_ch12.adb (Check_Abstract_Primitives): Match First_Formal
with Next_Formal.
* sem_ch6.adb (Is_Non_Overriding_Operation): Likewise.

3 years ago[Ada] Simplify iteration over formal parameters for Global/Depends check
Piotr Trojanek [Thu, 7 Jan 2021 10:50:51 +0000 (11:50 +0100)]
[Ada] Simplify iteration over formal parameters for Global/Depends check

gcc/ada/

* sem_prag.adb (Collect_Global_Item): Iterate directly over
formals.

3 years ago[Ada] Fix handling of access-to-variable objects in Global and Depends
Piotr Trojanek [Wed, 6 Jan 2021 11:47:28 +0000 (12:47 +0100)]
[Ada] Fix handling of access-to-variable objects in Global and Depends

gcc/ada/

* sem_prag.ads (Collect_Subprogram_Inputs_Outputs): Update
comment; this routine is no longer used by GNATprove.
* sem_prag.adb (Find_Role): The IN parameter is on output only
when it belongs to non-function; also, the otherwise constant
object can only be written by a non-function.
(Collect_Global_Item): The IN parameter can only be written when
it belongs to non-function; also, unnest this check to make it
easier to read.

3 years ago[Ada] Assert_Failure vs Assertion_Error
Arnaud Charlet [Wed, 6 Jan 2021 09:41:54 +0000 (04:41 -0500)]
[Ada] Assert_Failure vs Assertion_Error

gcc/ada/

* libgnat/s-assert.ads (Assert_Failure): Now a renaming of
Assertion_Error.
* libgnat/a-assert.ads (Assertion_Error): Now a first class
citizen.  Remove dependency on System.Assertions.
* gcc-interface/a-assert.ads, gcc-interface/a-assert.adb: New.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Add
a-assert.o from gcc-interface.

3 years ago[Ada] Move match function for pragma Warnings to public spec
Yannick Moy [Wed, 6 Jan 2021 13:39:23 +0000 (14:39 +0100)]
[Ada] Move match function for pragma Warnings to public spec

gcc/ada/

* erroutc.adb (Matches): Move spec...
* erroutc.ads (Matches): ...here.

3 years ago[Ada] Use error marker for messages in GNATprove mode
Yannick Moy [Wed, 6 Jan 2021 10:31:28 +0000 (11:31 +0100)]
[Ada] Use error marker for messages in GNATprove mode

gcc/ada/

* gnat1drv.adb (Adjust_Global_Switches): Force error marker in
GNATprove mode.

3 years ago[Ada] Clean up ??? marks
Bob Duff [Tue, 5 Jan 2021 19:16:00 +0000 (14:16 -0500)]
[Ada] Clean up ??? marks

gcc/ada/

* binde.adb: No need for ??? marks in Binde, because it is
superseded by Bindo.
* bindo-writers.adb (Write_Unit_Closure): Verified that -Ra
works.
* exp_ch4.adb, sinfo.ads (Expand_N_Type_Conversion): Rules for
conversions passed to gigi are documented in sinfo.ads.
(Expand_N_Unchecked_Type_Conversion): Comment is a duplicate of
one in sinfo.ads.
(Expand_N_In): Robert already added sufficient comments years
after the ??? comment was inserted.
(Expand_Membership_Minimize_Eliminate_Overflow): I don't see any
reason why Stand should export Long_Long_Integer'Base -- it
doesn't export any other base types.
(Size_In_Storage_Elements): We are doing an allocator, so we
don't care about sizes in bits.
(Expand_N_Allocator): PolyORB isn't going to be significantly
improved, so we're not going to mess with remote access to
class-wide types.
(Optimize_Return_Stmt): It's not important to optimize return
statements in predicate functions -- there are many
more-important optimizations we could do. Keep part of the
comment without "???", to clarify why the "and then ...".
(User_Defined_Primitive_Equality_Op): The optimization doesn't
seem important enough.
(Expand_N_Unchecked_Type_Conversion): Refactor to use
Expand_N_Unchecked_Expression.
(Make_Array_Comparison_Op): This seems like a case of "it it's
not broken, don't fix it". Too much risk of causing bugs.
* debug_a.adb: Remove ??? comments asking why Current_Error_Node
is maintained unconditionally, and add a comment explaining why.
* errout.adb: These kinds of minor bugs do indeed exist, but
we're never going to get around to fixing them "properly", so we
need this code for robustness.
* gnatchop.adb (Read_File): Document when read can fail.
* gnatdll.adb (Parse_Command_Line): Nobody is complaining about
these arbitrary limits, so no need to use Table. Increase the
limits just in case.  It is clear from the names what they are
limits on.
* gnatlink.adb: Add needed comments.
(Delete): An existing comment makes clear it's intentional, and
it's been like that since 1996.
(Process_Args): Improve comments.
(Search_Library_Path): Refactoring to avoid deep nesting.
* inline.adb (Build_Body_To_Inline): Probably won't get around
to doing that optimization.
(Is_Unit_Subprogram): No, this should not be moved to Sem_Aux,
because it is too specialized to this context.
(Do_Reset): No comment is needed here; it's clear from the
comment on Reset_Dispatching_Calls. Do_Reset is an artificial
subprogram; if we had proper iterators, it would just be an if
statement in the loop.
(Rewrite_Function_Call): Probably won't get around to doing that
optimization.
* layout.adb (Layout_Type): The gigi comment doesn't need to be
a ??? comment, and it's been that way since 2000.  The
limitation to scalars will likely never be investigated, and
it's been that way since 2009.
* lib.adb (Check_Same_Extended_Unit): This doesn't look like
something that needs fixing; it looks like a permanent
workaround.
* lib-load.adb (Change_Main_Unit_To_Spec): It is good enough in
practice.
(Load_Unit): Nobody will ever get around to investigating the
obscure PMES oddity, and the optimization is not worth the
trouble.
* live.adb: It's not worth documenting this. It is used only
with a debug switch. Nobody who has done significant work on it
is still around, so it would require substantial investigation.
* mdll.ads: I see no reason for USE.
* namet.ads: Routines are obsolete, but they're not going
anywhere anytime soon (too much work, and surprisingly delicate
because of dependences on global variables).
* osint.ads: Minor.
* osint.adb: Improve comments.
(Full_Lib_File_Name): Use Smart_Find_File.

3 years ago[Ada] Reuse Is_Formal_Object where convenient
Piotr Trojanek [Wed, 6 Jan 2021 11:04:56 +0000 (12:04 +0100)]
[Ada] Reuse Is_Formal_Object where convenient

gcc/ada/

* exp_prag.adb, sem_prag.adb: Replace low-level Ekind membership
tests with a high-level call to Is_Formal_Object.

3 years ago[Ada] Address some ??? comments
Arnaud Charlet [Tue, 5 Jan 2021 13:05:12 +0000 (08:05 -0500)]
[Ada] Address some ??? comments

gcc/ada/

* cstand.adb, sprint.adb, switch-c.adb, xr_tabls.ads,
xr_tabls.adb, xref_lib.adb: Address ??? comments.

3 years ago[Ada] Reject constants of access-to-variable type as function globals
Piotr Trojanek [Tue, 5 Jan 2021 22:54:09 +0000 (23:54 +0100)]
[Ada] Reject constants of access-to-variable type as function globals

gcc/ada/

* sem_prag.adb (Analyze_Global_Item): Take subprogram kind into
account when accepting or rejecting a constant of an
access-to-variable type as a global Output/In_Out; do this check
inside an ELSIF branch to avoid unnecessary evaluation of the
subsequent condition.

3 years ago[Ada] Simplify use of a global name buffer for Global/Depends errors
Piotr Trojanek [Tue, 5 Jan 2021 17:32:05 +0000 (18:32 +0100)]
[Ada] Simplify use of a global name buffer for Global/Depends errors

gcc/ada/

* sem_prag.adb (Role_Error, Usage_Error): Replace calls to
Name_Find and Get_Name_String with a call to To_String.

3 years ago[Ada] Ongoing work for AI12-0212: container aggregates
Ed Schonberg [Mon, 4 Jan 2021 20:28:55 +0000 (15:28 -0500)]
[Ada] Ongoing work for AI12-0212: container aggregates

gcc/ada/

* exp_aggr.adb (Build_Siz_Exp): new function, subsidiary of
Expand_Container_Aggregate, to create an expression to be used
in the dynamic allocation of a container with a single container
element association.
(Add_Range): Handle static bounds of ranges over enumerations.
(Expand_Container_Aggregate): Add declaration for size
expression when needed, and use it in container object
declaration for container.

3 years ago[Ada] Missing finalization on generic instantiation
Arnaud Charlet [Thu, 17 Dec 2020 08:09:00 +0000 (03:09 -0500)]
[Ada] Missing finalization on generic instantiation

gcc/ada/

* exp_ch7.adb (Build_Finalizer_Helper.New_Finalizer_Name):
Unnest so that it can be reused.
(Build_Finalizer_Helper.Process_Declarations): Call the
xxx__finalize_body procedure of a package instantiation in case
it contains finalization statements.  Code clean ups.
(Build_Finalizer_Helper.Create_Finalizer): Export and set an
Interface_Name for library level finalizers since these may be
imported now.
(Build_Finalizer_Helper): Need to process library level package
body instantiations which may contain objects requiring
finalization.
* libgnat/s-finmas.ads: Fix typo.

3 years ago[Ada] Address some ??? comments in checks.adb
Arnaud Charlet [Mon, 4 Jan 2021 11:43:09 +0000 (06:43 -0500)]
[Ada] Address some ??? comments in checks.adb

gcc/ada/

* checks.adb (Append_Range_Checks, Apply_Selected_Length_Checks,
Determine_Range, Insert_Range_Checks,
Install_Null_Excluding_Check, Selected_Length_Checks,
Selected_Range_Checks): Address ??? comments and code cleanups.

3 years ago[Ada] Reject formals of mode IN appearing as global outputs
Piotr Trojanek [Tue, 22 Dec 2020 00:06:31 +0000 (01:06 +0100)]
[Ada] Reject formals of mode IN appearing as global outputs

gcc/ada/

* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context):
Apply the rule even with no explicit Global contract (and remove
a dead condition for Refined_Global).

3 years ago[Ada] Check entries for formals of mode IN appearing as global outputs
Piotr Trojanek [Mon, 21 Dec 2020 23:58:21 +0000 (00:58 +0100)]
[Ada] Check entries for formals of mode IN appearing as global outputs

gcc/ada/

* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context):
Extend check to protected entries.

3 years ago[Ada] Fix reference to SPARK RM rule in comment
Piotr Trojanek [Tue, 22 Dec 2020 00:01:11 +0000 (01:01 +0100)]
[Ada] Fix reference to SPARK RM rule in comment

gcc/ada/

* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context):
Fix reference to SPARK RM rule number.

3 years ago[Ada] Preliminary cleanup in floating-point output implementation
Eric Botcazou [Mon, 21 Dec 2020 07:37:34 +0000 (08:37 +0100)]
[Ada] Preliminary cleanup in floating-point output implementation

gcc/ada/

* exp_intr.adb: Remove with/use clauses for Urealp.
(Expand_Is_Negative): Delete.
(Expand_Intrinsic_Call): Do not call it.
* rtsfind.ads (RE_Id): Remove RE_Float_Unsigned.
(RE_Unit_Table): Remove entry for RE_Float_Unsigned.
* snames.ads-tmpl (Name_Is_Negative): Delete.
* libgnat/s-imgrea.ads (Set_Image_Real): Fix mode of S parameter.
* libgnat/s-imgrea.adb: Add with/use clauses for System.Img_Util.
(LLU): New subtype.
(Maxdigs): Use it.
(Is_Negative): Reimplement.
(Image_Floating_Point): Simplify.
(Set_Image_Real): Fix mode of S parameter.  Remove the low-level
processing on characters.  Flip the sign of the Scale variable.
Compute the maximum number of digits for the straight notation.
Call Set_Decimal_Digits at the end to do the final formatting.
* libgnat/s-imguti.ads (Floating_Invalid_Value): New type.
(Set_Floating_Invalid_Value): New procedure.
* libgnat/s-imguti.adb (Set_Floating_Invalid_Value): Implement it
based on existing code from Set_Image_Real.
* libgnat/s-unstyp.ads (Float_Unsigned): Delete.

3 years ago[Ada] Fix inconsistent handling of character set control switches
Piotr Trojanek [Fri, 1 Jan 2021 23:51:21 +0000 (00:51 +0100)]
[Ada] Fix inconsistent handling of character set control switches

gcc/ada/

* csets.adb (Initialize): Refactor into CASE statement; raise
exception on unsupported code of character set (it will be
gently rejected earlier when scanning command line switches).
* switch-b.adb (Scan_Binder_Switches): Refactor into a
membership expression; add missing '9' choice; reorder as
described by GNAT UG, section 4.3.11.
* switch-c.adb (Scan_Front_End_Switches): Refactor into a
membership expression and reorder as above.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(gnatic): Mention '5' as an allowed value for "c".
* gnat_ugn.texi: Regenerate.

3 years ago[Ada] Guard against leading and trailing spaces reappearing in errors
Piotr Trojanek [Mon, 28 Dec 2020 14:33:08 +0000 (15:33 +0100)]
[Ada] Guard against leading and trailing spaces reappearing in errors

gcc/ada/

* errout.adb (Error_Msg_Internal): Add assertion to prevent
style mistakes reappearing in the future.