platform/upstream/gcc.git
4 years agoFix PR94880: Failure to recognize andn pattern
Przemyslaw Wirkus [Fri, 19 Jun 2020 15:48:55 +0000 (16:48 +0100)]
Fix PR94880: Failure to recognize andn pattern

Pattern "(x | y) - y" can be optimized to simple "(x & ~y)" andn
pattern.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/94880
* match.pd (A | B) - B -> (A & ~B): New simplification.

gcc/testsuite/ChangeLog:

PR tree-optimization/94880
* gcc.dg/tree-ssa/pr94880.c: New Test.

4 years agoHandle SLP_TREE_LANE_PERMUTATION in scalar costing
Richard Biener [Mon, 20 Apr 2020 08:05:06 +0000 (10:05 +0200)]
Handle SLP_TREE_LANE_PERMUTATION in scalar costing

This properly handles a lane permutation in scalar costing.
For the current only use this doesn't matter much but with
permutes that change the number of lanes it will eventually
ICE.

2020-06-19  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_bb_slp_scalar_cost): Adjust
for lane permutations.

4 years agolibstdc++: Remove redundant std:: qualification
Jonathan Wakely [Fri, 19 Jun 2020 14:02:54 +0000 (15:02 +0100)]
libstdc++: Remove redundant std:: qualification

* include/bits/stl_pair.h (_Index_tuple): Remove redundant
namespace qualification.
(pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)):
Likewise.
* include/std/tuple (_Head_base, _Tuple_impl, tuple_size)
(tuple_element, __get_helper, get, __make_tuple_impl)
(__make_1st_indices, __tuple_concater)
(pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)):
Likewise.
* include/std/utility (tuple_element, __is_tuple_like_impl)
(tuple_size, __pair_get, get): Likewise.

4 years agolibstdc++: Define all std::function members inline
Jonathan Wakely [Fri, 19 Jun 2020 13:37:52 +0000 (14:37 +0100)]
libstdc++: Define all std::function members inline

* include/bits/std_function.h (function): Define all member
functions inline.

4 years agolibstdc++: std::includes performance tweak
Marc Glisse [Fri, 19 Jun 2020 12:03:45 +0000 (13:03 +0100)]
libstdc++: std::includes performance tweak

A small tweak to the implementation of __includes, which in my
application saves 20% of the running time. I noticed it because using
range-v3 was giving unexpected performance gains.

Some of the gain comes from pulling the 2 calls ++__first1 out of the
condition so there is just one call. And most of the gain comes from
replacing the resulting

if (__comp(__first1, __first2))
  ;
else
  ++__first2;

with

if (!__comp(__first1, __first2))
  ++__first2;

I was very surprised that the code ended up being so different for such
a change, and I still don't really understand where the extra time is
going...

Anyway, while I blame the compiler for not generating very good code
with the current implementation, I believe the change can be seen as a
simplification.

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (__includes): Simplify the code.

4 years agotree-optimization/95761 - fix vector insertion place compute
Richard Biener [Fri, 19 Jun 2020 08:03:46 +0000 (10:03 +0200)]
tree-optimization/95761 - fix vector insertion place compute

I missed that indeed SLP permutation code generation can end up
refering to a non-last vectorized stmt in the last SLP_TREE_VEC_STMTS
element as optimization.  So walk them all.

2020-06-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95761
* tree-vect-slp.c (vect_schedule_slp_instance): Walk all
vectorized stmts for finding the last one.

* gcc.dg/torture/pr95761.c: New testcase.

4 years agolibstdc++: Optimize std::optional default constructor
Marc Glisse [Fri, 19 Jun 2020 11:07:33 +0000 (12:07 +0100)]
libstdc++: Optimize std::optional default constructor

The attached patch changes the code generated for

std::optional<std::array<int,1024>>f(){return{};}

from

        movq    $0, (%rdi)
        movq    %rdi, %r8
        leaq    8(%rdi), %rdi
        xorl    %eax, %eax
        movq    $0, 4084(%rdi)
        movq    %r8, %rcx
        andq    $-8, %rdi
        subq    %rdi, %rcx
        addl    $4100, %ecx
        shrl    $3, %ecx
        rep stosq
        movq    %r8, %rax

or with different tuning

        subq    $8, %rsp
        movl    $4100, %edx
        xorl    %esi, %esi
        call    memset
        addq    $8, %rsp

to the much shorter

        movb    $0, 4096(%rdi)
        movq    %rdi, %rax

i.e. the same as the nullopt constructor.

The constructor was already non-trivial, so we don't lose that. It passes the
testsuite without regression, but there is no new testcase to verify the
better codegen.

libstdc++-v3/ChangeLog:

* include/std/optional (optional()): Explicitly define it.

4 years ago[Ada] Remove handling of 'Pos and 'Val attributes from gigi
Eric Botcazou [Fri, 10 Apr 2020 09:19:22 +0000 (09:19 +0000)]
[Ada] Remove handling of 'Pos and 'Val attributes from gigi

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* gcc-interface/trans.c (lvalue_required_for_attribute_p): Do not deal
with 'Pos or 'Val.
(Attribute_to_gnu): Likewise.
* gcc-interface/utils.c (create_field_decl): Small formatting fix.

4 years ago[Ada] Consolidate handling of implicit dereferences
Eric Botcazou [Mon, 9 Mar 2020 17:20:59 +0000 (17:20 +0000)]
[Ada] Consolidate handling of implicit dereferences

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* gcc-interface/trans.c (adjust_for_implicit_deref): Delete.
(maybe_implicit_deref): Likewise.
(Attribute_to_gnu): Replace calls to maybe_implicit_deref by calls
to maybe_padded_object.
(Call_to_gnu): Likewise.
(gnat_to_gnu) <N_Indexed_Component>: Likewise.
<N_Slice>: Likewise.
<N_Selected_Component>: Likewise.
<N_Free_Statement>: Remove call to adjust_for_implicit_deref and
manually make sure that the designated type is complete.
* gcc-interface/utils2.c (build_simple_component_ref): Add comment.

4 years ago[Ada] AI12-0028-1 Import of variadic C functions
Eric Botcazou [Tue, 3 Mar 2020 17:57:51 +0000 (17:57 +0000)]
[Ada] AI12-0028-1 Import of variadic C functions

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* gcc-interface/decl.c (gnat_to_gnu_param): Tidy up.
(gnat_to_gnu_subprog_type): For a variadic C function, do not
build unnamed parameters and do not add final void node.
* gcc-interface/misc.c: Include snames.h.
* gcc-interface/trans.c (Attribute_to_gnu): Tidy up.
(Call_to_gnu): Implement support for unnamed parameters in a
variadic C function.
* gcc-interface/utils.c: Include snames.h.
(copy_type): Tidy up.

4 years ago[Ada] Further cleanup in constraint checking code for allocators
Eric Botcazou [Sun, 3 May 2020 21:26:11 +0000 (23:26 +0200)]
[Ada] Further cleanup in constraint checking code for allocators

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch5.adb (Expand_N_Assignment_Statement): Do not apply
range checks to allocators here.

4 years ago[Ada] Crash on compiling project with multiple subunits per file
Justin Squirek [Sat, 2 May 2020 21:17:24 +0000 (17:17 -0400)]
[Ada] Crash on compiling project with multiple subunits per file

2020-06-19  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* lib.adb (Check_Same_Extended_Unit): Add check to determine if
the body for the subunits exist in the same file as their
specifications.

4 years ago[Ada] Fix check for bounds in aggregate expansion of allocator
Eric Botcazou [Sat, 2 May 2020 15:45:21 +0000 (17:45 +0200)]
[Ada] Fix check for bounds in aggregate expansion of allocator

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_aggr.adb (In_Place_Assign_OK): In an allocator context,
check the bounds of an array aggregate against those of the
designated type, except if the latter is unconstrained.

4 years ago[Ada] Fix small fallout of previous change for Analyze_Selected_Component
Eric Botcazou [Sat, 2 May 2020 15:35:02 +0000 (17:35 +0200)]
[Ada] Fix small fallout of previous change for Analyze_Selected_Component

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch3.adb (Is_Visible_Component): Reason only on the private
status of the original type in an instance body.

4 years ago[Ada] Fix small fallout of previous change for allocator
Eric Botcazou [Sat, 2 May 2020 09:35:42 +0000 (11:35 +0200)]
[Ada] Fix small fallout of previous change for allocator

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_res.adb (Resolve_Qualified_Expression): Do not override the
type of the node when it is unconstrained if it is for an allocator.

4 years ago[Ada] Plug small loophole in implementation of AI12-0100
Eric Botcazou [Fri, 1 May 2020 13:26:08 +0000 (15:26 +0200)]
[Ada] Plug small loophole in implementation of AI12-0100

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_res.adb (Resolve_Allocator): Call Resolve_Qualified_Expression
on the qualified expression, if any, instead of doing an incomplete
type resolution manually.
(Resolve_Qualified_Expression): Apply predicate check to operand.

4 years ago[Ada] Fix internal error on component of class-wide parameter in instance body
Eric Botcazou [Thu, 30 Apr 2020 22:27:12 +0000 (00:27 +0200)]
[Ada] Fix internal error on component of class-wide parameter in instance body

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch4.adb (Analyze_Selected_Component): In an instance body,
also invoke Find_Component_In_Instance on the parent subtype of
a derived tagged type immediately visible.  Remove obsolete case.

4 years ago[Ada] Deal with enumeration types with very large size
Eric Botcazou [Wed, 29 Apr 2020 19:42:22 +0000 (21:42 +0200)]
[Ada] Deal with enumeration types with very large size

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_attr.adb (Get_Integer_Type): Return the largest supported
unsigned integer type if need be.

4 years ago[Ada] Spurious condition warning on type conversion in return
Justin Squirek [Thu, 30 Apr 2020 20:04:26 +0000 (16:04 -0400)]
[Ada] Spurious condition warning on type conversion in return

2020-06-19  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* sem_warn.adb (Warn_On_Known_Condition): Add general sanity
check that asserts the original source node being checked
contains an entity. If not, it could be the result of special
case expansion for type conversions.

4 years ago[Ada] Spurious error on private type in ghost expression function
Ed Schonberg [Thu, 30 Apr 2020 19:19:16 +0000 (15:19 -0400)]
[Ada] Spurious error on private type in ghost expression function

2020-06-19  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Do not indicate
that the function has a completion if it appears within a Ghost
generic package.

4 years ago[Ada] AI12-0293-1 Remove pragma Assert
Bob Duff [Thu, 30 Apr 2020 18:40:26 +0000 (14:40 -0400)]
[Ada] AI12-0293-1 Remove pragma Assert

2020-06-19  Bob Duff  <duff@adacore.com>

gcc/ada/

* libgnat/a-ststbo.adb (Write): Replace pragma Assert with "if
... raise Constraint_Error".

4 years ago[Ada] Style checks on invalid UTF character cause crash
Justin Squirek [Thu, 30 Apr 2020 12:55:33 +0000 (08:55 -0400)]
[Ada] Style checks on invalid UTF character cause crash

2020-06-19  Justin Squirek  <squirek@adacore.com>

gcc/ada/

* widechar.adb, widechar.ads (Skip_Wide): Catch validity check
failure when skipping over characters, and update comment to
reflect Skip_Wide's usage in error printing.

4 years ago[Ada] ACATS 4.1G - C760A02 - Near infinite finalization
Javier Miranda [Thu, 30 Apr 2020 15:55:42 +0000 (11:55 -0400)]
[Ada] ACATS 4.1G - C760A02 - Near infinite finalization

2020-06-19  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* exp_ch3.ads (Ensure_Activation_Chain_And_Master): New
subprogram.
* exp_ch3.adb (Ensure_Activation_Chain_And_Master): New
subprogram that factorizes code.
(Expand_N_Object_Declaration): Call new subprogram.
* sem_ch6.adb (Analyze_Function_Return): Returning a
build-in-place unconstrained array type defer the full analysis
of the returned object to avoid generating the corresponding
constrained subtype; otherwise the bounds would be created in
the stack and a dangling reference would be returned pointing to
the bounds.

4 years ago[Ada] AI12-0366 Changes to Big_Integer and Big_Real
Arnaud Charlet [Wed, 29 Apr 2020 16:38:22 +0000 (12:38 -0400)]
[Ada] AI12-0366 Changes to Big_Integer and Big_Real

2020-06-19  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* libgnat/a-nbnbin.adb, libgnat/a-nbnbin.ads,
libgnat/a-nbnbin__gmp.adb, libgnat/a-nbnbre.adb,
libgnat/a-nbnbre.ads: Update spec according to AI12-0366.

4 years ago[Ada] Minor remove extra whitespace in check suppression functions
Piotr Trojanek [Wed, 29 Apr 2020 16:52:22 +0000 (18:52 +0200)]
[Ada] Minor remove extra whitespace in check suppression functions

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.ads: Remove excessive whitespace in declarations of
functions for check suppression.

4 years ago[Ada] Attempt to hide public entities in nested instance bodies
Eric Botcazou [Tue, 28 Apr 2020 20:19:17 +0000 (22:19 +0200)]
[Ada] Attempt to hide public entities in nested instance bodies

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch7.adb (Hide_Public_Entities): Split handling of objects
and subprograms, and do not reject the latter upfront in nested
instance specs if there are no referencer subprograms at all.
(Analyze_Package_Body_Helper): Also call Hide_Public_Entities on
nested generic instances.

4 years ago[Ada] Reject junk expressions in attribute Update
Piotr Trojanek [Wed, 29 Apr 2020 09:30:46 +0000 (11:30 +0200)]
[Ada] Reject junk expressions in attribute Update

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Reject illegal positional
component associations; fix syntax in comment about named
component associations.

4 years ago[Ada] Decorate record delta aggregate for GNATprove
Piotr Trojanek [Tue, 28 Apr 2020 16:10:10 +0000 (18:10 +0200)]
[Ada] Decorate record delta aggregate for GNATprove

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* sem_aggr.adb (Resolve_Delta_Record_Aggregate): Modify a nested
Get_Component_Type routine to return a component and not just
its type; use this routine to decorate the identifier within the
delta aggregate.

4 years ago[Ada] universal_access equality and 'Access attributes
Arnaud Charlet [Sun, 26 Apr 2020 10:08:29 +0000 (06:08 -0400)]
[Ada] universal_access equality and 'Access attributes

2020-06-19  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_ch4.adb (Find_Equality_Types.Check_Access_Attribute): New.
(Find_Equality_Types): Move universal_access related checks at
the end of the processing and add call to
Check_Access_Attribute.

4 years ago[Ada] Remove second warning for convention C_Variadic_n
Eric Botcazou [Tue, 28 Apr 2020 18:51:51 +0000 (20:51 +0200)]
[Ada] Remove second warning for convention C_Variadic_n

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_prag.adb (Process_Convention): Revert previous change.

4 years ago[Ada] Small cleanup in Apply_Range_Check implementation
Eric Botcazou [Sat, 25 Apr 2020 15:10:43 +0000 (17:10 +0200)]
[Ada] Small cleanup in Apply_Range_Check implementation

2020-06-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* checks.ads (Apply_Static_Length_Check): Move up.
(Apply_Range_Check): Add parameter Insert_Node.
* checks.adb (Apply_Selected_Range_Checks): Merge into...
(Apply_Range_Check): ...this.  Add parameter Insert_Node,
pass it as Warn_Node to Selected_Range_Checks and use it
as insertion point for the checks.
* sem_ch3.adb (Analyze_Subtype_Declaration): Rewrite block
dealing with the range checks for the subtype indication.
Use local variable and call Apply_Range_Check in both cases.

4 years ago[Ada] Fix validity checks on attribute 'Old prefix
Piotr Trojanek [Mon, 27 Apr 2020 12:22:53 +0000 (14:22 +0200)]
[Ada] Fix validity checks on attribute 'Old prefix

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Call Ensure_Valid
on the expression of an object declaration that captures the
value of 'Old prefix.

4 years ago[Ada] Add comments about attribute 'Valid_Scalars on private tagged types
Piotr Trojanek [Mon, 27 Apr 2020 09:30:06 +0000 (11:30 +0200)]
[Ada] Add comments about attribute 'Valid_Scalars on private tagged types

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Add comment.
* sem_attr.adb (Analyze_Attribute): Add ??? comment.
* sem_util.ads (Valid_Scalars): This routine is only used for
'Valid_Scalars and not for 'Valid.

4 years ago[Ada] Simplify processing of 'Valid_Scalars on array types
Piotr Trojanek [Mon, 27 Apr 2020 09:14:31 +0000 (11:14 +0200)]
[Ada] Simplify processing of 'Valid_Scalars on array types

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Do not call
Scalar_Part_Present on the array component's type.
(Build_Array_VS_Func): Remove Comp_Typ parameter, because it can
be easily computed from the Array_Top parameter *and redundant
parameters are confusing and error-prone).

4 years ago[Ada] Fix validity checking for class-wide objects
Piotr Trojanek [Mon, 27 Apr 2020 07:56:17 +0000 (09:56 +0200)]
[Ada] Fix validity checking for class-wide objects

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* exp_attr.adb (Build_Record_VS_Func): Strip privacy and type
derivation from the root type when 'Valid_Scalars is applied to
a class-wide type.

4 years ago[Ada] Remove repeated testing of Check_Validity_Of_Parameters
Piotr Trojanek [Fri, 24 Apr 2020 15:36:24 +0000 (17:36 +0200)]
[Ada] Remove repeated testing of Check_Validity_Of_Parameters

2020-06-19  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb (Apply_Parameter_Validity_Checks): Remove testing
of Check_Validity_Of_Parameters for every formal parameter and
function result.

4 years ago[Ada] Add missing warning tag for some overlapping actuals warnings
Arnaud Charlet [Fri, 24 Apr 2020 16:17:51 +0000 (12:17 -0400)]
[Ada] Add missing warning tag for some overlapping actuals warnings

2020-06-19  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_warn.adb (Warn_On_Overlapping_Actuals): Add missing
warning tag.

4 years agoDaily bump.
GCC Administrator [Fri, 19 Jun 2020 00:16:32 +0000 (00:16 +0000)]
Daily bump.

4 years agoc++: More P2002 operator<=> refinements.
Jason Merrill [Wed, 17 Jun 2020 20:22:33 +0000 (16:22 -0400)]
c++: More P2002 operator<=> refinements.

* Disallow && references.
* Allow empty unions.
* Improve diagnostics for a subobject comparison with
  non-comparison-category type.

gcc/cp/ChangeLog:

* method.c (early_check_defaulted_comparison): Check for &&.
(build_comparison_op): Allow empty union.  Diagnose non-category
type.
(common_comparison_type): Remove handling for non-category type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-ref1.C: New test.
* g++.dg/cpp2a/spaceship-synth-neg4.C: New test.
* g++.dg/cpp2a/spaceship-union1.C: New test.

4 years agovect: Use vect_relevant_for_alignment_p consistently
Fei Yang [Thu, 18 Jun 2020 19:11:09 +0000 (20:11 +0100)]
vect: Use vect_relevant_for_alignment_p consistently

Minor code refactorings in tree-vect-data-refs.c.  When trying loop peeling
to force alignment, call vect_relevant_for_alignment_p to filter out data
references in the loop whose alignment is irrelevant.

2020-06-18  Felix Yang  <felix.yang@huawei.com>

gcc/
* tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Call
vect_relevant_for_alignment_p to filter out data references in
the loop whose alignment is irrelevant when trying loop peeling
to force alignment.

4 years agoi386: Fix mode of ZERO_EXTRACT RTXes, remove ext_register_operand predicate.
Uros Bizjak [Thu, 18 Jun 2020 18:12:48 +0000 (20:12 +0200)]
i386: Fix mode of ZERO_EXTRACT RTXes, remove ext_register_operand predicate.

The mode of ZERO_EXTRACT RTX should match the mode of its LOC register
operand.  The mode should be HI, SI or DImode to enable combine to synthesize
extractions from HImode and DImode operands, in addition to existing SImode.
Further, these changes tighten allowed modes for extv, extzv and insv
named patterns and finally enable removal of ext_register_operand
special predicate.

2020-18-06  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/i386.md (*cmpqi_ext<mode>_1): Use SWI248 mode
iterator instead of SImode for ZERO_EXTRACT RTX.  Use SWI248
mode iterator for the first operand of ZERO_EXTRACT RTX.
Change ext_register_operand predicate to register_operand.
Rename from *cmpqi_ext_1.
(*cmpqi_ext<mode>_2): Ditto.  Rename from *cmpqi_ext_2.
(*cmpqi_ext<mode>_3): Ditto.  Rename from *cmpqi_ext_3.
(*cmpqi_ext<mode>_4): Ditto.  Rename from *cmpqi_ext_4.
(cmpi_ext_3): Use HImode instead of SImode for ZERO_EXTRACT RTX.
(*extv<mode>): Use SWI24 mode iterator for the first operand
of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.
(*extzv<mode>): Use SWI248 mode iterator for the first operand
of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.
(*extzvqi): Use SWI248 mode iterator instead of SImode for
ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the first operand
of ZERO_EXTRACT RTX.  Change ext_register_operand predicate to
register_operand.
(*extzvqi_mem_rex64 and corresponding peephole2):  Use SWI248 mode
iterator instead of SImode for ZERO_EXTRACT RTX.  Use SWI248
mode iterator for the first operand of ZERO_EXTRACT RTX.
Change ext_register_operand predicate to register_operand.
(@insv<mode>_1): Use SWI248 mode iterator for the first operand
of ZERO_EXTRACT RTX.  Change ext_register_operand predicate to
register_operand.
(*insvqi_1): Use SWI248 mode iterator instead of SImode
for ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the
first operand of ZERO_EXTRACT RTX.  Change ext_register_operand
predicate to register_operand.
(*insvqi_2): Ditto.
(*insvqi_3): Ditto.
(*insvqi_1_mem_rex64 and corresponding peephole2):  Use SWI248 mode
iterator instead of SImode for ZERO_EXTRACT RTX.  Use SWI248
mode iterator for the first operand of ZERO_EXTRACT RTX.
Change ext_register_operand predicate to register_operand.
(addqi_ext_1): New expander.
(*addqi_ext<mode>_1): Use SWI248 mode iterator instead of SImode
for ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the first
operand of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.  Rename from *addqi_ext_1.
(*addqi_ext<mode>_2): Ditto. Rename from *addqi_ext_2.
(divmodqi4): Use HImode instead of SImode for ZERO_EXTRACT RTX.
(udivmodqi4): Ditto.
(testqi_ext_1): Use HImode instead of SImode for ZERO_EXTRACT RTX.
(*testqi_ext<mode>_1): Use SWI248 mode iterator instead of SImode
for ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the first
operand of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.  Rename from *testqi_ext_1.
(*testqi_ext<mode>_2): Ditto.  Rename from *testqi_ext_2.
(andqi_ext_1): New expander.
(*andqi_ext<mode>_1): Use SWI248 mode iterator instead of SImode
for ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the first
operand of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.  Rename from andqi_ext_1.
(*andqi_ext<mode>_1_cc): Ditto.  Rename from *andqi_ext_1_cc.
(*andqi_ext<mode>_2): Ditto.  Rename from *andqi_ext_2.
(*<code>qi_ext<mode>_1): Ditto.  Rename from *<code>qi_ext_1.
(*<code>qi_ext<mode>_2): Ditto.  Rename from *<code>qi_ext_2.
(xorqi_ext_1_cc): Use HImode instead of SImode for ZERO_EXTRACT RTX.
(*xorqi_ext<mode>_1_cc):  Use SWI248 mode iterator instead of SImode
for ZERO_EXTRACT RTX.  Use SWI248 mode iterator for the first
operand of ZERO_EXTRACT RTX.  Change ext_register_operand predicate
to register_operand.  Rename from *xorqi_ext_1_cc.
* config/i386/i386-expand.c (ix86_split_idivmod): Emit ZERO_EXTRACT
in mode, matching its first operand.
(promote_duplicated_reg): Update for renamed insv<mode>_1.
* config/i386/predicates.md (ext_register_operand): Remove predicate.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr78904-1a.c: New test.
* gcc.target/i386/pr78904-1b.c: Ditto.
* gcc.target/i386/pr78904-2a.c: Ditto.
* gcc.target/i386/pr78904-2b.c: Ditto.
* gcc.target/i386/pr78904-3a.c: Ditto.
* gcc.target/i386/pr78904-3b.c: Ditto.
* gcc.target/i386/pr78904-4a.c: Ditto.
* gcc.target/i386/pr78904-4b.c: Ditto.
* gcc.target/i386/pr78904-5a.c: Ditto.
* gcc.target/i386/pr78904-5b.c: Ditto.
* gcc.target/i386/pr78904-6a.c: Ditto.
* gcc.target/i386/pr78904-6b.c: Ditto.
* gcc.target/i386/pr78967-1a.c: Ditto.
* gcc.target/i386/pr78967-1b.c: Ditto.
* gcc.target/i386/pr78967-2a.c: Ditto.
* gcc.target/i386/pr78967-2b.c: Ditto.

4 years agoAvoid warning for memset writing over multiple members.
Martin Sebor [Thu, 18 Jun 2020 18:00:36 +0000 (12:00 -0600)]
Avoid warning for memset writing over multiple members.

Resolves:
PR middle-end/95667 - unintended warning for memset writing across multiple members
PR middle-end/92814 - missing -Wstringop-overflow writing into a dynamically allocated flexible array member

gcc/ChangeLog:

PR middle-end/95667
PR middle-end/92814
* builtins.c (compute_objsize): Remove call to
compute_builtin_object_size and instead compute conservative sizes
directly here.

gcc/testsuite/ChangeLog:

PR middle-end/95667
PR middle-end/92814
* gcc.dg/Wstringop-overflow-25.c: Remove xfails.
* gcc.dg/Wstringop-overflow-39.c: New test.

4 years agoc++: ICE in requires-expressions with invalid args [PR95735]
Marek Polacek [Thu, 18 Jun 2020 13:38:42 +0000 (09:38 -0400)]
c++: ICE in requires-expressions with invalid args [PR95735]

This ICE-on-invalid goes back to GCC 6.  In finish_template_variable,
if coerce_innermost_template_parms returns error_mark_node, we pass
it down to constraints_satisfied_p and that error_mark_node flows
down to various satisfy_* functions and then to various tsubst_*
functions, where we crash.  diagnose_constraints also doesn't cope
with error arglist, so I think we should just return as in the
patch below.

gcc/cp/ChangeLog:

PR c++/95735
* pt.c (finish_template_variable): Return if
coerce_innermost_template_parms return error_mark_node.

gcc/testsuite/ChangeLog:

PR c++/95735
* g++.dg/cpp2a/concepts-err2.C: New test.

4 years agoFix use of inaccessible member in pr94052.C
Christophe Lyon [Thu, 18 Jun 2020 15:25:18 +0000 (15:25 +0000)]
Fix use of inaccessible member in pr94052.C

The recent PR41437 fix exposed a latent use of an inaccessible member in
the below testcase.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/pr94052.C: Give z::ad public access.

4 years agovectorizer: add _bb_vec_info::region_stmts and reverse_region_stmts
Martin Liska [Thu, 11 Jun 2020 11:25:40 +0000 (13:25 +0200)]
vectorizer: add _bb_vec_info::region_stmts and reverse_region_stmts

gcc/ChangeLog:

* coretypes.h (struct iterator_range): New type.
* tree-vect-patterns.c (vect_determine_precisions): Use
range-based iterator.
(vect_pattern_recog): Likewise.
* tree-vect-slp.c (_bb_vec_info):  Likewise.
(_bb_vec_info::~_bb_vec_info): Likewise.
(vect_slp_check_for_constructors): Likewise.
* tree-vectorizer.h:Add new iterators
and functions that use it.

4 years agoAdd missing PR number to ChangeLog (PR 95378)
Jonathan Wakely [Thu, 18 Jun 2020 14:34:51 +0000 (15:34 +0100)]
Add missing PR number to ChangeLog (PR 95378)

gcc/c-family/ChangeLog:

* ChangeLog:

4 years agors6000: Fix creation of VEC_COND_EXPR
Martin Liska [Thu, 18 Jun 2020 07:25:32 +0000 (09:25 +0200)]
rs6000: Fix creation of VEC_COND_EXPR

gcc/ChangeLog:

* config/rs6000/rs6000-call.c (fold_build_vec_cmp):
Since 502d63b6d6141597bb18fd23c87736a1b384cf8f, first argument
of a VEC_COND_EXPR cannot be tcc_comparison and so that
a SSA_NAME needs to be created before we use it for the first
argument of the VEC_COND_EXPR.
(fold_compare_helper): Pass gsi to fold_build_vec_cmp.

4 years agoOpenMP/Fortran: Reject allocatable components in map clause
Tobias Burnus [Thu, 18 Jun 2020 13:27:30 +0000 (15:27 +0200)]
OpenMP/Fortran: Reject allocatable components in map clause

gcc/fortran/ChangeLog:

* openmp.c (resolve_omp_clauses): Reject vars with
allocatable components in OpenMP map clauses.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/map-alloc-comp-1.f90: New test.

4 years agomiddle-end/95739 - fix vector condition IFN expansion
Richard Biener [Thu, 18 Jun 2020 12:45:03 +0000 (14:45 +0200)]
middle-end/95739 - fix vector condition IFN expansion

This fixes the omission of moving the expansion result to the
target.

2020-06-18  Richard Biener  <rguenther@suse.de>

PR middle-end/95739
* internal-fn.c (expand_vect_cond_optab_fn): Move the result
to the target if necessary.
(expand_vect_cond_mask_optab_fn): Likewise.

4 years agoFix typo in tree-ssa-reassoc.c.
Martin Liska [Thu, 18 Jun 2020 12:46:02 +0000 (14:46 +0200)]
Fix typo in tree-ssa-reassoc.c.

gcc/ChangeLog:

* tree-ssa-reassoc.c (ovce_extract_ops): Replace *vcond with
vcond as we check for NULL pointer.

4 years agogcc-changelog: checkout & pull order
Martin Liska [Thu, 18 Jun 2020 12:44:04 +0000 (14:44 +0200)]
gcc-changelog: checkout & pull order

contrib/ChangeLog:

* gcc-changelog/git_update_version.py: First checkout and then
run git pull ---rebase.

4 years agoc++: Fix tsubst ICE with invalid static_cast [PR95728]
Marek Polacek [Wed, 17 Jun 2020 23:23:10 +0000 (19:23 -0400)]
c++: Fix tsubst ICE with invalid static_cast [PR95728]

Since r11-423 tsubst_copy_and_build/TREE_LIST uses tsubst_tree_list
instead of open coding it.  While the latter could return an error
node wrapped in a TREE_LIST, the former can return a naked error node.

That broke in tsubst_copy_and_build/NEW_EXPR:
  tree placement = RECUR (TREE_OPERAND (t, 0));
  // placement is now error_mark_node, so...
  for (; placement != NULL_TREE; placement = TREE_CHAIN (placement))
  // ... this crashes

If we just return, we avoid the ICE and improve the diagnostic a bit.

gcc/cp/ChangeLog:

PR c++/95728
* pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return error_mark_node
if placement is erroneous.

gcc/testsuite/ChangeLog:

PR c++/95728
* g++.dg/template/cast6.C: New test.

4 years agogcc-changelog: support merge commits in git_update_version
Martin Liska [Thu, 18 Jun 2020 12:14:24 +0000 (14:14 +0200)]
gcc-changelog: support merge commits in git_update_version

contrib/ChangeLog:

* gcc-changelog/git_update_version.py: Support merge commits
and walk only on the branch that is being merged and generate
missing ChangeLog entries.

4 years agosilence empty-body warning
Tobias Burnus [Thu, 18 Jun 2020 11:19:03 +0000 (13:19 +0200)]
silence empty-body warning

gcc/ChangeLog:

* gimple-pretty-print.c (dump_binary_rhs): Use braces to
silence empty-body warning with gcc_fallthrough.

4 years agophiopt: Improve minmax optimization [PR95699]
Jakub Jelinek [Thu, 18 Jun 2020 10:11:09 +0000 (12:11 +0200)]
phiopt: Improve minmax optimization [PR95699]

As discussed in the PR, the
x < 0x80000000U to (int) x >= 0
optimization stands in the way of minmax_replacement optimization,
so for comparisons with most of the constants it works well, but when the
above mentioned optimization triggers, it is unable to do it.
The match.pd (cond (cmp (convert? x) c1) (op x c2) c3) -> (op (minmax x c1) c2)
optimization is able to look through that and this patch
teaches minmax_replacement about it too.

2020-06-18  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/95699
* tree-ssa-phiopt.c (minmax_replacement): Treat (signed int)x < 0
as x > INT_MAX and (signed int)x >= 0 as x <= INT_MAX.  Move variable
declarations to the statements that set them where possible.

* gcc.dg/tree-ssa/pr95699.c: New test.

4 years agoforwprop: simplify_vector_constructor follow-up fix [PR95713]
Jakub Jelinek [Thu, 18 Jun 2020 10:08:06 +0000 (12:08 +0200)]
forwprop: simplify_vector_constructor follow-up fix [PR95713]

As the following testcase shows, the exception for the aarch64
vec_pack_trunc_di is not sufficient on x86, the halfvectype
"vectors" have SImode but the x86 vec_pack_trunc_si meant for
the bool bitmasks combines 2x SImode into DImode, while in the
testcase the halfvectype is 1x SImode "vector" with SImode and
result is 2x HImode "vector" with SImode.

Richard Sandiford's reply:
FWIW, since the aarch64 case was only found by inspection and might
not be useful, personally I'd prefer to drop that case after all.

2020-06-18  Jakub Jelinek  <jakub@redhat.com>

PR target/95713
* tree-ssa-forwprop.c (simplify_vector_constructor): Don't allow
scalar mode halfvectype other than vector boolean for
VEC_PACK_TRUNC_EXPR.

* gcc.dg/pr95713.c: New test.

4 years agoavoid early asm output
Richard Biener [Thu, 18 Jun 2020 09:02:26 +0000 (11:02 +0200)]
avoid early asm output

This avoids early assembler output via the gimplifier creating
new static CTORs.  The output machinery seems to be prepared to
output constants recursively and it's just a matter of
appropriately defering or not defering output.

This also has the advantage of not outputting .string for
optimized away local aggregate initializers containing string
references.

2020-06-18  Richard Biener  <rguenther@suse.de>

* varasm.c (assemble_variable): Make sure to not
defer output when outputting addressed constants.
(output_constant_def_contents): Likewise.
(add_constant_to_table): Take and pass on whether to
defer output.
(output_addressed_constants): Likewise.
(output_constant_def): Pass on whether to defer output
to add_constant_to_table.
(tree_output_constant_def): Defer output of constants.

4 years agoremove SLP_TREE_TWO_OPERATORS, add SLP permutation node
Richard Biener [Wed, 25 Mar 2020 13:42:49 +0000 (14:42 +0100)]
remove SLP_TREE_TWO_OPERATORS, add SLP permutation node

This removes the SLP_TREE_TWO_OPERATORS hack in favor of having
explicit SLP nodes for both computations and the blend operation.
For this introduce a generic merge + select + permute SLP node
(with implementation limits).

Building upon earlier patches it adds vect_stmt_dominates_stmt_p
and the ability to compute a vector insertion place from
vectorized stmts (which now have UID zero) as needed for
the permute node.

2020-06-17  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (_slp_tree::two_operators): Remove.
(_slp_tree::lane_permutation): New member.
(_slp_tree::code): Likewise.
(SLP_TREE_TWO_OPERATORS): Remove.
(SLP_TREE_LANE_PERMUTATION): New.
(SLP_TREE_CODE): Likewise.
(vect_stmt_dominates_stmt_p): Declare.
* tree-vectorizer.c (vect_stmt_dominates_stmt_p): New function.
* tree-vect-stmts.c (vect_model_simple_cost): Remove
SLP_TREE_TWO_OPERATORS handling.
* tree-vect-slp.c (_slp_tree::_slp_tree): Amend.
(_slp_tree::~_slp_tree): Likewise.
(vect_two_operations_perm_ok_p): Remove.
(vect_build_slp_tree_1): Remove verification of two-operator
permutation here.
(vect_build_slp_tree_2): When we have two different operators
build two computation SLP nodes and a blend.
(vect_print_slp_tree): Print the lane permutation if it exists.
(slp_copy_subtree): Copy it.
(vect_slp_rearrange_stmts): Re-arrange it.
(vect_slp_analyze_node_operations_1): Handle SLP_TREE_CODE
VEC_PERM_EXPR explicitely.
(vect_schedule_slp_instance): Likewise.  Remove old
SLP_TREE_TWO_OPERATORS code.
(vectorizable_slp_permutation): New function.

4 years ago[Ada] Fix small inefficiency in previous change to expander
Eric Botcazou [Sun, 26 Apr 2020 10:46:03 +0000 (12:46 +0200)]
[Ada] Fix small inefficiency in previous change to expander

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Get_Size_For_Range): Only make sure to return a
size lower than that of the original type if possible.
* libgnat/s-rannum.adb (Random_Discrete): Back out optimization
added for 32-bit types.

4 years ago[Ada] ACATS 4.1J - B854003 - Subtype conformance check missed
Arnaud Charlet [Thu, 23 Apr 2020 18:46:27 +0000 (14:46 -0400)]
[Ada] ACATS 4.1J - B854003 - Subtype conformance check missed

2020-06-18  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_ch6.ads, sem_ch6.adb (Check_Formal_Conformance): New
subprogram.
(Check_Conformance): Move code to Check_Formal_Conformance.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Check for formal
conformance when needed.

4 years ago[Ada] Narrow large arithmetic and comparison operations
Eric Botcazou [Fri, 24 Apr 2020 20:50:50 +0000 (22:50 +0200)]
[Ada] Narrow large arithmetic and comparison operations

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Narrow_Large_Operation): New procedure to try
and narrow large arithmetic and comparison operations.
(Expand_N_In): Call it.
(Expand_N_Op_Abs): Likewise.
(Expand_N_Op_Add): Likewise.
(Expand_N_Op_Divide): Likewise.
(Expand_N_Op_Eq): Likewise.
(Expand_N_Op_Ge): Likewise.
(Expand_N_Op_Gt): Likewise.
(Expand_N_Op_Le): Likewise.
(Expand_N_Op_Lt): Likewise.
(Expand_N_Op_Minus): Likewise.
(Expand_N_Op_Mod): Likewise.
(Expand_N_Op_Multiply): Likewise.
(Expand_N_Op_Ne): Likewise.
(Expand_N_Op_Plus): Likewise.
(Expand_N_Op_Rem): Likewise.
(Expand_N_Op_Subtract): Likewise.
(Expand_N_Type_Conversion): Use Convert_To procedure.
* exp_ch9.adb (Is_Pure_Barrier) <N_Identifier>: Skip all
numeric types.
<N_Type_Conversion>: Use explicit criterion.

4 years ago[Ada] Small cleanup in constraint checking code for allocators
Eric Botcazou [Fri, 24 Apr 2020 20:05:35 +0000 (22:05 +0200)]
[Ada] Small cleanup in constraint checking code for allocators

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Expand_Allocator_Expression): Apply constraint
and predicate checks for the qualified expression on entry,
followed by constraint and predicate checks for the allocator
itself, and return early if this results in a static error.
(Expand_N_Allocator): Do not do the same here.  Instead apply
constraint and predicate checks for arrays in the subtype
indication case.
* exp_ch5.adb (Expand_N_Assignment_Statement): Do not apply
range checks to allocators here.

4 years ago[Ada] Crash in tagged type constructor with task components
Javier Miranda [Thu, 23 Apr 2020 17:36:43 +0000 (13:36 -0400)]
[Ada] Crash in tagged type constructor with task components

2020-06-18  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* exp_ch6.adb (BIP_Suffix_Kind, Is_Build_In_Place_Entity): Move
declarations...
* exp_ch6.ads: Here.
* exp_util.adb (Is_Secondary_Stack_BIP_Func_Call): Do not rely
on the name of the scope to locate the extra formal BIPalloc
since they are copied when the pointer type associated with
dispatching calls is built; rely on routines
Is_Build_In_Place_Entity and BIP_Suffix_Kind.
* exp_disp.adb (Expand_Dispatching_Call): Set the scope of the
first extra formal of the internally built pointer type.
* sem_ch3.adb (Derive_Subprogram): Do not inherit extra formals
from a limited interface parent since limitedness is not
inherited in such case (AI-419) and this affects the extra
formals.
* sprint.adb (Write_Itype): Output extra formals of subprogram
types.

4 years ago[Ada] Update output of verbose error summary
Ghjuvan Lacambre [Thu, 23 Apr 2020 09:26:54 +0000 (11:26 +0200)]
[Ada] Update output of verbose error summary

2020-06-18  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

* errout.adb (Write_Error_Summary): Display number of warnings
treated as errors.
* errutil.ads: Update comment.

4 years ago[Ada] Small cleanup in the attribute code of the expander
Eric Botcazou [Thu, 23 Apr 2020 17:33:47 +0000 (19:33 +0200)]
[Ada] Small cleanup in the attribute code of the expander

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_attr.adb (Analyze_Attribute) <Asm_{In,Out}put>: Alphabetize.
<Component_Size>: Add check for universal integer attribute.
<Aft>, <Bit_Order>, <Definite>, <Max_Alignment_For_Allocation>,
<Scalar_Storage_Order>: Raise Program_Error on them.
* sem_attr.adb (Eval_Attribute) <Component_Size>: Add comment on
the packed array case.

4 years ago[Ada] Implement AI12-0032 fixes for 'Old attribute accessibility
Steve Baird [Thu, 23 Apr 2020 21:39:55 +0000 (14:39 -0700)]
[Ada] Implement AI12-0032 fixes for 'Old attribute accessibility

2020-06-18  Steve Baird  <baird@adacore.com>

gcc/ada/

* sem_util.adb (Object_Access_Level): Treat a 'Old attribute
reference like an aggregate in determining its static
accessibility level; after the evaluation of the relevant
post-condition, the implicitly declared constant associated with
an Old attribute reference ceases to exist. Similarly for
Loop_Entry attribute.
* exp_ch6.adb (Expand_Call_Helper): For an attribute reference
that is expanded into a reference to an implicitly declared
constant (e.g., a 'Old or 'Loop_Entry attribute), compute the
dynamic accessibility level of that constant by looking at the
declaration of the constant (as opposed to looking at the
attribute reference).

4 years ago[Ada] No Default_Initial_Condition check when declaring an imported object
Steve Baird [Thu, 23 Apr 2020 18:37:10 +0000 (11:37 -0700)]
[Ada] No Default_Initial_Condition check when declaring an imported object

2020-06-18  Steve Baird  <baird@adacore.com>

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Do not generate a
default initial condition check for the declaration of an
imported object.

4 years ago[Ada] Add support for XDR streaming in the default runtime
Arnaud Charlet [Thu, 23 Apr 2020 09:46:29 +0000 (05:46 -0400)]
[Ada] Add support for XDR streaming in the default runtime

2020-06-18  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* Makefile.rtl: Add s-statxd.o.
* bindgen.adb (Gen_Adainit): Add support for XDR_Stream.
* bindusg.adb (Display): Add mention of -xdr.
* gnatbind.adb: Process -xdr switch.
* init.c (__gl_xdr_stream): New.
* opt.ads (XDR_Stream): New.
* libgnat/s-stratt__xdr.adb: Rename to...
* libgnat/s-statxd.adb: this and adjust.
* libgnat/s-statxd.ads: New.
* libgnat/s-stratt.ads, libgnat/s-stratt.adb: Choose between
default and XDR implementation at runtime.
* libgnat/s-ststop.ads: Update comments.
* doc/gnat_rm/implementation_advice.rst: Update doc on XDR
streaming.
* gnat_rm.texi: Regenerate.

4 years ago[Ada] Fix host/target confusion for attribute To_Address
Eric Botcazou [Thu, 23 Apr 2020 14:22:28 +0000 (16:22 +0200)]
[Ada] Fix host/target confusion for attribute To_Address

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_attr.adb (Analyze_Attribute) <To_Address>: Use the address
size of the target instead of the host when checking the value of
a static expression.  Also use standard idiom for exponentiation.

4 years ago[Ada] Add second warning for convention C_Variadic_n
Eric Botcazou [Thu, 23 Apr 2020 12:26:48 +0000 (14:26 +0200)]
[Ada] Add second warning for convention C_Variadic_n

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_prag.adb (Process_Convention): Give a warning on C_Variadic_n
being applied to a subprogram with exactly n parameters.

4 years ago[Ada] Profile mismatch between C and Ada functions
Arnaud Charlet [Wed, 22 Apr 2020 10:11:48 +0000 (06:11 -0400)]
[Ada] Profile mismatch between C and Ada functions

2020-06-18  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* libgnarl/s-osinte__linux.ads, libgnat/g-io.adb,
libgnat/g-socket.adb, libgnat/g-socthi.adb,
libgnat/g-socthi.ads, libgnat/g-socthi__vxworks.adb,
libgnat/g-socthi__vxworks.ads, libgnat/g-sothco.ads,
libgnat/s-io.adb, libgnat/a-except.adb: Fix function profile
mismatch with imported C functions.

4 years ago[Ada] Minor cleanup in Expand_Call_Helper
Eric Botcazou [Wed, 22 Apr 2020 18:51:16 +0000 (20:51 +0200)]
[Ada] Minor cleanup in Expand_Call_Helper

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Remove superfluous calls
to Relocate_Node and merge calls to Analyze and Resolve in a
couple of places.  Do not attempt to generate a range check
for an actual parameter against the formal's type of a derived
subprogram after generating a conversion to the formal's type
of the parent subprogram.

4 years ago[Ada] Improve compile-time evaluation of value ranges
Eric Botcazou [Tue, 21 Apr 2020 20:28:00 +0000 (22:28 +0200)]
[Ada] Improve compile-time evaluation of value ranges

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* checks.adb (Compute_Range_For_Arithmetic_Op): New procedure to
compute a range for an arithmetical operation extracted from...
(Minimize_Eliminate_Overflows): ...here.  Call it.
(Determine_Range_Cache_O): New cache for Original_Node nodes.
(Determine_Range): Call Compute_Range_For_Arithmetic_Op for all
arithmetic expressions. Use Attribute_Id in lieu of Attribute_Name
for attributes. Add handling for Range_Length alongside Length.
Add specific handling for Alignment, Bit, First_Bit, Last_Bit,
Max_Size_In_Storage_Elements, Position, Bit_Position,
Component_Size, Object_Size, Size, Value_Size, Descriptor_Size.
(Enable_Overflow_Check): Omit the check for Abs and Minus if the
operand cannot be the largest negative number.
(Selected_Length_Checks): Use Pos for Number_Dimensions.
* exp_attr.adb (Expand_N_Attribute_Reference): Move compile-time
handling of Bit_Position, Descriptor_Size, First_Bit, Last_Bit
and Position to...
* sem_attr.adb (Eval_Attribute): ...here.  Move up Alignment for
objects and use Compile_Time_Known_Attribute in this case too.

4 years ago[Ada] Do not treat pragma Compile_Time_Warning as error even with -gnatwe
Ghjuvan Lacambre [Mon, 20 Apr 2020 07:41:08 +0000 (09:41 +0200)]
[Ada] Do not treat pragma Compile_Time_Warning as error even with -gnatwe

2020-06-18  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

* erroutc.ads: Declare new Is_Compile_Time_Msg boolean,
add new Compile_Time_Pragma field to Error_Msg_Object type.
(Count_Compile_Time_Pragma_Warnings): New function.
* erroutc.adb (Count_Compile_Time_Pragma_Warnings): New
function.
(Compilation_Errors): Take Compile_Time warnings into account
when tallying Errors/Warnings.
* errout.ads (Error_Msg): New procedure.
* errout.adb (Error_Msg): New procedure.
(Error_Msg_Internal): Set new Compile_Time_Pragma field in
Error_Msg_Object.
* errutil.adb (Error_Msg): Set new Compile_Time_Pragma field in
Error_Msg_Object.
* sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): Pass
True to new Error_Msg procedure.
* doc/gnat_rm/implementation_defined_pragmas.rst: Update doc for
the Compile_Time_Warning pragma.
* gnat_rm.texi: Regenerate.
* opt.ads: Update comment.

4 years ago[Ada] Suppress CodePeer message on possible uninitialized variable
Arnaud Charlet [Wed, 22 Apr 2020 07:51:24 +0000 (03:51 -0400)]
[Ada] Suppress CodePeer message on possible uninitialized variable

2020-06-18  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_ch4.adb (Check_Compatible_Profiles): Add explicit
initialization.

4 years ago[Ada] Fix failed assertion on a slice indexed by a subtype_indication
Piotr Trojanek [Thu, 16 Apr 2020 11:59:53 +0000 (13:59 +0200)]
[Ada] Fix failed assertion on a slice indexed by a subtype_indication

2020-06-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb (Generate_Index_Checks): Handle
N_Subtype_Indication returned from Scalar_Range.

4 years ago[Ada] Cleanups in code related to static expressions
Piotr Trojanek [Thu, 16 Apr 2020 09:03:49 +0000 (11:03 +0200)]
[Ada] Cleanups in code related to static expressions

2020-06-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* checks.adb, sem_ch3.adb: Minor refactorings.
* sem_eval.adb (Eval_Qualified_Expression): Fix reference to RM
rule in comment; only set a local variable Hex in the branch
where it is used.

4 years ago[Ada] Avoid forced loading of System.Priority in CodePeer mode
Piotr Trojanek [Fri, 17 Apr 2020 11:34:53 +0000 (13:34 +0200)]
[Ada] Avoid forced loading of System.Priority in CodePeer mode

2020-06-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* sem_eval.adb (Check_Non_Static_Context): Use Is_RTE.

4 years ago[Ada] ACATS 4.1L - B452002 - Wrong universal access "=" rules
Arnaud Charlet [Tue, 14 Apr 2020 07:29:43 +0000 (03:29 -0400)]
[Ada] ACATS 4.1L - B452002 - Wrong universal access "=" rules

2020-06-18  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* sem_ch4.adb (Find_Equality_Types.Check_Access_Object_Types):
New function, used to implement RM 4.5.2 (9.6/2).
(Find_Equality_Types.Check_Compatible_Profiles): New function,
used to implement RM 4.5.2(9.7/2).
(Find_Equality_Types.Reference_Anonymous_Access_Type): New
function.
(Find_Equality_Types.Try_One_Interp): Fix handling of anonymous
access types which was accepting both too much and too little.
Remove accumulated special and incomplete cases for
instantiations, replaced by Has_Compatible_Type.
(Analyze_Overloaded_Selected_Component): Use
Is_Anonymous_Access_Type instead of Ekind_In.
* sem_res.adb: Code cleanup and bug fix: use
Is_Anonymous_Access_Type instead of Ekind_In.  Relax checking of
anonymous access parameter when universal_access "=" is
involved.
* sem_type.adb: Likewise.
(Find_Unique_Type): Move code from here...
(Specific_Type): ...to here. Also add missing handling of access
to class wide types.
* einfo.ads, einfo.adb (Is_Access_Object_Type): New.

4 years ago[Ada] AI12-0293-1 Implement storage streams
Bob Duff [Mon, 20 Apr 2020 19:11:35 +0000 (15:11 -0400)]
[Ada] AI12-0293-1 Implement storage streams

2020-06-18  Bob Duff  <duff@adacore.com>

gcc/ada/

* libgnat/a-strsto.ads, libgnat/a-ststbo.adb,
libgnat/a-ststbo.ads, libgnat/a-ststun.adb,
libgnat/a-ststun.ads: New files, containing packages
Ada.Streams.Storage, Ada.Streams.Storage.Bounded, and
Ada.Streams.Storage.Unbounded.
* impunit.adb, Makefile.rtl: Add new file names.

4 years ago[Ada] Missing error on aspects Input and Output
Javier Miranda [Tue, 21 Apr 2020 13:22:28 +0000 (09:22 -0400)]
[Ada] Missing error on aspects Input and Output

2020-06-18  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* sem_ch13.adb (Has_Good_Profile): Enforce strictness in the
check. Required to detect wrong profiles for Input and Output.
(Analyze_Stream_TSS_Definition): Minor enhancement in the text
of the error for class-wide attributes.

4 years ago[Ada] Small adjustment to Get_Integer_Type function
Eric Botcazou [Mon, 20 Apr 2020 21:31:42 +0000 (23:31 +0200)]
[Ada] Small adjustment to Get_Integer_Type function

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_attr.adb (Get_Integer_Type): Pick an unsigned type based
on the Esize of the base type of the input type.

4 years ago[Ada] Fix invalid expression sharing in Expand_Array_Equality
Eric Botcazou [Tue, 21 Apr 2020 10:58:23 +0000 (12:58 +0200)]
[Ada] Fix invalid expression sharing in Expand_Array_Equality

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Expand_Array_Equality): For the optimization of
the 2-element case, build new expression lists for the indices.

4 years ago[Ada] Properly test for Protected_Body_Subprogram
Richard Kenner [Mon, 20 Apr 2020 21:11:20 +0000 (17:11 -0400)]
[Ada] Properly test for Protected_Body_Subprogram

2020-06-18  Richard Kenner  <kenner@adacore.com>

gcc/ada/

* sem_util.adb (Enclosing_Subprogram): No longer need
Convention_Protected.

4 years ago[Ada] The definition of constants in declare expressions is an interfering context
Claire Dross [Tue, 21 Apr 2020 12:15:22 +0000 (14:15 +0200)]
[Ada] The definition of constants in declare expressions is an interfering context

2020-06-18  Claire Dross  <dross@adacore.com>

gcc/ada/

* sem_util.adb (Is_OK_Volatile_Context): Return False on
definitions of constants declared in declare expressions.

4 years ago[Ada] List aspect Relaxed_Initialization in GNAT RM
Piotr Trojanek [Tue, 21 Apr 2020 11:13:02 +0000 (13:13 +0200)]
[Ada] List aspect Relaxed_Initialization in GNAT RM

2020-06-18  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

* doc/gnat_rm/implementation_defined_aspects.rst
(Relaxed_Initialization): New implementation-defined aspect.
* doc/gnat_rm/implementation_defined_attributes.rst
(Initialized): New implementation-defined attribute.
* gnat_rm.texi: Regenerate.

4 years ago[Ada] Crash in tagged type constructor with task components
Javier Miranda [Mon, 20 Apr 2020 19:17:05 +0000 (15:17 -0400)]
[Ada] Crash in tagged type constructor with task components

2020-06-18  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* exp_disp.adb (Expand_Dispatching_Call): Add missing decoration
of attribute Extra_Accessibility_Of_Result.
* freeze.adb (Check_Extra_Formals): No check required if
expansion is disabled; Adding check on
Extra_Accessibilty_Of_Result.
(Freeze_Subprogram): Fix decoration of
Extra_Accessibility_Of_Result.
* sem_ch3.adb (Derive_Subprogram): Fix decoration of
Extra_Accessibility_Of_Result

4 years ago[Ada] Small improvement to Optimize_Length_Comparison
Eric Botcazou [Sat, 18 Apr 2020 17:26:03 +0000 (19:26 +0200)]
[Ada] Small improvement to Optimize_Length_Comparison

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch4.adb (Optimize_Length_Comparison): Accept 32-bit values
in the full unsigned range.

4 years agoAdd missing check for gassign.
Martin Liska [Thu, 18 Jun 2020 07:11:31 +0000 (09:11 +0200)]
Add missing check for gassign.

gcc/ChangeLog:

* tree-vect-generic.c (expand_vector_condition): Check
for gassign before inspecting RHS.

4 years agogcc-changelog: fix Backported from timestamp.
Martin Liska [Thu, 18 Jun 2020 08:05:40 +0000 (10:05 +0200)]
gcc-changelog: fix Backported from timestamp.

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Fix Backported from timestamp when
use_commit_ts=True is used.

4 years agoDaily bump.
GCC Administrator [Thu, 18 Jun 2020 00:16:37 +0000 (00:16 +0000)]
Daily bump.

4 years ago[OpenMP, gimplifier] 'inform' after 'error' diagnostic
Thomas Schwinge [Thu, 30 Apr 2020 07:07:06 +0000 (09:07 +0200)]
[OpenMP, gimplifier] 'inform' after 'error' diagnostic

This is not a thorough review of the code, just a few cases I noticed while
scanning 'gcc/gimplify.c' for "enclosing".

gcc/
* gimplify.c (omp_notice_threadprivate_variable)
(omp_default_clause, omp_notice_variable): 'inform' after 'error'
diagnostic.  Adjust all users.
gcc/testsuite/
* c-c++-common/gomp/default-1.c: Update.
* c-c++-common/gomp/defaultmap-3.c: Likewise.
* c-c++-common/gomp/order-4.c: Likewise.
* g++.dg/gomp/parallel-2.C: Likewise.
* g++.dg/gomp/predetermined-1.C: Likewise.
* g++.dg/gomp/sharing-1.C: Likewise.
* gcc.dg/gomp/appendix-a/a.24.1.c: Likewise.
* gcc.dg/gomp/parallel-2.c: Likewise.
* gcc.dg/gomp/pr44085.c: Likewise.
* gcc.dg/gomp/sharing-1.c: Likewise.
* gcc.dg/gomp/vla-1.c: Likewise.
* gfortran.dg/gomp/appendix-a/a.24.1.f90: Likewise.
* gfortran.dg/gomp/crayptr3.f90: Likewise.
* gfortran.dg/gomp/pr33439.f90: Likewise.
* gfortran.dg/gomp/pr44036-1.f90: Likewise.
* gfortran.dg/gomp/pr44085.f90: Likewise.
* gfortran.dg/gomp/pr44536.f90: Likewise.
* gfortran.dg/gomp/pr94672.f90: Likewise.
* gfortran.dg/gomp/sharing-1.f90: Likewise.
* gfortran.dg/gomp/sharing-2.f90: Likewise.
* gfortran.dg/gomp/sharing-3.f90: Likewise.

4 years agoAdd 'dg-do run' to 'libgomp.fortran/use_device_ptr-optional-3.f90' [PR94848]
Thomas Schwinge [Tue, 7 Jan 2020 16:40:14 +0000 (17:40 +0100)]
Add 'dg-do run' to 'libgomp.fortran/use_device_ptr-optional-3.f90' [PR94848]

Fix-up for r279858/commit f760c0c77fe350616da9dbeaea16442b0acfb09c "Fortran]
OpenMP/OpenACC – fix more issues with OPTIONAL".

With offloading enabled, we then saw:

    PASS: libgomp.fortran/use_device_ptr-optional-3.f90   -O0  (test for excess errors)
    PASS: libgomp.fortran/use_device_ptr-optional-3.f90   -O0  execution test
    PASS: libgomp.fortran/use_device_ptr-optional-3.f90   -O1  (test for excess errors)
    PASS: libgomp.fortran/use_device_ptr-optional-3.f90   -O1  execution test
    FAIL: libgomp.fortran/use_device_ptr-optional-3.f90   -O2  (test for excess errors)
    UNRESOLVED: libgomp.fortran/use_device_ptr-optional-3.f90   -O2  compilation failed to produce executable
    FAIL: libgomp.fortran/use_device_ptr-optional-3.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
    UNRESOLVED: libgomp.fortran/use_device_ptr-optional-3.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  compilation failed to produce executable
    FAIL: libgomp.fortran/use_device_ptr-optional-3.f90   -O3 -g  (test for excess errors)
    UNRESOLVED: libgomp.fortran/use_device_ptr-optional-3.f90   -O3 -g  compilation failed to produce executable
    FAIL: libgomp.fortran/use_device_ptr-optional-3.f90   -Os  (test for excess errors)
    UNRESOLVED: libgomp.fortran/use_device_ptr-optional-3.f90   -Os  compilation failed to produce executable

 ... due to:

    /tmp/cciVc43I.o:(.gnu.offload_vars+0x10): undefined reference to `A.12.4064'
    [...]

..., but after the recent PR94848, PR95551 changes, that problem is now gone.

libgomp/
PR lto/94848
* testsuite/libgomp.fortran/use_device_ptr-optional-3.f90: Add
'dg-do run'.

4 years agohurd: libgcc unwinding support over signal trampolines
Samuel Thibault [Fri, 29 May 2020 11:46:50 +0000 (13:46 +0200)]
hurd: libgcc unwinding support over signal trampolines

libgcc/
* config.host (md_unwind_header) <i[34567]86-*-gnu*>: Set to
'i386/gnu-unwind.h'
* config/i386/gnu-unwind.h: New file.

Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
4 years agolibstdc++: Avoid stack overflow in std::vector (PR 94540)
Jonathan Wakely [Wed, 17 Jun 2020 21:49:06 +0000 (22:49 +0100)]
libstdc++: Avoid stack overflow in std::vector (PR 94540)

The std::__uninitialized_default_n algorithm used by std::vector creates
an initial object as a local variable then copies that into the
destination range. If the object is too large for the stack this
crashes. We should create the first object directly into the
destination and then copy it from there.

This doesn't fix the bug for C++98, because in that case the initial
value is created as a default argument of the vector constructor i.e. in
the user's code, not inside libstdc++. We can't prevent that.

PR libstdc++/94540
* include/bits/stl_uninitialized.h (__uninitialized_default_1<true>):
Construct the first value at *__first instead of on the stack.
(__uninitialized_default_n_1<true>): Likewise.
Improve comments on several of the non-standard algorithms.
* testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
New test.
* testsuite/23_containers/vector/cons/94540.cc: New test.

4 years ago[HSA] Avoid ICE when "HSA does not implement indirect calls"
Thomas Schwinge [Sat, 6 Jun 2020 16:44:34 +0000 (18:44 +0200)]
[HSA] Avoid ICE when "HSA does not implement indirect calls"

Made apparent by recent commit dc703151d4f4560e647649506d5b4ceb0ee11e90
"openmp: Implement discovery of implicit declare target to clauses":

    +FAIL: libgomp.c/target-39.c (internal compiler error)
    +FAIL: libgomp.c/target-39.c (test for excess errors)
    +UNRESOLVED: libgomp.c/target-39.c compilation failed to produce executable

This is in a '--enable-offload-targets=[...],hsa' build, with '-foffload=hsa'
enabled (by default).

    during GIMPLE pass: hsagen
    source-gcc/libgomp/testsuite/libgomp.c/target-39.c: In function ‘main._omp_fn.0.hsa.0’:
    source-gcc/libgomp/testsuite/libgomp.c/target-39.c:23:11: internal compiler error: Segmentation fault
       23 |   #pragma omp target map(from:err)
          |           ^~~
    [...]

GDB:

    Program received signal SIGSEGV, Segmentation fault.
    fndecl_built_in_p (node=0x0, name=BUILT_IN_PREFETCH) at [...]/source-gcc/gcc/tree.h:6267
    6267      return (fndecl_built_in_p (node, BUILT_IN_NORMAL)
    (gdb) bt
    #0  fndecl_built_in_p (node=0x0, name=BUILT_IN_PREFETCH) at [...]/source-gcc/gcc/tree.h:6267
    #1  0x0000000000b19739 in gen_hsa_insns_for_call (stmt=stmt@entry=0x7ffff693b200, hbb=hbb@entry=0x2b152c0) at [...]/source-gcc/gcc/hsa-gen.c:5304
    #2  0x0000000000b1aca7 in gen_hsa_insns_for_gimple_stmt (stmt=0x7ffff693b200, hbb=hbb@entry=0x2b152c0) at [...]/source-gcc/gcc/hsa-gen.c:5770
    #3  0x0000000000b1bd21 in gen_body_from_gimple () at [...]/source-gcc/gcc/hsa-gen.c:5999
    #4  0x0000000000b1dbd2 in generate_hsa (kernel=<optimized out>) at [...]/source-gcc/gcc/hsa-gen.c:6596
    #5  0x0000000000b1de66 in (anonymous namespace)::pass_gen_hsail::execute (this=0x2a2aac0) at [...]/source-gcc/gcc/hsa-gen.c:6680
    #6  0x0000000000d06f90 in execute_one_pass (pass=pass@entry=0x2a2aac0) at [...]/source-gcc/gcc/passes.c:2502
    [...]
    (gdb) up
    #1  0x0000000000b19739 in gen_hsa_insns_for_call (stmt=stmt@entry=0x7ffff693b200, hbb=hbb@entry=0x2b152c0) at /home/thomas/tmp/source/gcc/build/track-slim-omp/source-gcc/gcc/hsa-gen.c:5304
    5304          if (fndecl_built_in_p (function_decl, BUILT_IN_PREFETCH))
    (gdb) print function_decl
    $1 = (tree) 0x0
    (gdb) list
    5299      if (!gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
    5300        {
    5301          tree function_decl = gimple_call_fndecl (stmt);
    5302          /* Prefetch pass can create type-mismatching prefetch builtin calls which
    5303             fail the gimple_call_builtin_p test above.  Handle them here.  */
    5304          if (fndecl_built_in_p (function_decl, BUILT_IN_PREFETCH))
    5305            return;
    5306
    5307          if (function_decl == NULL_TREE)
    5308            {

The problem is present already since 2016-11-23 commit
56b1c60e412fcf1245b4780871553cbdebb956a3 (r242761) "Merge from HSA branch to
trunk", and the fix obvious enough.

gcc/
* hsa-gen.c (gen_hsa_insns_for_call): Move 'function_decl ==
NULL_TREE' check earlier.
gcc/testsuite/
* c-c++-common/gomp/hsa-indirect-call-1.c: New file.

4 years agoFix typo in attribute access example.
Forrest Timour [Wed, 17 Jun 2020 20:29:07 +0000 (14:29 -0600)]
Fix typo in attribute access example.

Fix typo in documentation example of access function attribute where the ref-indices should be one-indexed instead of zero-indexed.

gcc/ChangeLog:
* doc/extend.texi (attribute access): Fix a typo.

4 years agolibstdc++: Fix tests for uninitialized_value_construct_n
Jonathan Wakely [Wed, 17 Jun 2020 20:23:35 +0000 (21:23 +0100)]
libstdc++: Fix tests for uninitialized_value_construct_n

In my recent r11-1460 commit the tests had been "improved" before
commit, and no longer exercised the code paths changed by the patch.

This restores what I originally tested, so that the tests fail before
the r11-1460 change and pass after it.

* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
Replace Value type with int so trivial code path is used.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
Likewise.

4 years agolibstdc++: Handle non-integral sizes in std::uninitialized_fill_n
Jonathan Wakely [Wed, 17 Jun 2020 19:53:45 +0000 (20:53 +0100)]
libstdc++: Handle non-integral sizes in std::uninitialized_fill_n

The std::uninitialized_fill_n algorithm uses sd::fill_n for trivial
types, but that algorithm has a stronger requirement that the Size
parameter is convertible to an integral type. As the new test shows,
there are types which are valid for std::uninitialized_fill_n but which
produce a different result when converted to an integral type, or cannot
be converted at all. Only use the std::fill_n optimization when the Size
type is already an integral type.

The std::__uninitialized_default_n extension has the same problem, and
so does C++17's std::uninitialized_value_construct_n which uses it.

* include/bits/stl_uninitialized.h (uninitialized_fill_n): Only
use std::fill_n when the size is an integral type.
(__uninitialized_default_n): Likewise.
* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
New test.

4 years agoc++: Fix bogus "does not declare anything" warning (PR 66159)
Jonathan Wakely [Wed, 17 Jun 2020 19:26:13 +0000 (20:26 +0100)]
c++: Fix bogus "does not declare anything" warning (PR 66159)

G++ gives a bogus warning for 'struct A; using B = struct ::A;'
complaining that the elaborated-type-specifier doesn't declare anything.
That's true, but it's not trying to declare struct ::A, just refer to it
unambiguously. Do not emit the warning unless we're actually parsing a
declaration.

gcc/cp/ChangeLog:

PR c++/66159
* parser.c (cp_parser_elaborated_type_specifier): Do not warn
unless in a declaration.

gcc/testsuite/ChangeLog:

PR c++/66159
* g++.dg/warn/forward-inner.C: Check alias-declaration using
elaborated-type-specifier.