platform/upstream/gcc.git
3 years ago[Ada] Fix violation of No_Implicit_Loops restriction for enumeration type
Eric Botcazou [Mon, 31 May 2021 14:32:14 +0000 (16:32 +0200)]
[Ada] Fix violation of No_Implicit_Loops restriction for enumeration type

gcc/ada/

* exp_imgv.adb: Add with and use clause for Restrict and Rident.
(Build_Enumeration_Image_Tables): Do not generate the hash function
if the No_Implicit_Loops restriction is active.

3 years ago[Ada] Simplify redundant checks for non-empty lists
Piotr Trojanek [Thu, 27 May 2021 15:16:34 +0000 (17:16 +0200)]
[Ada] Simplify redundant checks for non-empty lists

gcc/ada/

* sem_ch12.adb, sem_ch6.adb, sem_ch9.adb, sprint.adb: Simplify
checks for non-empty lists.

3 years ago[Ada] Remove redundant condition for listing compilation units
Piotr Trojanek [Tue, 25 May 2021 18:41:55 +0000 (20:41 +0200)]
[Ada] Remove redundant condition for listing compilation units

gcc/ada/

* par-ch10.adb (Unit_Display): Remove redundant condition; fix
whitespace.

3 years ago[Ada] Restore context on failure in loading of renamed child unit
Piotr Trojanek [Tue, 25 May 2021 15:39:26 +0000 (17:39 +0200)]
[Ada] Restore context on failure in loading of renamed child unit

gcc/ada/

* lib-load.adb (Load): Replace early return with goto to properly
restore context on failure.

3 years ago[Ada] Replace low-level condition with a high-level call
Piotr Trojanek [Tue, 25 May 2021 15:40:38 +0000 (17:40 +0200)]
[Ada] Replace low-level condition with a high-level call

gcc/ada/

* lib-writ.adb (Ensure_System_Dependency): Simplify condition.

3 years ago[Ada] Fix style in comments and code related to compilation units
Piotr Trojanek [Wed, 26 May 2021 13:27:02 +0000 (15:27 +0200)]
[Ada] Fix style in comments and code related to compilation units

gcc/ada/

* lib-load.adb (Load_Unit): Fix style in comment.
* par-load.adb (Load): Likewise.
* scng.adb (Initialize_Scanner): Fix whitespace.

3 years ago[Ada] Prevent infinite recursion when there is no expected unit
Piotr Trojanek [Wed, 26 May 2021 13:05:28 +0000 (15:05 +0200)]
[Ada] Prevent infinite recursion when there is no expected unit

gcc/ada/

* par-load.adb (Load): Don't remove unit, but flag it as
erroneous and return.

3 years ago[Ada] Fix use of single question mark in error message
Ghjuvan Lacambre [Wed, 26 May 2021 16:02:34 +0000 (18:02 +0200)]
[Ada] Fix use of single question mark in error message

gcc/ada/

* exp_prag.adb (Expand_Pragma_Inspection_Point): Fix error
message.

3 years ago[Ada] Skip types in error for test to compute array size
Yannick Moy [Wed, 26 May 2021 12:54:02 +0000 (14:54 +0200)]
[Ada] Skip types in error for test to compute array size

gcc/ada/

* layout.adb (Layout_Type): Do not call Number_Dimensions if the
type does not have First_Index set.

3 years ago[Ada] Prevent crash on inspection point for unfrozen entity
Ghjuvan Lacambre [Tue, 25 May 2021 12:12:37 +0000 (14:12 +0200)]
[Ada] Prevent crash on inspection point for unfrozen entity

gcc/ada/

* exp_prag.adb (Expand_Pragma_Inspection_Point): After expansion
of the Inspection_Point pragma, check if referenced entities
that have a freeze node are already frozen. If they aren't, emit
a warning and turn the pragma into a no-op.

3 years ago[Ada] Fix on computation of packed array size in case of error
Yannick Moy [Wed, 26 May 2021 08:49:14 +0000 (10:49 +0200)]
[Ada] Fix on computation of packed array size in case of error

gcc/ada/

* layout.adb (Layout_Type): Add guard before calling Expr_Value.

3 years ago[Ada] Compute sizes when possible for packed array with Component_Size
Yannick Moy [Wed, 19 May 2021 13:50:02 +0000 (15:50 +0200)]
[Ada] Compute sizes when possible for packed array with Component_Size

gcc/ada/

* layout.adb (Layout_Type): Special case when RM_Size and Esize
can be computed for packed arrays.

3 years ago[Ada] Unsynchronized concurrent access to a Boolean variable
Steve Baird [Mon, 24 May 2021 21:38:07 +0000 (14:38 -0700)]
[Ada] Unsynchronized concurrent access to a Boolean variable

gcc/ada/

* rtsfind.ads, rtsfind.adb: Add support for finding the packages
System.Atomic_Operations and
System.Atomic_Operations.Test_And_Set and the declarations
within that latter package of the type Test_And_Set_Flag and the
function Atomic_Test_And_Set.
* exp_ch11.adb (Expand_N_Exception_Declaration): If an exception
is declared other than at library level, then we need to call
Register_Exception the first time (and only the first time) the
declaration is elaborated.  In order to decide whether to
perform this call for a given elaboration of the declaration, we
used to unconditionally use a (library-level) Boolean variable.
Now we instead use a variable of type
System.Atomic_Operations.Test_And_Set.Test_And_Set_Flag unless
either that type is unavailable or a No_Tasking restriction is
in effect (in which case we use a Boolean variable as before).

3 years ago[Ada] Add No_Tasking restriction is system.ads for bootstrap
Arnaud Charlet [Fri, 21 May 2021 08:04:55 +0000 (04:04 -0400)]
[Ada] Add No_Tasking restriction is system.ads for bootstrap

gcc/ada/

* gcc-interface/system.ads: Add No_Tasking restriction.

3 years ago[Ada] Incorrect iteration over hashed containers after multiple Inserts
Ed Schonberg [Fri, 21 May 2021 19:51:13 +0000 (15:51 -0400)]
[Ada] Incorrect iteration over hashed containers after multiple Inserts

gcc/ada/

* libgnat/a-cohama.ads: Introduce an equality operator over
cursors.
* libgnat/a-cohase.ads: Ditto.
* libgnat/a-cohama.adb: Add body for "=" over cursors.
(Insert): Do not set the Position component of the cursor that
denotes the inserted element.
* libgnat/a-cohase.adb: Ditto.

3 years ago[Ada] Make runtime code compatible with No_Dynamic_Accessibility_Checks
Arnaud Charlet [Tue, 25 May 2021 08:18:21 +0000 (04:18 -0400)]
[Ada] Make runtime code compatible with No_Dynamic_Accessibility_Checks

gcc/ada/

* libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb,
libgnat/a-cborma.adb, libgnat/a-cborse.adb,
libgnat/a-cobove.adb, libgnat/a-textio.adb,
libgnat/a-witeio.adb, libgnat/a-ztexio.adb: Make code compatible
with No_Dynamic_Accessibility_Checks restriction.

3 years ago[Ada] Revert meaning of -gnatd_b
Arnaud Charlet [Mon, 24 May 2021 12:38:20 +0000 (08:38 -0400)]
[Ada] Revert meaning of -gnatd_b

gcc/ada/

* debug.adb, sem_util.adb: Revert meaning of -gnatd_b.
* sem_res.adb: Minor reformatting.

3 years ago[Ada] Make tools compatible with No_Dynamic_Accessibility_Checks
Arnaud Charlet [Mon, 24 May 2021 11:07:49 +0000 (07:07 -0400)]
[Ada] Make tools compatible with No_Dynamic_Accessibility_Checks

gcc/ada/

* make.adb, osint.adb: Make code compatible with
No_Dynamic_Accessibility_Checks restriction.

3 years ago[Ada] Avoid linear search when ensuring dependency on System
Piotr Trojanek [Mon, 24 May 2021 14:14:40 +0000 (16:14 +0200)]
[Ada] Avoid linear search when ensuring dependency on System

gcc/ada/

* lib-writ.adb (Ensure_System_Dependency): Replace search in
Lib.Units with a search in Lib.Unit_Names.

3 years ago[Ada] Simplify string manipulation related to preprocessing
Piotr Trojanek [Mon, 24 May 2021 13:27:28 +0000 (15:27 +0200)]
[Ada] Simplify string manipulation related to preprocessing

gcc/ada/

* sinput-l.adb (Load_File): Simplify foreword manipulation with
concatenation; similar for filename with preprocessed output.

3 years agovect: Remove always-true condition
Richard Sandiford [Thu, 8 Jul 2021 11:58:13 +0000 (12:58 +0100)]
vect: Remove always-true condition

vectorizable_reduction had code guarded by:

  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
      || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)

But that's always true after:

  if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
      && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def
      && STMT_VINFO_DEF_TYPE (stmt_info) != vect_nested_cycle)
    return false;

  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle)
    {
      …
      return true;
    }

(I wasn't sure at first how the empty “else” for the first “if” above
was supposed to work.)

gcc/
* tree-vect-loop.c (vectorizable_reduction): Remove always-true
if condition.

3 years agomatch.pd: Relax rule to include POLY_INT_CSTs
Richard Sandiford [Thu, 8 Jul 2021 11:49:44 +0000 (12:49 +0100)]
match.pd: Relax rule to include POLY_INT_CSTs

match.pd has a rule to simplify an extension, operation and truncation
back to the original type:

 (simplify
   (convert (op:s@0 (convert1?@3 @1) (convert2?@4 @2)))

Currently it handles cases in which @2 is an INTEGER_CST, but it
also works for POLY_INT_CSTs.[*]

For INTEGER_CST it doesn't matter whether we test @2 or @4,
but for POLY_INT_CST it is possible to have unfolded (convert …)s.

Originally I saw this leading to some bad ivopts decisions, because
we weren't folding away redundancies from candidate iv expressions.
It's also possible to test the fold directly using the SVE ACLE.

[*] Not all INTEGER_CST rules work for POLY_INT_CSTs, since extensions
    don't necessarily distribute over the internals of the POLY_INT_CST.
    But in this case that isn't an issue.

gcc/
* match.pd: Simplify an extend-operate-truncate sequence involving
a POLY_INT_CST.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cntb_1.c: New test.

3 years agoPR tree-optimization/40210: Fold (bswap(X)>>C1)&C2 to (X>>C3)&C2 in match.pd
Roger Sayle [Thu, 8 Jul 2021 10:46:14 +0000 (11:46 +0100)]
PR tree-optimization/40210: Fold (bswap(X)>>C1)&C2 to (X>>C3)&C2 in match.pd

All of the optimizations/transformations mentioned in bugzilla for
PR tree-optimization/40210 are already implemented in mainline GCC,
with one exception.  In comment #5, there's a suggestion that
(bswap64(x)>>56)&0xff can be implemented without the bswap as
(unsigned char)x, or equivalently x&0xff.

This patch implements the above optimization, and closely related
variants.  For any single bit, (bswap(X)>>C1)&1 can be simplified
to (X>>C2)&1, where bit position C2 is the appropriate permutation
of C1.  Similarly, the bswap can eliminated if the desired set of
bits all lie within the same byte, hence (bswap(x)>>8)&255 can
always be optimized, as can (bswap(x)>>8)&123.

Previously,
int foo(long long x) {
  return (__builtin_bswap64(x) >> 56) & 0xff;
}

compiled with -O2 to
foo: movq    %rdi, %rax
        bswap   %rax
        shrq    $56, %rax
        ret

with this patch, it now compiles to
foo: movzbl  %dil, %eax
        ret

2021-07-08  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
PR tree-optimization/40210
* match.pd (bswap optimizations): Simplify (bswap(x)>>C1)&C2 as
(x>>C3)&C2 when possible.  Simplify bswap(x)>>C1 as ((T)x)>>C2
when possible.  Simplify bswap(x)&C1 as (x>>C2)&C1 when 0<=C1<=255.

gcc/testsuite/ChangeLog
PR tree-optimization/40210
* gcc.dg/builtin-bswap-13.c: New test.
* gcc.dg/builtin-bswap-14.c: New test.

3 years agoi386: Add pack/unpack patterns for 32bit vectors [PR100637]
Uros Bizjak [Thu, 8 Jul 2021 10:19:54 +0000 (12:19 +0200)]
i386: Add pack/unpack patterns for 32bit vectors [PR100637]

V1SI mode shift is needed to shift 32bit operands and consequently we
need to implement V1SI moves and pushes.

2021-07-08  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100637
* config/i386/i386-expand.c (ix86_expand_sse_unpack):
Handle V4QI mode.
* config/i386/mmx.md (V_32): New mode iterator.
(mov<V_32:mode>): Use V_32 mode iterator.
(*mov<V_32:mode>_internal): Ditto.
(*push<V_32:mode>2_rex64): Ditto.
(*push<V_32:mode>2): Ditto.
(movmisalign<V_32:mode>): Ditto.
(mmx_<any_shiftrt:insn>v1si3): New insn pattern.
(sse4_1_<any_extend:code>v2qiv2hi2): Ditto.
(vec_unpacks_lo_v4qi): New expander.
(vec_unpacks_hi_v4qi): Ditto.
(vec_unpacku_lo_v4qi): Ditto.
(vec_unpacku_hi_v4qi): Ditto.
* config/i386/i386.h (VALID_SSE2_REG_MODE): Add V1SImode.
(VALID_INT_MODE_P): Ditto.

3 years agoGenerate 128-bit int divide/modulus on power10.
Michael Meissner [Thu, 8 Jul 2021 01:55:38 +0000 (21:55 -0400)]
Generate 128-bit int divide/modulus on power10.

This patch adds support for the VDIVSQ, VDIVUQ, VMODSQ, and VMODUQ
instructions to do 128-bit arithmetic.

2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

gcc/
PR target/100809
* config/rs6000/rs6000.md (udivti3): New insn.
(divti3): New insn.
(umodti3): New insn.
(modti3): New insn.

gcc/testsuite/
PR target/100809
* gcc.target/powerpc/p10-vdivq-vmodq.c: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 8 Jul 2021 00:16:27 +0000 (00:16 +0000)]
Daily bump.

3 years agoanalyzer: remove add_any_constraints_from_ssa_def_stmt
David Malcolm [Wed, 7 Jul 2021 23:29:30 +0000 (19:29 -0400)]
analyzer: remove add_any_constraints_from_ssa_def_stmt

I'm working on reimplementing -Wanalyzer-use-of-uninitialized-value, but
I ran into issues with
region_model::add_any_constraints_from_ssa_def_stmt.
This function is from the initial commit of the analyzer and walks the
SSA names finding conditions that were missed due to the GCC 10 era
region_model not retaining useful information on how values were
created; as of GCC 11 the symbolic values contain this information,
and so the conditions can be reconstructed from them instead.

region_model::add_any_constraints_from_ssa_def_stmt is a liability
when tracking uninitialized values as it requires looking up SSA
values when those values may have been purged, thus greatly complicating
detection of uses of uninitialized values.

It's simplest to eliminate it and reimplement the condition-finding
via the makeup of the svalues, which this patch does.  Doing so requires
supporting add_condition on svalues rather than just on trees, which
requires some changes to ana::state_machine and its subclasses.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (null_assignment_sm_context::get_state):
New overload.
(null_assignment_sm_context::set_next_state): New overload.
(null_assignment_sm_context::get_diagnostic_tree): New.
* engine.cc (impl_sm_context::get_state): New overload.
(impl_sm_context::set_next_state): New overload.
(impl_sm_context::get_diagnostic_tree): New overload.
(impl_region_model_context::on_condition): Convert params from
tree to const svalue *.
* exploded-graph.h (impl_region_model_context::on_condition):
Likewise.
* region-model.cc (region_model::on_call_pre): Move handling of
internal calls to before checking for get_fndecl_for_call.
(region_model::add_constraints_from_binop): New.
(region_model::add_constraint): Split out into a new overload
working on const svalue * rather than tree.  Call
add_constraints_from_binop.  Drop call to
add_any_constraints_from_ssa_def_stmt.
(region_model::add_any_constraints_from_ssa_def_stmt): Delete.
(region_model::add_any_constraints_from_gassign): Delete.
(region_model::add_any_constraints_from_gcall): Delete.
* region-model.h
(region_model::add_any_constraints_from_ssa_def_stmt): Delete.
(region_model::add_any_constraints_from_gassign): Delete.
(region_model::add_any_constraints_from_gcall): Delete.
(region_model::add_constraint): Add overload decl.
(region_model::add_constraints_from_binop): New decl.
(region_model_context::on_condition): Convert params from tree to
const svalue *.
(noop_region_model_context::on_condition): Likewise.
* sm-file.cc (fileptr_state_machine::condition): Likewise.
* sm-malloc.cc (malloc_state_machine::on_condition): Likewise.
* sm-pattern-test.cc: Include tristate.h, selftest.h,
analyzer/call-string.h, analyzer/program-point.h,
analyzer/store.h, and analyzer/region-model.h.
(pattern_test_state_machine::on_condition): Convert params from tree to
const svalue *.
* sm-sensitive.cc (sensitive_state_machine::on_condition): Delete.
* sm-signal.cc (signal_state_machine::on_condition): Delete.
* sm-taint.cc (taint_state_machine::on_condition): Convert params
from tree to const svalue *.
* sm.cc: Include tristate.h, selftest.h, analyzer/call-string.h,
analyzer/program-point.h, analyzer/store.h, and
analyzer/region-model.h.
(any_pointer_p): Add overload taking const svalue *sval.
* sm.h (any_pointer_p): Add overload taking const svalue *sval.
(state_machine::on_condition): Convert params from tree to
const svalue *.  Provide no-op default implementation.
(sm_context::get_state): Add overload taking const svalue *sval.
(sm_context::set_next_state): Likewise.
(sm_context::on_transition): Likewise.
(sm_context::get_diagnostic_tree): Likewise.
* svalue.cc (svalue::all_zeroes_p): New.
(constant_svalue::all_zeroes_p): New.
(repeated_svalue::all_zeroes_p): Convert to vfunc.
* svalue.h (svalue::all_zeroes_p): New decl.
(constant_svalue::all_zeroes_p): New decl.
(repeated_svalue::all_zeroes_p): Convert decl to vfunc.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/pattern-test-2.c: Update expected results.
* gcc.dg/plugin/analyzer_gil_plugin.c
(gil_state_machine::on_condition): Remove.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoCorrect handling of variable offset minus constant in -Warray-bounds [PR100137]
Martin Sebor [Wed, 7 Jul 2021 20:05:25 +0000 (14:05 -0600)]
Correct handling of variable offset minus constant in -Warray-bounds [PR100137]

Resolves:
PR tree-optimization/100137 - -Warray-bounds false positive on varying offset plus negative
PR tree-optimization/99121 - ICE in -Warray-bounds on a multidimensional
PR tree-optimization/97027 - missing warning on buffer overflow storing a larger scalar into a smaller array

gcc/ChangeLog:

PR tree-optimization/100137
PR tree-optimization/99121
PR tree-optimization/97027
* builtins.c (access_ref::access_ref): Also set offmax.
(access_ref::offset_in_range): Define new function.
(access_ref::add_offset): Set offmax.
(access_ref::inform_access): Handle access_none.
(handle_mem_ref): Clear ostype.
(compute_objsize_r): Handle ASSERT_EXPR.
* builtins.h (struct access_ref): Add offmax member.
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Use
compute_objsize() and simplify.

gcc/testsuite/ChangeLog:

PR tree-optimization/100137
PR tree-optimization/99121
PR tree-optimization/97027
* c-c++-common/Warray-bounds-3.c: Remove xfail
* c-c++-common/Warray-bounds-4.c: Add an expected warning.
* c-c++-common/Warray-bounds-9.c: New test.
* c-c++-common/Warray-bounds-10.c: New test.
* g++.dg/asan/asan_test.C: Suppress expected warnings.
* g++.dg/pr95768.C: Same.
* g++.dg/warn/Warray-bounds-10.C: Adjust text of expected messages.
* g++.dg/warn/Warray-bounds-11.C: Same.
* g++.dg/warn/Warray-bounds-12.C: Same.
* g++.dg/warn/Warray-bounds-13.C: Same.
* g++.dg/warn/Warray-bounds-17.C: Same.
* g++.dg/warn/Warray-bounds-20.C: Same.
* gcc.dg/Warray-bounds-29.c: Same.
* gcc.dg/Warray-bounds-30.c: Add xfail.
* gcc.dg/Warray-bounds-31.c: Adjust text of expected messages.
* gcc.dg/Warray-bounds-32.c: Same.
* gcc.dg/Warray-bounds-52.c: Same.
* gcc.dg/Warray-bounds-53.c: Same.
* gcc.dg/Warray-bounds-58.c: Remove xfail.
* gcc.dg/Warray-bounds-63.c: Adjust text of expected messages.
* gcc.dg/Warray-bounds-66.c: Same.
* gcc.dg/Warray-bounds-69.c: Same.
* gcc.dg/Wstringop-overflow-34.c: Same.
* gcc.dg/Wstringop-overflow-47.c: Same.
* gcc.dg/Wstringop-overflow-61.c: Same.
* gcc.dg/Warray-bounds-77.c: New test.
* gcc.dg/Warray-bounds-78.c: New test.
* gcc.dg/Warray-bounds-79.c: New test.

3 years agors6000: Harden mma_init_builtins
Peter Bergner [Wed, 7 Jul 2021 16:39:34 +0000 (11:39 -0500)]
rs6000: Harden mma_init_builtins

The previous MMA patch added some fragile code to initialize its new
built-ins.  This patch hardens the initialization.

2021-07-07  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.c (mma_init_builtins): Use VSX_BUILTIN_LXVP
and VSX_BUILTIN_STXVP.

3 years ago[Ada] Remove unused define
Dmitriy Anisimkov [Thu, 20 May 2021 16:58:31 +0000 (22:58 +0600)]
[Ada] Remove unused define

gcc/ada/

* s-oscons-tmplt.c (MSG_WAITALL): Remove wrong #ifdef
__MINWGW32__.

3 years ago[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled
Gary Dismukes [Fri, 21 May 2021 17:59:30 +0000 (13:59 -0400)]
[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled

gcc/ada/

* einfo-utils.adb (Primitive_Operations): Default to returning
Direct_Primitive_Operations in the case of concurrent types
(when Corresponding_Record_Type not present).
* sem_ch9.adb (Analyze_Protected_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.
(Analyze_Task_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.

3 years ago[Ada] Stronger assertion about flag for checking static expressions
Piotr Trojanek [Fri, 21 May 2021 09:47:45 +0000 (11:47 +0200)]
[Ada] Stronger assertion about flag for checking static expressions

gcc/ada/

* sem_eval.adb (Set_Checking_Potentially_Static_Expression):
Stronger assertion.

3 years ago[Ada] Front-end inlining and instantiations of UC
Arnaud Charlet [Thu, 20 May 2021 10:40:48 +0000 (06:40 -0400)]
[Ada] Front-end inlining and instantiations of UC

gcc/ada/

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Mark Anon_Id
intrinsic before calling Analyze_Instance_And_Renamings because
this flag may be propagated to other nodes.

3 years ago[Ada] Keepalive control on Windows
Dmitriy Anisimkov [Thu, 20 May 2021 13:55:02 +0000 (19:55 +0600)]
[Ada] Keepalive control on Windows

gcc/ada/

* s-oscons-tmplt.c (TCP_KEEPCNT TCP_KEEPIDLE, TCP_KEEPINTVL):
Hardcode on Windows if undefined.

3 years ago[Ada] Optimize away certain elaboration checks
Bob Duff [Wed, 19 May 2021 18:24:13 +0000 (14:24 -0400)]
[Ada] Optimize away certain elaboration checks

gcc/ada/

* checks.adb (Install_Primitive_Elaboration_Check): Do not
generate elaboration checks for primitives if pragma Pure or
Preelaborate is present.  Misc comment fixes, including
referring to the correct kind of check (elaboration, not
accessibility).
* checks.ads, restrict.adb, sem_cat.ads, sinfo.ads: Minor
reformatting and comment fixes.

3 years ago[Ada] Simplify code by reusing Remove on list of primitive operations
Piotr Trojanek [Wed, 19 May 2021 12:05:01 +0000 (14:05 +0200)]
[Ada] Simplify code by reusing Remove on list of primitive operations

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Simplify processing of pragma
CPP_Constructor.

3 years ago[Ada] Minor code cleanup
Arnaud Charlet [Thu, 20 May 2021 08:21:39 +0000 (04:21 -0400)]
[Ada] Minor code cleanup

gcc/ada/

* libgnat/g-debpoo.adb (Code_Address_For_Allocate_End): Default
Initialize.

3 years ago[Ada] Code cleanups in System.Atomic_Counters
Arnaud Charlet [Wed, 12 May 2021 09:28:29 +0000 (05:28 -0400)]
[Ada] Code cleanups in System.Atomic_Counters

gcc/ada/

* libgnat/s-atocou.ads, libgnat/s-atocou__builtin.adb: Code
cleanups.

3 years ago[Ada] Implement new legality checks specified by AI12-0412
Gary Dismukes [Mon, 17 May 2021 07:35:25 +0000 (03:35 -0400)]
[Ada] Implement new legality checks specified by AI12-0412

gcc/ada/

* freeze.adb (Check_Inherited_Conditions): Setting of Ekind,
LSP_Subprogram, and Is_Wrapper needs to happen for null
procedures as well as other wrapper cases, so the code is moved
from the else part in front of the if statement.  (Fixes a
latent bug encountered while working on this set of changes.)
* sem_attr.adb (Resolve_Attribute): Report an error for the case
of an Access attribute applied to a primitive of an abstract
type when the primitive has any nonstatic Pre'Class or
Post'Class expressions.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Report an error for
the case of a actual subprogram associated with a nonabstract
formal subprogram when the actual is a primitive of an abstract
type and the primitive has any nonstatic Pre'Class or Post'Class
expressions.
* sem_disp.adb (Check_Dispatching_Context): Remove special
testing for null procedures, and replace it with a relaxed test
that avoids getting an error about illegal calls to abstract
subprograms in cases where RM 6.1.1(7/5) applies in
Pre/Post'Class aspects. Also, remove special test for
Postcondition, which seems to be unnecessary, update associated
comments, and fix a typo in one comment.
(Check_Dispatching_Call): Remove an unneeded return statement,
and report an error for the case of a nondispatching call to a
nonabstract subprogram of an abstract type where the subprogram
has nonstatic Pre/Post'Class aspects.
* sem_util.ads
(Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post): New function.
(In_Pre_Post_Condition): Add a flag formal Class_Wide_Only,
defaulted to False, for indicating whether the function should
only test for the node being within class-wide pre- and
postconditions.
* sem_util.adb
(Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post): New function
to determine whether a subprogram is a primitive of an abstract
type where the primitive has class-wide Pre/Post'Class aspects
specified with nonstatic expressions.
(In_Pre_Post_Condition): Extend testing to account for the new
formal Class_Wide_Only.

3 years ago[Ada] Fix location of errors about volatile compatibility
Piotr Trojanek [Wed, 19 May 2021 13:18:54 +0000 (15:18 +0200)]
[Ada] Fix location of errors about volatile compatibility

gcc/ada/

* sem_ch12.adb (Check_Shared_Variable_Control_Aspects): Errors
emitted via Check_Volatility_Compatibility are now emitted at
Actual, just like other errors emitted by
Check_Shared_Variable_Control_Aspects.

3 years ago[Ada] Use bounded string buffer in Get_Unit_Name
Piotr Trojanek [Tue, 11 May 2021 10:16:14 +0000 (12:16 +0200)]
[Ada] Use bounded string buffer in Get_Unit_Name

gcc/ada/

* uname.adb (Get_Unit_Name): Simplify with a bounded string
buffer; also, this addresses a ??? comment about the max length
being exceeded.

3 years ago[Ada] Replace obsolete calls that use global name buffer
Piotr Trojanek [Tue, 11 May 2021 14:44:40 +0000 (16:44 +0200)]
[Ada] Replace obsolete calls that use global name buffer

gcc/ada/

* uname.adb (Get_Body_Name, Get_Parent_Body_Name,
Get_Parent_Spec_Name, Get_Spec_Name, Is_Child_Name,
Is_Body_Name, Is_Spec_Name, Name_To_Unit_Name): Use a local
instead of the global buffer.

3 years ago[Ada] Fix bugs in Value_Size clauses and refactor
Bob Duff [Wed, 19 May 2021 15:37:47 +0000 (11:37 -0400)]
[Ada] Fix bugs in Value_Size clauses and refactor

gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Combine
processing of Size and Value_Size clauses. Ensure that
Value_Size is treated the same as Size, in the cases where both
are allowed (i.e. the prefix denotes a first subtype).  Misc
cleanup.
* einfo-utils.adb (Init_Size): Add assertions.
(Size_Clause): Return a Value_Size clause if present, instead of
just looking for a Size clause.
* einfo.ads (Has_Size_Clause, Size_Clause): Change documentation
to include Value_Size.
* sem_ch13.ads, layout.ads, layout.adb: Comment modifications.

3 years ago[Ada] Improve interactions between DSA and Put_Image routines for tagged types
Steve Baird [Wed, 19 May 2021 01:26:24 +0000 (18:26 -0700)]
[Ada] Improve interactions between DSA and Put_Image routines for tagged types

gcc/ada/

* exp_dist.adb (Add_RACW_Primitive_Declarations_And_Bodies): Add
TSS_Put_Image to list of predefined primitives that need special
treatment.
(Build_General_Calling_Stubs, Build_Subprogram_Receiving_Stubs):
Remove previous hack for dealing with TSS_Put_Image procedures.

3 years ago[Ada] Timeout correction on Get_Socket_Option
Dmitriy Anisimkov [Wed, 19 May 2021 12:26:16 +0000 (18:26 +0600)]
[Ada] Timeout correction on Get_Socket_Option

gcc/ada/

* libgnat/g-socket.adb (Get_Socket_Option): Add 500ms only when
Minus_500ms_Windows_Timeout is True.
(Set_Socket_Option): Use "* 1000" instead of "/ 0.001" to
convert to milliseconds.

3 years ago[Ada] Unchecked_Convert_To: set Parent
Bob Duff [Wed, 19 May 2021 11:52:32 +0000 (07:52 -0400)]
[Ada] Unchecked_Convert_To: set Parent

gcc/ada/

* tbuild.adb (Unchecked_Convert_To): Set the Parent of the new
node to the Parent of the old node.
* tbuild.ads (Unchecked_Convert_To): Document differences
between Convert_To and Unchecked_Convert_To. The previous
documentation claimed they are identical except for the
uncheckedness of the conversion.

3 years ago[Ada] Simplify handling of sure errors in GNATprove mode
Yannick Moy [Tue, 18 May 2021 10:35:08 +0000 (12:35 +0200)]
[Ada] Simplify handling of sure errors in GNATprove mode

gcc/ada/

* checks.adb (Apply_Scalar_Range_Check): Remove special case for
GNATprove mode.
* sem_res.adb (Resolve_Arithmetic_Op): Same.
* sem_util.adb (Apply_Compile_Time_Constraint_Error): Same.

3 years ago[Ada] Reduce scope of local variables
Piotr Trojanek [Wed, 19 May 2021 10:07:42 +0000 (12:07 +0200)]
[Ada] Reduce scope of local variables

gcc/ada/

* sem_ch6.adb (Check_For_Primitive_Subprogram): Move
declarations of local variables after nested subprogram bodies.

3 years ago[Ada] Simplify code by reusing List_Length
Piotr Trojanek [Wed, 19 May 2021 10:06:55 +0000 (12:06 +0200)]
[Ada] Simplify code by reusing List_Length

gcc/ada/

* exp_disp.adb (CPP_Num_Prims): Reuse List_Length.

3 years ago[Ada] Replace low-level membership tests with Is_Private_Type
Piotr Trojanek [Wed, 19 May 2021 10:05:31 +0000 (12:05 +0200)]
[Ada] Replace low-level membership tests with Is_Private_Type

gcc/ada/

* exp_ch3.adb, exp_ch6.adb, sem_ch6.adb: Replace Ekind
membership test in Private_Kind with a call to Is_Private_Type.

3 years ago[Ada] Linker_Section_Pragma cleanup
Bob Duff [Mon, 17 May 2021 19:39:29 +0000 (15:39 -0400)]
[Ada] Linker_Section_Pragma cleanup

gcc/ada/

* gen_il-gen-gen_entities.adb: Remove Linker_Section_Pragma
field from Record_Field_Kind.  Minor comment improvement.

3 years ago[Ada] Fix precondition of Cot for code analyzers
Yannick Moy [Mon, 17 May 2021 13:58:26 +0000 (15:58 +0200)]
[Ada] Fix precondition of Cot for code analyzers

gcc/ada/

* libgnat/a-ngelfu.ads (Cot): Fix precondition.

3 years ago[Ada] Replace chopped string copy with renaming
Piotr Trojanek [Tue, 18 May 2021 22:26:30 +0000 (00:26 +0200)]
[Ada] Replace chopped string copy with renaming

gcc/ada/

* par.adb (Par): A local Name variable is now a renaming of a
constant slice.

3 years ago[Ada] Simplify handling of Generate_Code flag for compilation units
Piotr Trojanek [Tue, 18 May 2021 12:54:24 +0000 (14:54 +0200)]
[Ada] Simplify handling of Generate_Code flag for compilation units

gcc/ada/

* gnat1drv.adb (Gnat1drv): Remove flagging of main unit and its
corresponding spec as requiring code generation; now the flags
are set much earlier.
* lib-load.adb (Load_Main_Source): Set Generate_Code flag on the
main unit source.
(Make_Instance_Unit): Copy Generate_Code flag from the main unit
to instance units.
* lib-writ.adb (Write_ALI): Remove redundant condition;
Generate_Code flag is always set for the main unit.
* par-load.adb (Load): Set Generate_Code flag on the main unit's
corresponding spec, if any.

3 years ago[Ada] Add socket options to control keepalive on TCP connection
Dmitriy Anisimkov [Tue, 18 May 2021 05:03:31 +0000 (11:03 +0600)]
[Ada] Add socket options to control keepalive on TCP connection

gcc/ada/

* libgnat/g-socket.ads (Option_Name): Add Keep_Alive_Count,
Keep_Alive_Idle, and Keep_Alive_Interval items to enumeration.
(Option_Type): Add Keep_Alive_Count, Keep_Alive_Idle, and
Keep_Alive_Interval alternatives to the case of discriminated
record.
* libgnat/g-socket.adb (Options): Add Keep_Alive_Count,
Keep_Alive_Idle, and Keep_Alive_Interval to items enumerator to
OS constant converter.
(Set_Socket_Option): Process Keep_Alive_Count, Keep_Alive_Idle,
and Keep_Alive_Interval socket options.
(Get_Socket_Option): Idem.

3 years ago[Ada] Tune discovery of No_Elaboration_Code restriction
Piotr Trojanek [Mon, 17 May 2021 22:55:27 +0000 (00:55 +0200)]
[Ada] Tune discovery of No_Elaboration_Code restriction

gcc/ada/

* lib-writ.adb (Write_ALI): Exit from loop after seeing first
unit that violates No_Elaboration_Code restriction.

3 years ago[Ada] Simplify iteration over pending instantiations
Piotr Trojanek [Mon, 17 May 2021 21:06:56 +0000 (23:06 +0200)]
[Ada] Simplify iteration over pending instantiations

gcc/ada/

* inline.adb (Instantiate_Bodies): Fix white in declaration.
(Remove_Dead_Instance): Change iteration from WHILE to FOR.

3 years ago[Ada] Transient scope cleanup
Bob Duff [Mon, 17 May 2021 16:42:20 +0000 (12:42 -0400)]
[Ada] Transient scope cleanup

gcc/ada/

* checks.adb, exp_attr.adb, exp_ch4.adb, exp_ch6.adb,
exp_ch9.adb, exp_disp.adb, exp_util.adb, inline.adb,
sem_res.adb: Change all calls to Make_Unchecked_Type_Conversion
to call Unchecked_Convert_To instead. This involves removing
New_Occurrence_Of on the first parameter, because
Unchecked_Convert_To expects a type entity, rather than the name
of one. Also, removed calls to Relocate_Node, because
Unchecked_Convert_To takes care of that.
* sinfo.ads: Change comment to be worded more firmly.

3 years ago[Ada] Unsynchronized access to a Boolean in tasking state
Steve Baird [Fri, 14 May 2021 22:03:02 +0000 (15:03 -0700)]
[Ada] Unsynchronized access to a Boolean in tasking state

gcc/ada/

* libgnarl/s-tassta.adb (Free_Task): Acquire the Task_Lock
before, rather than after, querying the task's Terminated flag.
Add a corresponding Task_Unlock call.

3 years agoaarch64: Remove a vestigial %K [PR101363]
Martin Sebor [Wed, 7 Jul 2021 14:49:13 +0000 (08:49 -0600)]
aarch64: Remove a vestigial %K [PR101363]

gcc/ChangeLog:
PR target/101363
* config/aarch64/aarch64.c (aarch64_simd_lane_bounds): Remove
a stray %K from error_at() missed in r12-2088.

3 years agotestsuite: gcc.dg/debug/btf/btf-bitfields-3.c remove -fno-short-enums PR debug/101321
Christophe Lyon [Wed, 7 Jul 2021 12:42:34 +0000 (12:42 +0000)]
testsuite: gcc.dg/debug/btf/btf-bitfields-3.c remove -fno-short-enums PR debug/101321

After r12-2094, -fno-short-enums is non longer necessary.

2021-07-07  Christophe Lyon  <christophe.lyon@foss.st.com>

PR debug/101321
gcc/testsuite/
* gcc.dg/debug/btf/btf-bitfields-3.c: Remove -fno-short-enums.

3 years agotree-optimization/34195 - testcase for fixed vectorization
Richard Biener [Wed, 7 Jul 2021 11:46:48 +0000 (13:46 +0200)]
tree-optimization/34195 - testcase for fixed vectorization

This adds a testcase for an old fixed PR.

2021-07-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/34195
* gcc.dg/vect/pr34195.c: New testcase.

3 years agotree-optimization/99728 - improve LIM for loops with aggregate copies
Richard Biener [Wed, 7 Jul 2021 09:41:03 +0000 (11:41 +0200)]
tree-optimization/99728 - improve LIM for loops with aggregate copies

This improves LIM by recording aggregate copies for disambiguation
purposes instead of as UNANALYZABLE_MEM which will prevent any
invariant or store motion across it.  This allows four of the six
references in the loop of the testcase to be promoted.

2021-07-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99728
* tree-ssa-loop-im.c (gather_mem_refs_stmt): Record
aggregate copies.
(mem_refs_may_alias_p): Add assert we handled aggregate
copies elsewhere.
(sm_seq_valid_bb): Give up when running into aggregate copies.
(ref_indep_loop_p): Handle aggregate copies as never
being invariant themselves but allow other refs to be
disambiguated against them.
(can_sm_ref_p): Do not try to apply store-motion to aggregate
copies.

* g++.dg/opt/pr99728.C: New testcase.

3 years agoAdd avx512 tests for MADDSUB and FMSUBADD SLP vectorization patterns.
liuhongt [Wed, 7 Jul 2021 07:19:42 +0000 (15:19 +0800)]
Add avx512 tests for MADDSUB and FMSUBADD SLP vectorization patterns.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512f-vect-fmaddsubXXXpd.c: New test.
* gcc.target/i386/avx512f-vect-fmaddsubXXXps.c: New test.
* gcc.target/i386/avx512f-vect-fmsubaddXXXpd.c: New test.
* gcc.target/i386/avx512f-vect-fmsubaddXXXps.c: New test.

3 years agoDaily bump.
GCC Administrator [Wed, 7 Jul 2021 00:17:12 +0000 (00:17 +0000)]
Daily bump.

3 years agoBTF testsuite: Remove explicit check on btm_type
Indu Bhagat [Tue, 6 Jul 2021 23:11:47 +0000 (16:11 -0700)]
BTF testsuite: Remove explicit check on btm_type

The value of btm_type is the BTF type ID of the referred type.  The order in
which the BTF types are added can change across platforms and also as the code
evolves, hence changing the BTF type ID. As there is no direct and portable
method of testing that a BTF type refers to another BTF type of a specific
kind, remove the explicit check on btm_type.

This patch adjusts the testcase without affecting the test coverage as other
testcases already have similar constructs. It also fixes a subset of failures
as seen on Darwin.

2021-07-06  Indu Bhagat  <indu.bhagat@oracle.com>

gcc/testsuite/ChangeLog:

PR debug/101283
* gcc.dg/debug/btf/btf-bitfields-3.c: Remove the check on btm_type.

3 years agoCTF testsuite: Remove explicit check on ctv_typeidx
Indu Bhagat [Tue, 6 Jul 2021 23:02:38 +0000 (16:02 -0700)]
CTF testsuite: Remove explicit check on ctv_typeidx

The value of ctv_typeidx is the CTF type ID of the data type of the associated
variable.  The order in which the CTF types are added can change across
platforms and also as the code evolves, hence changing the CTF type ID. As
there is no direct and portable method of testing that the data type of a CTF
variable is of a specific kind, remove the check on ctv_typeidx.

This also fixes a subset of failures as seen on Darwin.

2021-07-06  Indu Bhagat  <indu.bhagat@oracle.com>

gcc/testsuite/ChangeLog:

PR debug/101283
* gcc.dg/debug/ctf/ctf-attr-mode-1.c: Remove the check for ctv_typeidx.

3 years agoAdd test for [PR55881].
Martin Sebor [Tue, 6 Jul 2021 21:58:02 +0000 (15:58 -0600)]
Add test for [PR55881].

PR c++/55881

gcc/testsuite/ChangeLog:

* g++.dg/warn/uninit-pr55881.C: New test.

3 years agoAdd test for [PR86650].
Martin Sebor [Tue, 6 Jul 2021 21:15:53 +0000 (15:15 -0600)]
Add test for [PR86650].

PR tree-optimization/86650 - -Warray-bounds missing inlining context

gcc/testsuite/ChangeLog:
PR tree-optimization/86650
* gcc.dg/Warray-bounds-76.c: New test.

3 years agodwarf2ctf: the unit of sou field location is bits [PR101283]
Indu Bhagat [Tue, 6 Jul 2021 20:53:58 +0000 (13:53 -0700)]
dwarf2ctf: the unit of sou field location is bits [PR101283]

If the value of the DW_AT_data_member_location attribute is constant, the
associated unit is bytes. This patch amends incorrect behaviour which was being
exercised with -gdwarf-2. This caused some of the failures as noted in PR
debug/101283 (specifically the BTF tests involving btm_offset).

The testcase ctf-struct-array-2.c was erroneously checking for the value of
ctm_offset in number of bytes.

The patch fixes the calculation of the field location value for a struct member
in dwarf2ctf and adjusts the testcase. This patch also fixes some of the
failing tests as noted in PR debug/101283.

2021-07-06  Indu Bhagat  <indu.bhagat@oracle.com>

gcc/ChangeLog:

PR debug/101283
* dwarf2ctf.c (ctf_get_AT_data_member_location): Multiply by 8 to get
number of bits.

gcc/testsuite/ChangeLog:

PR debug/101283
* gcc.dg/debug/ctf/ctf-struct-array-2.c: Adjust the value in the testcase.

3 years agoRemove support for %G and %K.
Martin Sebor [Tue, 6 Jul 2021 20:13:31 +0000 (14:13 -0600)]
Remove support for %G and %K.

gcc/c-family/ChangeLog:

* c-format.c (gcc_tdiag_char_table): Remove support for %G and %K.
 (gcc_cdiag_char_table): Same.
 (gcc_cxxdiag_char_table): Same.

gcc/c/ChangeLog:

* c-objc-common.c (c_tree_printer): Remove support for %G and %K.

gcc/cp/ChangeLog:

* error.c (cp_printer):  Remove support for %G and %K.

gcc/ChangeLog:

* gimple-pretty-print.c (percent_G_format): Remove.
* tree-diagnostic.c (default_tree_printer): Remove calls.
* tree-pretty-print.c (percent_K_format): Remove.
* tree-pretty-print.h (percent_K_format): Remove.

gcc/testsuite/ChangeLog:

* gcc.dg/format/gcc_diag-10.c: Update expected warnings.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c: Remove %G.

3 years agoImprove warning suppression for inlined functions.
Martin Sebor [Tue, 6 Jul 2021 19:45:54 +0000 (13:45 -0600)]
Improve warning suppression for inlined functions.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.c (aarch64_simd_expand_builtin):
Remove %K and use error_at.
(aarch64_expand_fcmla_builtin): Same.
(aarch64_expand_builtin_tme): Same.
(aarch64_expand_builtin_memtag): Same.
* config/arm/arm-builtins.c (arm_expand_acle_builtin): Same.
(arm_expand_builtin): Same.
* config/arm/arm.c (bounds_check): Same.

3 years agoImprove warning suppression for inlined functions.
Martin Sebor [Tue, 6 Jul 2021 19:41:02 +0000 (13:41 -0600)]
Improve warning suppression for inlined functions.

Resolves:
PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration site
PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective in conjunction with alias attribute

gcc/ChangeLog:

* builtins.c (warn_string_no_nul): Remove %G.
(maybe_warn_for_bound): Same.
(warn_for_access): Same.
(check_access): Same.
(check_strncat_sizes): Same.
(expand_builtin_strncat): Same.
(expand_builtin_strncmp): Same.
(expand_builtin): Same.
(expand_builtin_object_size): Same.
(warn_dealloc_offset): Same.
(maybe_emit_free_warning): Same.
* calls.c (maybe_warn_alloc_args_overflow): Same.
(maybe_warn_nonstring_arg): Same.
(maybe_warn_rdwr_sizes): Same.
* expr.c (expand_expr_real_1): Remove %K.
* gimple-fold.c (gimple_fold_builtin_strncpy): Remove %G.
(gimple_fold_builtin_strncat): Same.
* gimple-ssa-sprintf.c (format_directive): Same.
(handle_printf_call): Same.
* gimple-ssa-warn-alloca.c (pass_walloca::execute): Same.
* gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same.
(maybe_diag_access_bounds): Same.  Call gimple_location.
(check_bounds_or_overlap): Same.
* trans-mem.c (ipa_tm_scan_irr_block): Remove %K.  Simplify.
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Remove %G.
* tree-ssa-strlen.c (maybe_warn_overflow): Same.
(maybe_diag_stxncpy_trunc): Same.
(handle_builtin_stxncpy_strncat): Same.
(maybe_warn_pointless_strcmp): Same.
* tree-ssa-uninit.c (maybe_warn_operand): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/Wobjsize-1.c: Prune expected output.
* gcc.dg/Warray-bounds-71.c: New test.
* gcc.dg/Warray-bounds-71.h: New test header.
* gcc.dg/Warray-bounds-72.c: New test.
* gcc.dg/Warray-bounds-73.c: New test.
* gcc.dg/Warray-bounds-74.c: New test.
* gcc.dg/Warray-bounds-75.c: New test.
* gcc.dg/Wfree-nonheap-object-4.c: Adjust expected output.
* gcc.dg/Wfree-nonheap-object-5.c: New test.
* gcc.dg/Wfree-nonheap-object-6.c: New test.
* gcc.dg/pragma-diag-10.c: New test.
* gcc.dg/pragma-diag-9.c: New test.
* gcc.dg/uninit-suppress_3.c: New test.
* gcc.dg/pr79214.c: Xfail tests.
* gcc.dg/tree-ssa/builtin-sprintf-warn-27.c: New test.
* gcc.dg/format/c90-printf-1.c: Adjust expected output.

3 years agofixincludes: AIX socket.h.
Clément Chigot [Mon, 5 Jul 2021 15:19:44 +0000 (11:19 -0400)]
fixincludes: AIX socket.h.

Add more context to aix_externcpp1 selection to ensure
that the fix is correctly applied even in future AIX versions.

fixincludes/Changelog:
2021-07-01  Clément Chigot  <clement.chigot@atos.net>

* inclhack.def (aix_externcpp1): Improve select regexp.
* fixincl.x: Regenerate.
* tests/base/sys/socket.h: Update.

3 years agoi386: Add variable vec_set for 32bit vectors [PR97194]
Uros Bizjak [Tue, 6 Jul 2021 17:27:34 +0000 (19:27 +0200)]
i386: Add variable vec_set for 32bit vectors [PR97194]

To generate sane code a SSE4.1 variable PBLENDV instruction is needed.

Also enable variable vec_set through vec_setm_operand predicate
for TARGET_SSE4_1 instead of TARGET_AVX2.  ix86_expand_vector_init_duplicate
is able to emulate vpbroadcast{b,w} with pxor/pshufb.

2021-07-06  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/97194
* config/i386/predicates.md (vec_setm_operand): Enable
register_operand for TARGET_SSE4_1.
* config/i386/mmx.md (vec_setv2hi): Use vec_setm_operand
as operand 2 predicate.  Call ix86_expand_vector_set_var
for non-constant index operand.
(vec_setv4qi): Use vec_setm_mmx_operand as operand 2 predicate.
Call ix86_expand_vector_set_var for non-constant index operand.

gcc/testsuite/

PR target/97194
* gcc.target/i386/sse4_1-vec-set-1a.c: New test.
* gcc.target/i386/sse4_1-vec-set-2a.c: Ditto.

3 years agoMAINTAINERS: Add myself for write after approval and DCO.
Gaius Mulley [Tue, 6 Jul 2021 15:47:36 +0000 (16:47 +0100)]
MAINTAINERS: Add myself for write after approval and DCO.

/
* MAINTAINERS: Add myself for write after approval and DCO.

2021-07-06  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoUse H8 nop moves as tst insns
Jeff Law [Tue, 6 Jul 2021 14:55:53 +0000 (10:55 -0400)]
Use H8 nop moves as tst insns

gcc
* config/h8300/jumpcall.md (*branch): When possible, generate
the comparison in CCZN mode.
* config/h8300/predicates.md (simple_memory_operand): Reject all
auto-increment addressing modes.

3 years ago[Ada] Initialize Current_Error_Node
Bob Duff [Mon, 17 May 2021 10:28:18 +0000 (06:28 -0400)]
[Ada] Initialize Current_Error_Node

gcc/ada/

* atree.ads (Current_Error_Node): Initialize to Empty.

3 years ago[Ada] Enable Ada 2020 Put_Image and Image support for tagged types
Steve Baird [Tue, 11 May 2021 18:45:06 +0000 (11:45 -0700)]
[Ada] Enable Ada 2020 Put_Image and Image support for tagged types

gcc/ada/

* exp_put_image.adb: Eliminate references to
Debug_Flag_Underscore_Z.  Change the meaning of the function
Enable_Put_Image. Previously, a result of False for a tagged
type would mean that the type does not get a Put_Image (PI)
routine at all. Now, it means that the type gets a PI routine
with very abbreviated functionality (just a call to
Unknown_Put_Image). This resolves problems in mixing code
compiled with and without the -gnat2022 switch.
* exp_ch3.adb: Enable_Put_Image no longer participates in
determining whether a tagged type gets a Put_Image procedure.  A
tagged type does not get a Put_Image procedure if the type
Root_Buffer_Type is unavailable. This is needed to support cross
targets where tagged types are supported but the type
Root_Buffer_Type is not available.
* exp_dist.adb: Add workarounds for some problems that arise
when using the (obsolete?) Garlic implementation of the
distributed systems annex with Ada 2022 constructs.
* libgnat/a-sttebu.ads: Workaround a bootstrapping problem.
Older compilers do not support raise expressions, so revise the
the Pre'Class condition to meet this requirement without
changing the condition's behavior at run time.

3 years ago[Ada] Fix old typo in comment
Eric Botcazou [Wed, 12 May 2021 21:37:20 +0000 (23:37 +0200)]
[Ada] Fix old typo in comment

gcc/ada/

* repinfo-input.adb (JSON_Entity_Kind, Read_Variant_Part): Fix
typo in comment.

3 years ago[Ada] Implement missing constraint checks for default streaming operations
Steve Baird [Tue, 11 May 2021 18:43:31 +0000 (11:43 -0700)]
[Ada] Implement missing constraint checks for default streaming operations

gcc/ada/

* sem_ch5.adb (Analyze_Assignment): Add new nested function,
Omit_Range_Check_For_Streaming, and make call to
Apply_Scalar_Range_Check conditional on the result of this new
function.
* exp_attr.adb (Compile_Stream_Body_In_Scope): Eliminate Check
parameter, update callers.  The new
Omit_Range_Check_For_Streaming parameter takes the place of the
old use of calling Insert_Action with Suppress => All_Checks,
which was insufficiently precise (it did not allow suppressing
checks for one component but not for another).
(Expand_N_Attribute_Reference): Eliminate another "Suppress =>
All_Checks" from an Insert_Action call, this one in generating
the expansion of a T'Read attribute reference for a composite
type T.

3 years ago[Ada] Warn on statically known empty loop caused by constraint
Ghjuvan Lacambre [Wed, 12 May 2021 12:43:06 +0000 (14:43 +0200)]
[Ada] Warn on statically known empty loop caused by constraint

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Check for
empty loops caused by constraints.

3 years ago[Ada] Handle malformed command line on Win32
Nicolas Roche [Tue, 11 May 2021 05:58:42 +0000 (07:58 +0200)]
[Ada] Handle malformed command line on Win32

gcc/ada/

* rtinit.c (skip_quoted_string): Handle malformed command line
with no closing double quote.
(skip_argument): Handle case in which a null character is
encountered by skip_quote_string.

3 years ago[Ada] Simplify code by removing local constant
Piotr Trojanek [Tue, 11 May 2021 14:53:36 +0000 (16:53 +0200)]
[Ada] Simplify code by removing local constant

gcc/ada/

* uname.adb (Add_Node_Name): Replace local constant whose
initial expression was evaluated even when unnecessary with just
that expression that is evaluated at most once and only when
needed.

3 years ago[Ada] Replace a question mark comment with assertion
Piotr Trojanek [Tue, 11 May 2021 12:11:12 +0000 (14:11 +0200)]
[Ada] Replace a question mark comment with assertion

gcc/ada/

* lib.adb (Remove_Unit): Replace defensive code with an
assertion.
* par-load.adb (Load): Address a question mark in the comment.

3 years ago[Ada] Simplify returning from Enclosing_Comp_Unit_Node
Piotr Trojanek [Tue, 11 May 2021 11:01:35 +0000 (13:01 +0200)]
[Ada] Simplify returning from Enclosing_Comp_Unit_Node

gcc/ada/

* sem_util.adb (Enclosing_Comp_Unit_Node): When the loop exits
the Current_Node is either an N_Compilation_Unit node or Empty,
so simply return it without redundant checks.

3 years ago[Ada] Simplify unit loading with membership tests
Piotr Trojanek [Mon, 10 May 2021 16:00:46 +0000 (18:00 +0200)]
[Ada] Simplify unit loading with membership tests

gcc/ada/

* lib-load.adb (Load_Unit): Remove excessive whitespace.
* lib.adb (Is_Internal_Unit, Is_Predefined_Unit): Likewise.
* par-ch10.adb (P_Compilation_Unit): Simplify with membership
test.
* par-load.adb (Load): Likewise.
* uname.adb (Get_Unit_Name): Likewise.

3 years ago[Ada] Simplify dependency on System
Piotr Trojanek [Mon, 10 May 2021 16:55:37 +0000 (18:55 +0200)]
[Ada] Simplify dependency on System

gcc/ada/

* lib-writ.adb (Ensure_System_Dependency): Simplify by reusing a
constant name.

3 years ago[Ada] Fix bug in casing on composite values with -gnatX
Steve Baird [Tue, 11 May 2021 21:27:09 +0000 (14:27 -0700)]
[Ada] Fix bug in casing on composite values with -gnatX

gcc/ada/

* exp_ch5.adb
(Expand_N_Case_Statement.Expand_General_Case_Statement.Pattern_Match):
When generating an equality test for a statically known discrete
value, only generate the numeric value if the discrete type is
not an enumeration type.  If it is an enumeration type, then
call Get_Enum_Lit_From_Pos instead.

3 years ago[Ada] Return_when_statement not working for non identifier return values
Justin Squirek [Fri, 7 May 2021 18:49:57 +0000 (14:49 -0400)]
[Ada] Return_when_statement not working for non identifier return values

gcc/ada/

* par-ch6.adb (Get_Return_Kind): Removed.
(Is_Extended): Created to identify simple and "when" return
statements from extended return statements.
(P_Return_Statement): Merged simple and "when" return statement
processing.

3 years ago[Ada] Regression on overloaded prefixed calls related to prefixed-call extension
Gary Dismukes [Tue, 11 May 2021 18:49:46 +0000 (14:49 -0400)]
[Ada] Regression on overloaded prefixed calls related to prefixed-call extension

gcc/ada/

* sem_ch4.adb (Try_One_Prefix_Interpretation): Augment test of
"not Extensions_Allowed" with test for absence of Obj_Type's
primitive operations Elist, as an additional condition for early
return from this procedure.

3 years ago[Ada] Reformatting, typo corrections, and minor rewording of a comment.
Gary Dismukes [Mon, 10 May 2021 19:14:38 +0000 (15:14 -0400)]
[Ada] Reformatting, typo corrections, and minor rewording of a comment.

gcc/ada/

* exp_ch4.adb (Process_Transient_In_Expression): In one comment,
fix two typos and reorder wording of one sentence, plus minor
reformatting.

3 years ago[Ada] Spurious initialization of element iterators in "for of" loops
Justin Squirek [Sat, 8 May 2021 04:28:55 +0000 (00:28 -0400)]
[Ada] Spurious initialization of element iterators in "for of" loops

gcc/ada/

* exp_ch5.adb (Expand_Formal_Container_Element_Loop): Remove
legacy expansion of element iterators, and use expansion form
used by unconstrained element types in the general case.

3 years ago[Ada] Crash on use of 'Img on record type in expression
Ed Schonberg [Mon, 10 May 2021 13:40:22 +0000 (09:40 -0400)]
[Ada] Crash on use of 'Img on record type in expression

gcc/ada/

* exp_ch4.adb (Process_Transient_In_Expression): Ensure that
Fin_Context, used to insert finalization code for the
expression, is a list member: the value returned by
Find_Hook_Context may be an expression node when the transient
is part of a larger expression and it has a non-boolean type.

3 years ago[Ada] Missing space in error message for pattern matching
Yannick Moy [Mon, 10 May 2021 12:36:25 +0000 (14:36 +0200)]
[Ada] Missing space in error message for pattern matching

gcc/ada/

* sem_case.adb: Fix error message.

3 years ago[Ada] Tbuild cleanup
Bob Duff [Sat, 8 May 2021 15:39:52 +0000 (11:39 -0400)]
[Ada] Tbuild cleanup

gcc/ada/

* tbuild.adb (Convert_To): Add assert, along with a comment.
(Make_DT_Access): Remove this function, which is not used.  It
was incorrect anyway (the call to New_Occurrence_Of should not
be there).
(Unchecked_Convert_To): Add assert.  The previous version's test
for unchecked conversion to the same type was redundant and
could never be true, because the previous 'if' already checked
for ANY expression of the same type. Remove that, and replace
with a test for unchecked conversion to a related type.
Otherwise, we somethings get things like
"finalize(some_type!(some_type!(x)))" in the generated code,
where x is already of type some_type, but we're converting it to
the private type and then to the full type or vice versa (so the
types aren't equal, so the previous 'if' doesn't catch it).
Avoid updating the Parent. This is not necessary; the Parent
will be updated if/when the node is attached to the tree.
* tbuild.ads: Fix comments. No need to say "this is safe" when
we just explained that a few lines earlier.  Remove
Make_DT_Access.
* sinfo.ads: Add comments.
* exp_ch7.adb (Make_Finalize_Address_Stmts): Minor comment fix.
* gen_il-gen.adb, gen_il-gen.ads, gen_il-gen-gen_nodes.adb,
gen_il-internals.ads: Implement a feature where you can put:
Nmake_Assert => "expr" where expr is a boolean expression in a
call to Create_Concrete_Node_Type. It is added in a pragma
Assert in the Nmake.Make_... function for that type.

3 years ago[Ada] Removal of various ??? comments plus related code changes
Gary Dismukes [Sat, 8 May 2021 21:49:04 +0000 (17:49 -0400)]
[Ada] Removal of various ??? comments plus related code changes

gcc/ada/

* checks.adb: Remove calls of Set_Do_Tag_Check (N, False).
* einfo.ads: Remove hanging unneeded ??? comment ("this real description
was clobbered").
* exp_util.ads (Insert_Actions_After): Remove ??? from spec comment.
* gen_il-fields.ads (Opt_Field_Enum): Remove literals
Do_Accessibility_Check and Do_Tag_Check.
* gen_il-gen-gen_nodes.adb: Remove all calls to Sm for
Do_Accessibility_Check and Do_Tag_Check.
* sem_type.ads (Is_Subtype_Of): Remove obsolete ???
comment (function is not limited to scalar subtypes).
* sem_util.ads (Is_Local_Variable_Reference): Revise comment to
mention out-mode parameters as well, and remove ???.
(Propagate_Concurrent_Flags): Minor reformatting.
(Propagate_Invariant_Attributes): Typo fix.
(Propagate_Predicate_Attributes): Indicate what is propagated
and remove ??? comment.
* sem_util.adb (Cannot_Raise_Constraint_Error): Remove unneeded
test of Do_Tag_Check.
(Is_Local_Variable_Reference): Extend function to testing for
formals of mode out as well.
* sinfo.ads: Remove ??? comment about flag
Convert_To_Return_False indicating that the flag is obsolete (in
fact it's used). Remove references to Do_Accessibility_Check and
Do_Tag_Check (and the two associated ??? comments), as these
flags are unneeded.
* sinfo-cn.adb (Change_Conversion_To_Unchecked): Remove call of
Set_Do_Tag_Check (N, False).
* targparm.ads (Support_Atomic_Primitives_On_Target): Remove ???
comment, plus minor reformatting.

3 years ago[Ada] Return when not working for procedures
Justin Squirek [Fri, 7 May 2021 16:26:09 +0000 (12:26 -0400)]
[Ada] Return when not working for procedures

gcc/ada/

* par-ch6.adb (Get_Return_Kind): Properly handle the case of a
"return when" statement in the procedure case.

3 years ago[Ada] Transient scope cleanup
Bob Duff [Fri, 7 May 2021 14:41:03 +0000 (10:41 -0400)]
[Ada] Transient scope cleanup

gcc/ada/

* sem.ads (Node_To_Be_Wrapped): Minor comment fix.
* exp_ch7.adb (Establish_Transient_Scope): Misc cleanups and
comment improvements.
(Set_Node_To_Be_Wrapped): Remove -- not worth putting this code
in a separate procedure, called only once.
* sem_util.adb (Requires_Transient_Scope): Assert that our
parameter has the right Kind. It probably shouldn't be E_Void,
but that is passed in in some cases.
(Ensure_Minimum_Decoration): Move the call later, so we know Typ
is Present, and remove "if Present (Typ)" from this procedure.
* exp_aggr.adb (Convert_To_Assignments): Use membership test,
and avoid the "if False" idiom.
(Expand_Array_Aggregate): Remove a ??? comment.
* sem_ch8.adb (Push_Scope): Take advantage of the full coverage
rules for aggregates.
* sem_res.adb (Resolve_Declare_Expression): Remove test for
Is_Type -- that's all it can be.  Use named notation in call to
Establish_Transient_Scope.
* libgnat/a-cdlili.adb (Adjust): Remove redundant code.
(Clear): Remove "pragma Warnings (Off);", which wasn't actually
suppressing any warnings.

3 years ago[Ada] Make parent of N_Exception_Declaration be N_Declaration
Bob Duff [Wed, 5 May 2021 22:29:28 +0000 (18:29 -0400)]
[Ada] Make parent of N_Exception_Declaration be N_Declaration

gcc/ada/

* gen_il-gen-gen_nodes.adb: Change the parent of
N_Exception_Declaration to be N_Declaration.  Minor comment fix.