aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-05-18c: Implement new -Wenum-int-mismatch warning [PR105131]Marek Polacek10-3/+177
In C, an enumerated type is compatible with char, a signed integer type, or an unsigned integer type (6.7.2.2/5). Therefore this code compiles: enum E { l = -1, z = 0, g = 1 }; int foo(void); enum E foo(void) { return z; } if the underlying type of 'enum E' is 'int' (if not, we emit an error). This is different for typedefs, where C11 permits typedefs to be redeclared to the same type, but not to compatible types. In C++, the code above is invalid. It seems desirable to emit a warning in the C case, because it is probably a mistake and definitely a portability error, given that the choice of the underlying type is implementation-defined. To that end, this patch implements a new -Wenum-int-mismatch warning. Conveniently, we already have comptypes_check_enum_int to detect such mismatches. This warning is enabled by either -Wall or -Wc++-compat. PR c/105131 gcc/c-family/ChangeLog: * c.opt (Wenum-int-mismatch): New. gcc/c/ChangeLog: * c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type mismatches. * c-tree.h (comptypes_check_enum_int): Declare. * c-typeck.cc (comptypes): No longer static. gcc/ChangeLog: * doc/invoke.texi: Document -Wenum-int-mismatch. gcc/testsuite/ChangeLog: * gcc.dg/Wenum-int-mismatch-1.c: New test. * gcc.dg/Wenum-int-mismatch-2.c: New test. * gcc.dg/Wenum-int-mismatch-3.c: New test. * gcc.dg/Wenum-int-mismatch-4.c: New test. * gcc.dg/Wenum-int-mismatch-5.c: New test.
2022-05-18Revert move of g++.dg/pr69667.CPaul A. Clarke1-1/+2
Commit eccbd7fcee5bbfc47731e8de83c44eee2e3dcc4b moved the subject file to g++.target/powerpc. Unfortunately, test g++.dg/tsan/pr88018.C includes "../pr69667.C". Revert the move of this file. Commit 14e678a2c4a76433fd4029568d28530c921e11ee relaxed some DejaGnu directives in g++.dg/tsan/pr88018.C, given its more restrictive environment within g++.target/powerpc. Revert these changes in that file as well. 2022-05-18 Paul A. Clarke <pc@us.ibm.com> gcc/testsuite PR target/105620 * g++.target/powerpc/pr69667.C: Move to ... * g++.dg/pr69667.C: here. Also, revert recent dg directives changes.
2022-05-18gm2tools/ChangeLog corrected to use GNU formatting.Gaius Mulley1-9/+9
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18libgm2 corrected spelling and comment formatting standard.Gaius Mulley3-2/+4
libgm2/ChangeLog: * libm2pim/Selective.c: Use initialize spelling. * libm2pim/dtoa.c: Corrected comment formatting. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18libgm2/libm2pim/termios.c changed comments to GNU coding standard.Gaius Mulley2-4/+5
libgm2/ChangeLog: * libm2pim/termios.c changed comments to GNU coding standard within an enum declaration. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18Changed spacing to comply with GCC Coding Standards.Gaius Mulley1-371/+371
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18x86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACKUros Bizjak2-4/+6
Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack is only supported on glibc targets. However, this original commit required some fixups. As part of the fixup, the changes to the gnu-user-common.h and gnu.h were partially reverted in commit 60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK to be defined for non-glibc targets even though -fsplit-stack is actually not supported and attempting to use it causes a runtime error. This causes gcc internal code, such as ./gcc/go/gospec.c to not correctly detect that -fsplit-stack is not supported and thus causes gccgo to fail compilation on non-glibc targets. This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the default libc is glibc. It is presently unclear to me if there is a better way to detect glibc at pre-processor time. The proposed changes have been tested on x86 and x86_64 Alpine Linux (which uses musl libc) and fix compilation of gccgo for this target. Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> gcc/ChangeLog: * config/i386/gnu-user-common.h (defined): Only define TARGET_CAN_SPLIT_STACK for glibc targets. * config/i386/gnu.h (defined): Ditto.
2022-05-18libgm2/libm2pim use GNU coding standard comment style.Gaius Mulley8-160/+111
Correct style of comments in all source files. libgm2/ChangeLog: * libm2pim/Selective.c: Reformatted comments. * libm2pim/SysExceptions.c: Reformatted comments. * libm2pim/dtoa.c: Reformatted comments. * libm2pim/ldtoa.c: Reformatted comments. * libm2pim/sckt.c: Reformatted comments. * libm2pim/termios.c: Reformatted comments. * libm2pim/wrapc.c: Reformatted comments. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18Correct ix86_rtx_cost for multi-word multiplication.Roger Sayle1-1/+11
This is the i386 backend specific piece of my revised patch for PR middle-end/98865, where Richard Biener has suggested that I perform the desired transformation during RTL expansion where the backend can control whether it is profitable to convert a multiplication into a bit-wise AND and a negation. This works well for x86_64, but alas exposes a latent bug with -m32, where a DImode multiplication incorrectly appears to be cheaper than negdi2+anddi3(!?). The fix to ix86_rtx_costs is to report that a DImode (multi-word) multiplication actually requires three SImode multiplications and two SImode additions. This also corrects the cost of TImode multiplication on TARGET_64BIT. 2022-05-18 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386.cc (ix86_rtx_costs) [MULT]: When mode size is wider than word_mode, a multiplication costs three word_mode multiplications and two word_mode additions.
2022-05-18Avoid andn and generate shorter not;and with -Oz on x86.Roger Sayle2-0/+49
The x86 instruction encoding for SImode andn is longer than the equivalent notl/andl sequence when the source for the not operand is the same register as the destination. This patch adds post_reload splitters to i386.md to avoid "-mbmi" (which enables andn) increasing code size with "-Oz". One minor subtlety with this patch is that the splitter for *andn_si_ccno swaps the order of operands (match_dup 2 and match_dup 3) as memory operands need to appear first in *test<mode>_1 patterns. 2022-05-18 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386.md (define_split): Split *andsi_1 and *andn_si_ccno after reload with -Oz. gcc/testsuite/ChangeLog * gcc.target/i386/bmi-andn-3.c: New test case.
2022-05-18gm2tools/m2color.c reformatted to use GNU coding standards.Gaius Mulley2-4/+10
Reformatted gm2tools/m2color.c to use GNU coding standards. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18* gm2l.1: Corrected default implementation/program module.Gaius Mulley2-10/+15
Corrected default implementation/program module extension statement to .mod. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18c, c++: -Wswitch warning on [[maybe_unused]] enumerator [PR105497]Marek Polacek3-2/+90
This PR complains that we emit the "enumeration value not handled in switch" warning even though the enumerator was marked with the [[maybe_unused]] attribute. I couldn't just check TREE_USED, because the enumerator could have been used earlier in the function, which doesn't play well with the c_do_switch_warnings warning. Instead, I had to check the attributes on the CONST_DECL. This is easy since the TYPE_VALUES of an enum type are now consistent between C and C++, both of which store the CONST_DECL in its TREE_VALUE. PR c++/105497 gcc/c-family/ChangeLog: * c-warn.cc (c_do_switch_warnings): Don't warn about unhandled enumerator when it was marked with attribute unused. gcc/testsuite/ChangeLog: * c-c++-common/Wswitch-1.c: New test. * g++.dg/warn/Wswitch-4.C: New test.
2022-05-18c++: fix SIGFPE with -Wclass-memaccess [PR105634]Marek Polacek8-0/+15
Here we crash because we attempt to % by 0. Thus fixed. While at it, I've moved the -Wclass-memaccess tests into warn/. I've checked that the # of expected passes is the same before/after the move. PR c++/105634 gcc/cp/ChangeLog: * call.cc (maybe_warn_class_memaccess): Avoid % by zero. gcc/testsuite/ChangeLog: * g++.dg/Wclass-memaccess-2.C: Moved to... * g++.dg/warn/Wclass-memaccess-2.C: ...here. * g++.dg/Wclass-memaccess-3.C: Moved to... * g++.dg/warn/Wclass-memaccess-3.C: ...here. * g++.dg/Wclass-memaccess-4.C: Moved to... * g++.dg/warn/Wclass-memaccess-4.C: ...here. * g++.dg/Wclass-memaccess-5.C: Moved to... * g++.dg/warn/Wclass-memaccess-5.C: ...here. * g++.dg/Wclass-memaccess-6.C: Moved to... * g++.dg/warn/Wclass-memaccess-6.C: ...here. * g++.dg/Wclass-memaccess.C: Moved to... * g++.dg/warn/Wclass-memaccess.C: ...here. * g++.dg/warn/Wclass-memaccess-7.C: New test.
2022-05-18Reduce usage of limited_with clauses with -fdump-ada-specEric Botcazou1-5/+27
The problem is that subtypes are not part of the limited view of a package so we need to use types in conjunction with limited_with clauses, which is not always desirable as this yields less portable Ada bindings. The patch also contains a small enhancement for complex floating-point types. gcc/c-family/ * c-ada-spec.cc (dump_ada_node) <COMPLEX_TYPE>: Deal with usual floating-point complex types. <POINTER_TYPE>: Do not use limited_with clause if the designated type is a scalar type.
2022-05-18testsuite/rs6000: Move pr83660.C to g++.targetKewen Lin1-0/+0
Move pr83660.C to g++.target. As comment #3 of PR83660, rename it to c isn't one option. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr83660.C: Moved to... * g++.target/powerpc/pr83660.C: ...here.
2022-05-18graphite: Extend SCoP detection dump outputFrederik Harwath2-21/+219
Extend dump output to make understanding why Graphite rejects to include a loop in a SCoP easier (for GCC developers). gcc/ChangeLog: * graphite-scop-detection.cc (scop_detection::can_represent_loop): Output reason for failure to dump file. (scop_detection::harmful_loop_in_region): Likewise. (scop_detection::graphite_can_represent_expr): Likewise. (scop_detection::stmt_has_simple_data_refs_p): Likewise. (scop_detection::stmt_simple_for_scop_p): Likewise. (print_sese_loop_numbers): New function. (scop_detection::add_scop): Use from here. gcc/testsuite/ChangeLog: * gcc.dg/graphite/scop-22a.c: New test.
2022-05-18Tidy up dates and correct spelling in documentation.Gaius Mulley36-45/+52
gcc/ChangeLog: * doc/gm2.texi: Corrected spelling and spaces between sentances. gm2tools/ChangeLog: * Corrected dates on all source files. libgm2/ChangeLog: * Corrected dates on all source files. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-18demangler: Reorganize for module demanglingNathan Sidwell1-139/+83
Module demangling requires some changes in how substitutions are handled. This adjusts things to make that possible. libiberty/ * cp-demangle.c (d_name): Add SUBSTABLE parameter, push substitution if requested. Adjust unscoped name handling. (d_prefix): Reorder main loop. Adjust all calls. (d_unqualified_name): Add SCOPE parameter, create qualified name here. Adjust all calls. (cplus_demangle_type): Do not handle 'S' here, leave all to d_class_enum_type. (d_class_enum_type): Add SUBSTABLE parameter.
2022-05-18'include/cuda/cuda.h': Add parts necessary for nvptx-tools 'nvptx-run'Thomas Schwinge1-1/+10
include/ * cuda/cuda.h (enum CUjit_option): Add 'CU_JIT_GENERATE_DEBUG_INFO', 'CU_JIT_GENERATE_LINE_INFO'. (enum CUlimit): Add 'CU_LIMIT_STACK_SIZE', 'CU_LIMIT_MALLOC_HEAP_SIZE'. (cuCtxSetLimit, cuGetErrorName): Add.
2022-05-18'include/cuda/cuda.h': For C++, wrap in 'extern "C"'Thomas Schwinge1-0/+8
include/ * cuda/cuda.h: For C++, wrap in 'extern "C"'.
2022-05-18OpenMP: Add Fortran support for inoutset depend-kindTobias Burnus13-13/+221
Fortran additions to the C/C++ + ME/libgomp commit r13-556-g2c16eb3157f86ae561468c540caf8eb326106b5f gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_depend_op): Add OMP_DEPEND_INOUTSET. (gfc_omp_clauses): Enlarge ENUM_BITFIELD. * dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle 'inoutset' depend modifier. * openmp.cc (gfc_match_omp_clauses, gfc_match_omp_depobj): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Likewise. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1): Set 'inoutset' to Y. (OpenMP Context Selectors): Add missing comma. * testsuite/libgomp.fortran/depend-5.f90: Add inoutset test. * testsuite/libgomp.fortran/depend-6.f90: Likewise. * testsuite/libgomp.fortran/depend-7.f90: Likewise. * testsuite/libgomp.fortran/depend-inoutset-1.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: Add inoutset test. * gfortran.dg/gomp/all-memory-2.f90: Likewise. * gfortran.dg/gomp/depobj-1.f90: Likewise. * gfortran.dg/gomp/depobj-2.f90: Likewise.
2022-05-18[Ada] Fix proof of runtime unit s-imageuClaire Dross1-8/+1
Update to provers caused some proof regressions. Fix the proof by adding an assertion. gcc/ada/ * libgnat/s-imageu.adb (Set_Image_Unsigned): Change assertion.
2022-05-18[Ada] qnx-7.1: warning in sigtramp-qnx.c __gnat_sigtrampDoug Rupp1-1/+1
Fix compilation warning. The code was using a cast to struct sigcontext *, which doesn't exist. It worked by accident. gcc/ada/ * sigtramp-qnx.c: Change struct sigcontext * to mcontext_t *.
2022-05-18[Ada] arm-qnx-7.1: stack-checking and sigtramp implementationDoug Rupp1-43/+36
Rewrite and base on VxWorks RTP implementation. gcc/ada/ * sigtramp-arm-qnx.c: Rewrite.
2022-05-18[Ada] Adapt proof of double arithmetic runtime unitYannick Moy1-16/+67
After changes in Why3 and generation of VCs, ghost code needs to be adapted for proofs to remain automatic. gcc/ada/ * libgnat/s-aridou.adb (Big3): Change return type. (Lemma_Mult_Non_Negative, Lemma_Mult_Non_Positive): Reorder alphabetically. (Lemma_Concat_Definition, Lemma_Double_Big_2xxsingle): New lemmas. (Double_Divide, Scaled_Divide): Add assertions.
2022-05-18[Ada] Fix proof of runtime unit s-valeuClaire Dross1-4/+8
Update to provers caused some proof regressions. Fix the proof by changing ghost code. gcc/ada/ * libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.
2022-05-18[Ada] Make sure output variable is always initializedKévin Le Gouguec1-0/+1
gcc/ada/ * libgnat/s-dwalin.adb (Read_Aranges_Header): Initialize output parameter in case we return early.
2022-05-18[Ada] Disable Vet calls when container checks are disabledBob Duff17-17/+79
Calls to various Vet functions are used throughout the containers packages to check internal consistency. This patch improves efficiency by disabling these calls when Container_Checks are suppressed. gcc/ada/ * libgnat/a-crbtgo.ads, libgnat/a-rbtgbo.ads, libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb, libgnat/a-cbhase.adb, libgnat/a-cdlili.adb, libgnat/a-cfdlli.adb, libgnat/a-cfhama.adb, libgnat/a-cfhase.adb, libgnat/a-cidlli.adb, libgnat/a-cihama.adb, libgnat/a-cihase.adb, libgnat/a-cohama.adb, libgnat/a-cohase.adb, libgnat/a-crbtgo.adb, libgnat/a-crdlli.adb, libgnat/a-rbtgbo.adb (Vet): Make the Vet functions do nothing when Container_Checks'Enabled is False, and inline them, so the calls disappear when optimizing.
2022-05-18[Ada] arm-qnx-7.1: undefined reference to fma* symbolsDoug Rupp1-1/+4
Configure the arm-qnx runtime packages to avoid generating these symbols. gcc/ada/ * Makefile.rtl (arm-qnx): Use default (non-fma) target pair.
2022-05-18[Ada] Fix DWARF parsing for 32-bit targets on 64-bit hostsKévin Le Gouguec1-25/+20
Currently, a 64-bit gnatsymbolize fails to output line numbers and accurate symbol names when run on 32-bit executables (and vice-versa). This is because a couple of spots in System.Dwarf_Lines expect the Address_Size found in the DWARF data to match the host Address'Size. This patch corrects that assumption. gcc/ada/ * libgnat/s-dwalin.adb (Aranges_Lookup, Enable_Cache): Adapt to changes in the signature of Read_Aranges_*. (Debug_Info_Lookup): Do not control address size read from DWARF. (Read_Aranges_Header): Do not control address size read from DWARF; return this size. (Read_Aranges_Entry): Use the size returned by Read_Aranges_Header.
2022-05-18[Ada] Improve error messages for occurrence of GNAT extensions without -gnatXGary Dismukes9-36/+32
The error message issued for use of GNAT extension features without specifying -gnatX (or pragma Extensions_Allowed) was confusing in the presence of a pragma specifying a language version (such as "pragma Ada_2022;"), because the pragma supersedes the switch. The message is improved by testing for use of such a pragma, plus use of pragma Extensions_Allowed is now suggested, and several cases are changed to call the common error procedure for flagging uses of extension features. gcc/ada/ * errout.ads (Error_Msg_GNAT_Extension): Add formal Loc and revise comment. * errout.adb (Error_Msg_GNAT_Extension): Condition message on the flag Ada_Version_Pragma, and add suggestion to use of pragma Extensions_Allowed in messages. * par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch11.adb, par-ch12.adb: Add actual Token_Ptr on calls to Error_Msg_GNAT_Extension. * par-ch4.adb: Change Error_Msg to Error_Msg_GNAT_Extension for error calls related to use of extension features. * sem_ch13.adb: Likewise.
2022-05-18[Ada] Fix Ada-QNX task priority conversionJohannes Kliemann1-1/+1
The conversion between OS and Ada priorties should be done in the wider Interfaces.C.int type rather than Any_Priority otherwise Constraint_Error will be raised when coverting Any_Priority'Last to int. gcc/ada/ * libgnarl/s-osinte__qnx.adb (To_Target_Priority): Perform arithmetic in int.
2022-05-18[Ada] Use specific predicate before manipulating BIP_Alloc_FormEric Botcazou1-4/+2
For the sake of consistency with other similar manipulations. gcc/ada/ * exp_ch7.adb (Build_BIP_Cleanup_Stmts): Use Needs_BIP_Alloc_Form.
2022-05-18[Ada] Crash building VSS with compiler built with assertionsJavier Miranda4-3/+17
When a tagged type T has aspect String_Literal, a derived type defines a null extension T2, and the context to resolve the use of an object of type T2 where the string literal is applicable is a class-wide type the frontend crashes trying to evaluate if the object is a null extension. This problem does not reproduce when the compiler is built with assertions disabled. gcc/ada/ * sem_ch6.adb (Find_Corresponding_Spec): Avoid calling Is_Null_Extension with a class-wide type entity. (Overrides_Visible_Function): Handle alias entities. * sem_res.adb (Has_Applicable_User_Defined_Literal): Conversion not needed if the result type of the call is class-wide or if the result type matches the context type. * sem_util.ads (Is_Null_Extension): Adding documentation. (Is_Null_Extension_Of): Adding documentation. * sem_util.adb (Is_Null_Extension): Adding assertion. (Is_Null_Extension_Of): Adding assertions.
2022-05-18[Ada] Ada2022: AI12-0143 Index attribute for entry familiesJavier Miranda5-1/+344
gcc/ada/ * snames.ads-tmpl (Name_Index): New attribute name. (Attribute_Id): Adding Attribute_Index as regular attribute. * sem_attr.adb (Attribute_22): Adding Attribute_Index as Ada 2022 attribute. (Analyze_Index_Attribute): Check that 'Index appears in a pre-/postcondition aspect or pragma associated with an entry family. (Analyze_Attribute): Adding semantic analysis for 'Index. (Eval_Attribute): Register 'Index as can never be folded. (Resolve_Attribute): Resolve attribute 'Index. * sem_ch9.adb (Check_Wrong_Attribute_In_Postconditions): New subprogram. (Analyze_Requeue): Check that the requeue target shall not have an applicable specific or class-wide postcondition which includes an Index attribute reference. * exp_attr.adb (Expand_N_Attribute_Reference): Transform attribute Index into a renaming of the second formal of the wrapper built for an entry family that has contract cases. * einfo.ads (Is_Entry_Wrapper): Complete documentation.
2022-05-18[Ada] Fix proof of runtime unitsYannick Moy3-0/+9
Update to latest version of Why3 caused some proof regressions. Fix the proof by changing ghost code. gcc/ada/ * libgnat/s-imagei.adb (Set_Digits): Add assertion. * libgnat/s-imgboo.adb (Image_Boolean): Add assertions. * libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertion.
2022-05-18[Ada] Errors missed on ACATS test B650007Arnaud Charlet2-14/+7
This ACATS test shows that we need to call Is_Immutably_Limited_Type in Analyze_Function_Return and also that we have a latent bug in Is_Immutably_Limited_Type which shouldn't look through private types. gcc/ada/ * sem_aux.adb (Is_Immutably_Limited_Type): Do not look through private types as per RM 7.5(8.1). * sem_ch6.adb (Analyze_Function_Return): Use Is_Immutably_Limited_Type as per RM 6.5(5.10).
2022-05-18[Ada] Fix the parsing for delta aggregateMarc Poulhiès3-1/+12
In Ada 2022, delta aggregate must use parentheses not square brackets except array delta aggregates. gcc/ada/ * gen_il-gen-gen_nodes.adb (Gen_IL.Gen.Gen_Nodes): Add Is_Homogeneous_Aggregate field for N_Delta_Aggregate nodes. * par-ch4.adb (P_Aggregate_Or_Paren_Expr): Minor reformatting. * sem_aggr.adb (Resolve_Delta_Aggregate): Reject square brackets for record aggregate. (Resolve_Record_Aggregate): Uniformise error message.
2022-05-18[Ada] Secondary stack and a-tagsArnaud Charlet3-66/+46
The simple use of Ada.Tags triggers a dependency on the secondary stack mechanism, which is unwanted on small embedded targets. To avoid this dependency, we special case a-tags.ali in ALI.Scan_ALI to not set Sec_Stack_Used. If some other code calls one of the functions returning a string, this code will also be marked as requiring the secondary stack. We also remove the need to import and set __gnat_binder_ss_count in this case by ensuring this variable defaults to 0. gcc/ada/ * ali.adb (Scan_ALI): Special case a-tags.ali when setting Sec_Stack_Used. * bindgen.adb (Gen_Adainit): Simplify handling of secondary stack related code, and only import __gnat_binder_ss_count when needed. * libgnat/s-secsta.adb (Binder_SS_Count): Default initialize to 0.
2022-05-18[Ada] Fix problematic underflow for Float_Type'ValueEric Botcazou2-1/+20
We need a couple of guards for boundary conditions in the support code. gcc/ada/ * libgnat/s-dourea.adb ("/"): Add guard for zero and infinite divisor. * libgnat/s-valuer.adb (Scan_Raw_Real): Add guard for very large exponent values.
2022-05-18[Ada] Spurious error on freezing of tagged types in SPARKYannick Moy1-1/+11
SPARK RM 7.7(8) mandates that the freezing point of a tagged type must occur within the so-called early call region of all its primitives. This check may lead to spurious errors due to generated constructs being considered in the search for the start of the early call region. gcc/ada/ * sem_elab.adb (Is_Suitable_Construct): Fix for generated constructs.
2022-05-18[Ada] Rework optimization skipping pragma check in object declarationMarc Poulhiès2-4/+8
When an object declaration is initialized with a type conversion: Var : Typ := Typ (Value); we skip the check for Typ's predicate as it is already checked during the type conversion. This is not correct when Var's subtype and the target subtype of the conversion do not statically match: Var : Typ := OtherTyp (Value); In such case, we can't skip the check of Typ's predicate. Fix minor typos in comment. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Skip predicate check for type conversion if object's subtype and expression's subtype statically match. * exp_prag.adb (Expand_Pragma_Check): Typo fix in comment.
2022-05-18[Ada] Fix internal error on subprogram instantiationEric Botcazou2-1/+2
The compiler builds renamings for actuals of formal objects for debugging purposes in this case, but it must not generate them for temporaries. gcc/ada/ * exp_dbug.ads (Build_Subprogram_Instance_Renamings): Fix typo. * exp_dbug.adb (Build_Subprogram_Instance_Renamings): Build the renaming only for actuals of formal objects.
2022-05-18[Ada] Overriding error on type derived from discriminated untagged private typeGary Dismukes1-1/+9
When a derived type DT has an untagged private parent type PT with a discriminant, where the full type of PT is tagged, and DT inherits a function F with an anonymous access result that designates the type, the compiler wrongly reports an error saying that DT must be declared abstract or F overridden. A test is added to exclude checking the abstract overriding rules that should only apply to inherited subprograms of tagged derived types. gcc/ada/ * sem_ch3.adb (Check_Abstract_Overriding): If the type is derived from an untagged type, then don't perform any of the abstract overriding error checks.
2022-05-18[Ada] Prevent overflow in computation of aggregate sizePiotr Trojanek1-2/+2
When computing size of a static aggregate to decide if it should be transformed into assignments and loops we could have an overflow check. This is mostly harmless, because colossal aggregates will likely crash the application anyway, no matter how we transform them. This was not detected because compiler was built with -gnatg switch that suppresses overflow checks (they are only enabled by an explicit -gnato switch). gcc/ada/ * exp_aggr.adb (Component_Count): Calculate size as an Uint and only then check if it is in the range of Int, as otherwise the multiplication of Int values can overflow.
2022-05-18[Ada] Fast implementation of floating-point mathematical functionsEric Botcazou8-149/+439
This adds a package renaming unit to the GNAT hierarchy so as to expose the underlying implementation of floating-point mathematical functions, thus also making it possible to use their vector implementation, if any. The change also contains a small improvement to the Hide_Public_Entities mechanism in Sem_Ch7 that makes it possible to clear the Is_Public flag within instances of generic packages that do not have a body. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-gfmafu$(objext). (SIMD_PATH_TARGET_PAIRS): New variable. (TRASYM_DWARF_COMMON_OBJS): Minor tweak. (x86-64/Linux): Use SIMD_PATH_TARGET_PAIRS. (x32/Linux): Likewise. * doc/gnat_rm/the_gnat_library.rst (Generic_Fast_Math_Functions): New entry. * gnat_rm.texi: Regenerate. * impunit.adb (Non_Imp_File_Names_95): Add g-gfmafu. * sem_ch7.adb (Has_Referencer): Do not set In_Nested_Instance for instances of generic packages that do not have a body. * libgnat/a-nalofl__simd.ads: New SIMD-enabled version. * libgnat/a-nuaufl__simd.ads: Likewise. * libgnat/g-gfmafu.ads: New package renaming unit.
2022-05-18[Ada] Freezing too strict in instancesArnaud Charlet1-7/+10
Should_Freeze_Type is relaxed to only take the relevant case into account (entities denoted by generic actual parameters as per 13.14(5/3), as well as profile of any subprograms named as per 13.14(10.2/4)), instead of being overly conservative wrt instances and as a result, wrongly rejecting some legal code. In practice this means we only need to worry about profile of subprograms named as part of instances. gcc/ada/ * freeze.adb (Should_Freeze_Type): Fix handling of freezing in instances.
2022-05-18[Ada] Fix incorrect freezing with generic child unitMarc Poulhiès1-2/+2
The Analyze_Associations.Check_Generic_Parent function was using an incorrect node as the instanciation node for the actual, possibly leading to incorrect freeze node being created (and later crashing in gigi). Using Get_Unit_Instantiation_Node fixes the issue. gcc/ada/ * sem_ch12.adb (Check_Generic_Parent): Use Get_Unit_Instantiation_Node instead of Next.
2022-05-18[Ada] Ada.Numerics.Aux.*: Mention more Intrinsic and less C Math LibraryAlexandre Oliva4-18/+27
Since we import the elemental math functions as intrinsics, it's not accurate to state we're drawing them in from the C math library. gcc/ada/ * libgnat/a-nagefl.ads: Replace mentions of C/unix math library with intrinsics. * libgnat/a-nallfl.ads: Likewise. State compatibility requirements. * libgnat/a-nalofl.ads: Likewise. * libgnat/a-nuaufl.ads: Likewise.