Commit graph

193272 commits

Author SHA1 Message Date
Richard Biener
ebce0e9bd8 tree-optimization/105618 - restore load sinking
The PR97330 fix caused some missed sinking of loads out of loops
the following patch re-instantiates.

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

	PR tree-optimization/105618
	* tree-ssa-sink.cc (statement_sink_location): For virtual
	PHI uses ignore those defining the used virtual operand.

	* gcc.dg/tree-ssa/ssa-sink-19.c: New testcase.
2022-05-17 10:45:45 +02:00
Piotr Trojanek
33400df641 [Ada] Restore defensive guard in checks for volatile actuals
When flagging names of volatile objects occurring in actual parameters
it is safer to guard against identifiers without entity. This is
redundant (because earlier in the resolution of actual parameters we
already guard against actuals with Any_Type), but perhaps such
identifiers will become allowed in constructs like:

   Subprogram_Call
     (Actual =>
        (declare
           X : Boolean := ...
             with Annotate (GNATprove, ...)));
                            ^^^^^^^^^

which include an identifier that does not denote any entity.

Code cleanup related to handling of volatile components; behaviour is
unaffected.

gcc/ada/

	* sem_res.adb (Flag_Effectively_Volatile_Objects): Restore
	redundant guard.
2022-05-17 08:25:50 +00:00
Gary Dismukes
de0665fc7f [Ada] Subprogram renaming fails to hide homograph
The compiler failed to detect an error where the first prefix of an
expanded name given as the renamed subprogram in a subprogram renaming
declaration denotes a unit with the same name as the name given for the
subprogram renaming. Such a unit must be hidden by the renaming itself.
An error check is added to catch this case.

gcc/ada/

	* sem_ch8.adb (Analyze_Subprogram_Renaming): Add error check for
	the case of a renamed subprogram given by an expanded name whose
	outermost prefix names a unit that is hidden by the name of the
	renaming.
	(Ult_Expanded_Prefix): New local expression function to return
	the ultimate prefix of an expanded name.
2022-05-17 08:25:49 +00:00
Ghjuvan Lacambre
a51b6016c9 [Ada] CUDA: remove code performing kernel registration
A previous commit implemented a new kernel registration scheme, using
the binder to generate registration code rather than inserting
registration code in packages.  Now that this new approach has had time
to be thoroughly tested, it is time to remove the old approach.

gcc/ada/

	* gnat_cuda.ads: Update package-level comments.
	(Build_And_Insert_CUDA_Initialization): Remove function.
	* gnat_cuda.adb (Build_And_Insert_CUDA_Initialization): Remove
	function.
	(Expand_CUDA_Package): Remove call to
	Build_And_Insert_CUDA_Initialization.
2022-05-17 08:25:49 +00:00
Etienne Servais
5ab656c5e9 [Ada] Enhance the warning on C enum with size clause for size /= 32
Improve the warning message and silence warning when size > 32, this is
likely intentional and does not warrant a warning.

gcc/ada/

	* freeze.adb (Freeze_Enumeration_Type): Fix comment, enhance
	message and silence warning for size > 32.
2022-05-17 08:25:49 +00:00
Yannick Moy
3c802e9749 [Ada] Allow inlining for proof inside generics
For local subprograms without contracts inside generics, allow their
inlining for proof in GNATprove mode. This requires forbidding the
inlining of subprograms which contain references to object renamings,
which would be replaced in the SPARK expansion and violate assumptions
of the inlining code.

gcc/ada/

	* exp_spark.adb (Expand_SPARK_Potential_Renaming): Deal with no
	entity case.
	* inline.ads (Check_Object_Renaming_In_GNATprove_Mode): New
	procedure.
	* inline.adb (Check_Object_Renaming_In_GNATprove_Mode): New
	procedure.
	(Can_Be_Inlined_In_GNATprove_Mode): Remove case forbidding
	inlining for subprograms inside generics.
	* sem_ch12.adb (Copy_Generic_Node): Preserve global entities
	when inlining in GNATprove mode.
	* sem_ch6.adb (Analyse_Subprogram_Body_Helper): Remove body to
	inline if renaming is detected in GNATprove mode.
2022-05-17 08:25:48 +00:00
Gary Dismukes
867bf6f087 [Ada] Provide allocation subtype for allocators of a Designated_Storage_Model type
When an allocator is for an access type that has a
Designated_Storage_Model aspect, and the designated type is an
unconstrained record type with discriminants, and the subtype associated
with the allocator is constrained, a dereference of the new access value
can be passed to the designated type's initialization procedure. The
post-front-end phase of the compiler needs to be able to create a
temporary object in the host memory space to pass to the init proc,
which requires creating such an object, but the subtype needed for the
allocation isn't readily available at the point of the dereference.  To
make the subtype easily accessible, we set the Actual_Designated_Subtype
of such a dereference to the subtype of the allocated object.

gcc/ada/

	* exp_ch4.adb (Expand_N_Allocator): For an allocator with an
	unconstrained discriminated designated type, and whose
	allocation subtype is constrained, set the
	Actual_Designated_Subtype of the dereference passed to the init
	proc of the designated type to be the allocation subtype.
	* sinfo.ads: Add documentation of new setting of
	Actual_Designated_Subtype on a dereference used as an actual
	parameter of call to an init proc associated with an allocator.
	Also add missing syntax and documentation for the GNAT language
	extension that allows an expression as a default for a concrete
	generic formal function.
2022-05-17 08:25:48 +00:00
Bob Duff
f2ef7a0545 [Ada] Cleanups related to front-end SJLJ
This patch cleans up some code that is left over from the front-end SJLJ
exception handling mechanism, which has been removed.
This is in preparation for fixing a finalization-related bug.

Most importantly:

    The documentation is changed: a Handled_Sequence_Of_Statements node
    CAN contain both Exception_Handlers and an At_End_Proc.

    The assertion contradicting that is removed from
    Expand_At_End_Handler.

    The From_At_End field is removed.

gcc/ada/

	* sinfo.ads: Remove From_At_End.  Update comments.
	* gen_il-fields.ads, gen_il-gen-gen_nodes.adb, sem_ch11.adb:
	Remove From_At_End.
	* exp_ch11.adb (Expand_At_End_Handler): Remove assertion.
	* fe.h (Exception_Mechanism, Exception_Mechanism_Type, Has_DIC,
	Has_Invariants, Is_List_Member, List_Containing): Remove
	declarations that are not used in gigi.
	* opt.ads (Exception_Mechanism): This is not used in gigi.
	* exp_util.ads: Minor comment fix.
2022-05-17 08:25:48 +00:00
Dmitriy Anisimkov
26b0b2ddf4 [Ada] GNAT.Binary_Search is not internal
Put package GNAT.Binary_Search to predefined units list.

gcc/ada/

	* impunit.adb: Add "g-binsea" to Non_Imp_File_Names_95 list.
2022-05-17 08:25:47 +00:00
Yannick Moy
5c44da007b [Ada] Fix insertion of declaration inside quantified expression
When the evaluation of the subtype_indication for the
iterator_specification of a quantified_expression leads to the insertion
of a type declaration, this should be done with Insert_Action instead of
Insert_Before.

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Use
	Insert_Action when possibly inside an expression.
2022-05-17 08:25:47 +00:00
Marc Poulhiès
5dbb65676f [Ada] Fix Forced sign flag in formatted string
Fix the Forced sign flag that is incorrectly ignored for scientific
notation and shortest representation.

gcc/ada/

	* libgnat/g-forstr.adb (Is_Number): Add scientific notation and
	shortest representation.
2022-05-17 08:25:46 +00:00
Eric Botcazou
42fe7c9a80 [Ada] Fix small glitch in Expand_N_Full_Type_Declaration
The original node is not guaranteed to also be an
N_Full_Type_Declaration, so the code needs to look into the node itself.

gcc/ada/

	* exp_ch3.adb (Expand_N_Full_Type_Declaration): Look into N.
2022-05-17 08:25:46 +00:00
Bob Duff
80d1067508 [Ada] Requires_Cleanup_Actions and N_Protected_Body
This patch disallows N_Protected_Body from being passed to
Requires_Cleanup_Actions. Protected bodies never need cleanup, and are
never passed to Requires_Cleanup_Actions, which is a good thing, because
it would blow up on Handled_Statement_Sequence, which doesn't exist for
N_Protected_Body.

gcc/ada/

	* exp_util.adb (Requires_Cleanup_Actions): Remove
	N_Protected_Body from the case statement, so that case will be
	covered by "raise Program_Error".
2022-05-17 08:25:46 +00:00
Bob Duff
b81c9e4f9f [Ada] Output.w always writes to stderr
There are several debugging procedures called Output.w, and some
output-redirection features. This patch modifies Output.w so their
output is not redirected; it always goes to standard error. Otherwise,
debugging output can get mixed in with some "real" output (perhaps to a
file), which causes confusion and in some cases failure to build.

gcc/ada/

	* output.adb (Pop_Output, Set_Output): Unconditionally flush
	output when switching from one output destination to another.
	Otherwise buffering can cause garbled output.
	(w): Push/pop the current settings, and temporarily
	Set_Standard_Error during these procedures.
2022-05-17 08:25:46 +00:00
Dmitriy Anisimkov
a2bcadcef0 [Ada] Generic binary search implementation
Allows binary search in sorted anonymous array (or array-like
container).

gcc/ada/

	* libgnat/g-binsea.ads, libgnat/g-binsea.adb
	(GNAT.Binary_Search): New package.
	* Makefile.rtl (GNATRTL_NONTASKING_OBJS): New item in list.
	* doc/gnat_rm/the_gnat_library.rst (GNAT.Binary_Search): New
	package record.
	* gnat_rm.texi: Regenerate.
2022-05-17 08:25:45 +00:00
Eric Botcazou
ca3e565395 [Ada] Fix bogus visibility error with partially parameterized formal package
The problem comes from the special instantiation (abbreviated instantiation
in GNAT parlance) done to check conformance between a formal package and its
corresponding actual in a generic instantiation: the compiler instantiates
the formal package, in the context of the generic instantiation, so that it
can check the conformance of the actual with the result.

More precisely, it occurs with formal packages that are only partially
parameterized, i.e. that have at least one parameter association and an
(others => <>) choice. In this case, RM 12.7(10/2) says that the visible
part of the formal package contains a copy of the formal parameters that
are not explicitly associated.

The analysis of these copies for the abbreviated instantiation is not done
in the correct context when the generic unit is a child generic unit.

gcc/ada/

	* sem_ch12.ads (Is_Abbreviated_Instance): Declare.
	* sem_ch12.adb (Check_Abbreviated_Instance): Declare.
	(Requires_Conformance_Checking): Declare.
	(Analyze_Association.Process_Default): Fix subtype of parameter.
	(Analyze_Formal_Object_Declaration): Check whether it is in the
	visible part of abbreviated instance.
	(Analyze_Formal_Subprogram_Declaration): Likewise.
	(Analyze_Formal_Type_Declaration): Likewise.
	(Analyze_Package_Instantiation): Do not check for a generic child
	unit in the case of an abbreviated instance.
	(Check_Abbreviated_Instance): New procedure.
	(Check_Formal_Packages): Tidy up.
	(Copy_Generic_Elist): Fix comment.
	(Instantiate_Formal_Package): Tidy up.  If the generic unit is a
	child unit, copy the qualified name onto the abbreviated instance.
	(Is_Abbreviated_Instance): New function.
	(Collect_Previous_Instances): Call Is_Abbreviated_Instance.
	(Requires_Conformance_Checking): New function.
	* sem_ch7.adb (Analyze_Package_Specification): Do not install the
	private declarations of the parent for an abbreviated instance.
2022-05-17 08:25:45 +00:00
Etienne Servais
27b2b83bd7 [Ada] Take full view of private type
This allows to resolve the following:

      type Rec (<>) is private;
      type Arr (<>) is private;
   private
      type Arr is array (Positive range <>) of Natural;
      type Rec (L : Natural) is record
         F1 : Integer;
         F2 : Arr (1 .. L);
      end record;

gcc/ada/

	* sem_ch3.adb (Analyze_Subtype_Declaration): Use underlying type
	of Indic_Typ.
	(Constrain_Array): Ditto for T.
2022-05-17 08:25:44 +00:00
Arnaud Charlet
c21a0097b6 [Ada] Allow 'Reduce with -gnat2022
After a period of experimentation, allow 'Reduce in Ada 2022 mode.

gcc/ada/

	* sem_attr.adb (Analyze_Attribute [Attribute_Reduce]): Allow
	'Reduce for Ada 2022 and above.
	* sem_attr.ads (Attribute_Impl_Def): 'Reduce is no longer
	implementation defined.
2022-05-17 08:25:44 +00:00
Ghjuvan Lacambre
6e2d6b8e8e [Ada] Don't create calls to Abort_Undefer when not Abort_Allowed
Prevent creation of references to Abort_Undefer when aborts aren't
allowed. Another solution could have been an early return at
Expand_N_Asynchronous_Select's beginning, but this would break backends
that currently expect trees that do not contain any
N_Asynchronous_Selects in their AST (e.g. CodePeer).

gcc/ada/

	* exp_ch9.adb (Expand_N_Asynchronous_Select): Don't generate
	Abort_Undefers when not Abort_Allowed.
2022-05-17 08:25:44 +00:00
Marc Poulhiès
98208e364c [Ada] Typo fix in finalization comment
Add missing 's' and reformat the comment block.

gcc/ada/

	* exp_ch7.adb: Fix typo.
2022-05-17 08:25:43 +00:00
Etienne Servais
83bfddac6f [Ada] Initialize Compiler_State to avoid Constraint_Error
When building gnat1 with `-gnatVa` as we do locally, rules like: `gcc -c
-gnatyM79 <any adb file with lines longer than 79>` will throw a
constraint error as `lib.compiler_state` is initialized by par.adb, ie
after scanning. Therefore any error_msg thrown during scanning will
perform this uninitialized read (which raises a Constraint_Error when
the compiler was compiled with `-gnatVa`).

Initialize this flag to `Parsing`.

gcc/ada/

	* lib.ads: initialize `Compiler_State` to `Parsing`.
2022-05-17 08:25:43 +00:00
Eric Botcazou
d678717ab2 [Ada] Deal with derived record types in Has_Compatible_Representation
More precisely, untagged record types, as tagged record types are already
handled by the predicate.  If the derived type has not been given its own
representation clause, then the representations are the same.

gcc/ada/

	* sem_ch13.adb (Has_Compatible_Representation): Return true for
	derived untagged record types without representation clause.
2022-05-17 08:25:43 +00:00
Eric Botcazou
e2f7d58cda [Ada] Streamline implementation of Has_Compatible_Representation
The predicate is only concerned with the internal representation of types
and this representation is shared by the subtypes of a given type, so the
implementation can directly look into the (implementation) base types.

No functional changes.

gcc/ada/

	* sem_ch13.ads (Has_Compatible_Representation): Minor tweaks.
	* sem_ch13.adb (Has_Compatible_Representation): Look directly into
	the (implementation) base types and simplifiy accordingly.
	* exp_ch5.adb (Change_Of_Representation): Adjust.
	* exp_ch6.adb (Expand_Actuals): Likewise.
2022-05-17 08:25:42 +00:00
Etienne Servais
87a6558424 [Ada] Remove superfluous call to Original_Node
The function Same_Object starts by taking the Original_Node of its
arguments.

gcc/ada/

	* sem_ch5.adb (Analyze_Assignment): Remove superfluous call to
	Original_Node.
2022-05-17 08:25:42 +00:00
Javier Miranda
6c72dc7d60 [Ada] Crash freezing declaration that will raise constraint error
When the compiler is built with assertions enabled and processes the
following declarations:

   type Vector_Boolean_Array is array (1 .. 10) of Boolean;
   O2 : constant Vector_Boolean_Array := [for J in 2 => True];

The expression is rewritten by the frontend with an N_Raise_CE node,
which leads to an assertion error at the freezing point of the object
declaration.

gcc/ada/

	* freeze.adb (Freeze_Entity): Protect the call to
	Declaration_Node against entities of expressions replaced by the
	frontend with an N_Raise_CE node.
2022-05-17 08:25:42 +00:00
Javier Miranda
c30e5ab027 [Ada] Spurious error on subprogram with class-wide preconditions
gcc/ada/

	* freeze.adb (Build_DTW_Spec): Do not inherit the not-overriding
	indicator because the DTW wrapper overrides its wrapped
	subprogram.
	* contracts.ads (Make_Class_Precondition_Subps): Adding
	documentation.
2022-05-17 08:25:41 +00:00
Eric Botcazou
d409061404 [Ada] Use Actions field of freeze nodes for subprograms
This has a couple of advantages: 1) the actions are analyzed with checks
disabled and 2) they are considered elaboration code by Sem_Elab.

gcc/ada/

	* exp_ch13.adb (Expand_N_Freeze_Entity): Delete freeze nodes for
	subprograms only if they have no actions.
	* exp_ch6.adb (Freeze_Subprogram): Put the actions into the Actions
	field of the freeze node instead of inserting them after it.
	* sem_elab.adb (Is_SPARK_Semantic_Target): Fix typo in comment.
	* gcc-interface/trans.cc (process_freeze_entity): Return early for
	freeze nodes of subprograms with Interface_Alias set.
2022-05-17 08:25:41 +00:00
Javier Miranda
a08f366ae8 [Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions
In some special cases involving class-wide pre/post conditions, Ada
allows a non-dispatching call to an abstract function (which is usually
illegal).  Fix a bug in the implementation of Ada's rules about the
run-time behavior of such a call. Thanks to Javier Miranda for producing
this patch.

gcc/ada/

	* contracts.adb (Build_Call_Helper_Body): Improve handling of
	the case of a (legal) non-dispatching call to an abstract
	subprogram.
2022-05-17 08:25:41 +00:00
Piotr Trojanek
8fc021c098 [Ada] Fix documentation of using attribute Loop_Entry in pragmas
Attribute Loop_Entry was initially only allowed to appear in pragmas
Loop_Variant and Loop_Invariant. Then it was also allowed to appear in
pragmas Assert, Assert_And_Cut and Assume, but this change was not
reflected in the GNAT RM.

gcc/ada/

	* doc/gnat_rm/implementation_defined_attributes.rst
	(Loop_Entry): Mention pragmas Assert, Assert_And_Cut and Assume;
	refill.
	* gnat_rm.texi: Regenerate.
2022-05-17 08:25:40 +00:00
Etienne Servais
7cff43618e [Ada] Check token to be "access", reject it if not
The parser skips the token without verifying it is indeed "access".  So
any token is accepted.

gcc/ada/

	* par-ch3.adb (P_Access_Type_Definition): Outputs an error if
	token is not "access".
2022-05-17 08:25:40 +00:00
Piotr Trojanek
bc17882341 [Ada] Enable current value propagation within pragma expressions
This patch fixes an odd incomplete optimization within pragma
expressions. For example, in this code:

   X := True;
   pragma Assert (X = True);
   pragma Assert (X);

the first assertion was eliminated by the frontend (regardless of the
optimization switches), while the second assertion was only eliminated
by the backend and only with switch -O1 or similar.

The problem was that the current value propagation was disabled for
references immediately within pragma argument associations. This was
meant to avoid a crash when such a reference appears in pragma
Inspection_Point, but this wasn't a proper fix. The proper solution is
rather to not expand references in pragma Inspection_Point at all.

Actually, this expansion was enabled to avoid a yet another crash, when
the parameter of pragma Inspection_Point is a prival (i.e. a renaming of
private protected component). It turns out that none of these suspicious
problematic fixes is no longer necessary.

Cleanup related to fixes of current value propagation in expansion of
attribute Loop_Entry.

gcc/ada/

	* exp_ch2.adb (Expand_Current_Value): Remove special case for
	references immediately within pragma argument associations.
	* exp_prag.adb (Expand_Pragma_Inspection_Point): Remove special
	case for privals.
2022-05-17 08:25:40 +00:00
Jakub Jelinek
bc9aa450eb forwprop: Fix a typo and comment formatting
When looking around the spot of the PR105591 fix, I've noticed a typo
and incorrectly formatted comment.

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

	* tree-ssa-forwprop.cc (simplify_bitfield_ref): Spelling fix:
	hanlde -> handle.  Fix up comment formatting.
2022-05-17 09:06:55 +02:00
liuhongt
105c56a8cf Optimize vpermtiw/b to vpunpcklqdq for certain cases.
Assembly Optimization like:
-       vmovq   %xmm0, %xmm2
-       vmovdqa .LC0(%rip), %xmm0
        vmovq   %xmm1, %xmm1
-       vpermi2w        %xmm1, %xmm2, %xmm0
+       vmovq   %xmm0, %xmm0
+       vpunpcklqdq     %xmm1, %xmm0, %xmm0

...

-.LC0:
-       .value  0
-       .value  1
-       .value  2
-       .value  3
-       .value  8
-       .value  9
-       .value  10
-       .value  11

gcc/ChangeLog:

	PR target/105033
	* config/i386/sse.md (*vec_concatv4si): Extend to ..
	(*vec_concat<mode>): .. V16QI and V8HImode.
	(*vec_concatv16qi_permt2): New pre_reload define_insn_and_split.
	(*vec_concatv8hi_permt2): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr105033.c: New test.
2022-05-17 09:30:22 +08:00
liuhongt
1fba0608d1 Clamp vec_perm_expr index in simplify_bitfield_ref to avoid ICE.
gcc/ChangeLog:

	PR tree-optimization/105591
	* tree-ssa-forwprop.cc (simplify_bitfield_ref): Clamp
	vec_perm_expr index.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr105591.c: New test.
2022-05-17 08:59:42 +08:00
GCC Administrator
702bd11fa7 Daily bump. 2022-05-17 00:16:28 +00:00
Jason Merrill
ed12749a3c attribs: fix typedefs in generic code [PR105492]
In my patch for PR100545 I added an assert to check for broken typedefs in
set_underlying_type, and it found one in this case:
rs6000_handle_altivec_attribute had the same problem as
handle_mode_attribute.  So let's move the fixup into decl_attributes.

	PR c/105492

gcc/ChangeLog:

	* attribs.cc (decl_attributes): Fix broken typedefs here.

gcc/c-family/ChangeLog:

	* c-attribs.cc (handle_mode_attribute): Don't fix broken typedefs
	here.
2022-05-16 17:32:46 -04:00
David Malcolm
2402dc6b98 analyzer: implement four new warnings for <stdarg.h> misuses [PR105103]
This patch adds support to the analyzer for checking usage of <stdarg.h>,
with four new warnings.

It adds:
(a) a state-machine for tracking "started" and "ended" states on va_list
instances, implementing two new warnings:
  -Wanalyzer-va-list-leak
    for complaining about missing va_end after a va_start or va_copy
  -Wanalyzer-va-list-use-after-va-end:
    for complaining about va_arg or va_copy used on a va_list that's had
    va_end called on it

(b) interprocedural tracking of variadic parameters, tracking symbolic
values, implementing two new warnings:
  -Wanalyzer-va-arg-type-mismatch
     for type-checking va_arg usage against the types of the parameters
     that were actually passed to the variadic call
  -Wanalyzer-va-list-exhausted
     for complaining if va_arg is used too many times on a va_list

Here's an LTO example of a type mismatch in a variadic call that
straddles two source files:

stdarg-lto-1-a.c: In function 'called_by_test_type_mismatch_1':
stdarg-lto-1-a.c:19:7: warning: 'va_arg' expected 'const char *' but
 received 'int' for variadic argument 1 of 'ap' [-Wanalyzer-va-arg-type-mismatch]
   19 |   str = va_arg (ap, const char *);
      |       ^
  'test_type_mismatch_1': events 1-2
    |
    |stdarg-lto-1-b.c:3:6:
    |    3 | void test_type_mismatch_1 (void)
    |      |      ^
    |      |      |
    |      |      (1) entry to 'test_type_mismatch_1'
    |    4 | {
    |    5 |   called_by_test_type_mismatch_1 (42, 1066);
    |      |   ~
    |      |   |
    |      |   (2) calling 'called_by_test_type_mismatch_1' from 'test_type_mismatch_1' with 1 variadic argument
    |
    +--> 'called_by_test_type_mismatch_1': events 3-4
           |
           |stdarg-lto-1-a.c:12:1:
           |   12 | called_by_test_type_mismatch_1 (int placeholder, ...)
           |      | ^
           |      | |
           |      | (3) entry to 'called_by_test_type_mismatch_1'
           |......
           |   19 |   str = va_arg (ap, const char *);
           |      |       ~
           |      |       |
           |      |       (4) 'va_arg' expected 'const char *' but received 'int' for variadic argument 1 of 'ap'
           |

gcc/ChangeLog:
	PR analyzer/105103
	* Makefile.in (ANALYZER_OBJS): Add analyzer/varargs.o.
	* doc/invoke.texi: Add -Wanalyzer-va-arg-type-mismatch,
	-Wanalyzer-va-list-exhausted, -Wanalyzer-va-list-leak, and
	-Wanalyzer-va-list-use-after-va-end.

gcc/analyzer/ChangeLog:
	PR analyzer/105103
	* analyzer.cc (make_label_text_n): New.
	* analyzer.h (class var_arg_region): New forward decl.
	(make_label_text_n): New decl.
	* analyzer.opt (Wanalyzer-va-arg-type-mismatch): New option.
	(Wanalyzer-va-list-exhausted): New option.
	(Wanalyzer-va-list-leak): New option.
	(Wanalyzer-va-list-use-after-va-end): New option.
	* checker-path.cc (call_event::get_desc): Split out decl access
	into..
	(call_event::get_caller_fndecl): ...this new function and...
	(call_event::get_callee_fndecl): ...this new function.
	* checker-path.h (call_event::get_desc): Drop "FINAL".
	(call_event::get_caller_fndecl): New decl.
	(call_event::get_callee_fndecl): New decl.
	(class call_event): Make fields protected.
	* diagnostic-manager.cc (null_assignment_sm_context::warn): New
	overload.
	(null_assignment_sm_context::get_new_program_state): New.
	(diagnostic_manager::add_events_for_superedge): Move case
	SUPEREDGE_CALL to a new pending_diagnostic::add_call_event vfunc.
	* engine.cc (impl_sm_context::warn): Implement new override.
	(impl_sm_context::get_new_program_state): New.
	* pending-diagnostic.cc: Include "analyzer/diagnostic-manager.h",
	"cpplib.h", "digraph.h", "ordered-hash-map.h", "cfg.h",
	"basic-block.h", "gimple.h", "gimple-iterator.h", "cgraph.h"
	"analyzer/supergraph.h", "analyzer/program-state.h",
	"alloc-pool.h", "fibonacci_heap.h", "shortest-paths.h",
	"sbitmap.h", "analyzer/exploded-graph.h", "diagnostic-path.h",
	and "analyzer/checker-path.h".
	(ht_ident_eq): New.
	(fixup_location_in_macro_p): New.
	(pending_diagnostic::fixup_location): New.
	(pending_diagnostic::add_call_event): New.
	* pending-diagnostic.h (pending_diagnostic::fixup_location): Drop
	no-op inline implementation in favor of the more complex
	implementation above.
	(pending_diagnostic::add_call_event): New vfunc.
	* region-model-impl-calls.cc: Include "analyzer/sm.h",
	"diagnostic-path.h", and "analyzer/pending-diagnostic.h".
	* region-model-manager.cc
	(region_model_manager::get_var_arg_region): New.
	(region_model_manager::log_stats): Log m_var_arg_regions.
	* region-model.cc (region_model::on_call_pre): Handle IFN_VA_ARG,
	BUILT_IN_VA_START, and BUILT_IN_VA_COPY.
	(region_model::on_call_post): Handle BUILT_IN_VA_END.
	(region_model::get_representative_path_var_1): Handle RK_VAR_ARG.
	(region_model::push_frame): Push variadic arguments.
	* region-model.h (region_model_manager::get_var_arg_region): New
	decl.
	(region_model_manager::m_var_arg_regions): New field.
	(region_model::impl_call_va_start): New decl.
	(region_model::impl_call_va_copy): New decl.
	(region_model::impl_call_va_arg): New decl.
	(region_model::impl_call_va_end): New decl.
	* region.cc (alloca_region::dump_to_pp): Dump the id.
	(var_arg_region::dump_to_pp): New.
	(var_arg_region::get_frame_region): New.
	* region.h (enum region_kind): Add RK_VAR_ARG.
	(region::dyn_cast_var_arg_region): New.
	(class var_arg_region): New.
	(is_a_helper <const var_arg_region *>::test): New.
	(struct default_hash_traits<var_arg_region::key_t>): New.
	* sm.cc (make_checkers): Call make_va_list_state_machine.
	* sm.h (sm_context::warn): New vfunc.
	(sm_context::get_old_svalue): Drop unused decl.
	(sm_context::get_new_program_state): New vfunc.
	(make_va_list_state_machine): New decl.
	* varargs.cc: New file.

gcc/testsuite/ChangeLog:
	PR analyzer/105103
	* gcc.dg/analyzer/stdarg-1.c: New test.
	* gcc.dg/analyzer/stdarg-2.c: New test.
	* gcc.dg/analyzer/stdarg-fmtstring-1.c: New test.
	* gcc.dg/analyzer/stdarg-lto-1-a.c: New test.
	* gcc.dg/analyzer/stdarg-lto-1-b.c: New test.
	* gcc.dg/analyzer/stdarg-lto-1.h: New test.
	* gcc.dg/analyzer/stdarg-sentinel-1.c: New test.
	* gcc.dg/analyzer/stdarg-types-1.c: New test.
	* gcc.dg/analyzer/stdarg-types-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-05-16 15:34:09 -04:00
Iain Buclaw
5eb9927aae d: Merge upstream dmd 60bfa0ee7, druntime 94bd5bcb, phobos 3a1cd9a01.
D front-end changes:

    - Import dmd v2.100.0.
    - Add bit fields to D, enabled via the -fpreview=bitfields switch.
    - Removed the -ftransition=markdown and -frevert=markdown switches.
    - Added new trait `__traits(classInstanceAlignment)' to provide the
      required data alignment for classes.
    - The check for `pragma(crt_constructor)' and `pragma(crt_destructor)'
      linkage has been relaxed to allow all `void()' signatures.
    - ImportC parser now recognizes the `typeof(...)' operator.

D runtime changes:

    - Import druntime v2.100.0.

Phobos changes:

    - Import phobos v2.100.0.
    - To comply with dip1000, `std.socket.Socket` methods now accept only
      `scope' arrays.
    - The `fill', `alignSize', `align2', and `align4' methods of
      `std.outbuffer.OutBuffer' have been extended to allow specifying a custom
      value when pre-filling or padding the buffer.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 60bfa0ee7.
	* dmd/VERSION: Update version to v2.100.0.
	* d-builtins.cc (d_init_versions): Update for new front-end interface.
	* d-codegen.cc (d_decl_context): Use resolvedLinkage to get
	declaration linkage.
	(build_struct_literal): Track offset in bits.
	* d-gimplify.cc (d_gimplify_modify_expr): Check both operands for a
	bit-field reference.
	* d-lang.cc (d_handle_option): Handle -fpreview=bitfields, remove
	-frevert=markdown and -ftransition=vmarkdown.
	(d_post_options): Set flag_rtti and flag_exceptions if -fno-druntime
	was seen on command-line.
	(d_parse_file): Update for new front-end interface.
	(d_type_promotes_to): Use resolvedLinkage to get declaration linkage.
	* decl.cc (make_thunk): Likewise.
	* expr.cc (ExprVisitor::visit (CatAssignExp *)): Remove lowering for
	appending of an element or array to another array.
	* lang.opt (fpreview=bitfields): New option.
	(frevert=markdown): Remove.
	(ftransition=vmarkdown): Remove.
	* types.cc (layout_aggregate_members): Ignore anonymous fields in
	total count.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 94bd5bcb.
	* libdruntime/Makefile.am (ALL_DRUNTIME_INSTALL_DSOURCES): Add
	$(DRUNTIME_DSOURCES_ELF).
	(ALL_DRUNTIME_SOURCES): Likewise.
	(DRUNTIME_DSOURCES_ELF): New variable.
	* libdruntime/Makefile.in: Regenerate.
	* src/MERGE: Merge upstream phobos 3a1cd9a01.
	* testsuite/libphobos.init_fini/custom_gc.d: Update test.
2022-05-16 19:07:45 +02:00
Jonathan Wakely
682e587f10 libstdc++: Fix hyperlink in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/prerequisites.xml: Fix attributes for external
	hyperlink.
	* doc/html/manual/setup.html: Regenerate.
2022-05-16 14:54:07 +01:00
Jonathan Wakely
8414dad54a libstdc++: Update C++23 status docs
These are the C++23 proposals supported in the gcc-12 branch.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2023.xml: Update with gcc-12 support.
	* doc/html/*: Regenerate.
2022-05-16 14:53:16 +01:00
Jonathan Wakely
4361867344 libstdc++: Add C++23 status docs
These are the C++23 proposals already supported in the gcc-11 branch.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Include new chapter.
	* doc/xml/manual/status_cxx2020.xml: Tweak release numbers.
	* doc/xml/manual/status_cxx2023.xml: New file.
	* doc/html/*: Regenerate.
2022-05-16 14:47:34 +01:00
Jonathan Wakely
64648821f1 libstdc++: Fix status docs for <bit> support
libstdc++-v3/ChangeLog:

	* doc/html/manual/status.html: Regenerate.
	* doc/xml/manual/status_cxx2020.xml: Fix supported version for
	C++20 bit operations.
2022-05-16 14:47:34 +01:00
Richard Biener
6f5b06032e Finish gimple_build API enhancement
This finishes the remaining parts of the gimple_build API enhancement,
converting the remaining workers to receive a gimple_stmt_iterator,
direction and update argument.  It also moves the code_helper
receiving functions from gimple-match.h to gimple-fold.h.

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

	* gimple-match.h (gimple_build): Move code_helper overloads ...
	* gimple-fold.h (gimple_build): ... here.
	(gimple_build): Transition to new worker API.  Provide
	overloads from sequence-based API.
	(gimple_convert): Likewise.
	(gimple_convert_to_ptrofftype): Likewise.
	(gimple_build_vector_from_val): Likewise.
	(gimple_build_vector): Likewise.
	(gimple_build_round_up): Likewise.
	* gimple-fold.cc (gimple_build_insert_seq): New helper.
	(gimple_build): Use it.  Transition combined_fn and code_helper
	API parts.
	(gimple_convert): Transition to new worker API.
	(gimple_convert_to_ptrofftype): Likewise.
	(gimple_build_vector_from_val): Likewise.
	(gimple_build_vector): Likewise.
	(gimple_build_round_up): Likewise.
2022-05-16 13:39:26 +02:00
Richard Biener
adace78911 Move code_helper to tree.h
tree.h already contains combined_fn handling at the top and moving
code_helper away from gimple-match.h makes improving the gimple_build
API easier.

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

	* gimple-match.h (code_helper): Move class ...
	* tree.h (code_helper): ... here.
2022-05-16 13:39:26 +02:00
Richard Biener
ef7b8976b9 rtl-optimization/105577 - testcase for the PR
2022-05-16  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/105577
	* g++.dg/torture/pr105577.C: New testcase.
2022-05-16 12:08:40 +02:00
Richard Biener
6230911cb9 ipa/105598 - testcase for PR105598
2022-05-16  Richard Biener  <rguenther@suse.de>

gcc/testsuite/
	* gcc.dg/torture/pr105598.c: New testcase.
2022-05-16 12:03:33 +02:00
Martin Liska
8ab53e65a6 opts-global.cc: document last change
gcc/ChangeLog:

	* opts-global.cc (write_langs): Add comment.
2022-05-16 11:07:57 +02:00
Eric Botcazou
cc7cd8d57c Do not use DW_OP_not for TRUTH_NOT_EXPR in conditional expressions
DW_OP_not is a bitwise, not a logical NOT, so it computes the wrong result
in a DWARF conditional expression.

gcc/
	* dwarf2out.cc (loc_list_from_tree_1) <TRUTH_NOT_EXPR>: Do a logical
	instead of a bitwise negation.
	<COND_EXPR>: Swap the operands if the condition is TRUTH_NOT_EXPR.
2022-05-16 11:04:51 +02:00
Eric Botcazou
b90e43dbbb [Ada] Fix fallout of change in equality for untagged record types
The problem is that the resolution of expanded names implicitly assumes
that the visible and private homonyms in a given scope are segregated on
the homonym chain, and this was no longer the case for equality operators
in the specific case at stake.

gcc/ada/

	* sem_ch7.adb (Inspect_Untagged_Record_Completion): Also move the
	equality operator on the homonym chain if there is another equality
	operator in the private part.
2022-05-16 08:42:06 +00:00
Piotr Trojanek
7e0c853c6f [Ada] Fix expansion of attribute Loop_Entry wrt value propagation
When expanding attribute Loop_Entry we create constant object
declarations and put them just before the loop. The current values of
variables at the point of Loop_Entry attribute must not be used when
analysing the initialization expressions of these constants, because
they might be different from the values at the loop entry itself.

gcc/ada/

	* exp_attr.adb (Expand_Loop_Entry_Attribute): Disable value
	propagation when analysing the constant that holds the
	Loop_Entry prefix value.
2022-05-16 08:42:06 +00:00