aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-06-23Daily bump.GCC Administrator4-1/+289
2021-06-22Fortran: fix sm computation in CFI_allocate [PR93524]Sandra Loosemore2-0/+50
This patch fixes a bug in setting the step multiplier field in the C descriptor for array dimensions > 2. 2021-06-21 Sandra Loosemore <sandra@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> libgfortran/ PR fortran/93524 * runtime/ISO_Fortran_binding.c (CFI_allocate): Fix sm computation. gcc/testsuite/ PR fortran/93524 * gfortran.dg/pr93524.c: New. * gfortran.dg/pr93524.f90: New.
2021-06-22analyzer: fix ICE on malloc/alloca param type mismatch [PR101143]David Malcolm2-4/+33
gcc/analyzer/ChangeLog: PR analyzer/101143 * region-model.cc (compat_types_p): New function. (region_model::create_region_for_heap_alloc): Convert assertion to an error check. (region_model::create_region_for_alloca): Likewise. gcc/testsuite/ChangeLog: PR analyzer/101143 * gcc.dg/analyzer/pr101143.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-06-22docs: drop unbalanced parenthesis in rtl.texiSergei Trofimovich1-1/+1
gcc/ChangeLog: * doc/rtl.texi: drop unbalanced parenthesis.
2021-06-22middle-end/101156 - remove not working optimization in gimplificationRichard Biener2-14/+9
This removes a premature and not working optimization from the gimplifier. When gimplification is requested not to produce a SSA name we try to avoid generating a copy when we did so anyway but instead replace the LHS of its definition. But that only works in case there are no uses of the SSA name already which is something we cannot easily check, so the following removes said optimization. Statistics on the whole bootstrap shows we hit this optimization only for libiberty/cp-demangle.c and overall we have 21652112 gimplifications where just 240 copies are elided. Preserving the optimization would require scanning the original expression and the pre and post sequences for SSA names and uses, that seems excessive to avoid these 240 copies. 2021-06-22 Richard Biener <rguenther@suse.de> PR middle-end/101156 * gimplify.c (gimplify_expr): Remove premature incorrect optimization. * gcc.dg/pr101156.c: New testcase.
2021-06-22testsuite: Add testcase for recently fixed PR [PR101159]Jakub Jelinek2-4/+14
On Tue, Jun 22, 2021 at 11:00:51AM +0200, Richard Biener wrote: > 2021-06-22 Richard Biener <rguenther@suse.de> > > PR tree-optimization/101159 > * tree-vect-patterns.c (vect_recog_popcount_pattern): Add > missing NULL vectype check. The following patch adds the testcase for it, IMHO it can't hurt and from my experience testcases often trigger other bugs later on (rather than the original bugs reappearing, though even that happens), and also fixes a couple of typos in the new function. 2021-06-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/101159 * tree-vect-patterns.c (vect_recog_popcount_pattern): Fix some comment typos. * gcc.c-torture/compile/pr101159.c: New test.
2021-06-22expand: Fix up empty class return optimization [PR101160]Jakub Jelinek3-9/+34
On Mon, Jun 14, 2021 at 11:24:22PM -0400, Jason Merrill via Gcc-patches wrote: > The x86_64 psABI says that an empty class isn't passed or returned in memory or > registers, so we shouldn't set %eax in this function. Is this a reasonable > place to implement that? Another possibility would be to remove the hack to > prevent i386.c:function_value_64 from returning NULL in this case and fix the > callers to deal, but that seems like more work. > > The df-scan hunk catches the case where we look at a 0-length reg and build > a range the length of unsigned int, which happened before I changed > assign_parms to match expand_function_end. The assign_params change unfortunately breaks e.g. the following testcase. The problem is that some passes (e.g. subreg lowering but assign_parms comments also talk about delayed slot scheduling) rely on crtl->return_rtx not to contain pseudo registers, and the assign_parms change results in the pseudo in there not being replaced with a hard register. The following patch instead clears the crtl->return_rtx if a function returns TYPE_EMPTY_P structure, that way (use (pseudo)) is not emitted into the IL and it is treated like more like functions returning void. I've also changed the effective target on the empty-class1.C testcase, so that it doesn't fail on x86_64-linux with -m32 testing. 2021-06-22 Jakub Jelinek <jakub@redhat.com> PR middle-end/101160 * function.c (assign_parms): For decl_result with TYPE_EMPTY_P type clear crtl->return_rtx instead of keeping it referencing a pseudo. * g++.target/i386/empty-class1.C: Require lp64 effective target instead of x86_64-*-*. * g++.target/i386/empty-class2.C: New test.
2021-06-22fold-const: Return corresponding integral type for OFFSET_TYPE in ↵Jakub Jelinek2-1/+22
range_check_type [PR101162] Andrew's recent r12-1608-g2f1686ff70b25fceb04ca2ffc0a450fb682913ef change to fail verification on various unary and binary operations with OFFSET_TYPE revealed that e.g. switchconv happily performs multiplications and additions in OFFSET_TYPE. 2021-06-22 Jakub Jelinek <jakub@redhat.com> Andrew Pinski <apinski@marvell.com> PR tree-optimization/101162 * fold-const.c (range_check_type): Handle OFFSET_TYPE like pointer types. * g++.dg/opt/pr101162.C: New test.
2021-06-22Add relational self-tests.Andrew MacLeod1-0/+25
* range-op.cc (range_relational_tests): New. (range_op_tests): Call range_relational_tests.
2021-06-22Add relation between LHS and op1 for casts and copies.Andrew MacLeod1-0/+41
* range-op.cc (operator_cast::lhs_op1_relation): New. (operator_identity::lhs_op1_relation): Mew.
2021-06-22Add relation effects between operands to MINUS_EXPR.Andrew MacLeod1-0/+44
* range-op.cc (operator_minus::op1_op2_relation_effect): New.
2021-06-22Add relations between LHS and op1/op2 for PLUS_EXPR.Andrew MacLeod1-0/+80
* range-op.cc (operator_plus::lhs_op1_relation): New. (operator_plus::lhs_op2_relation): New.
2021-06-22Add relational support to fold_using_rangeAndrew MacLeod3-63/+324
Enable a relation oracle in ranger, and add full range-op relation support to fold_using_range. * gimple-range-cache.cc (ranger_cache::ranger_cache): Create a relation_oracle if dominators exist. (ranger_cache::~ranger_cache): Dispose of oracle. (ranger_cache::dump_bb): Dump oracle. * gimple-range.cc (fur_source::fur_source): New. (fur_source::get_operand): Use mmeber query. (fur_source::get_phi_operand): Use member_query. (fur_source::query_relation): New. (fur_source::register_dependency): Delete. (fur_source::register_relation): New. (fur_edge::fur_edge): Adjust. (fur_edge::get_phi_operand): Fix comment. (fur_edge::query): Delete. (fur_stmt::fur_stmt): Adjust. (fur_stmt::query): Delete. (fur_depend::fur_depend): Adjust. (fur_depend::register_relation): New. (fur_depend::register_relation): New. (fur_list::fur_list): Adjust. (fur_list::get_operand): Use member query. (fold_using_range::range_of_range_op): Process and query relations. (fold_using_range::range_of_address): Adjust dependency call. (fold_using_range::range_of_phi): Ditto. (gimple_ranger::gimple_ranger): New. Use ranger_ache oracle. (fold_using_range::relation_fold_and_or): New. (fold_using_range::postfold_gcond_edges): New. * gimple-range.h (class gimple_ranger): Adjust. (class fur_source): Adjust members. (class fur_stmt): Ditto. (class fold_using_range): Ditto.
2021-06-22Add relational support to range-op.Andrew MacLeod2-139/+469
This patch integrates relations with range-op functionality so that any known relations can be used to help reduce or resolve ranges. Initially handle EQ_EXPR, NE_EXPR, LE_EXPR, LT_EXPR, GT_EXPR and GE_EXPR. * range-op.cc (range_operator::wi_fold): Apply relation effect. (range_operator::fold_range): Adjust and apply relation effect. (*::fold_range): Add relation parameters. (*::op1_range): Ditto. (*::op2_range): Ditto. (range_operator::lhs_op1_relation): New. (range_operator::lhs_op2_relation): New. (range_operator::op1_op2_relation): New. (range_operator::op1_op2_relation_effect): New. (relop_early_resolve): New. (operator_equal::op1_op2_relation): New. (operator_equal::fold_range): Call relop_early_resolve. (operator_not_equal::op1_op2_relation): New. (operator_not_equal::fold_range): Call relop_early_resolve. (operator_lt::op1_op2_relation): New. (operator_lt::fold_range): Call relop_early_resolve. (operator_le::op1_op2_relation): New. (operator_le::fold_range): Call relop_early_resolve. (operator_gt::op1_op2_relation): New. (operator_gt::fold_range): Call relop_early_resolve. (operator_ge::op1_op2_relation): New. (operator_ge::fold_range): Call relop_early_resolve. * range-op.h (class range_operator): Adjust parameters and methods.
2021-06-22Initial value-relation code.Andrew MacLeod7-2/+1155
This code provides a both an equivalence and relation oracle which can be accessed via a range_query object. This initial code drop includes the oracles and access them, but does not utilize them yet. * Makefile.in (OBJS): Add value-relation.o. * gimple-range.h: Adjust include files. * tree-data-ref.c: Adjust include file order. * value-query.cc (range_query::get_value_range): Default to no oracle. (range_query::query_relation): New. (range_query::query_relation): New. * value-query.h (class range_query): Adjust. * value-relation.cc: New. * value-relation.h: New.
2021-06-22tree-optimization/101151 - fix irreducible region check for sinkingRichard Biener2-1/+27
The check whether two blocks are in the same irreducible region and thus post-dominance checks being unreliable was incomplete since an irreducible region can contain reducible sub-regions but if one block is in the irreducible part and one not the check still doesn't work as expected. 2021-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/101151 * tree-ssa-sink.c (statement_sink_location): Expand irreducible region check. * gcc.dg/torture/pr101151.c: New testcase.
2021-06-22RISC-V: Add tune info for T-HEAD C906.Jojo R1-0/+14
gcc/ * config/riscv/riscv.c (thead_c906_tune_info): New. (riscv_tune_info_table): Use new tune.
2021-06-22testuite: Add pthread check to dg-module-cmi for omp module testingKito Cheng2-2/+2
gcc/testsuite: * g++.dg/modules/omp-1_a.C: Check pthread is available for dg-module-cmi. * g++.dg/modules/omp-2_a.C: Ditto.
2021-06-22tree-optimization/101158 - adjust SLP call matching sequenceRichard Biener2-15/+41
This moves the check for same operands after verifying we're facing compatible calls. 2021-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/101158 * tree-vect-slp.c (vect_build_slp_tree_1): Move same operand checking after checking for matching operation. * gfortran.dg/pr101158.f90: New testcase.
2021-06-22tree-optimization/101159 - fix missing NULL check in popcount patternRichard Biener1-3/+3
This fixes a missing check for a NULL vectype in the new popcount pattern. 2021-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/101159 * tree-vect-patterns.c (vect_recog_popcount_pattern): Add missing NULL vectype check.
2021-06-22tree-optimization/101154 - fix out-of bound access in SLPRichard Biener1-10/+11
This fixes an out-of-bound access of matches. 2021-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/101154 * tree-vect-slp.c (vect_build_slp_tree_2): Fix out-of-bound access.
2021-06-22i386: Use xor to write zero to memory with -Os even for more than 4 stores ↵Jakub Jelinek5-14/+104
[PR11877] > > 2021-06-20 Roger Sayle <roger@nextmovesoftware.com> > > > > gcc/ChangeLog > > PR target/11877 > > * config/i386/i386.md: New define_peephole2s to shrink writing > > 1, 2 or 4 consecutive zeros to memory when optimizing for size. It unfortunately doesn't extend well to larger memory clearing. Consider e.g. void foo (int *p) { p[0] = 0; p[7] = 0; p[23] = 0; p[41] = 0; p[48] = 0; p[59] = 0; p[69] = 0; p[78] = 0; p[83] = 0; p[89] = 0; p[98] = 0; p[121] = 0; p[132] = 0; p[143] = 0; p[154] = 0; } where with the patch we emit: xorl %eax, %eax xorl %edx, %edx xorl %ecx, %ecx xorl %esi, %esi xorl %r8d, %r8d movl %eax, (%rdi) movl %eax, 28(%rdi) movl %eax, 92(%rdi) movl %eax, 164(%rdi) movl %edx, 192(%rdi) movl %edx, 236(%rdi) movl %edx, 276(%rdi) movl %edx, 312(%rdi) movl %ecx, 332(%rdi) movl %ecx, 356(%rdi) movl %ecx, 392(%rdi) movl %ecx, 484(%rdi) movl %esi, 528(%rdi) movl %esi, 572(%rdi) movl %r8d, 616(%rdi) Here is an incremental patch that emits: xorl %eax, %eax movl %eax, (%rdi) movl %eax, 28(%rdi) movl %eax, 92(%rdi) movl %eax, 164(%rdi) movl %eax, 192(%rdi) movl %eax, 236(%rdi) movl %eax, 276(%rdi) movl %eax, 312(%rdi) movl %eax, 332(%rdi) movl %eax, 356(%rdi) movl %eax, 392(%rdi) movl %eax, 484(%rdi) movl %eax, 528(%rdi) movl %eax, 572(%rdi) movl %eax, 616(%rdi) instead. 2021-06-22 Jakub Jelinek <jakub@redhat.com> PR target/11877 * config/i386/i386-protos.h (ix86_last_zero_store_uid): Declare. * config/i386/i386-expand.c (ix86_last_zero_store_uid): New variable. * config/i386/i386.c (ix86_expand_prologue): Clear it. * config/i386/i386.md (peephole2s for 1/2/4 stores of const0_rtx): Remove "" from match_operand. Emit new insns using emit_move_insn and set ix86_last_zero_store_uid to INSN_UID of the last store. Add peephole2s for 1/2/4 stores of const0_rtx following previous successful peep2s. * gcc.target/i386/pr11877-2.c: New test.
2021-06-22autofdo: Bump AUTO_PROFILE_VERSION.Martin Liska1-1/+1
gcc/ChangeLog: * auto-profile.c (AUTO_PROFILE_VERSION): Bump as string format was changed.
2021-06-22gcov: update comment about paddingMartin Liska1-2/+1
gcc/ChangeLog: * gcov-io.h: Remove padding entries.
2021-06-22Add vect_recog_popcount_pattern to handle mismatch between the vectorized ↵liuhongt3-19/+129
popcount IFN and scalar popcount builtin. The patch remove those pro- and demotions when backend support direct optab. For i386: it enables vectorization for vpopcntb/vpopcntw and optimized for vpopcntq. gcc/ChangeLog: PR tree-optimization/97770 * tree-vect-patterns.c (vect_recog_popcount_pattern): New. (vect_recog_func vect_vect_recog_func_ptrs): Add new pattern. gcc/testsuite/ChangeLog: PR tree-optimization/97770 * gcc.target/i386/avx512bitalg-pr97770-1.c: Remove xfail. * gcc.target/i386/avx512vpopcntdq-pr97770-1.c: Remove xfail.
2021-06-22Optimize vpexpand* to mask mov when mask have all ones in it's lower part ↵liuhongt18-25/+920
(including 0 and -1). gcc/ChangeLog: PR target/100267 * config/i386/i386-builtin.def (BDESC): Adjust builtin name. * config/i386/sse.md (<avx512>_expand<mode>_mask): Rename to .. (expand<mode>_mask): this .. (*expand<mode>_mask): New pre_reload splitter to transform v{,p}expand* to vmov* when mask is zero, all ones, or has all ones in it's lower part, otherwise still generate v{,p}expand*. gcc/testsuite/ChangeLog: PR target/100267 * gcc.target/i386/avx512bw-pr100267-1.c: New test. * gcc.target/i386/avx512bw-pr100267-b-2.c: New test. * gcc.target/i386/avx512bw-pr100267-d-2.c: New test. * gcc.target/i386/avx512bw-pr100267-q-2.c: New test. * gcc.target/i386/avx512bw-pr100267-w-2.c: New test. * gcc.target/i386/avx512f-pr100267-1.c: New test. * gcc.target/i386/avx512f-pr100267-pd-2.c: New test. * gcc.target/i386/avx512f-pr100267-ps-2.c: New test. * gcc.target/i386/avx512vl-pr100267-1.c: New test. * gcc.target/i386/avx512vl-pr100267-pd-2.c: New test. * gcc.target/i386/avx512vl-pr100267-ps-2.c: New test. * gcc.target/i386/avx512vlbw-pr100267-1.c: New test. * gcc.target/i386/avx512vlbw-pr100267-b-2.c: New test. * gcc.target/i386/avx512vlbw-pr100267-d-2.c: New test. * gcc.target/i386/avx512vlbw-pr100267-q-2.c: New test. * gcc.target/i386/avx512vlbw-pr100267-w-2.c: New test.
2021-06-22Fix ICE for vpexpand*.liuhongt2-2/+15
gcc/ChangeLog PR target/100310 * config/i386/i386-expand.c (ix86_expand_special_args_builtin): Keep constm1_operand only if it satisfies insn's operand predicate. gcc/testsuite/ChangeLog PR target/100310 * gcc.target/i386/pr100310.c: New test.
2021-06-22Daily bump.GCC Administrator6-1/+511
2021-06-21expand: empty class return optimization [PR88529]Jason Merrill3-6/+21
The x86_64 psABI says that an empty class isn't passed or returned in memory or registers, so we shouldn't set %eax in this function. The df-scan hunk catches the case where we look at a 0-length reg and build a range the length of unsigned int, which happened before I changed assign_parms to match expand_function_end. PR target/88529 gcc/ChangeLog: * df-scan.c (df_ref_record): Check that regno < endregno. * function.c (assign_parms, expand_function_end): Do nothing with a TYPE_EMPTY_P result. gcc/testsuite/ChangeLog: * g++.target/i386/empty-class1.C: New test.
2021-06-21tree-optimization/101120 - fix compile-time issue with SLP groupsRichard Biener4-8/+44
This places two hacks to avoid an old compile-time issue when vectorizing large permuted SLP groups with gaps where we end up emitting loads and IV adjustments for the gap as well and those have quite a high cost until they are eventually cleaned up. The first hack is to fold the auto-inc style IV updates early in the vectorizer rather than in the next forwprop pass which shortens the SSA use-def chains of the used IV. The second hack is to remove the unused loads after we've picked all that we possibly use. 2021-06-18 Richard Biener <rguenther@suse.de> PR tree-optimization/101120 * tree-vect-data-refs.c (bump_vector_ptr): Fold the built increment. * tree-vect-slp.c (vect_transform_slp_perm_load): Add DR chain DCE capability. * tree-vectorizer.h (vect_transform_slp_perm_load): Adjust. * tree-vect-stmts.c (vectorizable_load): Remove unused loads in the DR chain for SLP.
2021-06-21c++: REF_PARENTHESIZED_P wrapper inhibiting NRVO [PR67302]Patrick Palka2-5/+18
Here, in C++14 or later, we remember the parentheses around 'a' in the return statement by using a REF_PARENTHESIZED_P wrapper, which ends up inhibiting NRVO because we don't look through this wrapper before checking the conditions for NRVO. This patch fixes this by calling maybe_undo_parenthesized_ref sooner in check_return_expr. PR c++/67302 gcc/cp/ChangeLog: * typeck.c (check_return_expr): Call maybe_undo_parenthesized_ref sooner, before the NRVO handling. gcc/testsuite/ChangeLog: * g++.dg/opt/nrv21.C: New test.
2021-06-21c++: conversion to base of vbase in NSDMI [PR80431]Patrick Palka2-9/+33
The delayed processing of conversions to a virtual base in an NSDMI assumes the target base type is a (possibly indirect) virtual base of the current class, but the target base type could also be a base of a virtual base, as in the testcase below. Since such a base isn't a part of CLASSTYPE_VBASECLASSES, we end up miscompiling the testcase due to the call to build_base_path (with binfo=NULL_TREE) silently returning error_mark_node. Fix this by using convert_to_base to build the conversion instead. PR c++/80431 gcc/cp/ChangeLog: * tree.c (bot_replace): Use convert_to_base to build the conversion to the (morally) virtual base. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nsdmi-virtual1a.C: New test.
2021-06-21inline-asm: Fix ICE with bitfields in "m" operands [PR100785]Jakub Jelinek7-17/+82
Bitfields, while they live in memory, aren't something inline-asm can easily operate on. For C and "=m" or "+m", we were diagnosing bitfields in the past in the FE, where c_mark_addressable had: case COMPONENT_REF: if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1))) { error ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1)); return false; } but that check got moved in GCC 6 to build_unary_op instead and now we emit an error during expansion and ICE afterwards (i.e. error-recovery). For "m" it used to be diagnosed in c_mark_addressable too, but since GCC 6 it is ice-on-invalid. For C++, this was never diagnosed in the FE, but used to be diagnosed in the gimplifier and/or during expansion before 4.8. The following patch does multiple things: 1) diagnoses it in the FEs 2) stops emitting a redundant diagnostic in the gimplifier using the usual way, if we already see error_mark_node, we assume error has been emitted already and only diagnose if it wasn't error_mark_node; this helps diagnosing the same bug with multiple different errors 3) simplifies during expansion the inline asm if any errors have been reported (similarly how e.g. vregs pass if it detects errors on inline-asm either deletes them or simplifies to bare minimum - just labels), so that we don't have error-recovery ICEs there 2021-06-11 Jakub Jelinek <jakub@redhat.com> PR inline-asm/100785 gcc/ * gimplify.c (gimplify_asm_expr): Don't diagnose errors if output or input operands were already error_mark_node. * cfgexpand.c (expand_asm_stmt): If errors are emitted, remove all inputs, outputs and clobbers from the asm and set template to "". gcc/c/ * c-typeck.c (c_mark_addressable): Diagnose trying to make bit-fields addressable. gcc/cp/ * typeck.c (cxx_mark_addressable): Diagnose trying to make bit-fields addressable. gcc/testsuite/ * c-c++-common/pr100785.c: New test. * gcc.dg/pr48552-1.c: Don't expect invalid lvalue errors. * gcc.dg/pr48552-2.c: Likewise.
2021-06-21[Ada] Implement fixed-lower-bound consistency checks for qualified_expressionsGary Dismukes1-0/+50
gcc/ada/ * checks.adb (Selected_Range_Checks): In the case of a qualified_expression where the qualifying subtype is an unconstrained array subtype with fixed lower bounds for some of its indexes, generate tests to check that those bounds are equal to the corresponding lower bounds of the qualified array object.
2021-06-21[Ada] Optimization of System.Value_NBob Duff1-3/+3
gcc/ada/ * libgnat/s-valuen.ads (Value_Enumeration, Valid_Enumeration_Value): Inline. (Value_Enumeration_Pos): Add Pure_Function.
2021-06-21[Ada] INOX: prototype "when" constructsJustin Squirek26-80/+343
gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Document new feature under pragma Extensions_Allowed. * gnat_rm.texi: Regenerate. * errout.adb, errout.ads (Error_Msg_GNAT_Extension): Created to issue errors when parsing extension only constructs. * exp_ch11.adb, exp_ch11.ads (Expand_N_Raise_When_Statement): Created to expand raise ... when constucts. * exp_ch5.adb, exp_ch5.ads (Expand_N_Goto_When_Statement): Created to expand goto ... when constructs. * exp_ch6.adb, exp_ch6.ads (Expand_N_Return_When_Statement): Created to expand return ... when constructs. * expander.adb (Expand): Add case entries for "when" constructs. * gen_il-gen-gen_nodes.adb, gen_il-types.ads: Add entries for "when" constructs. * par-ch11.adb (P_Raise_Statement): Add processing for raise ... when. * par-ch5.adb (Missing_Semicolon_On_Exit): Renamed to Missing_Semicolon_On_When and moved to par-util.adb. * par-ch6.adb (Get_Return_Kind): Renamed from Is_Simple and processing added for "return ... when" return kind. (Is_Simple): Renamed to Get_Return_Kind. (P_Return_Statement): Add case for return ... when variant of return statement. * par-util.adb, par.adb (Missing_Semicolon_On_When): Added to centeralize parsing of "when" keywords in the context of "when" constructs. * sem.adb (Analyze): Add case for "when" constructs. * sem_ch11.adb, sem_ch11.ads (Analyze_Raise_When_Statement): Created to analyze raise ... when constructs. * sem_ch5.adb, sem_ch5.ads (Analyzed_Goto_When_Statement): Created to analyze goto ... when constructs. * sem_ch6.adb, sem_ch6.ads (Analyze_Return_When_Statement): Created to analyze return ... when constructs. * sprint.adb (Sprint_Node_Actual): Add entries for new "when" nodes.
2021-06-21[Ada] Add Ada.Strings.Text_Buffers and replace uses of Ada.Strings.Text_OutputSteve Baird95-1011/+2180
gcc/ada/ * Make-generated.in (GEN_IL_FLAGS): Keep only GNAT flags. (ada/stamp-gen_il): Remove dependencies on libgnat/ sources. Do not copy libgnat/ sources locally and tidy up. * Makefile.rtl: Include object files for new Text_Buffer units in the GNATRTL_NONTASKING_OBJS list. * exp_put_image.ads, exp_put_image.adb: Update Rtsfind calls to match new specs. For example, calls to RE_Sink are replaced with calls to RE_Root_Buffer_Type. Update comments and change subprogram names accordingly (e.g., Preload_Sink is changed to Preload_Root_Buffer_Type). * impunit.adb: Add 6 new predefined units (Text_Buffers and 5 child units thereof). * rtsfind.ads, rtsfind.adb: Add interfaces for accessing the Ada.Strings.Text_Buffers package and declarations therein (including the Unbounded child unit). Do not (yet) delete interfaces for accessing the old Text_Output package. * sem_attr.adb (Check_Put_Image_Attribute): Replace RE_Sink uses with RE_Root_Buffer_Type and update comments accordingly. * sem_ch10.adb (Analyze_Compilation_Unit): Update call to reflect name change of callee (that is, the former Preload_Sink is now Preload_Root_Buffer_Type). * sem_ch13.adb (Has_Good_Profile): Replace RE_Sink use with RE_Root_Buffer_Type. (Build_Spec): Update comment describing a parameter type. * gen_il.ads: Remove clauses for the old Text_Output package and add them for Ada.Streams.Stream_IO. (Sink): Declare. (Create_File): Likewise. (Increase_Indent): Likewise. (Decrease_Indent): Likewise. (Put): Likewise. (LF): Likewise. * gen_il.adb: Add clauses for Ada.Streams.Stream_IO. (Create_File): New procedure. (Increase_Indent): Likewise. (Decrease_Indent): Likewise. (Put): New procedures. * gen_il-gen.adb: Add clauses for Ada.Text_IO. Replace Sink'Class with Sink throughout. Use string concatenation and LF marker instead of formatted strings and "\n" marker. Update Indent/Outdent calls to use new Increase_Indent/Decrease_Indent names. (Put_Membership_Query_Decl): Remove. * gen_il-internals.ads: Replace Sink'Class with Sink throughout. (Ptypes): Remove. (Pfields): Likewise. * gen_il-internals.adb: Remove clauses for GNAT.OS_Lib and Ada.Strings.Text_Buffers.Files. Replace Sink'Class with Sink throughout. Use string concatenation and LF marker instead of formatted strings and "\n" marker. (Stdout): Remove. (Ptypes): Likewise. (Pfields): Likewise. * libgnarl/s-putaim.ads: Modify context clause, update declaration of subtype Sink to refer to Text_Buffers.Root_Buffer_Type instead of the old Text_Output.Sink type. * libgnarl/s-putaim.adb: Modify context clause and add use clause to refer to Text_Buffers package. * libgnat/a-cbdlli.ads, libgnat/a-cbdlli.adb, libgnat/a-cbhama.ads, libgnat/a-cbhama.adb, libgnat/a-cbhase.ads, libgnat/a-cbhase.adb, libgnat/a-cbmutr.ads, libgnat/a-cbmutr.adb, libgnat/a-cborma.ads, libgnat/a-cborma.adb, libgnat/a-cborse.ads, libgnat/a-cborse.adb, libgnat/a-cdlili.ads, libgnat/a-cdlili.adb, libgnat/a-cidlli.ads, libgnat/a-cidlli.adb, libgnat/a-cihama.ads, libgnat/a-cihama.adb, libgnat/a-cihase.ads, libgnat/a-cihase.adb, libgnat/a-cimutr.ads, libgnat/a-cimutr.adb, libgnat/a-ciorma.ads, libgnat/a-ciorma.adb, libgnat/a-ciormu.ads, libgnat/a-ciormu.adb, libgnat/a-ciorse.ads, libgnat/a-ciorse.adb, libgnat/a-coboho.ads, libgnat/a-coboho.adb, libgnat/a-cobove.ads, libgnat/a-cobove.adb, libgnat/a-cohama.ads, libgnat/a-cohama.adb, libgnat/a-cohase.ads, libgnat/a-cohase.adb, libgnat/a-coinho.ads, libgnat/a-coinho.adb, libgnat/a-coinho__shared.ads, libgnat/a-coinho__shared.adb, libgnat/a-coinve.ads, libgnat/a-coinve.adb, libgnat/a-comutr.ads, libgnat/a-comutr.adb, libgnat/a-convec.ads, libgnat/a-convec.adb, libgnat/a-coorma.ads, libgnat/a-coorma.adb, libgnat/a-coormu.ads, libgnat/a-coormu.adb, libgnat/a-coorse.ads, libgnat/a-coorse.adb, libgnat/a-nbnbin.ads, libgnat/a-nbnbin.adb, libgnat/a-nbnbin__gmp.adb, libgnat/a-nbnbre.ads, libgnat/a-nbnbre.adb, libgnat/a-strunb.ads, libgnat/a-strunb.adb, libgnat/a-strunb__shared.ads, libgnat/a-strunb__shared.adb, libgnat/s-rannum.ads, libgnat/s-rannum.adb: Modify Put_Image procedure used in Put_Image aspect specification to conform to Ada profile rules (in particular, the first parameter shall be of type Ada.Strings.Text_Buffers.Root_Buffer_Type'Class). * libgnat/a-sttebu.ads, libgnat/a-sttebu.adb, libgnat/a-stbubo.ads, libgnat/a-stbubo.adb, libgnat/a-stbufi.ads, libgnat/a-stbufi.adb, libgnat/a-stbufo.ads, libgnat/a-stbufo.adb, libgnat/a-stbuun.ads, libgnat/a-stbuun.adb, libgnat/a-stbuut.ads, libgnat/a-stbuut.adb: A new predefined unit, Ada.Strings.Text_Buffers, and five child units. Two of the five are RM-defined: Bounded and Unbounded. The remaining three are GNAT-defined: Files, Utils, and Formatting. The buffer type corresponding to an output file, type Files.File_Buffer, is simpler (and perhaps therefore slower) than its predecessor. Caching similar to what was being done before could be added later if that seems appropriate. * libgnat/s-putima.ads: Modify context clause, update declaration of subtype Sink to refer to Text_Buffers.Root_Buffer_Type instead of the old Text_Output.Sink type. * libgnat/s-putima.adb: Modify context clause. Update Indent/Outdent calls to use new Increase_Indent/Decrease_Indent names; ditto for "Put_String => Put" name change. * libgnat/a-stteou__bootstrap.ads: Delete.
2021-06-21[Ada] Adjust new fast bit-field copy path to big-endian platformsEric Botcazou1-8/+61
gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Bitfield_Fast): If big-endian ordering is in effect for the operands and they are small, adjust the unchecked conversions done around them.
2021-06-21[Ada] Add Return_Statement fieldRichard Kenner4-0/+9
gcc/ada/ * einfo.ads (Return_Statement): Add documentation. * exp_ch6.adb (Expand_N_Extended_Return_Statement): Set it. * gen_il-fields.ads: Add it. * gen_il-gen-gen_entities.adb: Add it.
2021-06-21[Ada] Improve efficiency of small slice assignments of packed arraysBob Duff7-40/+271
gcc/ada/ * rtsfind.ads, libgnat/s-bitfie.ads, libgnat/s-bituti.adb, libgnat/s-bituti.ads (Fast_Copy_Bitfield): New run-time library function to copy bit fields faster than Copy_Bitfield. Cannot be called with zero-size bit fields. Remove obsolete ??? comments from s-bituti.adb; we already do "avoid calling this if Forwards_OK is False". * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield, Expand_Assign_Array_Bitfield_Fast): Generate calls to Fast_Copy_Bitfield when appropriate. * sem_util.adb, sem_util.ads (Get_Index_Bounds): Two new functions for getting the index bounds. These are more convenient than the procedure of the same name, because they can be used to initialize constants.
2021-06-21[Ada] Implementation of AI12-205: defaults for formal typesEd Schonberg5-6/+474
gcc/ada/ * gen_il-fields.ads: Add Default_Subtype_Mark to enumeration type for fields. * gen_il-gen-gen_nodes.adb: Add call to create new field for Formal_Type_Declaration node. * par-ch12.adb (P_Formal_Type_Declaration): in Ada_2022 mode, recognize new syntax for default: "or use subtype_mark". (P_Formal_Type_Definition): Ditto for the case of a formal incomplete type. * sinfo.ads: Add field Default_Subtype_Mark to N_Formal_Type_Declaration. * sem_ch12.adb (Validate_Formal_Type_Default): New procedure, to apply legality rules to default subtypes in formal type declarations. Some legality rules apply to all defaults, such as the requirement that the default for a formal type that depends on previous formal entities must itself be a previously declared formal of the same unit. Other checks are kind- specific. (Analyze_Associations): Use specified default if there is no actual provided for a formal type in an instance. (Analyze_Formal_Type_Declaration): Call Validate_Formal_Type_Default when default subtype is present.
2021-06-21[Ada] Implement 'Valid_Value attributeBob Duff15-511/+748
gcc/ada/ * libgnat/s-valuen.ads, libgnat/s-valuen.adb (Value_Enumeration_Pos): New function to compute the 'Pos of the enumeration literal for a given String. Return a special value instead of raising an exception on invalid input. Called by both Valid_Enumeration_Image and Value_Enumeration. (Valid_Enumeration_Image): Return a Boolean indicating whether the String is a valid Image for the given enumeration type. (Value_Enumeration): Implement in terms of Value_Enumeration_Pos. * libgnat/s-vaenu8.ads, libgnat/s-vaen16.ads, libgnat/s-vaen32.ads: Rename Valid_Enumeration_Image from the instances. * libgnat/s-valuti.ads: Correct documentation (it was not true for the null string). * libgnat/s-valuti.adb (Normalize_String): Do not raise Constraint_Error for the null string, nor strings containing nothing but blanks, so that Valid_Enumeration_Image can return False in these cases, rather than raising an exception. * rtsfind.ads (RE_Value_Enumeration_8, RE_Value_Enumeration_16, RE_Value_Enumeration_32): New functions. (RTE_Available): Improve comment (E doesn't have to be a subprogram, although that's the usual case). * sem_attr.adb (nalid_Value): Semantic analysis for new attribute. * exp_attr.adb: Call Expand_Valid_Value_Attribute for new attribute. * exp_imgv.ads, exp_imgv.adb (Expand_Valid_Value_Attribute): New procedure to expand Valid_Value into a call to Valid_Enumeration_Image_NN. (Expand_Value_Attribute): Misc code cleanups. Remove two ??? mark comments. RTE_Available won't work here. For one thing, RTE_Available (X) shouldn't be called until the compiler has decided to make use of X (see comments on RTE_Available), and in this case we're trying to AVOID calling something. * snames.ads-tmpl: New attribute name. * doc/gnat_rm/implementation_defined_attributes.rst: Document new attribute. * gnat_rm.texi: Regenerate.
2021-06-21[Ada] Export Opt.Assume_No_Invalid_Values for use in back-endEric Botcazou2-0/+4
gcc/ada/ * fe.h (Assume_No_Invalid_Values): Declare. * opt.ads (Assume_No_Invalid_Values): Add warning comment.
2021-06-21[Ada] Zero-size slicesBob Duff2-2/+13
gcc/ada/ * libgnat/s-bituti.ads (Small_Size): Do not include 0 in this type. * libgnat/s-bituti.adb (Copy_Bitfield): Do nothing for 0-bit bitfields.
2021-06-21[Ada] Address ??? commentsGhjuvan Lacambre3-3/+12
gcc/ada/ * exp_ch9.adb (Build_Simple_Entry_Call): Add comment. * libgnat/s-rannum.adb (Random): Update comment. * libgnat/s-rannum.ads (Generator): Update comment.
2021-06-21[Ada] Fix unbalanced parens in documentation of Address clausesPiotr Trojanek2-2/+2
gcc/ada/ * doc/gnat_rm/representation_clauses_and_pragmas.rst (Address Clauses): Fix unbalanced parens. * gnat_rm.texi: Regenerate.
2021-06-21[Ada] Minor reformattingsGhjuvan Lacambre4-6/+6
gcc/ada/ * errout.adb (Handle_Serious_Error): Capitalize comment. * exp_dbug.adb (Set_Entity_Name): Capitalize sentence. * exp_dist.adb (Expand_All_Calls_Remote_Subprogram_Call): Fix typo. * sem_ch3.adb (Modular_Type_Declaration): Add space after comma.
2021-06-21[Ada] Make -gnatU and -gnatw.d the defaultGhjuvan Lacambre6-6/+17
gcc/ada/ * debug.adb: Document -gnatd_U as taken. * err_vars.ads (Warning_Doc_Switch): Set to True. * errout.ads (Errout): Update documentation. * gnat1drv.adb (Adjust_Global_Switches): React to -gnatd_U. * hostparm.ads (Tag_Errors): Set to True. * opt.ads (Unique_Error_Tag): Document -gnatd_U.
2021-06-21[Ada] Fix invalid JSON real numbers generated with -gnatRjEric Botcazou3-20/+126
gcc/ada/ * urealp.ads (UR_Write_To_JSON): Declare. * urealp.adb (Decimal_Exponent_Hi): Treat numbers in base 10 specially and rewrite handling of numbers in other bases. (Decimal_Exponent_Lo): Likewise. (Normalize): Minor tweak. (UR_Write_To_JSON): New wrapper procedure around UR_Write. * repinfo.adb (List_Type_Info): When the output is to JSON, call UR_Write_To_JSON instead of UR_Write.
2021-06-21[Ada] Disable wrong computation of offsets within multidimensional arraysPiotr Trojanek1-1/+7
gcc/ada/ * sem_util.adb (Indexed_Component_Bit_Offset): Return an unknown offset for components within multidimensional arrays; remove redundant parens.