Skip to content
Snippets Groups Projects
  1. May 14, 2024
    • Jonathan Wakely's avatar
      libstdc++: Guard dynamic_cast use in src/c++23/print.cc [PR115015] · 6cc86982
      Jonathan Wakely authored
      Do not use dynamic_cast unconditionally, in case libstdc++ is built with
      -fno-rtti.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/115015
      	* src/c++23/print.cc (__open_terminal(streambuf*)) [!__cpp_rtti]:
      	Do not use dynamic_cast.
      6cc86982
    • Jonathan Wakely's avatar
      libstdc++: Document when std::string::shrink_to_fit was added · 0a99ad5c
      Jonathan Wakely authored
      This section can be misread to say that shrink_to_fit is available from
      GCC 3.4, but it was added later.
      
      libstdc++-v3/ChangeLog:
      
      	* doc/xml/manual/strings.xml: Clarify that GCC 4.5 added
      	std::string::shrink_to_fit.
      	* doc/html/manual/strings.html: Regenerate.
      0a99ad5c
    • Tom de Vries's avatar
      [debug] Fix dwarf v4 .debug_macro.dwo · b7003b4c
      Tom de Vries authored
      Consider a hello world, compiled with -gsplit-dwarf and dwarf version 4, and
      -g3:
      ...
      $ gcc -gdwarf-4 -gsplit-dwarf /data/vries/hello.c -g3 -save-temps -dA
      ...
      
      In section .debug_macro.dwo, we have:
      ...
      .Ldebug_macro0:
              .value  0x4     # DWARF macro version number
              .byte   0x2     # Flags: 32-bit, lineptr present
              .long   .Lskeleton_debug_line0
              .byte   0x3     # Start new file
              .uleb128 0      # Included from line number 0
              .uleb128 0x1    # file /data/vries/hello.c
              .byte   0x5     # Define macro strp
              .uleb128 0      # At line number 0
              .uleb128 0x1d0  # The macro: "__STDC__ 1"
      ...
      
      Given that we use a DW_MACRO_define_strp, we'd expect 0x1d0 to be an
      offset into a .debug_str.dwo section.
      
      But in fact, 0x1d0 is an index into the string offset table in
      section .debug_str_offsets.dwo:
      ...
              .long   0x34f0  # indexed string 0x1d0: __STDC__ 1
      ...
      
      Add asserts that catch this inconsistency, and fix this by using
      DW_MACRO_define_strx instead.
      
      Tested on x86_64.
      
      gcc/ChangeLog:
      
      2024-05-14  Tom de Vries  <tdevries@suse.de>
      
      	PR debug/115066
      	* dwarf2out.cc (output_macinfo_op): Fix DW_MACRO_define_strx/strp
      	choice for v4 .debug_macro.dwo.  Add asserts to check that choice.
      
      gcc/testsuite/ChangeLog:
      
      2024-05-14  Tom de Vries  <tdevries@suse.de>
      
      	PR debug/115066
      	* gcc.dg/pr115066.c: New test.
      b7003b4c
    • Jan Hubicka's avatar
      Reduce recursive inlining of always_inline functions · 1ec49897
      Jan Hubicka authored
      this patch tames down inliner on (mutiply) self-recursive always_inline functions.
      While we already have caps on recursive inlning, the testcase combines early inliner
      and late inliner to get very wide recursive inlining tree.  The basic idea is to
      ignore DISREGARD_INLINE_LIMITS when deciding on inlining self recursive functions
      (so we cut on function being large) and clear the flag once it is detected.
      
      I did not include the testcase since it still produces a lot of code and would
      slow down testing.  It also outputs many inlining failed messages that is not
      very nice, but it is hard to detect self recursin cycles in full generality
      when indirect calls and other tricks may happen.
      
      gcc/ChangeLog:
      
      	PR ipa/113291
      
      	* ipa-inline.cc (enum can_inline_edge_by_limits_flags): New enum.
      	(can_inline_edge_by_limits_p): Take flags instead of multiple bools; add flag
      	for forcing inlinie limits.
      	(can_early_inline_edge_p): Update.
      	(want_inline_self_recursive_call_p): Update; use FORCE_LIMITS mode.
      	(check_callers): Update.
      	(update_caller_keys): Update.
      	(update_callee_keys): Update.
      	(recursive_inlining): Update.
      	(add_new_edges_to_heap): Update.
      	(speculation_useful_p): Update.
      	(inline_small_functions): Clear DECL_DISREGARD_INLINE_LIMITS on self recursion.
      	(flatten_function): Update.
      	(inline_to_all_callers_1): Update.
      1ec49897
    • Jonathan Wakely's avatar
      libstdc++: Fix typo in std::stacktrace::max_size [PR115063] · ccc26a1a
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/115063
      	* include/std/stacktrace (basic_stacktrace::max_size): Fix typo
      	in reference to _M_alloc member.
      	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Check
      	max_size() compiles.
      ccc26a1a
    • Haochen Gui's avatar
      rs6000: Enable overlapped by-pieces operations · fbd115fe
      Haochen Gui authored
      This patch enables overlapped by-piece operations by defining
      TARGET_OVERLAP_OP_BY_PIECES_P to true.  On rs6000, default move/set/clear
      ratio is 2.  So the overlap is only enabled with compare by-pieces.
      
      gcc/
      	* config/rs6000/rs6000.cc (TARGET_OVERLAP_OP_BY_PIECES_P): Define.
      
      gcc/testsuite/
      	* gcc.target/powerpc/block-cmp-9.c: New.
      fbd115fe
    • Filip Kastl's avatar
      MAINTAINERS: Fix an entry using spaces instead of tabs · 1a809280
      Filip Kastl authored
      
      In the MAINTAINERS file, names and emails are separated by tabs.  One of
      the entries recently added used spaces.  This patch corrects this.
      
      The check-MAINTAINERS.py script breaks a bit when this happens.  This
      patch also adds warning about this situation into the script.
      
      ChangeLog:
      
      	* MAINTAINERS: Use tabs between name and email.
      
      contrib/ChangeLog:
      
      	* check-MAINTAINERS.py: Add warning about not using tabs.
      
      Signed-off-by: default avatarFilip Kastl <fkastl@suse.cz>
      1a809280
    • Piotr Trojanek's avatar
      ada: Fix classification of SPARK Boolean aspects · 8d15d848
      Piotr Trojanek authored
      The implementation of User_Aspect_Definition uses subtype
      Boolean_Aspects to decide which existing aspects can be used to define
      old aspects. This subtype didn't include many of the SPARK aspects,
      notably the Always_Terminates.
      
      gcc/ada/
      
      	* aspects.ads (Aspect_Id, Boolean_Aspect): Change categorization
      	of Boolean-valued SPARK aspects.
      	* sem_ch13.adb (Analyze_Aspect_Specification): Adapt CASE
      	statements to new classification of Boolean-valued SPARK
      	aspects.
      8d15d848
    • Ronan Desplanques's avatar
      ada: Fix crash with -gnatdJ and -gnatf · 4a45c993
      Ronan Desplanques authored
      This patch fixes a crash when the compiler emits a warning about
      an unchecked conversion and -gnatdJ is enabled.
      
      gcc/ada/
      
      	* sem_ch13.adb (Validate_Unchecked_Conversions): Add node
      	parameters to Error_Msg calls.
      4a45c993
    • Marc Poulhiès's avatar
      ada: Minor typo fix in comment · 0ec8c070
      Marc Poulhiès authored
      gcc/ada/
      
      	* sem_util.adb: Typo fix in comment.
      	* exp_aggr.adb: Likewise.
      0ec8c070
    • Eric Botcazou's avatar
      ada: Document more details of the implementation of finalization chains · 26afb004
      Eric Botcazou authored
      gcc/ada/
      
      	* exp_ch7.adb (Finalization Management): Add a short description of
      	the implementation of finalization chains.
      26afb004
    • Eric Botcazou's avatar
      ada: Fix small inaccuracy in previous change · a252022d
      Eric Botcazou authored
      The call to Build_Allocate_Deallocate_Proc must occur before the special
      accessibility check for class-wide allocation is generated, because this
      check comes with cleanup code.
      
      gcc/ada/
      
      	* exp_ch4.adb (Expand_Allocator_Expression): Move the first call to
      	Build_Allocate_Deallocate_Proc up to before the accessibility check.
      a252022d
    • Ronan Desplanques's avatar
      ada: Fix pragma Warnings and -gnatD interaction · 13d83741
      Ronan Desplanques authored
      A recent change broke pragma Warnings when -gnatD is enabled in some
      cases. This patch fixes this by caching more slocs at times when it's
      known that they haven't been modified by -gnatD.
      
      gcc/ada/
      
      	* errout.adb (Validate_Specific_Warnings): Adapt to record
      	definition change.
      	* erroutc.adb (Set_Specific_Warning_On, Set_Specific_Warning_Off,
      	Warning_Specifically_Suppressed): Likewise.
      	* erroutc.ads: Change record definition.
      13d83741
    • Eric Botcazou's avatar
      ada: Decouple attachment from dynamic allocation for controlled objects · 151d1533
      Eric Botcazou authored
      This decouples the attachment to the appropriate finalization collection of
      dynamically allocated objects that need finalization from their allocation.
      
      The current implementation immediately attaches them after allocating them,
      which means that they will be finalized even if their initialization does
      not complete successfully.  The new implementation instead generates the
      same sequence as the one generated for (statically) declared objects, that
      is to say, allocation, initialization and attachment in this order.
      
      gcc/ada/
      
      	* exp_ch3.adb (Build_Default_Initialization): Do not generate the
      	protection for finalization collections.
      	(Build_Heap_Or_Pool_Allocator): Set the No_Initialization flag on
      	the declaration of the temporary.
      	* exp_ch4.adb (Build_Aggregate_In_Place): Do not build an allocation
      	procedure here.
      	(Expand_Allocator_Expression): Build an allocation procedure, if it
      	is required, only just before rewriting the allocator.
      	(Expand_N_Allocator): Do not build an allocation procedure if the
      	No_Initialization flag is set on the allocator, except for those
      	generated for special return objects.  In other cases, build an
      	allocation procedure, if it is required, only before rewriting
      	the allocator.
      	* exp_ch7.ads (Make_Address_For_Finalize): New function declaration.
      	* exp_ch7.adb (Finalization Management): Update description for
      	dynamically allocated objects.
      	(Make_Address_For_Finalize): Remove declaration.
      	(Find_Last_Init): Change to function and move to...
      	(Process_Object_Declaration): Adjust to above change.
      	* exp_util.ads (Build_Allocate_Deallocate_Proc): Add Mark parameter
      	with Empty default and document it.
      	(Find_Last_Init): New function declaration.
      	* exp_util.adb (Build_Allocate_Deallocate_Proc): Add Mark parameter
      	with Empty default and pass it in recursive call.  Deal with type
      	conversions created for interface types.  Adjust call sequence to
      	Allocate_Any_Controlled by changing Collection to In/Out parameter
      	and removing Finalize_Address parameter.  For a controlled object,
      	generate a conditional call to Attach_Object_To_Collection for an
      	allocation and to Detach_Object_From_Collection for a deallocation.
      	(Find_Last_Init): ...here.  Compute the initialization type for an
      	allocator whose designating type is class wide specifically and also
      	handle concurrent types.
      	* rtsfind.ads (RE_Id): Add RE_Attach_Object_To_Collection and
      	RE_Detach_Object_From_Collection.
      	(RE_Unit_Table): Add entries for RE_Attach_Object_To_Collection and
      	RE_Detach_Object_From_Collection.
      	* libgnat/s-finpri.ads (Finalization_Started): Delete.
      	(Attach_Node_To_Collection): Likewise.
      	(Detach_Node_From_Collection): Move to...
      	(Attach_Object_To_Collection): New procedure declaration.
      	(Detach_Object_From_Collection): Likewise.
      	(Finalization_Collection): Remove Atomic for Finalization_Started.
      	Add pragma Inline for Initialize.
      	* libgnat/s-finpri.adb: Add clause for Ada.Unchecked_Conversion.
      	(To_Collection_Node_Ptr): New instance of Ada.Unchecked_Conversion.
      	(Detach_Node_From_Collection): ...here.
      	(Attach_Object_To_Collection): New procedure.
      	(Detach_Object_From_Collection): Likewise.
      	(Finalization_Started): Delete.
      	(Finalize): Replace allocation with attachment in comments.
      	* libgnat/s-stposu.ads (Allocate_Any_Controlled): Rename parameter
      	Context_Subpool into Named_Subpool, parameter Context_Collection
      	into Collection and change it to In/Out, and remove Fin_Address.
      	* libgnat/s-stposu.adb: Remove clause for Ada.Unchecked_Conversion
      	and Finalization_Primitives.
      	(To_Collection_Node_Ptr): Delete.
      	(Allocate_Any_Controlled): Rename parameter Context_Subpool into
      	Named_Subpool, parameter Context_Collection into Collection and
      	change it to In/Out, and remove Fin_Address.  Do not lock/unlock
      	and do not attach the object, instead only displace its address.
      	(Deallocate_Any_Controlled): Do not lock/unlock and do not detach
      	the object.
      	(Header_Size_With_Padding): Use qualified name for Header_Size.
      151d1533
    • Steve Baird's avatar
      ada: Follow up fixes for Put_Image/streaming regressions · 00c7f229
      Steve Baird authored
      A recent change to reduce duplication of compiler-generated Put_Image and
      streaming subprograms introduced two regressions. One is yet another of the
      many cases where generating these routines "on demand" (as opposed at the
      point of the associated type declaration) requires loosening the compiler's
      enforcement of privacy. The other is a use-before-definition issue that
      occurs because the declaration of a Put_Image procedure is not hoisted far
      enough.
      
      gcc/ada/
      
      	* exp_attr.adb (Build_And_Insert_Type_Attr_Subp): If a subprogram
      	associated with a (library-level) type declared in another unit is
      	to be inserted somewhere in a list, then insert it at the head of
      	the list.
      	* sem_ch5.adb (Analyze_Assignment): Normally a limited-type
      	assignment is illegal. Relax this rule if Comes_From_Source is
      	False and the type is not immutably limited.
      00c7f229
    • Ronan Desplanques's avatar
      ada: Fix pragma Compile_Time_Error and -gnatdJ crash · f5798041
      Ronan Desplanques authored
      This patch makes it so the diagnostics coming from occurrences of
      pragma Compile_Time_Error and Compile_Time_Warning are emitted with
      a node parameter so they don't cause a crash when -gnatdJ is enabled.
      
      gcc/ada/
      
      	* errout.ads (Error_Msg): Add node parameter.
      	* errout.adb (Error_Msg): Add parameter and pass it to
      	the underlying call.
      	* sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): Pass
      	pragma node when emitting errors.
      f5798041
    • Ronan Desplanques's avatar
      ada: Fix crash with -gnatdJ and -gnatyz · faf462cf
      Ronan Desplanques authored
      This patch makes it so -gnatyz style checks reports specify a node
      ID. That is required since those checks are sometimes made during
      semantic analysis of short-circuit operators, where the Current_Node
      mechanism that -gnatdJ uses is not operational.
      
      Check_Xtra_Parens_Precedence is moved from Styleg to Style to make
      this possible.
      
      gcc/ada/
      
      	* styleg.ads (Check_Xtra_Parens_Precedence): Moved ...
      	* style.ads (Check_Xtra_Parens_Precedence): ... here. Also
      	replace corresponding renaming.
      	* styleg.adb (Check_Xtra_Parens_Precedence): Moved ...
      	* style.adb (Check_Xtra_Parens_Precedence): here. Also use
      	Errout.Error_Msg and pass it a node parameter.
      faf462cf
    • Eric Botcazou's avatar
      ada: Small cleanup about allocators and aggregates · 08039257
      Eric Botcazou authored
      This eliminates a few oddities present in the expander for allocators and
      aggregates present in allocators:
      
        - Convert_Array_Aggr_In_Allocator takes both a Decl and Alloc parameters,
          and inserts new code before Alloc for records and after Decl for arrays
          through Convert_Array_Aggr_In_Allocator.  Now, for the 3 (duplicated)
          calls to the procedure, that's the same place.  It also creates a new
          list that it does not use in most cases.
      
        - Expand_Allocator_Expression uses the same code sequence in 3 places
          when the expression is an aggregate to build in place.
      
        - Build_Allocate_Deallocate_Proc takes an Is_Allocate parameter that is
          entirely determined by the N parameter: if N is an allocator, it must
          be true; if N is a free statement, it must be false.  Barring that,
          the procedure either raises an assertion or Program_Error.  It also
          contains useless pattern matching code in the second part.
      
      No functional changes.
      
      gcc/ada/
      
      	* exp_aggr.ads (Convert_Aggr_In_Allocator): Rename Alloc into N,
      	replace Decl with Temp and adjust description.
      	(Convert_Aggr_In_Object_Decl): Alphabetize.
      	(Is_Delayed_Aggregate): Likewise.
      	* exp_aggr.adb (Convert_Aggr_In_Allocator): Rename Alloc into N
      	and replace Decl with Temp.  Allocate a list only when neeeded.
      	(Convert_Array_Aggr_In_Allocator): Replace N with Decl and insert
      	new code before it.
      	* exp_ch4.adb (Build_Aggregate_In_Place): New procedure nested in
      	Expand_Allocator_Expression.
      	(Expand_Allocator_Expression): Call it to build aggregates in place.
      	Remove second parameter in calls to Build_Allocate_Deallocate_Proc.
      	(Expand_N_Allocator): Likewise.
      	* exp_ch13.adb (Expand_N_Free_Statement): Likewise.
      	* exp_util.ads (Build_Allocate_Deallocate_Proc): Remove Is_Allocate
      	parameter.
      	* exp_util.adb (Build_Allocate_Deallocate_Proc): Remove Is_Allocate
      	parameter and replace it with local variable of same name.  Delete
      	useless pattern matching.
      08039257
    • Ronan Desplanques's avatar
      ada: Fix warning indicators in usage string · ad510c7c
      Ronan Desplanques authored
      Before this patch, the default status of -gnatw.i and -gnatw.d are
      reported incorrectly in the usage string used throughout GNAT tools.
      This patch fixes this.
      
      gcc/ada/
      
      	* usage.adb (Usage): Fix enabled-by-default indicators.
      ad510c7c
    • Philippe Gil's avatar
      ada: Correct System.Win32.LocalFileTimeToFileTime wrapper typo · 42ea46c6
      Philippe Gil authored
      The parameters should be swapped to fit Fileapi.h documentation.
      BOOL LocalFileTimeToFileTime(
      	[in]  const FILETIME *lpLocalFileTime,
      	[out] LPFILETIME     lpFileTime
      );
      
      gcc/ada/
      	* libgnat/s-win32.ads (LocalFileTimeToFileTime): Swap parameters.
      42ea46c6
    • Ronan Desplanques's avatar
      ada: Fix crash with -gnatdJ and JSON output · 996fd764
      Ronan Desplanques authored
      This patch tweaks the calls made to Errout subprograms to report
      violations of dependence restrictions, in order fix a crash that
      occurred with -gnatdJ and -fdiagnostics-format=json.
      
      gcc/ada/
      
      	* restrict.adb (Violation_Of_No_Dependence): Tweak error
      	reporting calls.
      996fd764
    • Ronan Desplanques's avatar
      ada: Fix crash with -gnatdJ and -gnatw.w · 34aba154
      Ronan Desplanques authored
      This patch fixes a crash when -gnatdJ is enabled and a warning
      must be emitted about an ineffective pragma Warnings clause.
      
      Some modifications are made to the specific warnings machinery so
      that warnings carry the ID of the pragma node they're about, so the
      -gnatdJ mechanism can find an appropriate enclosing subprogram.
      
      gcc/ada/
      
      	* sem_prag.adb (Analyze_Pragma): Adapt call to new signature.
      	* erroutc.ads (Set_Specific_Warning_Off): change signature
      	and update documentation.
      	(Validate_Specific_Warnings): Move ...
      	* errout.adb: ... here and change signature. Also move body
      	of Validate_Specific_Warnings from erroutc.adb.
      	(Finalize): Adapt call.
      	* errout.ads (Set_Specific_Warning_Off): Adapt signature of
      	renaming.
      	* erroutc.adb (Set_Specific_Warning_Off): Adapt signature and
      	body.
      	(Validate_Specific_Warnings): Move to the body of Errout.
      	(Warning_Specifically_Suppressed): Adapt body.
      34aba154
    • Eric Botcazou's avatar
      ada: Restore default size for dynamic allocations of discriminated type · 06262650
      Eric Botcazou authored
      The allocation strategy for objects of a discriminated type with defaulted
      discriminants is not the same when the allocation is dynamic as when it is
      static (i.e a declaration): in the former case, the compiler allocates the
      default size whereas, in the latter case, it allocates the maximum size.
      
      This restores the default size, which was dropped during the refactoring.
      
      gcc/ada/
      
      	* exp_aggr.adb (Build_Array_Aggr_Code): Pass N in the call to
      	Build_Initialization_Call.
      	(Build_Record_Aggr_Code): Likewise.
      	(Convert_Aggr_In_Object_Decl): Likewise.
      	(Initialize_Discriminants): Likewise.
      	* exp_ch3.ads (Build_Initialization_Call): Replace Loc witn N.
      	* exp_ch3.adb (Build_Array_Init_Proc): Pass N in the call to
      	Build_Initialization_Call.
      	(Build_Default_Initialization): Likewise.
      	(Expand_N_Object_Declaration): Likewise.
      	(Build_Initialization_Call): Replace Loc witn N parameter and add
      	Loc local variable.  Build a default subtype for an allocator of
      	a discriminated type with defaulted discriminants.
      	(Build_Record_Init_Proc): Pass the declaration of components in the
      	call to Build_Initialization_Call.
      	* exp_ch6.adb (Make_CPP_Constructor_Call_In_Allocator): Pass the
      	allocator in the call to Build_Initialization_Call.
      06262650
    • Ronan Desplanques's avatar
      ada: Fix typo in diagnostic message · ab4a519a
      Ronan Desplanques authored
      A previous change introduced an error in the diagnostic message about
      overlapping actuals. This commit fixes this.
      
      gcc/ada/
      
      	* sem_warn.adb (Warn_On_Overlapping_Actuals): Fix typo.
      ab4a519a
    • Gary Dismukes's avatar
      ada: Compiler crash or errors on if_expression in container aggregate · a9714dce
      Gary Dismukes authored
      The compiler may either crash or incorrectly report errors when
      a component association in a container aggregate is an if_expression
      with an elsif part whose dependent expression is a call to a function
      returning a result that requires finalization. The compiler complains
      that a private type is expected, but a package or procedure name was
      found. This is due to the compiler improperly associating expanded
      calls to Finalize_Object with the aggregate, rather than the enclosing
      object declaration being initialized by the aggregate, which can result
      in the Finalize_Object procedure call being passed as an actual to
      the Add_Unnamed operation of the container type and leading to a type
      mismatch and the confusing error message. This is fixed by adjusting
      the code that locates the proper context for insertion of Finalize_Object
      calls to locate the enclosing declaration or statement rather than
      stopping at the aggregate.
      
      gcc/ada/
      
      	* exp_util.adb (Find_Hook_Context): Exclude N_*Aggregate Nkinds
      	of Parent (Par) from the early return in the second loop of the
      	In_Cond_Expr case, to prevent returning an aggregate from this
      	function rather than the enclosing declaration or statement.
      a9714dce
    • Steve Baird's avatar
      ada: Replace "not Present" tests with "No". · fb48b0aa
      Steve Baird authored
      Fix constructs that were flagged by CodePeer.
      
      gcc/ada/
      
      	* exp_attr.adb: Replace 6 "not Present" tests with equivalent calls to "No".
      fb48b0aa
    • Eric Botcazou's avatar
      ada: Follow-up adjustment after fix to Default_Initialize_Object · ba0b16a5
      Eric Botcazou authored
      Now that Default_Initialize_Object honors the No_Initialization flag in all
      cases, objects of an access type declared without initialization expression
      can no longer be considered as being automatically initialized to null.
      
      gcc/ada/
      
      	* exp_ch3.adb (Expand_N_Object_Declaration): Examine the Expression
      	field after the call to Default_Initialize_Object in order to set
      	Is_Known_Null, as well as Is_Known_Non_Null, on an access object.
      ba0b16a5
    • Steve Baird's avatar
      ada: Reduce generated code duplication for streaming and Put_Image subprograms · 0b7673ae
      Steve Baird authored
      In the case of an untagged composite type, the compiler does not generate
      streaming-related subprograms or a Put_Image procedure when the type is
      declared. Instead, these subprograms are declared "on demand" when a
      corresponding attribute reference is encountered. In this case, hoist the
      declaration of the implicitly declared subprogram out as far as possible
      in order to maximize the chances that it can be reused (as opposed to
      generating an identical second subprogram) in the case where a second
      reference to the same attribute is encountered. Also relax some
      privacy-related rules to allow these procedures to do what they need to do
      even when constructed in a scope where some of those actions would
      normally be illegal.
      
      gcc/ada/
      
      	* exp_attr.adb: Change name of package Cached_Streaming_Ops to
      	reflect the fact that it is now also used for Put_Image
      	procedures. Similarly change other "Streaming_Op" names therein.
      	Add Validate_Cached_Candidate procedure to detect case where a
      	subprogram found in the cache cannot be reused. Add new generic
      	procedure Build_And_Insert_Type_Attr_Subp; the "Build" part is
      	handled by just calling a formal procedure; the bulk of this
      	(generic) procedure's code has to with deciding where in the tree
      	to insert the newly-constructed subprogram. Replace each later
      	"Build" call (and the following Insert_Action or
      	Compile_Stream_Body_In_Scope call) with a declare block that
      	instantiates and then calls this generic procedure. Delete the
      	now-unused procedure Compile_Stream_Body_In_Scope. A constructed
      	subprogram is entered in the appropriate cache if the
      	corresponding type is untagged; this replaces more complex tests.
      	A new function Interunit_Ref_OK is added to determine whether an
      	attribute reference occuring in one unit can safely refer to a
      	cached subprogram declared in another unit.
      	* exp_ch3.adb (Build_Predefined_Primitive_Bodies): A formal
      	parameter was deleted, so delete the corresponding actual in a
      	call.
      	* exp_put_image.adb (Build_Array_Put_Image_Procedure): Because the
      	procedure being built may be referenced more than once, the
      	generated procedure takes its source position info from the type
      	declaration instead of the (first) attribute reference.
      	(Build_Record_Put_Image_Procedure): Likewise.
      	* exp_put_image.ads (Build_Array_Put_Image_Procedure): Eliminate
      	now-unused Nod parameter.
      	(Build_Record_Put_Image_Procedure): Eliminate now-unused Loc parameter.
      	* sem_ch3.adb (Constrain_Discriminated_Type): For declaring a
      	subtype with a discriminant constraint, ignore privacy if
      	Comes_From_Source is false (as is already done if Is_Instance is
      	true).
      	* sem_res.adb (Resolve): When passed two type entities that have
      	the same underlying base type, Sem_Type.Covers may return False in
      	some cases because of privacy. [This can happen even if
      	Is_Private_Type returns False both for Etype (N) and for Typ;
      	Covers calls Base_Type, which can take a non-private argument and
      	yield a private result.] If Comes_From_Source (N) is False
      	(e.g., for a compiler-generated Put_Image or streaming subprogram), then
      	avoid that scenario by not calling Covers. Covers already has tests for
      	doing this sort of thing (see the calls therein to Full_View_Covers),
      	but the Comes_From_Source test is too coarse to apply there. So instead
      	we handle the problem here at the call site.
      	(Original_Implementation_Base_Type): A new function. Same as
      	Implementation_Base_Type except if the Original_Node attribute of
      	a non-derived type declaration indicates that it once was a derived
      	type declaration. Needed for looking through privacy.
      	(Valid Conversion): Ignore privacy when converting between different views
      	of the same type if Comes_From_Source is False for the conversion.
      	(Valid_Tagged_Conversion): An ancestor-to-descendant conversion is not an
      	illegal downward conversion if there is no type extension involved
      	(because the derivation was from an untagged view of the parent type).
      0b7673ae
    • Steve Baird's avatar
      ada: Better error message for bad general case statements · 33541b88
      Steve Baird authored
      If -gnatX0 is specified, we allow case statements with a selector
      expression of a record or array type, but not of a private type.
      If the selector expression is of a private type then we should generate
      an appropriate error message instead of a bugbox.
      
      gcc/ada/
      
      	* sem_ch5.adb (Analyze_Case_Statement): Emit a message and return
      	early in the case where general case statements are allowed but
      	the selector expression is of a private type. This is done to
      	avoid a bugbox.
      33541b88
    • Justin Squirek's avatar
      ada: Spurious unreferenced warning on selected component · 416e572e
      Justin Squirek authored
      This patch fixes an error in the compiler whereby a selected component on the
      left hand side of an assignment statement may not get marked as referenced -
      leading to spurious unreferenced warnings on such objects.
      
      gcc/ada/
      
      	* sem_util.adb (Set_Referenced_Modified): Use Original_Node to
      	avoid recursive calls on expanded / internal objects such that
      	source nodes get appropriately marked as referenced.
      416e572e
    • Ronan Desplanques's avatar
      ada: Fix overlap warning suppression · f5454123
      Ronan Desplanques authored
      Before this patch, some warnings about overlapping actuals were
      emitted regardless of the Value of
      Warnsw.Warnings_Package.Warn_On_Overlap. This patch fixes this.
      
      gcc/ada/
      
      	* sem_warn.adb (Warn_On_Overlapping_Actuals): Stop ignoring
      	warning suppression settings.
      f5454123
    • Eric Botcazou's avatar
      ada: Follow-up adjustment to earlier fix in Build_Allocate_Deallocate_Proc · 4f3567cf
      Eric Botcazou authored
      The profile of the procedure built for an allocation on the secondary stack
      now includes the alignment parameter, so the parameter can just be forwarded
      in the call to Allocate_Any_Controlled.
      
      gcc/ada/
      
      	* exp_util.adb (Build_Allocate_Deallocate_Proc): Pass the alignment
      	parameter in the inner call for a secondary stack allocation too.
      4f3567cf
    • Javier Miranda's avatar
      ada: Missing support for consistent assertion policy · 3f079f22
      Javier Miranda authored
      Add missing support for RM 10.2/5: the region for a pragma
      Assertion_Policy given as a configuration pragma is the
      declarative region for the entire compilation unit (or units)
      to which it applies.
      
      gcc/ada/
      
      	* sem_ch10.adb (Install_Inherited_Policy_Pragmas): New subprogram.
      	(Remove_Inherited_Policy_Pragmas): New subprogram.
      	(Analyze_Compilation_Unit): Call the new subprograms to
      	install and remove inherited assertion policy pragmas.
      3f079f22
    • Eric Botcazou's avatar
      ada: Fix double finalization for dependent expression of case expression · 59c4d2e5
      Eric Botcazou authored
      The recent fix to Default_Initialize_Object, which has ensured that the
      No_Initialization flag set on an object declaration, for example for the
      temporary created by Expand_N_Case_Expression, is honored in all cases,
      has also uncovered a latent issue in the machinery responsible for the
      finalization of transient objects.
      
      More specifically, the answer returned by the Is_Finalizable_Transient
      predicate for an object of an access type is different when it is left
      uninitialized (true) than when it is initialized to null (false), which
      is incorrect; it must return false in both cases, because the only case
      where an object can be finalized by the machinery through an access value
      is when this value is a reference (N_Reference node) to the object.
      
      This was already more or less the current state of the evolution of the
      predicate, but this now explicitly states it in the code.
      
      The change also sets the No_Initialization flag for the temporary created
      by Expand_N_If_Expression for the sake of consistency.
      
      gcc/ada/
      
      	* exp_ch4.adb (Expand_N_If_Expression): Set No_Initialization on the
      	declaration of the temporary in the by-reference case.
      	* exp_util.adb (Initialized_By_Access): Delete.
      	(Is_Allocated): Likewise.
      	(Initialized_By_Reference): New predicate.
      	(Is_Finalizable_Transient): If the transient object is of an access
      	type, do not return true unless it is initialized by a reference.
      59c4d2e5
    • Steve Baird's avatar
      ada: Error in determining accumulator subtype for a reduction expression · d9f3a1d6
      Steve Baird authored
      There was an earlier bug in determining the accumulator subtype for a
      reduction expression in the case where the reducer subprogram is overloaded.
      The fix for that bug introduced a recently-discovered
      regression. Redo accumulator subtype computation in order to address
      this regression while preserving the benefits of the earlier fix.
      
      gcc/ada/
      
      	* exp_attr.adb:	Move computation of Accum_Typ entirely into the
      	function Build_Stat.
      d9f3a1d6
    • Steve Baird's avatar
      ada: Rtsfind should not trash state used in analyzing instantiations. · b2453909
      Steve Baird authored
      During analysis of an instantiation, Sem_Ch12 manages formal/actual binding
      information in package state (see Sem_Ch12.Generic_Renamings_HTable).
      A call to rtsfind can cause another unit to be loaded and compiled.
      If this occurs during the analysis of an instantiation, and if the loaded
      unit contains a second instantiation, then the Sem_Ch12 state needed for
      analyzing the first instantiation can be trashed during the analysis of the
      second instantiation. Rtsfind calls that can include the analysis of an
      instantiation need to save and restore Sem_Ch12's state.
      
      gcc/ada/
      
      	* sem_ch12.ads: Declare new Instance_Context package, which
      	declares a private type Context with operations Save_And_Reset and
      	Restore.
      	* sem_ch12.adb: Provide body for new Instance_Context package.
      	* rtsfind.adb (Load_RTU): Wrap an Instance_Context Save/Restore
      	call pair around the call to Semantics.
      	* table.ads: Add initial value for Last_Val (because
      	Save_And_Reset expects Last_Val to be initialized).
      b2453909
    • Eric Botcazou's avatar
      ada: Factor out implementation of default initialization for objects · cad2744c
      Eric Botcazou authored
      As written down in a comment, "There is a *huge* amount of code duplication"
      in the implementation of default initializaion for objects in the front-end,
      between the (static) declaration case and the dynamic allocation case.
      
      This change factors out the implementation of the (static) declaration case
      and uses it for the dynamic allocation case, with the following benefits:
      
        1. getting rid of the duplication and reducing total line count,
      
        2. bringing optimizations implemented for the (static) declaration case
           to the dynamic allocation case,
      
        3. performing the missing abort deferral prescribed by RM 9.8(9) in the
           dynamic allocation case.
      
      gcc/ada/
      
      	* exp_aggr.adb (Build_Record_Aggr_Code): Replace reference to
      	Build_Task_Allocate_Block_With_Init_Stmts in comment with reference
      	to Build_Task_Allocate_Block.
      	(Convert_Aggr_In_Allocator): Likewise for the call in the code.
      	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
      	* exp_ch3.ads: Alphabetize clauses.
      	(Build_Default_Initialization): New function declaration.
      	(Build_Default_Simple_Initialization): Likewise.
      	(Build_Initialization_Call): Add Target_Ref parameter with default.
      	* exp_ch3.adb (Build_Default_Initialization): New function extracted
      	from...
      	(Build_Default_Simple_Initialization): Likewise.
      	(Build_Initialization_Call): Add Target_Ref parameter with default.
      	(Expand_N_Object_Declaration): ...here.
      	(Default_Initialize_Object): Call Build_Default_Initialization and
      	Build_Default_Simple_Initialization.
      	* exp_ch4.adb (Expand_Allocator_Expression): Minor comment tweaks.
      	(Expand_N_Allocator): Call Build_Default_Initialization and
      	Build_Default_Simple_Initialization to implement the default
      	initialization of the allocated object.
      	* exp_ch9.ads (Build_Task_Allocate_Block): Delete.
      	(Build_Task_Allocate_Block_With_Init_Stmts): Rename into...
      	(Build_Task_Allocate_Block): ...this.
      	* exp_ch9.adb: Remove clauses for Exp_Tss.
      	(Build_Task_Allocate_Block): Delete.
      	(Build_Task_Allocate_Block_With_Init_Stmts): Rename into...
      	(Build_Task_Allocate_Block): ...this.
      	* exp_util.adb (Build_Allocate_Deallocate_Proc): Remove unnecessary
      	initialization expression, adjust commentary and replace early exit
      	with assertion.
      	* sem_ch4.adb (Analyze_Allocator): In the null-exclusion case, call
      	Apply_Compile_Time_Constraint_Error to insert the raise.
      cad2744c
    • Ronan Desplanques's avatar
      ada: Fix crash with -gnatyB and -gnatdJ · 82177247
      Ronan Desplanques authored
      The crash this patch fixes happened because calling the Errout.Error_Msg
      procedures that don't have an N parameter is not allowed when not
      parsing and -gnatdJ is on. And -gnatyB style checks are not emitted during
      parsing but during semantic analysis.
      
      This commit moves Check_Boolean_Operator from Styleg to Style so it can
      call Errout.Error_Msg with a Node_Id parameter. This change of package
      makes sense because:
      
      1. The compiler is currently the only user of Check_Boolean_Operator.
      2. Other tools don't do semantic analysis, and so cannot possibly
      know when to use Check_Boolean_Operator anyway.
      
      gcc/ada/
      
      	* styleg.ads (Check_Boolean_Operator): Moved ...
      	* style.ads (Check_Boolean_Operator): ... here.
      	* styleg.adb (Check_Boolean_Operator): Moved ...
      	* style.adb (Check_Boolean_Operator): ... here. Also add node
      	parameter to call to Errout.Error_Msg.
      82177247
    • Eric Botcazou's avatar
      ada: Small fix to printing of raise statements · 4dd6f75e
      Eric Botcazou authored
      The Name is optional on these nodes and a superflous space is printed if
      it is not present on them.
      
      gcc/ada/
      
      	* sprint.adb (Sprint_Node_Actual) <N_Raise_Statement>: Be prepared
      	for an empty Name.
      	<N_Raise_When_Statement>: Likewise.
      4dd6f75e
    • Yannick Moy's avatar
      ada: Update of SPARK RM legality rules on ghost code · df48963b
      Yannick Moy authored
      Update checking of ghost code after a small change in SPARK RM
      rules 6.9(15) and 6.9(20), so that the Ghost assertion policy
      that matters when checking the validity of a reference to a ghost entity
      in an assertion expression is the Ghost assertion policy at the point
      of declaration of the entity.
      
      Also fix references to SPARK RM rules in comments, which were off by two
      in many cases after the insertion of rules 13 and 14 regarding generic
      instantiations.
      
      gcc/ada/
      
      	* contracts.adb: Fix references to SPARK RM rules.
      	* freeze.adb: Same.
      	* ghost.adb: Fix references to SPARK RM rules.
      	(Check_Ghost_Context): Update checking of references to
      	ghost entities in assertion expressions.
      	* sem_ch6.adb: Fix references to SPARK RM rules.
      	* sem_prag.adb: Same.
      df48963b
Loading