platform/upstream/gcc.git
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.

4 years agovect: CSE for bump and offset in strided load/store operations.
Kaipeng Zhou [Wed, 17 Jun 2020 19:19:16 +0000 (20:19 +0100)]
vect: CSE for bump and offset in strided load/store operations.

Every time "vect_get_strided_load_store_ops" is called, new bump and offset
variables and a series of stmts are created.  And IVOPTs is not able to
eliminate them.  The patch use "cse_and_gimplify_to_preheader" to CSE them.

2020-06-17  Bin Cheng  <bin.cheng@linux.alibaba.com>
    Kaipeng Zhou  <zhoukaipeng3@huawei.com>

PR tree-optimization/95199
* tree-vect-stmts.c: Eliminate common stmts for bump and offset in
strided load/store operations and remove redundant code.

2020-06-17  Bin Cheng  <bin.cheng@linux.alibaba.com>
    Kaipeng Zhou  <zhoukaipeng3@huawei.com>

PR tree-optimization/95199
* gcc.target/aarch64/sve/pr95199.c: New test.

4 years agoc++: implicit operator== adjustments from P2002.
Jason Merrill [Mon, 15 Jun 2020 21:11:38 +0000 (17:11 -0400)]
c++: implicit operator== adjustments from P2002.

P2002R1, adopted at the February C++ meeting, made several refinements to
the wording for operator<=>.  This implements clarifications in how the
implicit operator== is declared: as a duplicate of the operator<=>, with
only the return type and name changed.  To that end I factored out the
declaration copying from build_clone.

gcc/cp/ChangeLog:

* cp-tree.h (copy_fndecl_with_name): Declare.
* class.c (copy_fndecl_with_name): Split out from...
(build_clone): ...here.
(add_implicitly_declared_members): Add op== to TYPE_FIELDS.
* method.c (implicitly_declare_fn): Use copy_fndecl_with_name.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth9.C: New test.

4 years agoc++: Add test for C++20 NB comment CA107.
Jason Merrill [Thu, 11 Jun 2020 22:21:57 +0000 (18:21 -0400)]
c++: Add test for C++20 NB comment CA107.

We already implemented this, but it's good to have a test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ca107.C: New test.

4 years agoc++: Fix consteval operator handling.
Jason Merrill [Tue, 16 Jun 2020 04:19:53 +0000 (00:19 -0400)]
c++: Fix consteval operator handling.

We were crashing trying to find the CALL_EXPR in the result of a call to a
consteval operator.

gcc/cp/ChangeLog:

* call.c (build_new_op_1): Don't look for a CALL_EXPR when
calling a consteval function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/consteval17.C: New test.

4 years agoc++: Treat in-class default/delete as definitions.
Jason Merrill [Tue, 16 Jun 2020 04:20:58 +0000 (00:20 -0400)]
c++: Treat in-class default/delete as definitions.

We were complaining about a constrained defaulted non-template friend in a
template class because funcdef_flag wasn't set.  grokdeclarator would set it
for default/delete, but grokfield wasn't passing the 'initialized' values
needed.  Fixing that revealed some errors in existing tests that we weren't
diagnosing.  Since we accepted them for so long, I'm reducing the error to a
pedwarn to ease compiler upgrade.

gcc/cp/ChangeLog:

* decl2.c (grokfield): Pass SD_DEFAULTED and SD_DELETED.
* decl.c (duplicate_decls): Reduce error for delete
after earlier declaration to pedwarn.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/pr62101.C: Expect error.
* g++.dg/cpp0x/pr80259.C: Expect error.
* g++.dg/cpp2a/concepts-friend8.C: New test.

4 years agoc-family: check qualifiers of arguments to __atomic built-ins (PR 95378)
Jonathan Wakely [Wed, 17 Jun 2020 18:48:05 +0000 (19:48 +0100)]
c-family: check qualifiers of arguments to __atomic built-ins (PR 95378)

Currently the __atomic_{load,store,exchange,compare_exchange} built-ins
will happily store values through pointers to const, or use pointers to
volatile as the input and output arguments. This patch ensures that any
pointer that will be written through does not point to a const object,
and only the pointer to the atomic variable can be volatile.

This differs slightly from Clang, which allows the third argument to
__atomic_exchange (the one that is used to return the old value) to be
volatile if and only if the first argument is volatile. That doesn't
seem useful.

For C++ emit errors, but for C use pedwarns that are controlled by
-Wincompatible-pointer-types.

gcc/c-family/ChangeLog:

* c-common.c (get_atomic_generic_size): Check cv-qualifiers in
pointer arguments.

gcc/testsuite/ChangeLog:

* c-c++-common/pr95378.c: New test.

4 years agorecog: Tweak insn_gen_fn::operator() definition
Richard Sandiford [Wed, 17 Jun 2020 16:45:29 +0000 (17:45 +0100)]
recog: Tweak insn_gen_fn::operator() definition

Fixes a “left operand of comma has no effect” warning that some were
seeing.  Also fixes a spurious ellipsis that Jonathan Wakely pointed
out.

2020-06-17  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* coretypes.h (first_type): New alias template.
* recog.h (insn_gen_fn::operator()): Use it instead of a decltype.
Remove spurious “...” and split the function type out into a typedef.

4 years agoIBM Z: Prevent mach optimization on doloop patterns
Andreas Krebbel [Wed, 17 Jun 2020 15:10:05 +0000 (17:10 +0200)]
IBM Z: Prevent mach optimization on doloop patterns

s390_fix_long_loop_prediction is used in machine dependent
reorg. There we use single_set to distingiush between conditional
jumps and branch on count patterns.  However, single_set returns a
non-NULL value also for PARALLELs in case one of the SETs is dead.

2020-06-17  Andreas Krebbel  <krebbel@linux.ibm.com>

gcc/
* config/s390/s390.c (s390_fix_long_loop_prediction): Exit early
for PARALLELs.

gcc/testsuite/
* gcc.target/s390/20200617.c: New test.

4 years agoUse SLP_TREE_VECTYPE consistently
Richard Biener [Wed, 17 Jun 2020 13:22:10 +0000 (15:22 +0200)]
Use SLP_TREE_VECTYPE consistently

This assigns SLP_TREE_VECTYPE to all SLP nodes and uses it when
analyzing def operands.  It does not deal with mismatches between
SLP_TREE_VECTYPE and STMT_VINFO_VECTYPE yet - those cases are
still rejected until I get to clean up the interaction with data
reference groups.

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

* tree-vect-slp.c (vect_build_slp_tree_1): Set the passed
in *vectype parameter.
(vect_build_slp_tree_2): Set SLP_TREE_VECTYPE from what
vect_build_slp_tree_1 computed.
(vect_analyze_slp_instance): Set SLP_TREE_VECTYPE.
(vect_slp_analyze_node_operations_1): Use the SLP node vector type.
(vect_schedule_slp_instance): Likewise.
* tree-vect-stmts.c (vect_is_simple_use): Take the vector type
from SLP_TREE_VECTYPE.

4 years agoc++: ICE with IMPLICIT_CONV_EXPR in array subscript [PR95508]
Marek Polacek [Wed, 17 Jun 2020 13:19:02 +0000 (09:19 -0400)]
c++: ICE with IMPLICIT_CONV_EXPR in array subscript [PR95508]

Since r10-7096 convert_like, when called in a template, creates an
IMPLICIT_CONV_EXPR when we're converting to/from array type.

In this test, we have e[f], and we're converting f (of type class A) to
int, so convert_like in build_new_op_1 created the IMPLICIT_CONV_EXPR
that got into cp_build_array_ref which calls maybe_constant_value.  My
patch above failed to adjust this spot to call fold_non_dependent_expr
instead, which can handle codes like I_C_E in a template.  Fixed by
using a new function maybe_fold_non_dependent_expr, which, if the expr
can't be evaluated to a constant, returns the original expression.

gcc/cp/ChangeLog:

PR c++/95508
* constexpr.c (maybe_fold_non_dependent_expr): New.
* cp-tree.h (maybe_fold_non_dependent_expr): Declare.
* typeck.c (cp_build_array_ref): Call maybe_fold_non_dependent_expr
instead of maybe_constant_value.

gcc/testsuite/ChangeLog:

PR c++/95508
* g++.dg/template/conv16.C: New test.

4 years agoFix use of inaccessible member in pr85503.C [PR95716]
Patrick Palka [Wed, 17 Jun 2020 13:09:53 +0000 (09:09 -0400)]
Fix use of inaccessible member in pr85503.C [PR95716]

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

gcc/testsuite/ChangeLog:

PR testsuite/95716
* g++.dg/ext/pr85503.C: Give ai::cv public access.

4 years agotree-optimization/95717 - fix SSA update for vectorizer epilogue
Richard Biener [Wed, 17 Jun 2020 12:57:59 +0000 (14:57 +0200)]
tree-optimization/95717 - fix SSA update for vectorizer epilogue

This fixes yet another issue with the custom SSA updating in the
vectorizer when we copy from the non-if-converted loop.  We must
not mess with current defs before we updated the BB copies.

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

PR tree-optimization/95717
* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
Move BB SSA updating before exit/latch PHI current def copying.

* g++.dg/torture/pr95717.C: New testcase.

4 years agotestsuite: clean up .gcov files in test-suite.
Martin Liska [Wed, 17 Jun 2020 11:42:20 +0000 (13:42 +0200)]
testsuite: clean up .gcov files in test-suite.

gcc/testsuite/ChangeLog:

PR testsuite/95720
* gcc.misc-tests/gcov-pr94029.c: Remove not needed remove-gcda.
* lib/gcov.exp: Delete properly .gcov files.

4 years agoLower VEC_COND_EXPR into internal functions.
Martin Liska [Mon, 9 Mar 2020 12:23:03 +0000 (13:23 +0100)]
Lower VEC_COND_EXPR into internal functions.

gcc/ChangeLog:

* Makefile.in: Add new file.
* expr.c (expand_expr_real_2): Add gcc_unreachable as we should
not meet this condition.
(do_store_flag): Likewise.
* gimplify.c (gimplify_expr): Gimplify first argument of
VEC_COND_EXPR to be a SSA name.
* internal-fn.c (vec_cond_mask_direct): New.
(vec_cond_direct): Likewise.
(vec_condu_direct): Likewise.
(vec_condeq_direct): Likewise.
(expand_vect_cond_optab_fn):  New.
(expand_vec_cond_optab_fn): Likewise.
(expand_vec_condu_optab_fn): Likewise.
(expand_vec_condeq_optab_fn): Likewise.
(expand_vect_cond_mask_optab_fn): Likewise.
(expand_vec_cond_mask_optab_fn): Likewise.
(direct_vec_cond_mask_optab_supported_p): Likewise.
(direct_vec_cond_optab_supported_p): Likewise.
(direct_vec_condu_optab_supported_p): Likewise.
(direct_vec_condeq_optab_supported_p): Likewise.
* internal-fn.def (VCOND): New OPTAB.
(VCONDU): Likewise.
(VCONDEQ): Likewise.
(VCOND_MASK): Likewise.
* optabs.c (get_rtx_code): Make it global.
(expand_vec_cond_mask_expr): Removed.
(expand_vec_cond_expr): Removed.
* optabs.h (expand_vec_cond_expr): Likewise.
(vector_compare_rtx): Make it global.
* passes.def: Add new pass_gimple_isel pass.
* tree-cfg.c (verify_gimple_assign_ternary): Add check
for VEC_COND_EXPR about first argument.
* tree-pass.h (make_pass_gimple_isel): New.
* tree-ssa-forwprop.c (pass_forwprop::execute): Prevent
propagation of the first argument of a VEC_COND_EXPR.
* tree-ssa-reassoc.c (ovce_extract_ops): Support SSA_NAME as
first argument of a VEC_COND_EXPR.
(optimize_vec_cond_expr): Likewise.
* tree-vect-generic.c (expand_vector_divmod): Make SSA_NAME
for a first argument of created VEC_COND_EXPR.
(expand_vector_condition): Fix coding style.
* tree-vect-stmts.c (vectorizable_condition): Gimplify
first argument.
* gimple-isel.cc: New file.

gcc/testsuite/ChangeLog:

* g++.dg/vect/vec-cond-expr-eh.C: New test.

4 years agogcc-changelog: Support 'Backported from master'.
Martin Liska [Wed, 17 Jun 2020 08:41:17 +0000 (10:41 +0200)]
gcc-changelog: Support 'Backported from master'.

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Print 'Backported from master'
heading to backported commits.
* gcc-changelog/test_email.py: Test it.
* gcc-changelog/test_patches.txt: Add new patch.
* gcc-changelog/git_repository.py: Add commit_to_date hook.
* gcc-changelog/git_email.py: Add fuzzy implementation
of commit_to_date_hook.

4 years agoamdgcn: Switch to HSACO v3 binary format
Andrew Stubbs [Tue, 2 Jun 2020 20:00:40 +0000 (21:00 +0100)]
amdgcn: Switch to HSACO v3 binary format

This upgrades the compiler to emit HSA Code Object v3 binaries.  This means
changing the assembler directives, and linker command line options.

The gcn-run and libgomp loaders need corresponding alterations.  The
relocations no longer need to be fixed up manually, and the kernel symbol
names have changed slightly.

This move makes the binaries compatible with the new rocgdb from ROCm 3.5.

2020-06-17  Andrew Stubbs  <ams@codesourcery.com>

gcc/
* config/gcn/gcn-hsa.h (TEXT_SECTION_ASM_OP): Use ".text".
(BSS_SECTION_ASM_OP): Use ".bss".
(ASM_SPEC): Remove "-mattr=-code-object-v3".
(LINK_SPEC): Add "--export-dynamic".
* config/gcn/gcn-opts.h (processor_type): Replace PROCESSOR_VEGA with
PROCESSOR_VEGA10 and PROCESSOR_VEGA20.
* config/gcn/gcn-run.c (HSA_RUNTIME_LIB): Use ".so.1" variant.
(load_image): Remove obsolete relocation handling.
Add ".kd" suffix to the symbol names.
* config/gcn/gcn.c (MAX_NORMAL_SGPR_COUNT): Set to 62.
(gcn_option_override): Update gcn_isa test.
(gcn_kernel_arg_types): Update all the assembler directives.
Remove the obsolete options.
(gcn_conditional_register_usage): Update MAX_NORMAL_SGPR_COUNT usage.
(gcn_omp_device_kind_arch_isa): Handle PROCESSOR_VEGA10 and
PROCESSOR_VEGA20.
(output_file_start): Rework assembler file header.
(gcn_hsa_declare_function_name): Rework kernel metadata.
* config/gcn/gcn.h (GCN_KERNEL_ARG_TYPES): Set to 16.
* config/gcn/gcn.opt (PROCESSOR_VEGA): Remove enum.
(PROCESSOR_VEGA10): New enum value.
(PROCESSOR_VEGA20): New enum value.

libgomp/
* plugin/plugin-gcn.c (init_environment_variables): Use ".so.1"
variant for HSA_RUNTIME_LIB name.
(find_executable_symbol_1): Delete.
(find_executable_symbol): Delete.
(init_kernel_properties): Add ".kd" suffix to symbol names.
(find_load_offset): Delete.
(create_and_finalize_hsa_program): Remove relocation handling.

4 years agogcov*: collapse lisence header to 2 lines in --version.
Martin Liska [Wed, 17 Jun 2020 08:53:44 +0000 (10:53 +0200)]
gcov*: collapse lisence header to 2 lines in --version.

gcc/ChangeLog:

* gcov-dump.c (print_version): Collapse lisence header to 2 lines
in --version.
* gcov-tool.c (print_version): Likewise.
* gcov.c (print_version): Likewise.

4 years ago[Ada] Add early return to Apply_Universal_Integer_Attribute_Checks
Eric Botcazou [Mon, 20 Apr 2020 11:04:45 +0000 (13:04 +0200)]
[Ada] Add early return to Apply_Universal_Integer_Attribute_Checks

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

gcc/ada/

* checks.adb (Apply_Universal_Integer_Attribute_Checks): Do not do
anything when the type of the node is already Universal_Integer.

4 years ago[Ada] ACATS 4.1H - BA12018 - Missed errors for private with
Arnaud Charlet [Sun, 19 Apr 2020 09:44:10 +0000 (05:44 -0400)]
[Ada] ACATS 4.1H - BA12018 - Missed errors for private with

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

gcc/ada/

* sem_ch10.adb (Expand_With_Clause): Add missing handling of
N_Generic_Subprogram_Declaration, N_Subprogram_Declaration,
N_Subprogram_Body.

4 years ago[Ada] Additional legality rule for indexing operation for derived type
Ed Schonberg [Fri, 17 Apr 2020 18:07:18 +0000 (14:07 -0400)]
[Ada] Additional legality rule for indexing operation for derived type

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

gcc/ada/

* sem_ch13.adb: (Check_Inherited_Indexing): Check that a type
derived from an indexable container type cannot specify an
indexing aspect if the same aspect is not specified for the
parent type (RM 4.1.6 (6/5), AI12-160). Add a check that a
specified indexing aspect for a derived type is confirming.

4 years ago[Ada] Nested subprograms in protected subprograms improperly handled in GNAT-LLVM
Gary Dismukes [Fri, 17 Apr 2020 20:56:58 +0000 (16:56 -0400)]
[Ada] Nested subprograms in protected subprograms improperly handled in GNAT-LLVM

2020-06-17  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* exp_ch9.adb (Build_Protected_Subp_Specification): Add ???
comment about the flag Has_Nested_Subprogram not being set here.
(Expand_N_Protected_Body): If the original body for a protected
subprogram has the flag Has_Nested_Subprogram set, then set that
flag on the new unprotected subprogram body that's created for
it, and reset the Scope fields of its top level declarations,
which have been effectively taken from the original protected
subprogram body. Add ??? comment about unclear testing of
Corresponding_Spec.

4 years ago[Ada] Ada2020: AI12-0279 more dispatching points with aspect Yield
Javier Miranda [Fri, 17 Apr 2020 18:41:58 +0000 (14:41 -0400)]
[Ada] Ada2020: AI12-0279 more dispatching points with aspect Yield

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

gcc/ada/

* aspects.ads (type Aspect_Id): Add Aspect_Yield as a Boolean
aspect, and update the Is_Representation_Aspect, Aspect_Names,
and Aspect_Delay arrays.
* einfo.ads, einfo.adb (Has_Yield_Aspect, Yield_Aspect): New
subprograms.
* exp_ch6.adb (Add_Return, Expand_Non_Function_Return,
Expand_Simple_Function_Return): Add calls to Yield.
* exp_ch9.adb (Build_Accept_Body, Expand_N_Accept_Statement):
Add calls to Yield.
* rtsfind.ads (RE_Yield): Adding support to generate calls to
the runtime service Ada.Dispatching.Yield
* sem_ch13.adb (Analyze_Aspect_Yield): New subprogram.
* sem_ch3.adb (Derive_Subprogram): Inherit attribute
Has_Yield_Aspect.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Check consistency
of Has_Yield in the actual subprogram of a generic
instantiation.
* sem_disp.adb (Check_Dispatching_Operation): Check that if the
Yield aspect is specified for a dispatching subprogram that
inherits the aspect, the specified value shall be confirming.
* sem_prag.adb (Analyze_Pragma [Pragma_Implemented]): Check that
the implementation kind By_Protected_Procedure cannot be applied
to a procedure that has aspect Yield.

4 years ago[Ada] Fix incorrect operand sharing after expansion
Eric Botcazou [Thu, 16 Apr 2020 21:42:13 +0000 (23:42 +0200)]
[Ada] Fix incorrect operand sharing after expansion

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

gcc/ada/

* exp_ch4.adb (Expand_N_Op_Expon): Replace all occurrences of
the original right operand with the relocated version.

4 years ago[Ada] Crash in tagged type constructor with task components
Javier Miranda [Thu, 16 Apr 2020 15:06:31 +0000 (11:06 -0400)]
[Ada] Crash in tagged type constructor with task components

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

gcc/ada/

* exp_ch6.adb (Has_BIP_Extra_Formal): New subprogram.
(Needs_BIP_Task_Actuals): Add support for the subprogram type
internally generated for dispatching calls.
* exp_disp.adb (Expand_Dispatching_Call): Adding code to
explicitly duplicate the extra formals of the target subprogram.
* freeze.adb (Check_Extra_Formals): New subprogram.
(Freeze_Subprogram): Fix decoration of Extra_Formals.
* sem_ch3.adb (Derive_Subprogram): Fix decoration of
Extra_Formals.

4 years ago[Ada] Do not give "bad indentation" error inside a declare_expression
Bob Duff [Thu, 16 Apr 2020 15:19:48 +0000 (11:19 -0400)]
[Ada] Do not give "bad indentation" error inside a declare_expression

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

gcc/ada/

* par.adb (P_Basic_Declarative_Items): Update comment about
Declare_Expression.
* par-ch3.adb (P_Declarative_Items): Pass in Declare_Expression
flag, and if True, skip the call to Style.Check_Indentation.
* par-ch4.adb (P_Declare_Expression): Fix incorrect comment.

4 years ago[Ada] Improve error message on anonymous access parameter conversion
Arnaud Charlet [Thu, 16 Apr 2020 12:37:56 +0000 (08:37 -0400)]
[Ada] Improve error message on anonymous access parameter conversion

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

gcc/ada/

* sem_res.adb (Valid_Conversion): Change error message to make
it more user-friendly.

4 years ago[Ada] Do not generate useless length check for array initialization
Eric Botcazou [Wed, 15 Apr 2020 19:11:17 +0000 (21:11 +0200)]
[Ada] Do not generate useless length check for array initialization

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

gcc/ada/

* checks.ads (Apply_Length_Check_On_Assignment): Declare.
* checks.adb (Apply_Length_Check_On_Assignment): New procedure
to apply a length check to an expression in an assignment.
* exp_ch5.adb (Expand_Assign_Array): Call it instead of calling
Apply_Length_Check to generate a length check.
* sem_ch5.adb (Analyze_Assignment): Likewise.

4 years ago[Ada] Support aspect Relaxed_Initialization on private types and constants
Piotr Trojanek [Tue, 14 Apr 2020 13:10:52 +0000 (15:10 +0200)]
[Ada] Support aspect Relaxed_Initialization on private types and constants

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

gcc/ada/

* einfo.adb (Is_Relaxed_Initialization_State): Add reference to
SPARK RM.
* sem_attr.adb (Analyze_Attribute_Old_Result): Likewise.
* sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Reject
aspect on completions of private types and deferred constants.
* sem_util.ads, sem_util.adb (Has_Relaxed_Initialization):
Adjust comments; support queries for constants.

4 years ago[Ada] Small cleanup throughout CStand body
Eric Botcazou [Wed, 15 Apr 2020 08:42:05 +0000 (10:42 +0200)]
[Ada] Small cleanup throughout CStand body

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

gcc/ada/

* cstand.adb (Stloc): Change to a renaming.
(Staloc): Likewise.
(Build_Unsigned_Integer_Type): Remove Nam parameter, use local
constants and do not call Make_Name.
(Make_Dummy_Index): Use local constants.
(Create_Standard): Pass the name of entities as parameter in
calls to New_Standard_Entity and remove calls to Make_Name.
Adjust calls to Build_Unsigned_Integer_Type.
(Identifier_For): Use local constant.
(Make_Component): Pass the name of the component as parameter
in call to New_Standard_Entity and remove call to Make_Name.
(Make_Formal): Likewise.  Rename Formal_Name parameter into
Nam and use local constant.
(Make_Name): Delete.
(New_Operator): Use local constant.
(New_Standard_Entity): Rename S parameter into Nam and build
the name here.  Remove call to Make_Name.
(Register_Float_Type): Pass the name of the type as parameter
in call to New_Standard_Entity and remove call to Make_Name.

4 years ago[Ada] Remove new problematic condition for LLVM
Eric Botcazou [Tue, 14 Apr 2020 21:49:22 +0000 (23:49 +0200)]
[Ada] Remove new problematic condition for LLVM

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

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_First>:
Remove condition added for scalar types.

4 years ago[Ada] Various typo corrections plus minor reformatting
Gary Dismukes [Tue, 14 Apr 2020 18:13:47 +0000 (14:13 -0400)]
[Ada] Various typo corrections plus minor reformatting

2020-06-17  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* exp_ch3.ads (Build_Access_Subprogram_Wrapper_Body): Adjust
colon columns; reformat comment.
* exp_ch3.adb
(Build_Access_Subprogram_Wrapper_Body): Likewise.
* sem_ch3.adb (Build_Access_Subprogram_Wrapper): Reformat spec
comment and reformat comment in body.
(Analyze_Full_Type_Declaration): Reformat comment.
(Replace_Type_Name): Fixed three typos, plus reformatting of
comment.
* sem_prag.adb (Analyze_Pre_Post_Condition): Fix typos.
* sem_warn.adb (Warn_On_Overlapping_Actuals): Edit comments:
remove hyphen, add missing word.

4 years ago[Ada] Ada2020: AI12-0110 Tampering checks are performed first
Bob Duff [Fri, 10 Apr 2020 22:23:15 +0000 (18:23 -0400)]
[Ada] Ada2020: AI12-0110 Tampering checks are performed first

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

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-cdlili.adb, libgnat/a-chtgbk.adb,
libgnat/a-chtgke.adb, libgnat/a-cidlli.adb,
libgnat/a-cihama.adb, libgnat/a-cihase.adb,
libgnat/a-cimutr.adb, libgnat/a-ciorma.adb,
libgnat/a-ciorse.adb, libgnat/a-cobove.adb,
libgnat/a-cohama.adb, libgnat/a-cohase.adb,
libgnat/a-coinve.adb, libgnat/a-comutr.adb,
libgnat/a-convec.adb, libgnat/a-coorma.adb,
libgnat/a-coorse.adb, libgnat/a-crbtgk.adb,
libgnat/a-crbtgo.adb, libgnat/a-rbtgso.adb: Move tampering
checks earlier.

4 years ago[Ada] Couple of small tweaks related to integer conversions
Eric Botcazou [Tue, 14 Apr 2020 09:20:18 +0000 (11:20 +0200)]
[Ada] Couple of small tweaks related to integer conversions

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

gcc/ada/

* exp_attr.adb (Get_Integer_Type): Use standard types without
a specific size.
* sem_res.adb (Resolve_Unchecked_Type_Conversion): Remove a
redundant intermediate conversion to Universal_Integer.

4 years ago[Ada] Fix comment of Get_Iterable_Type_Primitive
Piotr Trojanek [Sat, 11 Apr 2020 11:04:31 +0000 (13:04 +0200)]
[Ada] Fix comment of Get_Iterable_Type_Primitive

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

gcc/ada/

* sem_util.ads, sem_util.adb (Get_Iterable_Type_Primitive): Fix
comment and enforce it with an assertion in the body.

4 years ago[Ada] Ada_2020 AI12-0220 Pre/Postconditions on Access_To_Subprogram types
Ed Schonberg [Sun, 12 Apr 2020 14:34:46 +0000 (10:34 -0400)]
[Ada] Ada_2020 AI12-0220 Pre/Postconditions on Access_To_Subprogram types

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

gcc/ada/

* sem_ch3.adb (Analyze_Full_Type_Declaration): For an
access_to_subprogram declaration that has aspect specifications,
call Build_Access_ Subprogram_Wrapper at once, so that pre- and
postcondition aspects are analyzed in the context of a
subprogram declaration.
(Build_Access_Subprogram_Wrapper): Examine aspect specifications
of an Access_To_Subprogram declaration. If pre- or
postconditions are declared for it, create declaration for
subprogram wrapper and add the corresponding aspect
specifications to it. Replace occurrences of the type name by
that of the generated subprogram, so that attributes 'Old and
'Result can appear in a postcondition.
* exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Moved
here from sem_prag.adb.
* exp_ch3.ads (Build_Access_Subprogram_Wrapper_Body): Visible
subprogram.
* sem_prag.adb (Build_Access_Subprogram_Wrapper / _Body): Moved
to sem_ch3.adb and exp_ch3.adb.

4 years ago[Ada] Add assertions to Preserve_Comes_From_Source and reuse it
Piotr Trojanek [Sat, 11 Apr 2020 10:38:06 +0000 (12:38 +0200)]
[Ada] Add assertions to Preserve_Comes_From_Source and reuse it

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

gcc/ada/

* atree.adb (Preserve_Comes_From_Source): Rewrite using
Set_Comes_From_Source and Comes_From_Source, which enforce that
the parameters are valid.
* exp_ch4.adb, exp_ch5.adb, sem_ch12.adb, sem_ch6.adb,
sem_res.adb: Rewrite using Preserve_Comes_From_Source.

4 years ago[Ada] Remove obsolete comments in Big_Numbers
Arnaud Charlet [Thu, 9 Apr 2020 07:33:20 +0000 (03:33 -0400)]
[Ada] Remove obsolete comments in Big_Numbers

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

gcc/ada/

* libgnat/a-nbnbin.ads, libgnat/a-nbnbre.ads: Remove obsolete
comments.

4 years ago[Ada] Implement static expression functions for Ada 202x (AI12-0075)
Gary Dismukes [Tue, 7 Apr 2020 05:14:26 +0000 (01:14 -0400)]
[Ada] Implement static expression functions for Ada 202x (AI12-0075)

2020-06-17  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* aspects.ads (type Aspect_Id): Add Aspect_Static as a Boolean
aspect, and update the Is_Representation_Aspect, Aspect_Names,
and Aspect_Delay arrays.
* exp_ch6.adb (Expand_Simple_Function_Return): In the case of a
return for a static expression function, capture a copy of the
expression of the return statement before it's expanded and
reset its Analyzed flags. Then, just before leaving this
procedure, if the expression was rewritten, set the
Original_Node of the rewritten expression to the new copy and
also set the Expression of the associated static expression
function to designate that copy. This ensures that later copies
of the expression made via New_Copy_Tree will fully copy all
nodes of the expression tree.
* inline.ads (Inline_Static_Expression_Function_Call): New
procedure to evaluate and produce the result of a static call to
a static expression function.
* inline.adb: Add with and use for Sem_Res.
(Establish_Actual_Mapping_For_Inlined_Call): New procedure
extracted from code in Expand_Inlined_Call that traverses the
actuals and formals of an inlined call and in some cases creates
temporaries for holding the actuals, plus establishes an
association between formals and actuals (via the Renamed_Object
fields of the formals).
(Formal_Is_Used_Once): Function removed from Expand_Inlined_Call
and now nested in the above procedure.
(Expand_Inlined_Call): Code for doing the formal/actual
traversal is moved to Create_Actual_Temporaries and replaced
with a call to that new procedure.
(Inline_Static_Expression_Function_Call): New procedure to
evaluate a static call to a static expression function,
substituting actuals for their corresponding formals and
producing a fully folded and static result expression. The
function has subsidiary functions Replace_Formal and Reset_Sloc
that take care of doing the mapping of formals to actuals and
resetting the Slocs of subnodes of the mapped expression to that
of the call so errors will be flagged on the call rather than
function.
* sem_ch6.adb (Analyze_Expression_Function): In the case of a
static expression function, perform an additional preanalysis of
the function's expression to ensure that it's a potentially
static expression (according to the requirements of
6.8(3.2/5-3.4/5)), and issue an error if it's not. The global
flag Checking_Potentially_Static_Expression is set and unset
around this checking.
* sem_ch13.adb (Analyze_Aspect_Static): New procedure to enforce
selected requirements of the new aspect Static on expression
functions, including checking that the language version is
Ada_2020 and that the entity to which it applies is an
expression function whose formal parameters are of a static
subtype and have mode 'in', its result subtype is a static
subtype, and it has no pre- or postcondition aspects. A ???
comment is added to indicate the need for adding checking that
type invariants don't apply to the result type if the function
is a boundary entity.
(Analyze_One_Aspect): Call Analyze_Aspect_Static for aspect
Static.
* sem_elab.adb (Build_Call_Marker): Return without creating a
call marker when the subprogram is a static expression function,
since no ABE checking is needed for such functions.
* sem_eval.ads (Checking_Potentially_Static_Expression): New
function to return whether the checking for potentially static
expressions is enabled.
(Set_Checking_Potentially_Static_Expression): New procedure to
enable or disable checking of potentially static expressions.
* sem_eval.adb (Checking_For_Potentially_Static_Expression): New
global flag for determining whether preanalysis of potentially
static expression is being done, which affects the behavior of
certain static evaluation routines.
(Checking_Potentially_Static_Expression): New function to return
whether the checking for potentially static expressions is
enabled.
(Eval_Call): When evaluating a call within a static expression
function with checking of potentially static expression
functions enabled, substitutes a static value in place of the
call to allow folding of the expression.
(Eval_Entity_Name): When evaluating a formal parameter of a
static expression function with checking of potentially static
expression functions enabled, substitutes a static value in
place of the reference to the formal to allow folding of the
expression.
(Set_Checking_Potentially_Static_Expression): New procedure to
enable or disable checking of potentially static expressions.
* sem_res.adb (Resolve_Call): Test for a recursive call
occurring within a static expression function and issue an error
for such a call. Prevent the establishment of a transient scope
in the case this is a call to a (string-returning) static
expression function. When calling a static expression function,
if no error has been posted on the function, call
Inline_Static_Expression_Function_Call to convert the call into
its equivalent static value.
* sem_util.ads (Is_Static_Expression_Function): New function
returning whether the subprogram entity passed to it is a static
expression function.
(Is_Static_Expression_Function_Call): New function to determine
whether the call node passed to it is a static call to a static
expression function.
* sem_util.adb (Compile_Time_Constraint_Error): Suppress
compile-time Constraint_Error reporting when checking for a
potentially static expression.
(Is_Static_Expression_Function): New function returning whether
the subprogram entity passed to it is a static expression
function by testing for the presence of aspect Static.
(Has_All_Static_Actuals): New function in
Is_Static_Expression_Function_Call that traverses the actual
parameters of a function call and returns True only when all of
the actuals are given by static expressions. In the case of a
string-returning function, we call Resolve on each actual to
ensure that their Is_Static_Expression flag properly reflects
whether they're static, to allow suppressing creation of a
transient scope within Resolve_Call. A prominent ??? comment is
added to explain this rather unconventional call to Resolve.
(Is_Static_Expression_Function_Call): New function that
determines whether a node passed to it is a call to a static
expression function all of whose actual parameters are given by
static expressions.

4 years ago[Ada] Deal with second specific superflat case in Optimize_Length_Comparison
Eric Botcazou [Mon, 13 Apr 2020 07:16:18 +0000 (09:16 +0200)]
[Ada] Deal with second specific superflat case in Optimize_Length_Comparison

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

gcc/ada/

* exp_ch4.adb (Optimize_Length_Comparison): New local variable to
record whether this may be a dynamic superflat case.
(Is_Optimizable): Accept 0 as lower bound and set it in this case,
but return false if the operand is not a length too.
(Rewrite_For_Equal_Lengths): New procedure.
Optimize the comparison of two lengths in the superflat case when
the arrays have the same bounds.

4 years ago[Ada] Adjust documentation of 'Bit and 'Descriptor_Size attributes
Eric Botcazou [Mon, 13 Apr 2020 09:10:43 +0000 (11:10 +0200)]
[Ada] Adjust documentation of 'Bit and 'Descriptor_Size attributes

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

gcc/ada/

* doc/gnat_rm/implementation_defined_attributes.rst (Bit): Sharpen
the comparison with System.Storage_Unit.
(Descriptor_Size): Clear confusion about alignment and padding.
* gnat_rm.texi: Regenerate.

4 years ago[Ada] Work around problematic interaction with public symbol generation
Eric Botcazou [Sat, 11 Apr 2020 16:28:49 +0000 (18:28 +0200)]
[Ada] Work around problematic interaction with public symbol generation

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

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_First>:
Do not replace the bound for an array type if it is public.

4 years ago[Ada] Fix small oversight in change to Optimize_Length_Comparison
Eric Botcazou [Sat, 11 Apr 2020 13:40:24 +0000 (15:40 +0200)]
[Ada] Fix small oversight in change to Optimize_Length_Comparison

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

gcc/ada/

* exp_ch4.adb (Optimize_Length_Comparison): Make sure the base
types are the same when comparing Y'Last and X'Last directly.

4 years ago[Ada] Optimize length checks generated for slice assignments
Eric Botcazou [Fri, 10 Apr 2020 21:03:18 +0000 (23:03 +0200)]
[Ada] Optimize length checks generated for slice assignments

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

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_First>:
Replace it with a direct reference to an entity which is not a
discriminant for constrained array types.  Add same condition
for scalar types.
<Attribute_Last>: Merge with above implementation.
* exp_ch4.adb (Optimize_Length_Comparison): Be prepared for a
second entity whose length is compared.  Rename Prepare_64 to
Convert_To_Long_Long_Integer.  If the second entity is present,
compute the difference of the 'First attributes and compare the
sum of 'Last of the second entity with this difference against
'Last of the first entity.  Add a special case when the 'First
attributes are equal.  Suppress overflow checks in all cases.

4 years ago[Ada] Fix casing from GNATProve to GNATprove
Piotr Trojanek [Fri, 10 Apr 2020 17:33:44 +0000 (19:33 +0200)]
[Ada] Fix casing from GNATProve to GNATprove

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

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst, lib-writ.ads,
par-prag.adb, sem_ch12.adb, sem_ch8.adb, sem_prag.adb: Fix
casing of GNATprove.
* gnat_rm.texi: Regenerate.

4 years ago[Ada] Remove unnecessary special-casing of GNATprove expansion
Piotr Trojanek [Fri, 10 Apr 2020 17:30:13 +0000 (19:30 +0200)]
[Ada] Remove unnecessary special-casing of GNATprove expansion

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

gcc/ada/

* checks.adb (Generate_Range_Check): Simplify redundant
condition.
* sem_ch3.adb (Check_Initialization, Process_Discriminants):
Likewise.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Likewise.

4 years ago[Ada] Fix small fallout of change for 'Pos and 'Val attributes
Eric Botcazou [Fri, 10 Apr 2020 09:20:55 +0000 (11:20 +0200)]
[Ada] Fix small fallout of change for 'Pos and 'Val attributes

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

gcc/ada/

* exp_fixd.adb (Build_Conversion): Also preserve the
Conversion_OK flag of an inner conversion.

4 years ago[Ada] Fix expansion of "for X of Y loop" in GNATprove
Piotr Trojanek [Wed, 8 Apr 2020 21:38:51 +0000 (23:38 +0200)]
[Ada] Fix expansion of "for X of Y loop" in GNATprove

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

gcc/ada/

* sem_ch5.adb (Analyze_Iterator_Specification): Enable expansion
that creates a renaming that removes side effects from the
iterated object in the GNATprove mode; then analyze reference to
this renaming (it is required for GNATprove and harmless for
GNAT).

4 years agoOptimize V16QI/V32QI/V64QI shift by constant.
liuhongt [Mon, 15 Jun 2020 05:48:45 +0000 (13:48 +0800)]
Optimize V16QI/V32QI/V64QI shift by constant.

gcc/ChangeLog:
PR target/95524
* config/i386/i386-expand.c
(ix86_expand_vec_shift_qihi_constant): New function.
* config/i386/i386-protos.h
(ix86_expand_vec_shift_qihi_constant): Declare.
* config/i386/sse.md (<shift_insn><mode>3): Optimize shift
V*QImode by constant.

gcc/testsuite/ChangeLog:
* gcc.target/i386/avx2-shiftqihi-constant-1.c: New test.
* gcc.target/i386/avx2-shiftqihi-constant-2.c: Ditto.
* gcc.target/i386/avx512bw-shiftqihi-constant-1.c: Ditto.
* gcc.target/i386/avx512bw-shiftqihi-constant-2.c: Ditto.
* gcc.target/i386/sse2-shiftqihi-constant-1.c: Ditto.
* gcc.target/i386/sse2-shiftqihi-constant-2.c: Ditto.

4 years agogcov: fix gcov-tool merge for TOPN counters
Martin Liska [Tue, 16 Jun 2020 12:14:03 +0000 (14:14 +0200)]
gcov: fix gcov-tool merge for TOPN counters

libgcc/ChangeLog:

* libgcov-util.c (read_gcda_finalize): Remove const operator.
(merge_wrapper): Add both counts and use them properly.
(topn_to_memory_representation): New function.
(gcov_merge): Covert on disk representation to in memory
representation.
* libgcov.h: Remove const operator.

4 years agoDaily bump.
GCC Administrator [Wed, 17 Jun 2020 00:16:36 +0000 (00:16 +0000)]
Daily bump.

4 years agomiddle-end: Add another testcase for PR 95493
Jonathan Wakely [Tue, 16 Jun 2020 22:14:23 +0000 (23:14 +0100)]
middle-end: Add another testcase for PR 95493

This was reported on the gcc-help mailing list. The regression started
with r10-589 and was fixed by r11-963.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr95493-1.C: New test.

4 years agod: Remove names of unused function parameters.
Iain Buclaw [Thu, 14 May 2020 20:29:48 +0000 (22:29 +0200)]
d: Remove names of unused function parameters.

gcc/d/ChangeLog:

* d-attribs.cc (handle_noreturn_attribute): Remove names of unused
function parameters.
(handle_leaf_attribute): Likewise.
(handle_const_attribute): Likewise.
(handle_malloc_attribute): Likewise.
(handle_pure_attribute): Likewise.
(handle_novops_attribute): Likewise.
(handle_nonnull_attribute): Likewise.
(handle_nothrow_attribute): Likewise.
(handle_type_generic_attribute): Likewise.
(handle_transaction_pure_attribute): Likewise.
(handle_returns_twice_attribute): Likewise.
(handle_fnspec_attribute): Likewise.
(handle_always_inline_attribute): Likewise.
(d_handle_noinline_attribute): Likewise.
(d_handle_forceinline_attribute): Likewise.
(d_handle_flatten_attribute): Likewise.
(d_handle_noclone_attribute): Likewise.
(d_handle_section_attribute): Likewise.
(d_handle_alias_attribute): Likewise.
(d_handle_weak_attribute): Likewise.

4 years agod: Update code formatting in a consistent style.
Iain Buclaw [Tue, 16 Jun 2020 14:23:44 +0000 (16:23 +0200)]
d: Update code formatting in a consistent style.

gcc/d/ChangeLog:

* d-attribs.cc: Update code formatting in a consistant style.
* d-builtins.cc: Likewise.
* d-codegen.cc: Likewise.
* d-compiler.cc: Likewise.
* d-convert.cc: Likewise.
* d-diagnostic.cc: Likewise.
* d-frontend.cc: Likewise.
* d-lang.cc: Likewise.
* d-longdouble.cc: Likewise.
* d-port.cc: Likewise.
* d-spec.cc: Likewise.
* d-tree.h: Likewise.
* decl.cc: Likewise.
* expr.cc: Likewise.
* longdouble.h: Likewise.
* modules.cc: Likewise.
* toir.cc: Likewise.
* typeinfo.cc: Likewise.

4 years agod: Consistently format quotations in comments.
Iain Buclaw [Tue, 16 Jun 2020 13:57:58 +0000 (15:57 +0200)]
d: Consistently format quotations in comments.

gcc/d/ChangeLog:

* d-builtins.cc: Update quotation formatting of comments.
* d-codegen.cc: Likewise.
* d-lang.cc: Likewise.
* decl.cc: Likewise.
* expr.cc: Likewise.
* imports.cc: Likewise.
* runtime.cc: Likewise.
* toir.cc: Likewise.
* typeinfo.cc: Likewise.
* types.cc: Likewise.

4 years agod: Remove dependency on front-end OutBuffer for diagnostic and deps file generation.
Iain Buclaw [Tue, 16 Jun 2020 13:42:23 +0000 (15:42 +0200)]
d: Remove dependency on front-end OutBuffer for diagnostic and deps file generation.

gcc/d/ChangeLog:

* d-diagnostic.cc (expand_d_format): Replace OutBuffer with obstack.
(d_diagnostic_report_diagnostic): Don't free xformat.
* d-lang.cc (struct d_option_data): Change deps_target type from
OutBuffer to vec <const char *>.
(deps_add_target): Update to push each target to deps_target.
(deps_write_string): New function.
(deps_write): Change buffer type to obstack* and remove colmax.
(d_init_options): Update initialization of deps_target.
(d_parse_file): Replace OutBuffer with obstack.

4 years agod: Remove dependency on front-end File type for json and deps file generation.
Iain Buclaw [Tue, 16 Jun 2020 08:27:52 +0000 (10:27 +0200)]
d: Remove dependency on front-end File type for json and deps file generation.

gcc/d/ChangeLog:

* d-lang.cc (d_parse_file): Replace uses of File with FILE.

4 years agod: Move generation of array bounds error to own function.
Iain Buclaw [Tue, 16 Jun 2020 08:11:07 +0000 (10:11 +0200)]
d: Move generation of array bounds error to own function.

gcc/d/ChangeLog:

* d-codegen.cc (build_array_bounds_call): New function.
(build_bounds_condition): Use build_array_bounds_call.
* d-lang.cc (d_init_options): Explicitly set default check action to
CHECKACTION_D.
(d_post_options): Set check action to CHECKACTION_C if the flag
-fno-druntime was seen.
* d-tree.h (build_array_bounds_call): Declare.
* expr.cc (ExprVisitor::visit (AssertExp *)): Use
build_array_bounds_call.

4 years agolibstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)
Jonathan Wakely [Tue, 16 Jun 2020 21:34:55 +0000 (22:34 +0100)]
libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)

This improves the previous fix for PR 95282, and extends it to also
apply to the exchange function (which has a similar problem and would
become ill-formed with my proposed fix for PR 95378).

PR libstdc++/95282
* include/bits/atomic_base.h (__atomic_impl::load): Use the _Val
alias instead of deducing _Tp as an unqualified type.
(__atomic_impl::exchange): Use the _Val alias to remove volatile
from the reinterpret_cast result type.

4 years agolibstdc++: Enforce copyable/movable checks in std::atomic
Jonathan Wakely [Tue, 16 Jun 2020 21:34:55 +0000 (22:34 +0100)]
libstdc++: Enforce copyable/movable checks in std::atomic

C++20 adds some new preconditions to std::atomic, which weren't
previously checked by our implementation.

* include/std/atomic (atomic): Add static assertions.
* testsuite/29_atomics/atomic/requirements/types_neg.cc: New test.

4 years agod: Use toStringExp instead of explicit cast
Iain Buclaw [Mon, 15 Jun 2020 15:43:31 +0000 (17:43 +0200)]
d: Use toStringExp instead of explicit cast

gcc/d/ChangeLog:

* d-attribs.cc (build_attributes): Use toStringExp instead of cast.
* toir.cc (IRVisitor::visit): Likewise.

4 years agod: Use new isXxxxExp helpers where possible
Iain Buclaw [Mon, 15 Jun 2020 15:39:12 +0000 (17:39 +0200)]
d: Use new isXxxxExp helpers where possible

gcc/d/ChangeLog:

* d-attribs.cc (build_attributes): Use isXxxxExp helpers instead of
explicit casts.
* d-codegen.cc (d_build_call): Likewise.
* d-compiler.cc (Compiler::paintAsType): Likewise.
* decl.cc (ExprVisitor::visit): Likewise.
(layout_class_initializer): Likewise.
* expr.cc (ExprVisitor::lvalue_p): Likewise
(ExprVisitor::visit): Likewise.
* types.cc (layout_aggregate_members): Likewise.

4 years agod: Use toTypeFunction instead of explicit cast
Iain Buclaw [Mon, 15 Jun 2020 14:56:02 +0000 (16:56 +0200)]
d: Use toTypeFunction instead of explicit cast

gcc/d/ChangeLog:

* d-frontend.cc (eval_builtin): Use toTypeFunction instead of cast.
* decl.cc (DeclVisitor::visit): Likewise.
* toir.cc (IRVisitor::visit): Likewise.
* typeinfo.cc (TypeInfoVisitor::visit): Likewise.

4 years agod: Use new isTypeXxxx helpers where possible.
Iain Buclaw [Wed, 3 Jun 2020 13:26:25 +0000 (15:26 +0200)]
d: Use new isTypeXxxx helpers where possible.

gcc/d/ChangeLog:

* d-builtins.cc (d_eval_constant_expression): Use isTypeXxxx helpers
instead of explicit casts.
(d_build_builtins_module): Likewise.
* d-codegen.cc (get_array_length): Likewise.
(identity_compare_p): Likewise.
(lower_struct_comparison): Likewise.
(build_array_from_val): Likewise.
(array_bounds_check): Likewise.
(get_function_type): Likewise.
(d_build_call): Likewise.
* d-compiler.cc (Compiler::paintAsType): Likewise.
* d-convert.cc (convert_expr): Likewise.
(convert_for_assignment): Likewise.
* d-lang.cc (d_classify_record): Likewise.
(d_build_eh_runtime_type): Likewise.
* decl.cc (DeclVisitor::visit): Likewise.
* expr.cc (ExprVisitor::needs_postblit): Likewise.
(ExprVisitor::needs_dtor): Likewise.
(ExprVisitor::visit): Likewise.
* imports.cc (ImportVisitor::visit): Likewise.
* typeinfo.cc (get_typeinfo_kind): Likewise.
(TypeInfoVisitor::visit): Likewise.
(TypeDeclInfoVisitor::visit): Likewise.
* types.cc (merge_aggregate_types): Likewise.
(TypeVisitor::visit): Likewise.

4 years agoFix pasto in the substitute_and_fold_engine merge with evrp.
Aldy Hernandez [Tue, 16 Jun 2020 11:43:57 +0000 (13:43 +0200)]
Fix pasto in the substitute_and_fold_engine merge with evrp.

The original code only propagated into PHI arguments if the value was
a constant.  This behavior was lost in the conversion, allowing
any value (SSAs for instance) to be propagated into PHIs.

gcc/ChangeLog:

PR tree-optimization/95649
* tree-ssa-propagate.c (propagate_into_phi_args): Do not propagate unless
value is a constant.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr95649.C: New test.
* gcc.dg/tree-ssa/pr95649.c: New test.

4 years agoOpenACC/Fortran: permit 'routine' inside PURE
Tobias Burnus [Tue, 16 Jun 2020 18:18:31 +0000 (20:18 +0200)]
OpenACC/Fortran: permit 'routine' inside PURE

gcc/fortran/ChangeLog

* parse.c (decode_oacc_directive): Permit 'acc routine' also
inside pure procedures.
* openmp.c (gfc_match_oacc_routine): Inside pure procedures
do not permit gang, worker or vector clauses.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/routine-10.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/pure-elemental-procedures-2.f90: New test.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
4 years agoOpenMP/Fortran: Permit impure ELEMENTAL in omp directives
Tobias Burnus [Tue, 16 Jun 2020 18:17:20 +0000 (20:17 +0200)]
OpenMP/Fortran: Permit impure ELEMENTAL in omp directives

OpenMP since 4.5 permits IMPURE ELEMENTAL in directives and
the code already only checked for PURE. – Followup for
-fopenmp-simd.

gcc/fortran/ChangeLog:

* parse.c (decode_omp_directive): Remove "or ELEMENTAL"
from "in PURE" error message also for -fopenmp-simd.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr79154-simd.f90: New test.

4 years agoc++: Don't allow designated initializers with non-aggregates [PR95369]
Marek Polacek [Mon, 15 Jun 2020 19:31:32 +0000 (15:31 -0400)]
c++: Don't allow designated initializers with non-aggregates [PR95369]

Another part of 95369 is that we accept designated initializers with
non-aggregate types.  That seems to be wrong since they're part of
aggregate initialization.  clang/icc also reject it.

There are multiple contexts where we can use designated initializers:
function-like casts, member list initializers, NTTP, etc.  I've adjusted
add_list_candidates and implicit_conversion_error in order to to detect
this case.

gcc/cp/ChangeLog:

PR c++/95369
* call.c (add_list_candidates): Return if a designated initializer
is used with a non-aggregate.
(implicit_conversion_error): Give an error for the case above.

gcc/testsuite/ChangeLog:

PR c++/95369
* g++.dg/cpp2a/desig11.C: Adjust dg-error.
* g++.dg/cpp2a/desig16.C: New test.

4 years agoc++: Fix ICE in check_local_shadow with enum [PR95560]
Marek Polacek [Tue, 16 Jun 2020 17:02:23 +0000 (13:02 -0400)]
c++: Fix ICE in check_local_shadow with enum [PR95560]

Another indication that perhaps this warning is emitted too early.  We
crash because same_type_p gets a null type: we have an enumerator
without a fixed underlying type and finish_enum_value_list hasn't yet
run.  So check if the type is null before calling same_type_p.

PR c++/95560
* name-lookup.c (check_local_shadow): Check if types are
non-null before calling same_type_p.

* g++.dg/warn/Wshadow-local-3.C: New test.

4 years agotestsuite: Make sure the *san/inline* tests aren't UNRESOLVED with LTO
Jakub Jelinek [Tue, 16 Jun 2020 16:19:44 +0000 (18:19 +0200)]
testsuite: Make sure the *san/inline* tests aren't UNRESOLVED with LTO

These tests are UNRESOLVED because -fdump-tree-optimized can't be scanned
with slim LTO.  Other *san/ tests deal with this by adding -ffat-lto-objects.

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

* c-c++-common/asan/inline.c: Add -ffat-lto-objects to dg-options.
* c-c++-common/asan/inline-kernel.c: Likewise.
* c-c++-common/ubsan/inline.c: Likewise.

4 years agoS/390: Emit vector alignment hints for z13 if AS accepts them
Stefan Schulze Frielinghaus [Thu, 4 Jun 2020 11:50:49 +0000 (13:50 +0200)]
S/390: Emit vector alignment hints for z13 if AS accepts them

Since 87cb9423add vector alignment hints are emitted for target z13,
too.  This patch changes this behaviour in the sense that alignment
hints are only emitted for target z13 if the assembler accepts them.

gcc/ChangeLog:

* config.in: Regenerate.
* config/s390/s390.c (print_operand): Emit vector alignment hints
for target z13, if AS accepts them.  For other targets the logic
stays the same.
* config/s390/s390.h (TARGET_VECTOR_LOADSTORE_ALIGNMENT_HINTS): Define
macro.
* configure: Regenerate.
* configure.ac: Check HAVE_AS_VECTOR_LOADSTORE_ALIGNMENT_HINTS_ON_Z13.

4 years ago[PATCH][GCC] arm: Fix the MVE ACLE vaddq_m polymorphic variants.
Srinath Parvathaneni [Tue, 16 Jun 2020 14:58:07 +0000 (15:58 +0100)]
[PATCH][GCC] arm: Fix the MVE ACLE vaddq_m polymorphic variants.

Hello,

This patch fixes the MVE ACLE vaddq_m polymorphic variants by modifying the corresponding
intrinsic parameters and vaddq_m polymorphic variant's _Generic case entries in "arm_mve.h"
header file.

2020-06-04  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

gcc/
* config/arm/arm_mve.h (__arm_vaddq_m_n_s8): Correct the intrinsic
arguments.
(__arm_vaddq_m_n_s32): Likewise.
(__arm_vaddq_m_n_s16): Likewise.
(__arm_vaddq_m_n_u8): Likewise.
(__arm_vaddq_m_n_u32): Likewise.
(__arm_vaddq_m_n_u16): Likewise.
(__arm_vaddq_m): Modify polymorphic variant.

gcc/testsuite/
* gcc.target/arm/mve/intrinsics/mve_vaddq_m.c: New test.

4 years ago[PATCH][GCC] arm: Fix MVE scalar shift intrinsics code-gen.
Srinath Parvathaneni [Tue, 16 Jun 2020 14:55:55 +0000 (15:55 +0100)]
[PATCH][GCC] arm: Fix MVE scalar shift intrinsics code-gen.

This patch modifies the MVE scalar shift RTL patterns. The current patterns
have wrong constraints and predicates due to which the values returned from
MVE scalar shift instructions are overwritten in the code-gen.

example:
$ cat x.c
int32_t  foo(int64_t acc, int shift)
{
  return sqrshrl_sat48 (acc, shift);
}

Code-gen before applying this patch:
$ arm-none-eabi-gcc -march=armv8.1-m.main+mve -mfloat-abi=hard -O2 -S
$  cat x.s
foo:
   push    {r4, r5}
   sqrshrl r0, r1, #48, r2   ----> (a)
   mov     r0, r4  ----> (b)
   pop     {r4, r5}
   bx      lr

Code-gen after applying this patch:
foo:
   sqrshrl r0, r1, #48, r2
   bx      lr

In the current compiler the return value (r0) from sqrshrl (a) is getting
overwritten by the mov statement (b).
This patch fixes above issue.

2020-06-12  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

gcc/
* config/arm/mve.md (mve_uqrshll_sat<supf>_di): Correct the predicate
and constraint of all the operands.
(mve_sqrshrl_sat<supf>_di): Likewise.
(mve_uqrshl_si): Likewise.
(mve_sqrshr_si): Likewise.
(mve_uqshll_di): Likewise.
(mve_urshrl_di): Likewise.
(mve_uqshl_si): Likewise.
(mve_urshr_si): Likewise.
(mve_sqshl_si): Likewise.
(mve_srshr_si): Likewise.
(mve_srshrl_di): Likewise.
(mve_sqshll_di): Likewise.
* config/arm/predicates.md (arm_low_register_operand): Define.

gcc/testsuite/
* gcc.target/arm/mve/intrinsics/mve_scalar_shifts1.c: New test.
* gcc.target/arm/mve/intrinsics/mve_scalar_shifts2.c: Likewise.
* gcc.target/arm/mve/intrinsics/mve_scalar_shifts3.c: Likewise.
* gcc.target/arm/mve/intrinsics/mve_scalar_shifts4.c: Likewise.

4 years agoopenmp: Initial part of OpenMP 5.0 non-rectangular loop support
Jakub Jelinek [Tue, 16 Jun 2020 14:31:13 +0000 (16:31 +0200)]
openmp: Initial part of OpenMP 5.0 non-rectangular loop support

OpenMP 5.0 adds support for non-rectangular loop collapses, e.g.
triangular and more complex.

This patch deals just with the diagnostics so that they aren't rejected
immediately as before.  As the spec generally requires as before that the
iteration variable initializer and bound in the comparison as invariant
vs. the outermost loop, and just add some exceptional forms that can violate
that, we need to avoid folding the expressions until we can detect them and
in order to avoid folding it later on, I chose to use a TREE_VEC in those
expressions to hold the var_outer * expr1 + expr2 triplet, the patch adds
pretty-printing of that, gimplification etc. and just sorry_at during
omp expansion for now.

The next step will be to implement the different cases of that one by one.

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

gcc/
* tree.h (OMP_FOR_NON_RECTANGULAR): Define.
* gimplify.c (gimplify_omp_for): Diagnose schedule, ordered
or dist_schedule clause on non-rectangular loops.  Handle
gimplification of non-rectangular lb/b expressions.  When changing
iteration variable, adjust also non-rectangular lb/b expressions
referencing that.
* omp-general.h (struct omp_for_data_loop): Add m1, m2 and outer
members.
(struct omp_for_data): Add non_rect member.
* omp-general.c (omp_extract_for_data): Handle non-rectangular
loops.  Fill in non_rect, m1, m2 and outer.
* omp-low.c (lower_omp_for): Handle non-rectangular lb/b expressions.
* omp-expand.c (expand_omp_for): Emit sorry_at for unsupported
non-rectangular loop cases and assert for cases that can't be
non-rectangular.
* tree-pretty-print.c (dump_mem_ref): Formatting fix.
(dump_omp_loop_non_rect_expr): New function.
(dump_generic_node): Handle non-rectangular OpenMP loops.
* tree-pretty-print.h (dump_omp_loop_non_rect_expr): Declare.
* gimple-pretty-print.c (dump_gimple_omp_for): Handle non-rectangular
OpenMP loops.
gcc/c-family/
* c-common.h (c_omp_check_loop_iv_exprs): Add an int argument.
* c-omp.c (struct c_omp_check_loop_iv_data): Add maybe_nonrect and
idx members.
(c_omp_is_loop_iterator): New function.
(c_omp_check_loop_iv_r): Use it.  Add support for silent scanning
if outer loop iterator is present.  Perform duplicate checking through
hash_set in the function rather than expecting caller to do that.
Pass NULL instead of d->ppset to walk_tree_1.
(c_omp_check_nonrect_loop_iv): New function.
(c_omp_check_loop_iv): Use it.  Fill in new members, allow
non-rectangular loop forms, diagnose multiple associated loops with
the same iterator.  Pass NULL instead of &pset to walk_tree_1.
(c_omp_check_loop_iv_exprs): Likewise.
gcc/c/
* c-parser.c (c_parser_expr_no_commas): Save, clear and restore
c_in_omp_for.
(c_parser_omp_for_loop): Set c_in_omp_for around some calls to avoid
premature c_fully_fold.  Defer explicit c_fully_fold calls to after
c_finish_omp_for.
* c-tree.h (c_in_omp_for): Declare.
* c-typeck.c (c_in_omp_for): Define.
(build_modify_expr): Avoid c_fully_fold if c_in_omp_for.
(digest_init): Likewise.
(build_binary_op): Likewise.
gcc/cp/
* semantics.c (handle_omp_for_class_iterator): Adjust
c_omp_check_loop_iv_exprs caller.
(finish_omp_for): Likewise.  Don't call fold_build_cleanup_point_expr
before calling c_finish_omp_for and c_omp_check_loop_iv, move it
after those calls.
* pt.c (tsubst_omp_for_iterator): Handle non-rectangular loops.
gcc/testsuite/
* c-c++-common/gomp/loop-6.c: New test.
* gcc.dg/gomp/loop-1.c: Don't expect diagnostics on valid
non-rectangular loops.
* gcc.dg/gomp/loop-2.c: New test.
* g++.dg/gomp/loop-1.C: Don't expect diagnostics on valid
non-rectangular loops.
* g++.dg/gomp/loop-2.C: Likewise.
* g++.dg/gomp/loop-5.C: New test.
* g++.dg/gomp/loop-6.C: New test.

4 years agoopenmp: Diagnose invalid OpenMP schedule(simd, static)
Jakub Jelinek [Tue, 16 Jun 2020 14:30:05 +0000 (16:30 +0200)]
openmp: Diagnose invalid OpenMP schedule(simd, static)

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

gcc/c/
* c-parser.c (c_parser_omp_clause_schedule): Reject modifier separated
from kind by comma rather than colon.
gcc/cp/
* parser.c (cp_parser_omp_clause_schedule): Reject modifier separated
from kind by comma rather than colon.
gcc/testsuite/
* c-c++-common/gomp/schedule-modifiers-2.c: New test.

4 years agotestsuite: Add offloading_enabled check and use it for xfail (PR95622)
Tobias Burnus [Tue, 16 Jun 2020 13:14:13 +0000 (15:14 +0200)]
testsuite: Add offloading_enabled check and use it for xfail (PR95622)

gcc/testsuite/ChangeLog:

PR middle-end/95622
* lib/target-supports.exp (check_effective_target_offloading_enabled):
New.
* c-c++-common/goacc/kernels-alias-ipa-pta-2.c: Use it for xfail.
* c-c++-common/goacc/kernels-alias-ipa-pta-4.c: Likewise.
* c-c++-common/goacc/kernels-alias-ipa-pta.c: Likewise.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
4 years agoOpenMP/Fortran: Permit impure ELEMENTAL in omp directives
Tobias Burnus [Tue, 16 Jun 2020 13:11:12 +0000 (15:11 +0200)]
OpenMP/Fortran: Permit impure ELEMENTAL in omp directives

OpenMP since 4.5 permits IMPURE ELEMENTAL in directives and
the code already only checked for PURE.

gcc/fortran/ChangeLog:

* parse.c (decode_omp_directive): Remove "or ELEMENTAL"
from "in PURE" error message.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr79154-1.f90: Update dg-*;
add an impure elemental example.
* gfortran.dg/gomp/pr79154-2.f90: Likewise.

4 years ago[Ada] Expand 'Pos and 'Val for enumeration types with standard representation
Eric Botcazou [Thu, 9 Apr 2020 09:42:22 +0000 (11:42 +0200)]
[Ada] Expand 'Pos and 'Val for enumeration types with standard representation

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

gcc/ada/

* sinfo.ads (Conversion_OK): Document use for 'Pos and 'Val.
* exp_attr.adb (Get_Integer_Type): New function returning a
small integer type appropriate for an enumeration type.
(Expand_N_Attribute_Reference) <Attribute_Enum_Rep>: Call it.
<Attribute_Pos>: For an enumeration type with a standard
representation, expand to a conversion with Conversion_OK.
<Attribute_Val>: Likewise.
* exp_ch4.adb (Expand_N_Type_Conversion): Do not expand when
the target is an enumeration type and Conversion_OK is set.

4 years ago[Ada] Fix spurious error on derived private type with predicate
Eric Botcazou [Thu, 9 Apr 2020 10:56:01 +0000 (12:56 +0200)]
[Ada] Fix spurious error on derived private type with predicate

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

gcc/ada/

* sem_ch4.adb (Common_Type): Go to Underlying_Full_View, if any.