165728 Commits

Author SHA1 Message Date
Richard Earnshaw
7bd0ca1100 Fix PR number in my last commit
From-SVN: r267058
2018-12-12 16:31:12 +00:00
Jonathan Wakely
9e16052644 Overload std::distance and std::advance for path::iterator
Although filesystem::path::iterator is only a bidirectional iterator,
the underlying sequence has random access iterators (specifically, raw
pointers). This means std::distance and std::advance can be implemented
more efficiently than the generic versions which apply ++ and --
repeatedly.

	PR libstdc++/71044 (partial)
	* include/bits/fs_path.h (__path_iter_distance, __path_iter_advance):
	New friend functions to implement std::distance and std::advance more
	efficiently.
	(distance, advance): Add overloads for path::iterator.
	* testsuite/27_io/filesystem/path/itr/components.cc: Test new
	overload.

From-SVN: r267057
2018-12-12 16:13:49 +00:00
Jonathan Wakely
6b7c0b5559 PR libstdc++/80762 avoid ambiguous __constructible_from<void, void>
Ensure we don't try to instantiate __is_constructible_from<void, void>,
because there are two partial specializations that are equally good
matches.

	PR libstdc++/80762
	* include/bits/fs_path.h (path::_Path): Use remove_cv_t and is_void.
	* include/experimental/bits/fs_path.h (path::_Path): Likewise.
	* testsuite/27_io/filesystem/path/construct/80762.cc: New test.
	* testsuite/experimental/filesystem/path/construct/80762.cc: New test.

From-SVN: r267056
2018-12-12 16:13:43 +00:00
Joel Brobecker
5da5fefeeb require profiling support for gcc.dg/lto/20100430-1_0.c test
This test currently fails unexpectedly if GCC is configured with
--disable-gcov, because it requires -fprofile-arcs. This patch
fixes the issue by requiring profiling support in order to run
this test.

Tested with two compilers, one built with --disable-gcov, resulting
in the test reporting an UNSUPPORTED result; and one built with gcov
support, resulting in 2 PASS tests.

gcc/testsuite/ChangeLog:

        * gcc.dg/lto/20100430-1_0.c: Add dg-require-profiling requirement.

From-SVN: r267055
2018-12-12 14:22:37 +00:00
Tom de Vries
d665cd9b13 [libbacktrace] Add allocfail.sh test-case
Add test-case that forces alloc.c functions to fail, and check whether fail
handling is robust.

This is the test-case for "[libbacktrace] Fix segfault upon allocation
failure".  Without that patch, this test-case fails like this:
...
allocfail.sh: line 71: 26041 Segmentation fault      (core dumped) \
  ./allocfail $i > /dev/null 2>&1
Unallowed fail found: 13
FAIL allocfail.sh (exit status: 1)
...

This is a seperate patch because the test-case is nontrivial.

Bootstrapped and reg-tested on x86_64.

2018-12-12  Tom de Vries  <tdevries@suse.de>

	* Makefile.am (TESTS): Add allocfail.sh.
	(check_PROGRAMS): Add allocfail.
	* Makefile.in: Regenerate.
	* instrumented_alloc.c: New file.  Redefine malloc and realloc.
	Include alloc.c.
	* allocfail.c: New file.
	* allocfail.sh: New file.

From-SVN: r267054
2018-12-12 13:50:51 +00:00
Eric Botcazou
bf4eca2e56 re PR target/86806 (SPARC port needs updating for CVE-2017-5753)
PR target/86806
	* config/sparc/sparc.md (unspecv): Add UNSPECV_SPECULATION_BARRIER.
	(speculation_barrier): New instruction for V9.

From-SVN: r267053
2018-12-12 11:40:28 +00:00
Andreas Schwab
9c47a01994 Don't mark stack pointer as clobbered in asm
* config/linux/ia64/futex.h (sys_futex0): Don't mark r12 as
clobbered.

From-SVN: r267052
2018-12-12 11:22:42 +00:00
Rasmus Villemoes
5a2580b6ad libgcc: rs6000: tramp.S: fix placement of .cfi_endproc for __trampoline_setup
Currently, .cfi_endproc and FUNC_END(__trampoline_setup) are placed
inside the #else branch of an "#if defined (__VXWORKS__) ...", so
non-pic vxworks does not get proper CFI nor a .size directive for
__trampoline_setup. I assume there's no magic reason for that (which
would warrant a comment), so move them outside.

From-SVN: r267051
2018-12-12 10:12:36 +00:00
Iain Sandoe
0c1342dfad rs6000 - add missed hunk
This add the hunk
	(macho_call_template): Remove.

missed from r267049

From-SVN: r267050
2018-12-12 09:25:13 +00:00
Segher Boessenkool
be611c9c5a rs6000 - Fix PR target/88343
The PR is about unnecessary saves of the pic base register, it shows on m32 Linux and m32/m64 Darwin.

The fix is to check that we are in a pic mode and that the picbase has actually been used.
As a bonus, some #ifdef’d TARGET_MACHO code is no longer required.

2018-12-12 Segher Boessenkool  <segher@kernel.crashing.org>
	   Iain Sandoe  <iain@sandoe.co.uk>

	PR target/88343
	* config/rs6000/rs6000.c (save_reg_p): Do not save the picbase reg
	unless it has been used.
	(first_reg_to_save): Remove dead code.


Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

From-SVN: r267049
2018-12-12 08:53:49 +00:00
Iain Sandoe
aa3a2eca42 rs6000, update Darwin call handling to latest scheme.
This patch mormalises Darwin's call handling to match the scheme
recently introduced and gives it target-specific call expanders.

2018-12-12  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/rs6000-protos.h (rs6000_call_darwin): New.
	(rs6000_sibcall_darwin): New. (macho_call_template): Remove.
	* config/rs6000/rs6000.c (get_prev_label): Forward declaration. 
	(rs6000_call_template_1): Handle Darwin.
	(macho_call_template): Remove.
	(rs6000_call_sysv): Remove handling for Darwin.
	(rs6000_call_darwin_1, rs6000_call_darwin): New
	(rs6000_sibcall_darwin): New.
	* config/rs6000/rs6000.md (define_expand “call”): Handle Darwin
	with its own expander. (define_expand “call_value”): Likewise.
	(define_expand “sibcall”): Likewise.
	(define_expand “sibcall_value”): Likewise.
	(call_nonlocal_sysv): Remove Darwin special-casing.
	(call_value_nonlocal_sysv): Likewise.

From-SVN: r267048
2018-12-12 08:47:16 +00:00
Jakub Jelinek
13de99bc7d re PR c++/88446 (__builtin_is_constant_evaluated rejects some converted constant expressions.)
PR c++/88446
	* cp-tree.h (maybe_constant_value): Add manifestly_const_eval
	argument.
	* constexpr.c (struct constexpr_call): Rename pretend_const_required
	member to manifestly_const_eval.
	(struct constexpr_ctx): Likewise.
	(constexpr_call_hasher::equal): Adjust users.
	(cxx_eval_builtin_function_call): Likewise.  Formatting fix.
	(cxx_eval_call_expression): Adjust users.
	(cxx_eval_outermost_constant_expr, maybe_constant_init_1,
	maybe_constant_init): Rename pretend_const_required argument to
	manifestly_const_eval, adjust function comments.
	(maybe_constant_value): Add manifestly_const_eval argument.  If true,
	don't cache and call cxx_eval_outermost_constant_expr with true as
	manifestly_const_eval.
	* decl.c (compute_array_index_type_loc): Call maybe_constant_value
	with true as manifestly_const_eval.

	* g++.dg/cpp2a/is-constant-evaluated3.C: New test.

From-SVN: r267047
2018-12-12 09:44:27 +01:00
Iain Sandoe
66e30545db rs6000, darwin - fix bootstrap.
Recent changes to the lowerings for call handling in rs6000
have broken bootstrap for powerpc-darwin.  This patch modifies
the calls to handle Darwin asa subset, a subsequent patch will
split Darwin out.

2018-12-12  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/darwin.md (call_indirect_nonlocal_darwin64): Remove.
	(call_nonlocal_darwin64): Remove.
	(call_value_indirect_nonlocal_darwin64): Remove.
	(call_value_nonlocal_darwin64): Remove.
	* config/rs6000/rs6000.c (rs6000_call_template_1): Handle Darwin with
	the same asm output as AIX/ELFv2.  (rs6000_call_sysv): Preserve the
	CALL_LONG flag when needed for Darwin.
	* config/rs6000/rs6000.md (define expand “call”): Expand Darwin as
	per sysv.
	(define_expand “call_value”): Likewise.
	(define_expand “sibcall”): Likewise.
	(define_expand “sibcall_value”): Likewise.
	(call_indirect_nonlocal_sysv): Mark the clobber mode P.
	(call_nonlocal_sysv): Likewise.
	(call_nonlocal_sysv_secure): Likewise.
	(call_value_indirect_nonlocal_sysv): Likewise.
	(call_value_nonlocal_sysv): Likewise.
	(call_value_nonlocal_sysv_secure): Likewise.
	(call_local64): Mark the clobber DI.
	(call_value_local64): Likewise.

From-SVN: r267046
2018-12-12 08:42:28 +00:00
Jakub Jelinek
0d7924f2e7 P0595R2 - is_constant_evaluated
P0595R2 - is_constant_evaluated
	* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED):
	Define if __builtin_is_constant_evaluated is available.
	* include/std/type_traits (std::is_constant_evaluated): New constexpr
	inline function.
	* testsuite/20_util/is_constant_evaluated/1.cc: New test.
	* testsuite/20_util/is_constant_evaluated/noexcept.cc: New test.

From-SVN: r267045
2018-12-12 09:31:01 +01:00
Jakub Jelinek
cce3ae91f2 re PR c++/88449 (__builtin_is_constant_evaluated misbehaves due to constexpr call caching)
PR c++/88449
	* constexpr.c (struct constexpr_call): Add pretend_const_required
	member.
	(constexpr_call_hasher::equal): Return false if pretend_const_required
	members differ.
	(cxx_eval_call_expression): Adjust new_call initialization.  Hash in
	ctx->pretend_const_required.

	* g++.dg/cpp2a/is-constant-evaluated1.C: Change from dg-do compile
	to dg-do run.
	(e): Adjust comment with correct expected value.
	(main): Expect e == 1.
	* g++.dg/cpp2a/is-constant-evaluated2.C: New test.

From-SVN: r267044
2018-12-12 09:28:43 +01:00
Steven G. Kargl
2f00fb3d0b re PR fortran/88155 (ICE in gfc_format_decoder, at fortran/error.c:947)
2018-12-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/88155
	* primary.c (gfc_match_structure_constructor):  Set the locus of
	an expression to avoid a NULL pointer dereference.

2018-12-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/88155
	* gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu.
	* gfortran.dg/pr88155.f90: New test.

From-SVN: r267041
2018-12-12 00:53:08 +00:00
GCC Administrator
85c223fa12 Daily bump.
From-SVN: r267040
2018-12-12 00:16:18 +00:00
Steven G. Kargl
3d07fb21d2 re PR fortran/88249 (ICE in gfc_resolve_filepos, at fortran/io.c:2853)
2018-12-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/88249
	* gfortran.h: Update prototype for gfc_resolve_filepos().
	* io.c (gfc_resolve_filepos): Check for UNIT number if ERR= is present.
	Use passed in locus for error message.
	* resolve.c (gfc_resolve_code): Pass locus in gfc_resolve_filepos()
	call.

2018-12-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/88249
	* gfortran.dg/pr88249.f90: New test.

From-SVN: r267035
2018-12-11 23:13:19 +00:00
Eric Botcazou
3b31a90608 re PR ada/88429 (libada build fails with --disable-shared)
libada/
	PR ada/88429
	* configure.ac (default_gnatlib_target): Set to gnatlib instead of
	gnatlib-plain if --disable-shared.
	* configure: Regenerate.
	* Makefile.in (all): Replace gnatlib prerequisite with libada.
	(ADA_RTS_SUBDIR): Delete.
	(libada): New target, renamed from...
	(gnatlib): ...this.  Merge with other library targets.
	(gnatlib-plain): Delete.
	(install-gnatlib): Rename to...
	(install-libada): ...this.
	(install): Replace install-gnatlib prerequisite with install-libada.
gcc/ada/
	PR ada/88429
	* gcc-interface/Makefile.in (./stamp-gnatlib1-$(RTSDIR)): Also pass
	MULTISUBDIR to sub-make and add quotes around $(THREAD_KIND).
	(gnatlib-shared-dual): Also pass PICFLAG_FOR_TARGET to sub-make.
	(gnatlib-sjlj): Also pass MULTISUBDIR to sub-make, but do not pass
	PICFLAG_FOR_TARGET.
	(gnatlib-zcx): Likewise.

From-SVN: r267034
2018-12-11 23:04:39 +00:00
Ian Lance Taylor
be68937be2 runtime: use _URC_FAILURE on ARM32
ARM32 EABI unwinder does not define _URC_NORMAL_STOP. Instead,
    it has _URC_FAILURE. Use _URC_FAILURE there.
    
    Should fix ARM32 build.
    
    Reviewed-on: https://go-review.googlesource.com/c/153417

From-SVN: r267033
2018-12-11 20:50:59 +00:00
Jakub Jelinek
582d2481f7 re PR c++/87861 (ICE in output_constructor_regular_field, at varasm.c:5165)
PR c++/87861
	* class.c (build_vtbl_initializer): For TARGET_VTABLE_USES_DESCRIPTORS
	bump index for each added word.
	* constexpr.c (find_array_ctor_elt): Add forward declaration.
	(cxx_eval_call_expression): Handle TARGET_VTABLE_USES_DESCRIPTORS
	vtable calls.
	(cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Divide token
	by TARGET_VTABLE_USES_DESCRIPTORS if non-zero.

From-SVN: r267032
2018-12-11 21:37:53 +01:00
Jakub Jelinek
3c0517a653 re PR tree-optimization/80520 (Performance regression from missing if-conversion)
PR tree-optimization/80520
	* gcc.dg/tree-ssa/split-path-11.c (foo): Make the test ilp32 target
	clean.

From-SVN: r267031
2018-12-11 21:28:35 +01:00
Marek Polacek
3c393a2c01 PR c++/86608 - reading constexpr volatile variable.
* constexpr.c (potential_constant_expression_1): Check want_rval
	instead of checking if we have a decl.
	* decl2.c (decl_maybe_constant_var_p): Don't consider volatile
	constexpr variables as maybe constant.

	* g++.dg/cpp0x/constexpr-volatile2.C: New test.
	* g++.dg/cpp0x/pr65327.C: Add dg-error.

From-SVN: r267030
2018-12-11 18:53:03 +00:00
Paolo Carlini
6b9ef867ec decl.c (grokvardecl): Add location_t parameter and use it in build_lang_decl_loc and build_decl calls.
/cp
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokvardecl): Add location_t parameter and use it
	in build_lang_decl_loc and build_decl calls.
	(grokdeclarator): Move up loc declaration and use it in the
	grokvardecl call too.

/testsuite
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/pr53037-4.C: Test the first two locations too.

From-SVN: r267029
2018-12-11 17:47:56 +00:00
Paolo Carlini
f214a6415a decl.c (grokvardecl): Add location_t parameter and use it in build_lang_decl_loc and build_decl calls.
/cp
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokvardecl): Add location_t parameter and use it
	in build_lang_decl_loc and build_decl calls.
	(grokdeclarator): Move up loc declaration and use it in the
	grokvardecl call too.

/testsuite
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/pr53037-4.C: Test the first two locations too.

From-SVN: r267028
2018-12-11 17:47:47 +00:00
Paolo Carlini
296e379a50 decl2.c (grokvardecl): Add location_t parameter and use it in build_lang_decl_loc and build_decl calls.
/cp
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl2.c (grokvardecl): Add location_t parameter and use it
	in build_lang_decl_loc and build_decl calls.
	(grokdeclarator): Move up loc declaration and use it in the
	grokvardecl call too.

/testsuite
2018-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/pr53037-4.C: Test the first two locations too.

From-SVN: r267027
2018-12-11 17:46:42 +00:00
Jakub Jelinek
ccef67160c re PR tree-optimization/88444 (ICE: tree check: expected ssa_name, have integer_cst in live_on_edge, at tree-vrp.c:468; or ICE: tree check: expected ssa_name, have integer_cst in get_value_range, at vr-values.c:84)
PR tree-optimization/88444
	* tree-vrp.c (register_edge_assert_for_2): Only register assertions
	for conversions if rhs1 is a SSA_NAME.

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

From-SVN: r267026
2018-12-11 18:16:48 +01:00
Dimitar Dimitrov
5b238a4591 cfgexpand.c (asm_clobber_reg_is_valid): Also produce error when stack pointer is clobbered.
gcc/
2018-12-11  Dimitar Dimitrov  <dimitar@dinux.eu>

	* cfgexpand.c (asm_clobber_reg_is_valid): Also produce
	error when stack pointer is clobbered.
	(expand_asm_stmt): Refactor clobber check in separate function.

gcc/testsuite/
2018-12-11  Dimitar Dimitrov  <dimitar@dinux.eu>

	* gcc.target/i386/pr52813.c: New test.

From-SVN: r267025
2018-12-11 15:50:51 +00:00
Eric Botcazou
f9d4d3cf93 Fix stack offsets and alloca alignments on ppc-vxworks
* config/rs6000/vxworks.h (RS6000_STARTING_FRAME_OFFSET): Define,
	accounting for STACK_BOUNDARY 128 regardless of TARGET_ALTIVEC/VSX.
	(STACK_DYNAMIC_OFFSET): Likewise.

From-SVN: r267024
2018-12-11 15:03:29 +00:00
Jakub Jelinek
61d1d9a664 re PR target/88425 (suboptimal code for a<imm?-1:0)
PR target/88425
	* config/i386/i386.md (*x86_mov<SWI48:mode>cc_0_m1_neg_leu<SWI:mode>):
	New define_insn_and_split.

	* gcc.target/i386/pr88425.c: New test.

From-SVN: r267023
2018-12-11 15:50:22 +01:00
Jakub Jelinek
6d9391732b re PR sanitizer/88426 (Compiler crash if use special code with command line switch -fsanitize=float-cast-overflow)
PR sanitizer/88426
	* c-convert.c (convert): Call c_fully_fold before calling
	ubsan_instrument_float_cast.

	* c-c++-common/ubsan/float-cast-overflow-11.c: New test.

From-SVN: r267022
2018-12-11 14:51:44 +01:00
Richard Biener
ef9fc3ba34 re PR middle-end/88448 (gnat.dg/opt66.adb etc. FAIL)
2018-12-11  Richard Biener  <rguenther@suse.de>

	PR middle-end/88448
	PR middle-end/88415
	* gimple.c (gimple_assign_set_rhs_with_ops): Revert previous
	change.
	* tree-complex.c (update_complex_assignment): Properly transfer
	or clean EH info around gimple_assign_set_rhs_with_ops.

From-SVN: r267021
2018-12-11 13:00:49 +00:00
Nick Clifton
921a4c3057 Fix a failure in the libiberty testsuite by increasing the demangle recursion limit to 2048.
PR 88409
	* demangle.h (DEMANGLE_RECURSION_LIMIT): Increase to 2048.

From-SVN: r267020
2018-12-11 11:59:53 +00:00
Richard Earnshaw
315fdae8f9 [aarch64] PR target/87369 Prefer bsl/bit/bif for copysign
The copysign operations will almost always be performed on values in
floating-point registers.  As such, we do not want the compiler to
simplify the operations into code sequences that can only be done
using the general-purpose register set.  Unfortunately, this is what
is currently happening.

Fortunately, it seems quite unlikely that copysign() will be
subsequently followed by other logical operations on the values
involved, so I think it is acceptable to use an unspec here.  This
allows us to preserve the operation in a form that allows the register
allocator to make the right choice later on, without limitation on the
final form of the operation (well, if we do end up using the gp
register bank, we get a dead constant load that we cannot easily
eliminate at a late stage).

	PR target/37369
	* config/aarch64/iterators.md (sizem1): Add sizes for SFmode and DFmode.
	(Vbtype): Add SFmode mapping.
	* config/aarch64/aarch64.md (copysigndf3, copysignsf3): Delete.
	(copysign<GPF:mode>3): New expand pattern.
	(copysign<GPF:mode>3_insn): New insn pattern.

From-SVN: r267019
2018-12-11 11:26:15 +00:00
Piotr Trojanek
c47fb5d9da [Ada] Add "Global => null" contracts to Ada.Calendar routines
Routines in Ada.Real_Time are already annotated with Global => null
contracts to suppress spurious warnings from the flow analysis in
GNATprove. This patch adds such contracts to Ada.Calendar. No change in
runtime behavior expected.

2018-12-11  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* libgnat/a-calend.ads: Add "Global => null" contracts to pure
	routines.

From-SVN: r267018
2018-12-11 11:12:41 +00:00
Hristian Kirtchev
921186579c [Ada] Spurious error with pragma Thread_Local_Storage
The following patch modifies the checks related to pragma
Thread_Local_Storage to correct a confusion in semantics which led to
spurious errors.

------------
-- Source --
------------

--  pack.ads

package Pack is
   type Arr is array (1 .. 5) of Boolean;

   type Arr_With_Default is array (1 .. 5) of Boolean
     with Default_Component_Value => False;

   type Int is new Integer range 1 .. 5;

   type Int_With_Default is new Integer range 1 .. 5
     with Default_Value => 1;

   protected type Prot_Typ is
      entry E;
   end Prot_Typ;

   type Rec_1 is record
      Comp : Integer;
   end record;

   type Rec_2 is record
      Comp : Int;
   end record;

   type Rec_3 is record
      Comp : Int_With_Default;
   end record;

   task type Task_Typ is
      entry E;
   end Task_Typ;
end Pack;

--  pack.adb

package body Pack is
   function F (Val : Int) return Int is
   begin
      if Val <= 1 then
         return 1;
      else
         return F (Val - 1) * Val;
      end if;
   end F;

   function F (Val : Int_With_Default) return Int_With_Default is
   begin
      if Val <= 1 then
         return 1;
      else
         return F (Val - 1) * Val;
      end if;
   end F;

   function F (Val : Integer) return Integer is
   begin
      if Val <= 1 then
         return 1;
      else
         return F (Val - 1) * Val;
      end if;
   end F;

   protected body Prot_Typ is
      entry E when True is begin null; end E;
   end Prot_Typ;

   task body Task_Typ is
   begin
      accept E;
   end Task_Typ;

   Obj_1 : Arr;                                                      --  OK
   pragma Thread_Local_Storage (Obj_1);

   Obj_2 : Arr := (others => True);                                  --  OK
   pragma Thread_Local_Storage (Obj_2);

   Obj_3 : Arr := (others => F (2) = Integer (3));                   --  ERROR
   pragma Thread_Local_Storage (Obj_3);

   Obj_4 : Arr_With_Default;                                         --  ERROR
   pragma Thread_Local_Storage (Obj_4);

   Obj_5 : Arr_With_Default := (others => True);                     --  OK
   pragma Thread_Local_Storage (Obj_5);

   Obj_6 : Arr_With_Default := (others => F (2) = Integer (3));      --  ERROR
   pragma Thread_Local_Storage (Obj_6);

   Obj_7 : Integer;                                                  --  OK
   pragma Thread_Local_Storage (Obj_7);

   Obj_8 : Integer := 1;                                             --  OK
   pragma Thread_Local_Storage (Obj_8);

   Obj_9 : Integer := F (2);                                         --  ERROR
   pragma Thread_Local_Storage (Obj_9);

   Obj_10 : Int;                                                     --  OK
   pragma Thread_Local_Storage (Obj_10);

   Obj_11 : Int := 1;                                                --  OK
   pragma Thread_Local_Storage (Obj_11);

   Obj_12 : Int := F (2);                                            --  ERROR
   pragma Thread_Local_Storage (Obj_12);

   Obj_13 : Int_With_Default;                                        --  ERROR
   pragma Thread_Local_Storage (Obj_13);

   Obj_14 : Int_With_Default := 1;                                   --  OK
   pragma Thread_Local_Storage (Obj_14);

   Obj_15 : Int_With_Default := F (2);                               --  ERROR
   pragma Thread_Local_Storage (Obj_15);

   Obj_16 : Prot_Typ;                                                --  ERROR
   pragma Thread_Local_Storage (Obj_16);

   Obj_17 : Rec_1;                                                   --  OK
   pragma Thread_Local_Storage (Obj_17);

   Obj_18 : Rec_1 := (others => 1);                                  --  OK
   pragma Thread_Local_Storage (Obj_18);

   Obj_19 : Rec_1 := (others => F (2));                              --  ERROR
   pragma Thread_Local_Storage (Obj_19);

   Obj_20 : Rec_2;                                                   --  OK
   pragma Thread_Local_Storage (Obj_20);

   Obj_21 : Rec_2 := (others => 1);                                  --  OK
   pragma Thread_Local_Storage (Obj_21);

   Obj_22 : Rec_2 := (others => F (2));                              --  ERROR
   pragma Thread_Local_Storage (Obj_22);

   Obj_23 : Rec_3;                                                   --  ERROR
   pragma Thread_Local_Storage (Obj_23);

   Obj_24 : Rec_3 := (others => 1);                                  --  OK
   pragma Thread_Local_Storage (Obj_24);

   Obj_25 : Rec_3 := (others => F (2));                              --  ERROR
   pragma Thread_Local_Storage (Obj_25);

   Obj_26 : Task_Typ;                                                --  ERROR
   pragma Thread_Local_Storage (Obj_26);
end Pack;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c pack.adb
pack.adb:47:04: Thread_Local_Storage variable "Obj_4" is improperly
  initialized
pack.adb:47:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:62:04: Thread_Local_Storage variable "Obj_9" is improperly
  initialized
pack.adb:62:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:71:04: Thread_Local_Storage variable "Obj_12" is improperly
  initialized
pack.adb:71:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:74:04: Thread_Local_Storage variable "Obj_13" is improperly
  initialized
pack.adb:74:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:80:04: Thread_Local_Storage variable "Obj_15" is improperly
  initialized
pack.adb:80:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:83:04: Thread_Local_Storage variable "Obj_16" is improperly
  initialized
pack.adb:83:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:92:04: Thread_Local_Storage variable "Obj_19" is improperly
  initialized
pack.adb:92:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:101:04: Thread_Local_Storage variable "Obj_22" is improperly
  initialized
pack.adb:101:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:104:04: Thread_Local_Storage variable "Obj_23" is improperly
  initialized
pack.adb:104:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:110:04: Thread_Local_Storage variable "Obj_25" is improperly
  initialized
pack.adb:110:04: only allowed initialization is explicit "null", static
  expression or static aggregate
pack.adb:113:04: Thread_Local_Storage variable "Obj_26" is improperly
  initialized
pack.adb:113:04: only allowed initialization is explicit "null", static
  expression or static aggregate

2018-12-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* freeze.adb (Check_Pragma_Thread_Local_Storage): Use the
	violating set to diagnose detect an illegal initialization,
	rather than the complement of the OK set.
	(Freeze_Object_Declaration): Factorize code in
	Has_Default_Initialization.
	(Has_Default_Initialization, Has_Incompatible_Initialization):
	New routines.

From-SVN: r267017
2018-12-11 11:12:37 +00:00
Dmitriy Anisimkov
759f164802 [Ada] GNAT.Sockets: add IPv6 support
2018-12-11  Dmitriy Anisimkov  <anisimko@adacore.com>

gcc/ada/

	* libgnat/g-socket.ads (Family_Type): Add new enumerated value
	Family_Unspec to be able to use it in Get_Address_Info parameter
	and find IPv4 together with IPv6 addresses.
	(Inet_Addr_Bytes_Length): Zero length for Family_Unspec.  New
	IPv6 predefined constant addresses.
	(IPv4_To_IPv6_Prefix): IPv4 mapped to IPv6 address prefix.
	(Is_IPv4_Address): Rename from Is_IP_Address and published.
	(Is_IPv6_Address): New routine.
	(Image of Inet_Addr_Type): Fix description about IPv6 address
	text representation.
	(Level_Type): New propocol level IP_Protocol_For_IPv6_Level.
	(Add_Membership_V4): New socket option equal to Add_Membership.
	(Drop_Membership_V4): New socket option equal to
	Drop_Membership.
	(Multicast_If_V4): New socket option equal to Multicast_If.
	(Multicast_Loop_V4, Add_Membership_V6, Drop_Membership_V6,
	Multicast_If_V6, Multicast_Loop_V6, Multicast_Hops, IPv6_Only):
	New socket option for IPv6.
	(Address_Info): New record to keep address info.
	(Address_Info_Array): Array to keep address info records.
	(Get_Address_Info): Routine to get address info records by host
	and service names.
	(Host_Service): Record to keep host and service names.
	(Get_Name_Info): New routine to get host and service names by
	address.
	(Create_Socket): Add Level parameter, IP_Protocol_For_IP_Level
	default.
	(Name_Array, Inet_Addr_Array): Change array index to Positive.
	* libgnat/g-socket.adb (IPV6_Mreq): New record definition for
	IPv6.
	(Hex_To_Char): Remove.
	(Short_To_Network, Network_To_Short): Move to package
	GNAT.Sockets.Thin_Common.
	(Is_IP_Address): Remove.
	(To_In_Addr, To_Inet_Addr): Move to package
	GNAT.Sockets.Thin_Common.
	(Get_Socket_Option): Get value of Multicast_Loop option as
	integer boolean, process IPv6 options. Don't try to get
	Add_Membership_V4, Add_Membership_V6, Drop_Membership_V4, and
	Drop_Membership_V6 as not supported by the socket API.
	(Set_Socket_Option): Set value of Multicast_Loop option as
	integer boolean, process IPv6 options.
	* gsocket.h
	(IPV6_ADD_MEMBERSHIP): Define from IPV6_JOIN_GROUP if necessary
	for VxWorks.
	(IPV6_DROP_MEMBERSHIP): Define from IPV6_LEAVE_GROUP if
	necessary for VxWorks
	(HAVE_INET_NTOP): New definition.
	(HAVE_INET_PTON): Includes VxWorks now.
	* socket.c (__gnat_getaddrinfo, __gnat_getnameinfo,
	__gnat_freeaddrinfo, __gnat_gai_strerror, __gnat_inet_ntop): New
	routines.
	* libgnat/g-sothco.ads, libgnat/g-sothco.adb
	(socklen_t, In6_Addr, To_In6_Addr): New.
	(To_In_Addr, To_Inet_Addr): Move from package body GNAT.Sockets.
	(To_Inet_Addr): New overload with In6_Addr type parmeter.
	(In_Addr_Access_Array): Remove.
	(Sockaddr): Unchecked_Union instead of Sockaddr_In and old
	defined generic Sockaddr.
	(Set_Address): Use it to set family, port and address into
	Sockaddr.
	(Get_Address): New routine to get Socket_Addr_Type from
	Sockaddr.
	(Addrinfo): Structure to use with getaddrinfo.
	(C_Getaddrinfo, C_Freeaddrinfo, C_Getnameinfo, C_GAI_Strerror,
	Inet_Ntop): New routine import.
	(Short_To_Network, Network_To_Short): Move from package body
	GNAT.Sockets.
	* libgnat/g-stsifd__sockets.adb: Use Sockaddr instead of
	Sockaddr_In.
	* s-oscons-tmplt.c (AF_UNSPEC, EAI_SYSTEM, SOCK_RAW,
	IPPROTO_IPV6, IP_RECVERR, SIZEOF_socklen_t, IF_NAMESIZE): New
	constants.
	(AI_xxxx_OFFSET): Constants to consider platform differences in
	field positions and sizes for addrinfo structure.
	(AI_xxxxx): Flags for getaddrinfo.
	(NI_xxxxx): Flags for getnameinfo.
	(IPV6_xxxxx): Socket options for IPv6.
	(Inet_Ntop_Linkname): New routine.

From-SVN: r267016
2018-12-11 11:12:32 +00:00
Yannick Moy
d71b0a9a04 [Ada] Do not expand code inside ignored ghost bodies
While ignored ghost code is not compiled into the executable, it may
lead to compilation errors when it makes use of language features
requiring runtime support that is not available in the available runtime
library.  These errors are spurious, as the executable will never call
in these runtime units.

This patch deactivates the expansion of code inside ignored ghost bodies
of subprograms and packages, so that this code is still checked for
possible semantic errors, but it does not force the presence of useless
runtime units.

There is no impact on the executable produced.

2018-12-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Deactivate
	expansion in ignored ghost subprogram body.
	* sem_ch7.adb (Analyze_Package_Body_Helper): Deactivate
	expansion in ignored ghost package body.

gcc/testsuite/

	* gnat.dg/ghost4.adb: New testcase.

From-SVN: r267015
2018-12-11 11:12:26 +00:00
Ed Schonberg
c132699650 [Ada] Unnesting: do not eliminate subprogram whose address is taken
2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.adb (Register_Subprogram): A subprogram whose address
	is taken (through attribute Address or Access) is reachable and
	cannot be eliminated, even if there is no explicit call to it:
	the address may be used in an indirect call or in some
	address-related operation.

From-SVN: r267014
2018-12-11 11:12:21 +00:00
Ed Schonberg
2f42b6ead4 [Ada] Crash on misplaced First operation for GNAT iterable type
This patch improves the handling of an improper declaaration of aspect
First for a GNAT-defined iterable type,

2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_util.adb (Get_Actual_Subtype): Function can return type
	mark.
	(Get_Cursor_Type): Improve recovery and error message on a
	misplaced First aspect for an iterable type.

gcc/testsuite/

	* gnat.dg/iter4.adb: New testcase.

From-SVN: r267013
2018-12-11 11:12:16 +00:00
Hristian Kirtchev
155f4f34d1 [Ada] Volatility, validity checks, and System.Aux_DEC
This patch updates validity checks to prevent the validation of an
by-reference formal parameter because the parameter is not being read in
the process.

2018-12-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* checks.adb: Add with and use clauses for Sem_Mech.
	(Ensure_Valid): Update the "annoying special case" to include
	entry and function calls. Use Get_Called_Entity to obtain the
	entry or subprogram being invoked, rather than retrieving it
	manually. Parameters passed by reference do not need a validity
	check.

gcc/testsuite/

	* gnat.dg/valid4.adb, gnat.dg/valid4_pkg.adb,
	gnat.dg/valid4_pkg.ads: New testcase.

From-SVN: r267012
2018-12-11 11:12:11 +00:00
Yannick Moy
4a60c9a20c [Ada] Improve error message when named number passed as global item
When a named number is used in Global/Depends contracts as global item,
the error message could be confusing to users new to Ada. Now the
message explains that named numbers are not objects.

For instance on the following illegal code snippet:

     $ gcc -c bad_global.ads

     1. package Bad_Global is
     2.
     3.    X : constant := 1;
     4.    Y : constant := 1.0;
     5.
     6.    procedure P with
     7.      Global => (Input => X,
                                 |
        >>> global item must denote object, state or current instance
            of concurrent type
        >>> named number "X" is not an object

     8.                 In_Out => Y);
                                  |
        >>> global item must denote object, state or current instance
            of concurrent type
        >>> named number "Y" is not an object

     9.
    10. end Bad_Global;

2018-12-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_prag.adb (Analyze_Global_Item): Refine error message.

From-SVN: r267011
2018-12-11 11:12:03 +00:00
Ed Schonberg
e60c10b3b9 [Ada] Unnesting: fix a missing activation record
2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada

	* exp_ch7.adb (Check_Unnesting_In_Declarations): Extend
	subprogram so that it is usable for visible and private
	declarations of a package declaration, not just for declarations
	in the pakage body.
	* exp_ch13.adb (Expand_Freeze_Entity): Handle properly the
	freezing of a finalizer routine generated for a controlled objet
	declaration. Special processing already applies to finalizers
	because they are usually displaced into another construct.

From-SVN: r267010
2018-12-11 11:11:58 +00:00
Arnaud Charlet
2ffa39d247 [Ada] Unnesting: ensure Current_Subprogram is always initialized
2018-12-11  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* exp_unst.adb (Unnest_Subprogram): Ensure Current_Subprogram is
	always initialized.

From-SVN: r267009
2018-12-11 11:11:53 +00:00
Eric Botcazou
f2bee23951 [Ada] Fix -gnatR3 output for dynamically constrained record
2018-12-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* gcc-interface/decl.c (gnat_to_gnu_entity): Add
	gnat_annotate_type local variable initialized to Empty.
	<E_Record_Subtype>: Set it to the Cloned_Subtype, if any.  For
	types, back-annotate alignment and size values earlier and only
	if the DECL was created here; otherwise, if gnat_annotate_type
	is present, take the values from it.
	(gnat_to_gnu_field): Add gnat_clause local variable.  If a
	component clause is present, call validate_size only once on the
	Esize of the component.  Otherwise, in the packed case, do not
	call validate_size again on the type of the component but
	retrieve directly its RM size.
	(components_to_record): Minor tweak.
	(set_rm_size): Remove useless test.
	* gcc-interface/trans.c (gnat_to_gnu): Do wrap the instance of a
	boolean discriminant attached to a variant part.

From-SVN: r267008
2018-12-11 11:11:47 +00:00
Ed Schonberg
619bfd9fef [Ada] Fix setting of Has_Predicate flag for aggregate subtypes
This patch enures that the subtype of an aggregate has the Has_Predicate
flag properly set if the array component has a predicate, including the
case the predicate function for the component has not been constructed
yet.

2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_aggr.adb (Array_Aggr_Subtype. Resolve_Aggr_Expr): Indicate
	that aggregate subtype has a predicate if the component type has
	a predicate; do not rely on exisatence of predicate function for
	component, in case component is a type no yet frozen, for which
	predicate function has not been created yet.

From-SVN: r267007
2018-12-11 11:11:42 +00:00
Eric Botcazou
78326189ea [Ada] Plug small loophole with pathological packed array type
This fixes a crash in gigi on a pathological packed array type, whose
component type is a record type without representation clause or packing
but with a clause that bumps its size to a non-multiple value of the
storage unit.  In this case, the front-end fails to detect that calls
to the packing manpulation routines of the run time are necessary.

The fix doesn't change anything for non-pathological cases, i.e. when
the component type has a representation clause or is packed.

2018-12-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_aggr.adb (Packed_Array_Aggregate_Handled): Bail out for
	any non-scalar type as component type of the array.

gcc/testsuite/

	* gnat.dg/packed_array.adb, gnat.dg/packed_array.ads,
	gnat.dg/packed_array_pkg.ads: New testcase.

From-SVN: r267006
2018-12-11 11:11:37 +00:00
Eric Botcazou
6186a6ef3c [Ada] Fix elaboration of record with 1-element dynamic array
2018-12-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* einfo.ads (Is_Bit_Packed_Array): Fix values of component size.
	(Is_Packed): Likewise.
	* gcc-interface/utils.c (convert): Do not extract the value of a
	justified modular type if the destination type is a regular
	array.
	* gcc-interface/decl.c (gnat_to_gnu_component_type): Pass
	TYPE_DECL to validate_size wherever the array has packed
	components.

From-SVN: r267005
2018-12-11 11:11:31 +00:00
Bob Duff
af3ded0832 [Ada] gnatbind: ghost code with -gnatQ
This patch fixes a bug where if a library unit is compiled with -gnatQ,
and that library unit is an ignored Ghost unit, then gnatbind silently
fails.

2018-12-11  Bob Duff  <duff@adacore.com>

gcc/ada/

	* gnat1drv.adb (gnat1drv): Pass the correct Object value when
	calling Write_ALI in the case of -gnatQ.
	* gnatbind.adb (Gnatbind): Avoid silent failure; give an error
	message.

From-SVN: r267004
2018-12-11 11:11:26 +00:00
Ed Schonberg
1d499c15a8 [Ada] Unnesting: fix for constrained arrays and improve static constants
2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.adb (Needs_Fat_Pointer): A fat pointer is required if
	the entity has a private type whose full view is an
	unconstrained array type.
	(Rewrite_One_Ref): If the reference is to a static constant, use
	its value rather than create a reference through the activation
	record. This is more efficient, and furthermore indispensable if
	the context requires a static constant, such as in a branch of a
	case statement.

From-SVN: r267003
2018-12-11 11:11:22 +00:00