aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
AgeCommit message (Collapse)AuthorFilesLines
2019-12-18trans.c (Pragma_to_gnu): Push a diagnostics state for pragma Warnings (Off) ↵Eric Botcazou1-0/+19
before turning off all the... * gcc-interface/trans.c (Pragma_to_gnu) <Pragma_Warnings>: Push a diagnostics state for pragma Warnings (Off) before turning off all the warnings and only pop it for pragma Warnings (On). From-SVN: r279519
2019-12-16[Ada] AI12-0001: Independence and Representation clauses for atomic objectsEric Botcazou2-5/+5
2019-12-16 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust calls to validate_size. (gnat_to_gnu_component_type): Likewise. (gnat_to_gnu_field): Likewise and pass string for error messages. (components_need_strict_alignment): Remove test on Is_Aliased and add test for the independence of the component. (validate_size): Add S1 and S2 string parameters and use them to give better error messages for fields. Tweak a couple of messages. * einfo.ads (Has_Independent_Components): Document more cases. (Is_Independent): Likewise. (Strict_Alignment): Document new semantics. * exp_ch9.adb (Install_Private_Data_Declarations): Also set the Is_Independent flag along with Is_Aliased on the renaming entity. * freeze.adb (Size_Known): Remove always-false test and add test for the strict-alignment on the record type. Remove redundant tests and add test for the strict-alignment on the component type. (Check_Strict_Alignment): Set the flag if the type is by-ref and remove now redundant conditions. Set the flag on an array type if it has aliased components. In the record type case, do not set type for C_Pass_By_Copy convention. (Freeze_Array_Type): Move code checking for conflicts between representation aspects and clauses to before specific handling of packed array types. Give a warnind instead of an error for a conflict with pragma Pack. Do not test Has_Pragma_Pack for the specific handling of packed array types. (Freeze_Record_Type): Move error checking of representation clause to... (Freeze_Entity): ...here after Check_Strict_Alignment is called. * sem_aggr.adb (Array_Aggr_Subtype): Also set the Is_Independent flag along with Is_Aliased on the Itype. * sem_ch13.adb (Check_Record_Representation_Clause): Do not set the RM size for a strict-alignment type. * sem_ch3.adb (Add_Interface_Tag_Components): Also set the Is_Independent flag along with Is_Aliased on the tag. (Add_Interface_Tag_Components): Likewise on the offset. (Analyze_Component_Declaration): Likewise on the component. (Analyze_Object_Declaration): Likewise on the object. (Constrain_Array): Likewise on the array. (Record_Type_Declaration: Likewise on the tag. (Array_Type_Declaration): Also set the Has_Independent_Components flag along with Has_Aliased_Components on the array. (Copy_Array_Base_Type_Attributes): Copy Has_Independent_Components. (Copy_Array_Subtype_Attributes): Copy Is_Atomic, Is_Independent and Is_Volatile_Full_Access. (Analyze_Iterator_Specification): Set Is_Independent on the loop variable according to Independent_Components on the array. * sem_ch5.adb: Likewise. * sem_ch6.adb (Process_Formals): Also set the Is_Independent flag along with Is_Aliased on the formal. gcc/testsuite/ * gnat.dg/specs/clause_on_volatile.ads, gnat.dg/specs/size_clause3.ads: Update expected diagnostics. From-SVN: r279430
2019-12-12[Ada] Constraint is ignored on constrained access record componentEd Schonberg1-1/+1
2019-12-12 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch3.adb (Constrain_Access): Remove obsolete comments and warning concerning component types of an access type whose designated type is a constrained record type. (Such constraints were previously ignored). Set scope of itype for component to the scope of the enclosing record. * sem_ch4.adb: Remove call to Set_Ekind. * sem_util.adb (Build_Actual_Subtype_Of_Component): Handle components whose type is an access to a constrained discriminant, where the constraints may be given by the discriminants of the enclosing type. New subprogram Build_Access_Record_Constraint. gcc/testsuite/ * gnat.dg/warn24.adb: Remove expected warning. From-SVN: r279281
2019-12-12[Ada] Remove implicit anonymous access conversion in testcasePierre-Marie de Rodat1-1/+1
2019-12-12 Pierre-Marie de Rodat <derodat@adacore.com> gcc/testsuite/ * gnat.dg/subp_inst_pkg.adb: Remove implicit anonymous access conversion. From-SVN: r279276
2019-12-09tree.c (build_array_type_1): Add SET_CANONICAL parameter and compute ↵Eric Botcazou1-0/+20
TYPE_CANONICAL from the element type... * tree.c (build_array_type_1): Add SET_CANONICAL parameter and compute TYPE_CANONICAL from the element type only if it is true. Remove a few obsolete lines and adjust recursive call. (fld_process_array_type): Adjust call to build_array_type_1. (build_array_type): Likewise. (build_nonshared_array_type): Likewise. From-SVN: r279133
2019-11-25re PR ada/92362 (double elaboration of expression in Address aspect)Eric Botcazou1-0/+24
PR ada/92362 * gcc-interface/trans.c (gnat_to_gnu) <N_Attribute_Definition_Clause>: Use a temporary instead of clobbering the result with a freeze node. From-SVN: r278675
2019-10-11decl.c (gnat_to_gnu_field): Adjust again the packing for a field without ↵Eric Botcazou1-0/+20
strict alignment and with an... * gcc-interface/decl.c (gnat_to_gnu_field): Adjust again the packing for a field without strict alignment and with an oversized clause. From-SVN: r276873
2019-10-11decl.c (Gigi_Equivalent_Type): New case.Eric Botcazou3-0/+37
* gcc-interface/decl.c (Gigi_Equivalent_Type) <E_Array_Subtype>: New case. Return the base type if the subtype is not constrained. From-SVN: r276865
2019-10-02tree-eh.h (unsplit_eh_edges): Declare.Eric Botcazou2-0/+24
* tree-eh.h (unsplit_eh_edges): Declare. * tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases. (unsplit_eh_edges): New function wrapping unsplit_all_eh. * gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h. (struct store_immediate_info): Add lp_nr field. (store_immediate_info::store_immediate_info): Add NR2 parameter and initialize lp_nr with it. (struct merged_store_group): Add lp_nr and only_constants fields. (merged_store_group::merged_store_group): Initialize them. (merged_store_group::can_be_merged_into): Deal with them. (pass_store_merging): Rename terminate_and_release_chain into terminate_and_process_chain. (pass_store_merging::terminate_and_process_all_chains): Adjust to above renaming and remove useless assertions. (pass_store_merging::terminate_all_aliasing_chains): Small tweak. (stmts_may_clobber_ref_p): Be prepared for different basic blocks. (imm_store_chain_info::coalesce_immediate_stores): Use only_constants instead of always recomputing it and compare lp_nr. (imm_store_chain_info::output_merged_store): If the group is in an active EH region, register new stores if they can throw. Moreover, if the insertion has created new basic blocks, adjust the PHI nodes of the post landing pad. (imm_store_chain_info::output_merged_stores): If the original stores are in an active EH region, deregister them. (lhs_valid_for_store_merging_p): Prettify. (adjust_bit_pos): New function extracted from... (mem_valid_for_store_merging): ...here. Use it for the base address and also for the offset if it is the addition of a constant. (lp_nr_for_store): New function. (pass_store_merging::process_store): Change return type to bool. Call lp_nr_for_store to initialize the store info. Propagate the return status of various called functions to the return value. (store_valid_for_store_merging_p): New predicate. (enum basic_block_status): New enumeration. (get_status_for_store_merging): New function. (pass_store_merging::execute): If the function can throw and catch non-call exceptions, unsplit the EH edges on entry and clean up the CFG on exit if something changed. Call get_status_for_store_merging for every basic block and keep the chains open across basic blocks when possible. Terminate and process open chains at the end, if any. From-SVN: r276459
2019-09-23Provide Task_Info.Number_Of_Processors on SolarisRainer Orth1-1/+1
gcc/ada: * libgnarl/s-osinte__solaris.ads (sysconf): Declare. (SC_NPROCESSORS_ONLN): Define. * libgnarl/s-tasinf__solaris.ads (Number_Of_Processors): Declare. * libgnarl/s-tasinf__solaris.adb (N_CPU): New variable. (Number_Of_Processors): New function. gcc/testsuite: * gnat.dg/system_info1.adb: Sort dg-do target list. Add *-*-solaris2.*. From-SVN: r276049
2019-09-23trans.c (gnat_compile_time_expr_list): New variable.Eric Botcazou2-0/+16
* gcc-interface/trans.c (gnat_compile_time_expr_list): New variable. (Pragma_to_gnu): Rename local variable. Save the (first) expression of pragma Compile_Time_{Error|Warning} for later processing. (Compilation_Unit_to_gnu): Process the expressions saved above. From-SVN: r276045
2019-09-20Restrict gnat.dg/system_info1.adb to Linux and Windows hostsOlivier Hainque1-2/+7
Where it is know to work, still covering the original test intent. From-SVN: r275999
2019-09-19[Ada] Emit DW_AT_GNU_bias with -fgnat-encodings=gdbTom Tromey1-0/+34
Emit DW_AT_GNU_bias with -fgnat-encodings=gdb. gdb implements this, but not the encoded variant. 2019-09-19 Tom Tromey <tromey@adacore.com> gcc/ada/ * gcc-interface/misc.c (gnat_get_type_bias): Return the bias when -fgnat-encodings=gdb. gcc/testsuite/ * gnat.dg/bias1.adb: New testcase. From-SVN: r275958
2019-09-19[Ada] Accept concatentation arguments to pragma AnnotateSteve Baird1-0/+7
In cases where pragma Annotate accepts a string literal as an argument, we now also accept a concatenation of string literals. 2019-09-19 Steve Baird <baird@adacore.com> gcc/ada/ * sem_prag.adb (Preferred_String_Type): A new function. Given an expression, determines whether the preference rules defined for the third-and-later arguments of pragma Annotate suffice to determine the type of the expression. If so, then the preferred type is returned; if not then Empty is returned. Handles concatenations. (Analyze_Pragma): Replace previous code, which dealt only with string literals, with calls to the new Preferred_String_Type function, which also handles concatenations. * doc/gnat_rm/implementation_defined_pragmas.rst: Update documentation for pragma Annotate. * gnat_rm.texi: Regenerate. gcc/testsuite/ * gnat.dg/annotation1.adb: New testcase. From-SVN: r275957
2019-09-19[Ada] Fix bogus "too late" error with nested generics and inliningEric Botcazou5-0/+50
This prevents the compiler from issuing a bogus error about a constant whose full declaration appears too late, if it is declared in a nested generic package and instantiated in another nested instantiation, when the instantiations are done in a unit withed from the main unit and containing an inlined subprogram, and cross-unit inlining is enabled. It turns out that, under these very peculiar conditions, the compiler ends up instantiating the body of the generic package twice, which leads to various semantic errors, in particular for declarations of constants. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch12.adb (Instantiate_Package_Body): Check that the body has not already been instantiated when the body of the parent was being loaded. gcc/testsuite/ * gnat.dg/inline21.adb, gnat.dg/inline21_g.ads, gnat.dg/inline21_h.adb, gnat.dg/inline21_h.ads, gnat.dg/inline21_q.ads: New testcase. From-SVN: r275953
2019-09-19[Ada] Fix bogus visibility error with nested generics and inliningEric Botcazou8-0/+95
This prevents the compiler from issuing a bogus error about the visibility of an operator in an instantiation of a nested generic package which is itself used as an actual of an instantiation of another generic package, when the instantiations are done in a unit withed from the main unit and containing an inlined subprogram, and cross-unit inlining is enabled. In most cases, the compiler does not check the visibility of operators in an instantiation context because this has already been done when the generic package has been analyzed. However, there are exceptions like the actuals of an instantiation of a generic child unit which is done as a compilation unit and the In_Instance predicate has a special check for these cases. This check would incorrectly trigger here and needs to be tightened. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_util.adb (In_Instance): Test whether the current unit has been analyzed instead of being on the scope stack to detect the case of actuals of an instantiation of a generic child unit done as a compilation unit. gcc/testsuite/ * gnat.dg/inline20.adb, gnat.dg/inline20_g.adb, gnat.dg/inline20_g.ads, gnat.dg/inline20_h.ads, gnat.dg/inline20_i.ads, gnat.dg/inline20_q-io.ads, gnat.dg/inline20_q.ads, gnat.dg/inline20_r.ads: New testcase. From-SVN: r275952
2019-09-19[Ada] Spurious visibility error in generic child unitEd Schonberg4-0/+21
2019-09-19 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch7.adb (Install_Parent_Private_Declarations): If a generic child unit is instantiated within a sibling child unit, the analysis of its private part requires that the private part of the ancestor be available, as is done when the context includes an instance of the ancestor. gcc/testsuite/ * gnat.dg/generic2-child.ads, gnat.dg/generic2-io_any.adb, gnat.dg/generic2-io_any.ads, gnat.dg/generic2.ads: New testcase. From-SVN: r275949
2019-09-19[Ada] Allow constants of access type in Global contractsYannick Moy2-0/+18
Now that SPARK supports access types, global constants of access type may appear as outputs of a subprogram, with the meaning that the underlying memory can be modified (see SPARK RM 3.10). 2019-09-19 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_prag.adb (Analyze_Global_In_Decl_Part): Do not issue an error when a constant of an access type is used as output in a Global contract. (Analyze_Depends_In_Decl_Part): Do not issue an error when a constant of an access type is used as output in a Depends contract. gcc/testsuite/ * gnat.dg/global2.adb, gnat.dg/global2.ads: New testcase. From-SVN: r275947
2019-09-19[Ada] Fix run-time segfault with derived access-to-subprogram typeEric Botcazou1-0/+20
This fixes a segfault at run time for the call to a local subprogram through an access value if the type of this access value is derived from an initial access-to-subprogram type and the access value was originally obtained with the initial type. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch3.adb (Build_Derived_Access_Type): If this is an access- to-subprogram type, copy Can_Use_Internal_Rep from the parent. gcc/testsuite/ * gnat.dg/access9.adb: New testcase. From-SVN: r275945
2019-09-19[Ada] Crash on predicate in full view in a generic unitEd Schonberg2-0/+60
This patch fixes a compiler abort on a dynamic predicate applied to the full view of a type in a generic package declaration, when the expression for the predicate is a conditionql expression that contains references to components of the full view of the type. 2019-09-19 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Simplify handling of expressions in predicates when the context is a generic unit. gcc/testsuite/ * gnat.dg/predicate14.adb, gnat.dg/predicate14.ads: New testcase. From-SVN: r275939
2019-09-19[Ada] Fix spurious type mismatch failure on nested instantiationsEric Botcazou4-0/+56
This fixes a spurious type mismatch failure reported between formal and actual of a call to a subprogram that comes from the instantiation of a child generic unit that itself contains an instantiation of a slibling child generic unit, when the parent is itself a generic unit with private part. The regression was introduced by a recent change made to clear the Is_Generic_Actual_Type on the implicit full view built when a generic package is instantiated on a private type. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch12.adb (Restore_Private_Views): Comment out new code that clear the Is_Generic_Actual_Type also on the full view. gcc/testsuite/ * gnat.dg/generic_inst13.adb, gnat.dg/generic_inst13_pkg-nested_g.ads, gnat.dg/generic_inst13_pkg-ops_g.ads, gnat.dg/generic_inst13_pkg.ads: New testcase. From-SVN: r275935
2019-09-19[Ada] Infinite loop with concatenation and aspectBob Duff1-0/+14
This patch fixes a bug where an array object initialized with a concatenation, and that has an aspect_specification for Alignment, causes the compiler goes into an infinite loop. 2019-09-19 Bob Duff <duff@adacore.com> gcc/ada/ * exp_ch3.adb (Rewrite_As_Renaming): Return False if there are any aspect specifications, because otherwise Insert_Actions blows up. gcc/testsuite/ * gnat.dg/concat3.adb: New testcase. From-SVN: r275934
2019-09-19[Ada] Fix fallout of previous change for bit-packed arraysEric Botcazou1-0/+23
This fixes a regression introduced by the previous change that improved the handling of explicit by-reference mechanism. For the very specific case of a component of a bit-packed array, the front-end still needs to insert a copy around the call because this is where the rewriting into the sequence of mask-and-shifts is done for the code generator. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_ch6.adb (Add_Simple_Call_By_Copy_Code): Add Bit_Packed_Array parameter and documet it. Always insert a copy if it is set True. (Expand_Actuals): Adjust the calls to Add_Simple_Call_By_Copy_Code. gcc/testsuite/ * gnat.dg/pack26.adb: New testcase. From-SVN: r275933
2019-09-18[Ada] Fix spurious alignment warning on simple address clauseEric Botcazou2-0/+25
This eliminates a spurious alignment warning given by the compiler on an address clause when the No_Exception_Propagation restriction is in effect and the -gnatw.x switch is used. In this configuration the address clauses whose expression is itself of the form X'Address would not be sufficiently analyzed and, therefore, the compiler might give false positive warnings. 2019-09-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * checks.ads (Alignment_Warnings_Record): Add P component. * checks.adb (Apply_Address_Clause_Check): Be prepared to kill the warning also if the clause is of the form X'Address. (Validate_Alignment_Check_Warning): Kill the warning if the clause is of the form X'Address and the alignment of X is compatible. gcc/testsuite/ * gnat.dg/warn31.adb, gnat.dg/warn31.ads: New testcase. From-SVN: r275865
2019-09-18[Ada] Crash on universal case expression in fixed-point divisionEd Schonberg1-0/+28
This patch fixes a compiler abort on a case expression whose alternatives are universal_real constants, when the case expression is an operand in a multiplication or division whose other operand is of a fixed-point type. 2019-09-18 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_res.adb (Set_Mixed_Node_Expression): If a conditional expression has universal_real alternaitves and the context is Universal_Fixed, as when it is an operand in a fixed-point multiplication or division, resolve the expression with a visible fixed-point type, which must be unique. gcc/testsuite/ * gnat.dg/fixedpnt8.adb: New testcase. From-SVN: r275864
2019-09-18[Ada] Crash on aggregate with dscriminant in if-expression as defaultEd Schonberg1-0/+33
This patch fixes a crash on a an aggregate for a discriminated type, when a component of the aggregate is also a discriminated type constrained by a discriminant of the enclosing object, and the default value for the component is a conditional expression that includes references to that outer discriminant. 2019-09-18 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_aggr.adb (Expand_Record_Aggregate, Rewrite_Discriminant): After rewriting a reference to an outer discriminant as a selected component of the enclosing object, analyze the selected component to ensure that the entity of the selector name is properly set. This is necessary when the aggregate appears within an expression that may have been analyzed already. gcc/testsuite/ * gnat.dg/discr58.adb: New testcase. From-SVN: r275862
2019-09-18[Ada] Spurious ineffective use_clause warningJustin Squirek2-0/+16
This patch fixes an issue whereby expansion of post conditions may lead to spurious ineffective use_clause warnings when a use type clause is present in a package specification and a use package clause exists in the package body on the package containing said type. 2019-09-18 Justin Squirek <squirek@adacore.com> gcc/ada/ * sem_ch8.adb (Use_One_Type): Add guard to prevent warning on a reundant use package clause where there is no previous use_clause in the chain. gcc/testsuite/ * gnat.dg/warn30.adb, gnat.dg/warn30.ads: New testcase. From-SVN: r275861
2019-09-18[Ada] Missing accessibility check on discrim assignmentJustin Squirek3-0/+95
This patch fixes an issue whereby assignments from anonymous access descriminants which are part of stand alone objects of anonymous access did not have runtime checks generated based on the accessibility level of the object according to ARM 3.10.2 (12.5/3). 2019-09-18 Justin Squirek <squirek@adacore.com> gcc/ada/ * exp_ch4.adb (Expand_N_Type_Conversion): Add calculation of an alternative operand for the purposes of generating accessibility checks. gcc/testsuite/ * gnat.dg/access8.adb, gnat.dg/access8_pkg.adb, gnat.dg/access8_pkg.ads: New testcase. From-SVN: r275860
2019-09-18[Ada] Fix sharing of expression in array aggregate with others choiceEric Botcazou1-0/+29
This change fixes a long-standing issue in the compiler that is generally silent but may lead to wrong code generation in specific circumstances. When an others choice in an array aggregate spans multiple ranges, the compiler may generate multiple (groups of) assignments for the ranges. The problem is that it internally reuses the original expression for all the ranges, which is problematic if this expression gets rewritten during the processing of one of the ranges and typically causes a new temporary to be shared between different ranges. The solution is to duplicate the original expression for each range. 2019-09-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): In STEP 1 (c), duplicate the expression and reset the Loop_Actions for each loop generated for an others choice. gcc/testsuite/ * gnat.dg/aggr28.adb: New testcase. From-SVN: r275859
2019-09-18[Ada] Implement AI12-0086's rules for discriminants in aggregatesSteve Baird1-0/+24
In Ada2012, a discriminant value that governs an active variant part in an aggregate had to be static. AI12-0086 relaxes this restriction - if the subtype of the discriminant value is a static subtype all of whose values select the same variant, then that is good enough. 2019-09-18 Steve Baird <baird@adacore.com> gcc/ada/ * sem_util.ads (Interval_Lists): A new visible package. This package is visible because it is also intended for eventual use in Sem_Eval.Subtypes_Statically_Compatible when that function is someday upgraded to handle static predicates correctly. This new package doesn't really need to be visible for now, but it still seems like a good idea. * sem_util.adb (Gather_Components): Implement AI12-0086 via the following strategy. The existing code knows how to take a static discriminant value and identify the corresponding variant; in the newly-permitted case of a non-static value of a static subtype, we arbitrarily select a value of the subtype and find the corresponding variant using the existing code. Subsequently, we check that every other value of the discriminant's subtype corresponds to the same variant; this is done using the newly introduced Interval_Lists package. (Interval_Lists): Provide a body for the new package. gcc/testsuite/ * gnat.dg/ai12_0086_example.adb: New testcase. From-SVN: r275857
2019-09-18[Ada] Ensure that Scan_Real result does not depend on trailing zerosNicolas Roche1-0/+10
Previous change in that procedure to handle overflow issues during scanning removed the special handling for trailing zeros in the decimal part. Beside the absence of overflow during scanning the special handling of these zeros is still necessary. 2019-09-18 Nicolas Roche <roche@adacore.com> gcc/ada/ * libgnat/s-valrea.adb (Scan_Integral_Digits): New procedure. (Scan_Decimal_Digits): New procedure. (As_Digit): New function. (Scan_Real): Use Scan_Integral_Digits and Scan_Decimal_Digits. gcc/testsuite/ * gnat.dg/float_value2.adb: New testcase. From-SVN: r275849
2019-09-18[Ada] Raise exception on call to Expect for a dead processVadim Godunko1-0/+35
Call to Expect for a dead process results in SIGBUS signal on Linux systems. Process_Died exception is raised in this case now. 2019-09-18 Vadim Godunko <godunko@adacore.com> gcc/ada/ * libgnat/g-expect.adb (Expect_Internal): Don't include invalid file descriptors into the set of file descriptors for Poll. Raise Process_Died exception when computed set of file descriptors to monitor is empty. gcc/testsuite/ * gnat.dg/expect4.adb: New testcase. From-SVN: r275847
2019-09-18[Ada] No Storage_Error for an oversized disabled ghost array objectSteve Baird2-0/+14
In some cases where the size computation for an object declaration will unconditionally overflow, the FE generates code to raise Storage_Error at the point of the object declaration (and may generate an associated warning). Don't do this if the object declaration is an ignored (i.e., disabled) ghost declaration. 2019-09-18 Steve Baird <baird@adacore.com> gcc/ada/ * freeze.adb (Freeze_Object_Declaration): Do not call Check_Large_Modular_Array when the object declaration being frozen is an ignored ghost entity. gcc/testsuite/ * gnat.dg/ghost7.adb, gnat.dg/ghost7.ads: New testcase. From-SVN: r275845
2019-09-18[Ada] Fix 32/64bit mistake on SYSTEM_INFO component in s-win32Olivier Hainque1-0/+23
The dwActiveProcessorMask field in a SYSTEM_INFO structure on Windows should be DWORD_PTR, an integer the size of a pointer. In s-win32, it is currently declared as DWORD. This happens to work on 32bit hosts and is wrong on 64bit hosts, causing mishaps in accesses to this component and all the following ones. The proposed correction adds a definition for DWORD_PTR and uses it for dwActiveProcessorMask in System.Win32.SYSTEM_INFO. 2019-09-18 Olivier Hainque <hainque@adacore.com> gcc/ada/ * libgnat/s-win32.ads (DWORD_PTR): New type, pointer size unsigned int. (SYSTEM_INFO): Use it for dwActiveProcessorMask. gcc/testsuite/ * gnat.dg/system_info1.adb: New testcase. From-SVN: r275843
2019-09-18[Ada] Avoid uninitialized variable in bounded containersBob Duff2-0/+11
In function Copy in Ada.Containers.Bounded_Ordered_Sets and other bounded containers packages, remove a possible use of an uninitialized variable. This was not a bug, because the uninitialized variable could be used only if checks are suppressed, and the checks would have failed, leading to erroneous execution. However, it seems more robust this way, and is probably equally efficient, and avoids a warning that is given if checks are suppressed, and the -Wall switch is given, and optimization is turned on. 2019-09-18 Bob Duff <duff@adacore.com> gcc/ada/ * libgnat/a-cbhama.adb, libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb, libgnat/a-cborma.adb, libgnat/a-cborse.adb, libgnat/a-cobove.adb (Copy): Avoid reading the uninitialized variable C in the Checks = False case. Change variable to be a constant. gcc/testsuite/ * gnat.dg/containers1.adb, gnat.dg/containers1.ads: New testcase. From-SVN: r275839
2019-09-17[Ada] Fix rounding of fixed-point arithmetic operationYannick Moy1-0/+20
Fixed-point multiplication, division and conversion may lead to calling the function Double_Divide in s-arit64 runtime unit. In the special case where arguments have the special values X = -2**63 and the absolute value of the product of its other arguments Y*Z = 2**64, the rounded value should be either -1 or 1, but currently Double_Divide returns a quotient of 0. Rounding only applies when Round attribute is called on the arithmetic operation for a decimal fixed-point result, or the result type is integer. This fixes correctly applies rounding away from 0 in that special case. 2019-09-17 Yannick Moy <moy@adacore.com> gcc/ada/ * libgnat/s-arit64.adb (Double_Divide): Correctly handle the special case when rounding. gcc/testsuite/ * gnat.dg/fixedpnt7.adb: New testcase. From-SVN: r275796
2019-09-17[Ada] Raise Constraint_Error in overflow case involving roundingYannick Moy1-0/+24
Function Scaled_Divide in s-arith runtime unit computes the combined multiplication and division of its arguments ((X*Y) / Z). In a very special case where the quotient computed before rounding is 2**64-1, then rounding may lead to undesirable wrap-around, leading to a computed quotient of 0 instead of raising Constraint_Error as expected. This function is only called in the runtime for arithmetic operations involving fixed-point types. Rounding is performed only when the target type is of a decimal fixed-point type, and the attribute 'Round of the type is used to round the result of the arithmetic operation. This fix correctly raises Constraint_Error in this special case. 2019-09-17 Yannick Moy <moy@adacore.com> gcc/ada/ * libgnat/s-arit64.adb (Scaled_Divide): Add protection against undesirable wrap-around. gcc/testsuite/ * gnat.dg/multfixed.adb: New testcase. From-SVN: r275791
2019-09-17[Ada] Avoid to close irrelevant file descriptorsVadim Godunko1-0/+33
'Close' subprogram of GNAT.Expect can close irrelevant file descriptors when 'Expect' was terminated by Process_Died exception and any file open operations was done before call to 'Close'. 2019-09-17 Vadim Godunko <godunko@adacore.com> gcc/ada/ * libgnat/g-expect.ads, libgnat/g-expect.adb (Close_Input): New subprogram. (Get_Command_Output): Call Close_Input to close input stream. (Expect_Internal): Likewise. (Close): Likewise. * libgnat/g-exptty.adb (Close): Likewise. gcc/testsuite/ * gnat.dg/expect3.adb: New testcase. From-SVN: r275781
2019-09-17[Ada] In a generic use Presanalyze_Spec_Expression on PredicatesEd Schonberg2-0/+26
When verifying that the meaning of an aspect has not changed between the freeze point of the entity and the end of the declarations, we analkyze a copy of the expression to verify its conformance to previous analysis. If the expression contains overloaded references, these have to be resolved, which is not done if the expression is only preanalyzed. This applies in particular to expressions in predicates. 2019-09-17 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In a generic context, for a Predicate aspect, use Preanalyze_Spec_Expression to verify conformance. gcc/testsuite/ * gnat.dg/predicate13.adb, gnat.dg/predicate13.ads: New testcase. From-SVN: r275778
2019-09-17[Ada] Ada 2020: Raise expressions in limited contexts (AI12-0172)Javier Miranda1-0/+58
This patch adds support for the use of raise expressions in more limited contexts (as described in the Ada Isssue AI12-0172). 2019-09-17 Javier Miranda <miranda@adacore.com> gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc): Do not generate code to adjust the tag component when the record is initialized with a raise expression. * sem_aggr.adb (Valid_Limited_Ancestor): Return True for N_Raise_Expression nodes. (Valid_Ancestor_Type): Return True for raise expressions. * sem_ch3.adb (Analyze_Component_Declaration): Do not report an error when a component is initialized with a raise expression. * sem_ch4.adb (Analyze_Qualified_Expression): Do not report an error when the aggregate has a raise expression. gcc/testsuite/ * gnat.dg/limited4.adb: New testcase. From-SVN: r275776
2019-09-17[Ada] Fix wrong value of 'Size for slices of bit-packed arraysEric Botcazou1-0/+21
This fixes a long-standing issue in the compiler which would return a wrong value for the Size attribute applied to slices of bit-packed arrays whose size is not a multiple of the storage unit. The problem is that the computation was done in the code generator after the bit-packed array had been internally rewritten into an array of bytes, so the Size was always rounded up to the next byte. The computation is now rewritten into the product of the Length and Compnent_Size attribute of the slices before being sent to the code generator. 2019-09-17 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_attr.adb (Expand_Size_Attribute): Chain the special cases on the back-end path and rewrite the attribute appled to slices of bit-packed arrays into the product of the Length and the Compoent_Size attributes of the slices. * exp_ch5.adb (Expand_Assign_Array_Bitfield): Use Size attribute directly to compute the bitfield's size. gcc/testsuite/ * gnat.dg/pack25.adb: New testcase. From-SVN: r275769
2019-08-30gigi.h (aggregate_type_contains_array_p): Declare.Eric Botcazou1-0/+38
* gcc-interface/gigi.h (aggregate_type_contains_array_p): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: For an extension, test Has_Record_Rep_Clause instead of Has_Specified_Layout. (adjust_packed): Return 0 if the type of the field is an aggregate type that contains (or is) a self-referential array. (type_has_variable_size): Delete. * gcc-interface/utils.c (inish_record_type): Constify a variable. (aggregate_type_contains_array_p): Add parameter SELF_REFERENTIAL. <RECORD_TYPE>: Pass it in the recursive call. <ARRAY_TYPE>: If it is true, return true only if the array type is self-referential. (create_field_decl): Streamline the setting of the alignment on the field. Pass false to aggregate_type_contains_array_p. From-SVN: r275196
2019-08-21[Ada] Fix assertion failure on derived private protected typeEric Botcazou4-0/+46
This fixes an assertion failure on the instantiation of a generic package on a type derived from the private view of a protected type, ultimately caused by Finalize_Address returning Empty for the subtype built for the generic actual type of the instantiation. Finalize_Address has a special processing for untagged derivations of private views, but it would no longer trigger for the subtype because this subtype is now represented as a subtype of an implicit derived base type instead of as the derived type of an implicit subtype previously. 2019-08-21 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_util.adb (Finalize_Address): Deal consistently with subtypes of private protected types. gcc/testsuite/ * gnat.dg/prot9.adb, gnat.dg/prot9_gen.ads, gnat.dg/prot9_pkg1.ads, gnat.dg/prot9_pkg2.ads: New testcase. From-SVN: r274778
2019-08-21[Ada] Missing attribute update in new_copy_treeJavier Miranda2-0/+27
The compiler crashes processing an internally generated cloned tree that has a subprogram call with a named actual parameter. 2019-08-21 Javier Miranda <miranda@adacore.com> gcc/ada/ * sem_util.adb (Update_Named_Associations): Update First_Named_Actual when the subprogram call has a single named actual. gcc/testsuite/ * gnat.dg/implicit_param.adb, gnat.dg/implicit_param_pkg.ads: New testcase. From-SVN: r274776
2019-08-20[Ada] Crash on a Storage_Size aspect depending on attr. of another typeEd Schonberg1-0/+19
This patch fixes a crash on an aspect specification for Storage_Size for a type T when the expression for the aspect depends on attributes of a previously declared type that is not frozen yet. The temporary declaration that captures the value of the aspect must be part of the actions attached to the freeze node for T. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_ch13.adb (Expand_N_Attribute_Definition_Clause, case Storage_Size): If the expression for Storage_Size is not static it may depend on characterstics of another type that may bot be frozen yet, so the elaboration of the expression for the aspect must be attached directly to the freeze actions of the type to which it applies. gcc/testsuite/ * gnat.dg/storage_size1.adb: New testcase. From-SVN: r274742
2019-08-20[Ada] Crash on Loop_Entry for while_loop involving substringsEd Schonberg1-0/+11
When expanding a loop entry attribute for a while_loop we construct a function that incorporates the expanded condition of the loop. The itypes that may be generated in that expansion must carry the scope of the constructed function for proper handling in the backend. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_attr.adb (Expand_Loop_Entry_Attribute): When expanding a loop entry attribute for a while_loop we construct a function that incorporates the expanded condition of the loop. The itypes that may be generated in that expansion must carry the scope of the constructed function for proper handling in gigi. gcc/testsuite/ * gnat.dg/loop_entry2.adb: New testcase. From-SVN: r274734
2019-08-20[Ada] Spurious error in dispatching call with class-wide preconditionEd Schonberg2-0/+24
This patch fixes a spurious visibility error on a dispatching call to a subprogram with a classwide precondition, when the call qppears in the same declarative part as the subprogram declaration itself. 2019-08-20 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_disp.adb (Build_Class_Wide_Check, Replace_Formals): When a dispatching call tp a subprogram with a class-wide precondition occurrs in the same declarative part as the ancestor subprogram being called, the`expression for the precondition has not been analyzed yet. Such a call may appear, e.g. in an expression function. In that case, the replacement of formals by actuals in the call cannot use the formal entities of the subprogram being called, and the occurrence of the formals in the expression must be located by name (Chars fields) as would be done at a later freeze point, when the expression is resolved in the context of the subprogram itself. gcc/testsuite/ * gnat.dg/tagged5.adb, gnat.dg/tagged5.ads: New testcase. From-SVN: r274733
2019-08-20[Ada] Illegal limited function call accepted in a type conversionGary Dismukes2-0/+29
It's illegal to call a function with a result of an immutably limited type inside a type conversion that's used in one of the special contexts that allow such a function call by itself (see RM 7.5 (2.1-2.10)), such as in the initialization expression of an object declaration. The compiler was recursively applying OK_For_Limited_Init_In_05 to the expression inside of a rewritten type conversion, rather than directly to the Original_Node itself (which is what was cased on to get to the type conversion case alternative), which allowed such illegal initialization, and that's corrected by this fix. However, when the expression is not a rewriting of a user-written conversion, the recursive call to OK_For_Limited_Init_In_05 must be applied to the Expression of the conversion. 2019-08-20 Gary Dismukes <dismukes@adacore.com> gcc/ada/ * sem_ch3.adb (OK_For_Limited_Init_In_05): In the case of type conversions, apply the recursive call to the Original_Node of the expression Exp rather than the Expression of the Original_Node, in the case where Exp has been rewritten; otherwise, when Original_Node is the same as Exp, apply the recursive call to the Expression. (Check_Initialization): Revise condition for special check on type conversions of limited function calls to test Original_Node (avoiding spurious errors on expanded unchecked conversions applied to build-in-place dispatching calls). gcc/testsuite/ * gnat.dg/type_conv2.adb, gnat.dg/type_conv2.ads: New testcase. From-SVN: r274731
2019-08-20[Ada] Warn on Unchecked_Conversion to zero-sized arrayBob Duff1-0/+30
The compiler usually warns on Unchecked_Conversion between types with mismatched sizes. This warning is now extended to the case where the target type is a zero-sized array. 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Is_Null_Array): New function, used to detect the null array case; used to warn about uncheckedly converting to a zero-sized array. It is unfortunate that we can't just check the size, and warn on all cases of converting from a nonzero-sized type to a zero-sized one. That's because "0" means two different things: "size is zero" and "size is unknown". Until we fix that design flaw, we need this more targeted fix. gcc/testsuite/ * gnat.dg/unchecked_convert14.adb: New testcase. From-SVN: r274725
2019-08-20[Ada] Object_Size clause specifying 0 bits is illegalBob Duff1-0/+13
The patch gives an error message on "for T'Object_Size use 0;". 2019-08-20 Bob Duff <duff@adacore.com> gcc/ada/ * sem_ch13.adb (Object_Size): Give an error for zero. It really rubs me the wrong way that we don't honor "for T'Object_Size use 0;", but it's not important enough to fix. In any case, if we're not going to obey the clause, we should give an error. gcc/testsuite/ * gnat.dg/object_size1.adb: New testcase. From-SVN: r274722