diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-28 10:21:31 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-28 10:21:31 +0000 |
commit | 9ee468275aea8f34a5666e521e3189c7d88e3184 (patch) | |
tree | 9a5ebf6aed7503e38481012c638931f33fc1e220 | |
parent | 368811993c26300893ac022025d98b3ef43fbc4d (diff) | |
download | gcc-9ee468275aea8f34a5666e521e3189c7d88e3184.tar.gz |
2014-01-28 Basile Starynkevitch <basile@starynkevitch.net>
{{merge using svnmerge.py with trunk GCC 4.9 svn rev.207172. All is
well compiled.}}
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@207179 138bc75d-0d04-0410-961f-82ee72b054a4
416 files changed, 11314 insertions, 6893 deletions
diff --git a/ChangeLog.MELT b/ChangeLog.MELT index 1e1de9f3979..c4b130720ee 100644 --- a/ChangeLog.MELT +++ b/ChangeLog.MELT @@ -1,5 +1,10 @@ +2014-01-28 Basile Starynkevitch <basile@starynkevitch.net> + {{merge using svnmerge.py with trunk GCC 4.9 svn rev.207172. All is + well compiled.}} + + 2014-01-23 Basile Starynkevitch <basile@starynkevitch.net> {{merge using svnmerge.py with trunk GCC 4.9 svn rev.206958. All is well compiled.}} diff --git a/contrib/mklog b/contrib/mklog index 16ce1914db6..8392642678b 100755 --- a/contrib/mklog +++ b/contrib/mklog @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Free Software Foundation, Inc. +# Copyright (C) 2012-2014 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # This script parses a .diff file generated with 'diff -up' or 'diff -cp' -# and writes a skeleton ChangeLog file to stdout. It does not try to be +# and adds a skeleton ChangeLog file to the file. It does not try to be # very smart when parsing function names, but it produces a reasonable # approximation. # diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c67c6ff10c6..eafbbe5f243 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,491 @@ +2014-01-28 Richard Biener <rguenther@suse.de> + + PR rtl-optimization/45364 + PR rtl-optimization/59890 + * var-tracking.c (local_get_addr_clear_given_value): Handle + already cleared slot. + (val_reset): Handle not allocated local_get_addr_cache. + (vt_find_locations): Use post-order on the inverted CFG. + +2014-01-28 Alan Modra <amodra@gmail.com> + + * Makefile.in (BUILD_CPPFLAGS): Do not use ALL_CPPFLAGS. + * configure.ac <recursive call for build != host>: Define + GENERATOR_FILE. Comment. Use CXX_FOR_BUILD, CXXFLAGS_FOR_BUILD + and LD_FOR_BUILD too. + * configure: Regenerate. + +2014-01-27 Allan Sandfeld Jensen <sandfeld@kde.org> + + * config/i386/i386.c (get_builtin_code_for_version): Separate + Westmere from Nehalem, Ivy Bridge from Sandy Bridge and + Broadwell from Haswell. + +2014-01-27 Steve Ellcey <sellcey@mips.com> + + * common/config/mips/mips-common.c (TARGET_DEFAULT_TARGET_FLAGS): + Remove TARGET_FP_EXCEPTIONS_DEFAULT and MASK_FUSED_MADD. + * config/mips/mips.c (mips_option_override): Change setting + of TARGET_DSP. + * config/mips/mips.h (TARGET_FP_EXCEPTIONS_DEFAULT): Remove. + * config/mips/mips.opt (DSP, DSPR2, FP_EXCEPTIONS, FUSED_MADD, MIPS3D): + Change from Mask to Var. + +2014-01-27 Jeff Law <law@redhat.com> + + * ipa-inline.c (inline_small_functions): Fix typo. + +2014-01-27 Ilya Tocar <ilya.tocar@intel.com> + + * config/i386/avx512fintrin.h (_mm512_mask_cvtepi32_storeu_epi8): New. + (_mm512_mask_cvtsepi32_storeu_epi8): Ditto. + (_mm512_mask_cvtusepi32_storeu_epi8): Ditto. + (_mm512_mask_cvtepi32_storeu_epi16): Ditto. + (_mm512_mask_cvtsepi32_storeu_epi16): Ditto. + (_mm512_mask_cvtusepi32_storeu_epi16): Ditto. + (_mm512_mask_cvtepi64_storeu_epi32): Ditto. + (_mm512_mask_cvtsepi64_storeu_epi32): Ditto. + (_mm512_mask_cvtusepi64_storeu_epi32): Ditto. + (_mm512_mask_cvtepi64_storeu_epi16): Ditto. + (_mm512_mask_cvtsepi64_storeu_epi16): Ditto. + (_mm512_mask_cvtusepi64_storeu_epi16): Ditto. + (_mm512_mask_cvtepi64_storeu_epi8): Ditto. + (_mm512_mask_cvtsepi64_storeu_epi8): Ditto. + (_mm512_mask_cvtusepi64_storeu_epi8): Ditto. + (_mm512_storeu_epi64): Ditto. + (_mm512_cmpge_epi32_mask): Ditto. + (_mm512_cmpge_epu32_mask): Ditto. + (_mm512_cmpge_epi64_mask): Ditto. + (_mm512_cmpge_epu64_mask): Ditto. + (_mm512_cmple_epi32_mask): Ditto. + (_mm512_cmple_epu32_mask): Ditto. + (_mm512_cmple_epi64_mask): Ditto. + (_mm512_cmple_epu64_mask): Ditto. + (_mm512_cmplt_epi32_mask): Ditto. + (_mm512_cmplt_epu32_mask): Ditto. + (_mm512_cmplt_epi64_mask): Ditto. + (_mm512_cmplt_epu64_mask): Ditto. + (_mm512_cmpneq_epi32_mask): Ditto. + (_mm512_cmpneq_epu32_mask): Ditto. + (_mm512_cmpneq_epi64_mask): Ditto. + (_mm512_cmpneq_epu64_mask): Ditto. + (_mm512_expand_pd): Ditto. + (_mm512_expand_ps): Ditto. + * config/i386/i386-builtin-types.def: Add PV16QI, PV16QI, PV16HI, + VOID_PV8SI_V8DI_QI, VOID_PV8HI_V8DI_QI, VOID_PV16QI_V8DI_QI, + VOID_PV16QI_V16SI_HI, VOID_PV16HI_V16SI_HI. + * config/i386/i386.c (ix86_builtins): Add + IX86_BUILTIN_EXPANDPD512_NOMASK, IX86_BUILTIN_EXPANDPS512_NOMASK, + IX86_BUILTIN_PMOVDB512_MEM, IX86_BUILTIN_PMOVDW512_MEM, + IX86_BUILTIN_PMOVQB512_MEM, IX86_BUILTIN_PMOVQD512_MEM, + IX86_BUILTIN_PMOVQW512_MEM, IX86_BUILTIN_PMOVSDB512_MEM, + IX86_BUILTIN_PMOVSDW512_MEM, IX86_BUILTIN_PMOVSQB512_MEM, + IX86_BUILTIN_PMOVSQD512_MEM, IX86_BUILTIN_PMOVSQW512_MEM, + IX86_BUILTIN_PMOVUSDB512_MEM, IX86_BUILTIN_PMOVUSDW512_MEM, + IX86_BUILTIN_PMOVUSQB512_MEM, IX86_BUILTIN_PMOVUSQD512_MEM, + IX86_BUILTIN_PMOVUSQW512_MEM. + (bdesc_special_args): Add __builtin_ia32_pmovusqd512mem_mask, + __builtin_ia32_pmovsqd512mem_mask, + __builtin_ia32_pmovqd512mem_mask, + __builtin_ia32_pmovusqw512mem_mask, + __builtin_ia32_pmovsqw512mem_mask, + __builtin_ia32_pmovqw512mem_mask, + __builtin_ia32_pmovusdw512mem_mask, + __builtin_ia32_pmovsdw512mem_mask, + __builtin_ia32_pmovdw512mem_mask, + __builtin_ia32_pmovqb512mem_mask, + __builtin_ia32_pmovusqb512mem_mask, + __builtin_ia32_pmovsqb512mem_mask, + __builtin_ia32_pmovusdb512mem_mask, + __builtin_ia32_pmovsdb512mem_mask, + __builtin_ia32_pmovdb512mem_mask. + (bdesc_args): Add __builtin_ia32_expanddf512, + __builtin_ia32_expandsf512. + (ix86_expand_special_args_builtin): Handle VOID_FTYPE_PV8SI_V8DI_QI, + VOID_FTYPE_PV8HI_V8DI_QI, VOID_FTYPE_PV16HI_V16SI_HI, + VOID_FTYPE_PV16QI_V8DI_QI, VOID_FTYPE_PV16QI_V16SI_HI. + * config/i386/sse.md (unspec): Add UNSPEC_EXPAND_NOMASK. + (avx512f_<code><pmov_src_lower><mode>2_mask_store): New. + (*avx512f_<code>v8div16qi2_store_mask): Renamed to ... + (avx512f_<code>v8div16qi2_mask_store): This. + (avx512f_expand<mode>): New. + +2014-01-27 Kirill Yukhin <kirill.yukhin@intel.com> + + * config/i386/avx512pfintrin.h (_mm512_mask_prefetch_i32gather_pd): + New. + (_mm512_mask_prefetch_i64gather_pd): Ditto. + (_mm512_prefetch_i32scatter_pd): Ditto. + (_mm512_mask_prefetch_i32scatter_pd): Ditto. + (_mm512_prefetch_i64scatter_pd): Ditto. + (_mm512_mask_prefetch_i64scatter_pd): Ditto. + (_mm512_mask_prefetch_i32gather_ps): Fix operand type. + (_mm512_mask_prefetch_i64gather_ps): Ditto. + (_mm512_prefetch_i32scatter_ps): Ditto. + (_mm512_mask_prefetch_i32scatter_ps): Ditto. + (_mm512_prefetch_i64scatter_ps): Ditto. + (_mm512_mask_prefetch_i64scatter_ps): Ditto. + * config/i386/i386-builtin-types.def: Define + VOID_FTYPE_QI_V8SI_PCINT64_INT_INT + and VOID_FTYPE_QI_V8DI_PCINT64_INT_INT. + * config/i386/i386.c (ix86_builtins): Define IX86_BUILTIN_GATHERPFQPD, + IX86_BUILTIN_GATHERPFDPD, IX86_BUILTIN_SCATTERPFDPD, + IX86_BUILTIN_SCATTERPFQPD. + (ix86_init_mmx_sse_builtins): Define __builtin_ia32_gatherpfdpd, + __builtin_ia32_gatherpfdps, __builtin_ia32_gatherpfqpd, + __builtin_ia32_gatherpfqps, __builtin_ia32_scatterpfdpd, + __builtin_ia32_scatterpfdps, __builtin_ia32_scatterpfqpd, + __builtin_ia32_scatterpfqps. + (ix86_expand_builtin): Expand new built-ins. + * config/i386/sse.md (avx512pf_gatherpf<mode>): Add SF suffix, + fix memory access data type. + (*avx512pf_gatherpf<mode>_mask): Ditto. + (*avx512pf_gatherpf<mode>): Ditto. + (avx512pf_scatterpf<mode>): Ditto. + (*avx512pf_scatterpf<mode>_mask): Ditto. + (*avx512pf_scatterpf<mode>): Ditto. + (GATHER_SCATTER_SF_MEM_MODE): New. + (avx512pf_gatherpf<mode>df): Ditto. + (*avx512pf_gatherpf<mode>df_mask): Ditto. + (*avx512pf_scatterpf<mode>df): Ditto. + +2014-01-27 Jakub Jelinek <jakub@redhat.com> + + PR bootstrap/59934 + * expmed.h (expmed_mode_index): Rework so that analysis and optimziers + know when the MODE_PARTIAL_INT and MODE_VECTOR_INT cases can never be + reached. + +2014-01-27 James Greenhalgh <james.greenhalgh@arm.com> + + * common/config/arm/arm-common.c + (arm_rewrite_mcpu): Handle multiple names. + * config/arm/arm.h + (BIG_LITTLE_SPEC): Do not discard mcpu switches. + +2014-01-27 James Greenhalgh <james.greenhalgh@arm.com> + + * gimple-builder.h (create_gimple_tmp): Delete. + +2014-01-27 Christian Bruel <christian.bruel@st.com> + + * config/sh/sh-mem.cc (sh_expand_cmpnstr): Fix remaining bytes after + words comparisons. + +2014-01-26 John David Anglin <danglin@gcc.gnu.org> + + * config/pa/pa.md (call): Generate indirect long calls to non-local + functions when outputing 32-bit code. + (call_value): Likewise except for special call to buggy powf function. + + * config/pa/pa.c (pa_attr_length_indirect_call): Adjust length of + portable runtime and PIC indirect calls. + (pa_output_indirect_call): Remove unnecessary nop from portable runtime + and PIC call sequences. Use ldo instead of blr to set return register + in PIC call sequence. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/sync.md (atomic_fetch_sub): Fix negation and + avoid clobbering a live register. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/tilegx-c.c (tilegx_cpu_cpp_builtins): + Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2}. + * config/tilegx/tilepro-c.c (tilepro_cpu_cpp_builtins): + Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4,8}. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/tilegx.c (tilegx_function_arg): Start 16-byte + arguments on even registers. + (tilegx_gimplify_va_arg_expr): Align 16-byte var args to + STACK_BOUNDARY. + * config/tilegx/tilegx.h (STACK_BOUNDARY): Change to 16 bytes. + (BIGGEST_ALIGNMENT): Ditto. + (BIGGEST_FIELD_ALIGNMENT): Ditto. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/tilegx.c (tilegx_gen_bundles): Delete barrier + insns before bundling. + * config/tilegx/tilegx.md (tile_network_barrier): Update comment. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/tilegx.c (tilegx_expand_builtin): Set + PREFETCH_SCHEDULE_BARRIER_P to true for prefetches. + * config/tilepro/tilepro.c (tilepro_expand_builtin): Ditto. + +2014-01-25 Richard Sandiford <rdsandiford@googlemail.com> + + * config/mips/constraints.md (kl): Delete. + * config/mips/mips.md (divmod<mode>4, udivmod<mode>4): Turn into + define expands, using... + (divmod<mode>4_mips16, udivmod<mode>4_mips16): ...these new + instructions for MIPS16. + (*divmod<mode>4, *udivmod<mode>4): New patterns, taken from the + non-MIPS16 version of the old divmod<mode>4 and udivmod<mode>4. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilepro/tilepro.md (ctzdi2): Use register_operand predicate. + (clzdi2): Ditto. + (ffsdi2): Ditto. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilegx/tilegx.c (tilegx_expand_to_rtl_hook): New. + (TARGET_EXPAND_TO_RTL_HOOK): Define. + +2014-01-25 Richard Sandiford <rdsandiford@googlemail.com> + + * rtlanal.c (canonicalize_condition): Split out duplicated mode check. + Handle XOR. + +2014-01-25 Jakub Jelinek <jakub@redhat.com> + + * print-rtl.c (in_call_function_usage): New var. + (print_rtx): When in CALL_INSN_FUNCTION_USAGE, always print + EXPR_LIST mode as mode and not as reg note name. + + PR middle-end/59561 + * cfgloopmanip.c (copy_loop_info): If + loop->warned_aggressive_loop_optimizations, make sure + the flag is set in target loop too. + +2014-01-24 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * builtins.c (is_builtin_name): Renamed flag_enable_cilkplus to + flag_cilkplus. + * builtins.def: Likewise. + * cilk.h (fn_contains_cilk_spawn_p): Likewise. + * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Likewise. + * ira.c (ira_setup_eliminable_regset): Likewise. + * omp-low.c (gate_expand_omp): Likewise. + (execute_lower_omp): Likewise. + (diagnose_sb_0): Likewise. + (gate_diagnose_omp_blocks): Likewise. + (simd_clone_clauses_extract): Likewise. + (gate): Likewise. + +2014-01-24 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + * config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Remove + correction for little endian... + * config/rs6000/vsx.md (vsx_xxpermdi2_<mode>_1): ...and move it to + here. + +2014-01-24 Jeff Law <law@redhat.com> + + PR tree-optimization/59919 + * tree-vrp.c (find_assert_locations_1): Do not register asserts + for non-returning calls. + +2014-01-24 James Greenhalgh <james.greenhalgh@arm.com> + + * common/config/aarch64/aarch64-common.c + (aarch64_rewrite_mcpu): Handle multiple names. + * config/aarch64/aarch64.h + (BIG_LITTLE_SPEC): Do not discard mcpu switches. + +2014-01-24 Dodji Seketeli <dodji@redhat.com> + + * input.c (add_file_to_cache_tab): Handle the case where fopen + returns NULL. + +2014-01-23 H.J. Lu <hongjiu.lu@intel.com> + + PR target/59929 + * config/i386/i386.md (pushsf splitter): Get stack adjustment + from push operand if code of push isn't PRE_DEC. + +2014-01-23 Michael Meissner <meissner@linux.vnet.ibm.com> + + PR target/59909 + * doc/invoke.texi (RS/6000 and PowerPC Options): Document + -mquad-memory-atomic. Update -mquad-memory documentation to say + it is only used for non-atomic loads/stores. + + * config/rs6000/predicates.md (quad_int_reg_operand): Allow either + -mquad-memory or -mquad-memory-atomic switches. + + * config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Add + -mquad-memory-atomic to ISA 2.07 support. + + * config/rs6000/rs6000.opt (-mquad-memory-atomic): Add new switch + to separate support of normal quad word memory operations (ldq, stq) + from the atomic quad word memory operations. + + * config/rs6000/rs6000.c (rs6000_option_override_internal): Add + support to separate non-atomic quad word operations from atomic + quad word operations. Disable non-atomic quad word operations in + little endian mode so that we don't have to swap words after the + load and before the store. + (quad_load_store_p): Add comment about atomic quad word support. + (rs6000_opt_masks): Add -mquad-memory-atomic to the list of + options printed with -mdebug=reg. + + * config/rs6000/rs6000.h (TARGET_SYNC_TI): Use + -mquad-memory-atomic as the test for whether we have quad word + atomic instructions. + (TARGET_SYNC_HI_QI): If either -mquad-memory-atomic, -mquad-memory, + or -mp8-vector are used, allow byte/half-word atomic operations. + + * config/rs6000/sync.md (load_lockedti): Insure that the address + is a proper indexed or indirect address for the lqarx instruction. + On little endian systems, swap the hi/lo registers after the lqarx + instruction. + (load_lockedpti): Use indexed_or_indirect_operand predicate to + insure the address is valid for the lqarx instruction. + (store_conditionalti): Insure that the address is a proper indexed + or indirect address for the stqcrx. instruction. On little endian + systems, swap the hi/lo registers before doing the stqcrx. + instruction. + (store_conditionalpti): Use indexed_or_indirect_operand predicate to + insure the address is valid for the stqcrx. instruction. + + * gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros): + Define __QUAD_MEMORY__ and __QUAD_MEMORY_ATOMIC__ based on what + type of quad memory support is available. + +2014-01-23 Vladimir Makarov <vmakarov@redhat.com> + + PR regression/59915 + * lra-constraints.c (simplify_operand_subreg): Spill pseudo if + there is a danger of looping. + +2014-01-23 Pat Haugen <pthaugen@us.ibm.com> + + * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't + force flag_ira_loop_pressure if set via command line. + +2014-01-23 Alex Velenko <Alex.Velenko@arm.com> + + * config/aarch64/aarch64-simd-builtins.def (ashr): DI mode removed. + (ashr_simd): New builtin handling DI mode. + * config/aarch64/aarch64-simd.md (aarch64_ashr_simddi): New pattern. + (aarch64_sshr_simddi): New match pattern. + * config/aarch64/arm_neon.h (vshr_n_s32): Builtin call modified. + (vshrd_n_s64): Likewise. + * config/aarch64/predicates.md (aarch64_shift_imm64_di): New predicate. + +2014-01-23 Nick Clifton <nickc@redhat.com> + + * config/msp430/msp430.h (ASM_SPEC): Pass the -mcpu as -mcpu. + (LIB_SPEC): Drop use of memory.ld and peripherals.ld scripts in + favour of mcu specific scripts. + * config/msp430/t-msp430 (MULTILIB_MATCHES): Add more matches for + 430x multilibs. + +2014-01-23 James Greenhalgh <james.greenhalgh@arm.com> + Alex Velenko <Alex.Velenko@arm.com> + + * config/aarch64/arm_neon.h (vaddv_s8): __LANE0 cleanup. + (vaddv_s16): Likewise. + (vaddv_s32): Likewise. + (vaddv_u8): Likewise. + (vaddv_u16): Likewise. + (vaddv_u32): Likewise. + (vaddvq_s8): Likewise. + (vaddvq_s16): Likewise. + (vaddvq_s32): Likewise. + (vaddvq_s64): Likewise. + (vaddvq_u8): Likewise. + (vaddvq_u16): Likewise. + (vaddvq_u32): Likewise. + (vaddvq_u64): Likewise. + (vaddv_f32): Likewise. + (vaddvq_f32): Likewise. + (vaddvq_f64): Likewise. + (vmaxv_f32): Likewise. + (vmaxv_s8): Likewise. + (vmaxv_s16): Likewise. + (vmaxv_s32): Likewise. + (vmaxv_u8): Likewise. + (vmaxv_u16): Likewise. + (vmaxv_u32): Likewise. + (vmaxvq_f32): Likewise. + (vmaxvq_f64): Likewise. + (vmaxvq_s8): Likewise. + (vmaxvq_s16): Likewise. + (vmaxvq_s32): Likewise. + (vmaxvq_u8): Likewise. + (vmaxvq_u16): Likewise. + (vmaxvq_u32): Likewise. + (vmaxnmv_f32): Likewise. + (vmaxnmvq_f32): Likewise. + (vmaxnmvq_f64): Likewise. + (vminv_f32): Likewise. + (vminv_s8): Likewise. + (vminv_s16): Likewise. + (vminv_s32): Likewise. + (vminv_u8): Likewise. + (vminv_u16): Likewise. + (vminv_u32): Likewise. + (vminvq_f32): Likewise. + (vminvq_f64): Likewise. + (vminvq_s8): Likewise. + (vminvq_s16): Likewise. + (vminvq_s32): Likewise. + (vminvq_u8): Likewise. + (vminvq_u16): Likewise. + (vminvq_u32): Likewise. + (vminnmv_f32): Likewise. + (vminnmvq_f32): Likewise. + (vminnmvq_f64): Likewise. + +2014-01-23 James Greenhalgh <james.greenhalgh@arm.com> + + * config/aarch64/aarch64-simd.md + (aarch64_dup_lane<mode>): Correct lane number on big-endian. + (aarch64_dup_lane_<vswap_widthi_name><mode>): Likewise. + (*aarch64_mul3_elt<mode>): Likewise. + (*aarch64_mul3_elt<vswap_width_name><mode>): Likewise. + (*aarch64_mul3_elt_to_64v2df): Likewise. + (*aarch64_mla_elt<mode>): Likewise. + (*aarch64_mla_elt_<vswap_width_name><mode>): Likewise. + (*aarch64_mls_elt<mode>): Likewise. + (*aarch64_mls_elt_<vswap_width_name><mode>): Likewise. + (*aarch64_fma4_elt<mode>): Likewise. + (*aarch64_fma4_elt_<vswap_width_name><mode>): Likewise. + (*aarch64_fma4_elt_to_64v2df): Likewise. + (*aarch64_fnma4_elt<mode>): Likewise. + (*aarch64_fnma4_elt_<vswap_width_name><mode>): Likewise. + (*aarch64_fnma4_elt_to_64v2df): Likewise. + (aarch64_sq<r>dmulh_lane<mode>): Likewise. + (aarch64_sq<r>dmulh_laneq<mode>): Likewise. + (aarch64_sqdml<SBINQOPS:as>l_lane<mode>_internal): Likewise. + (aarch64_sqdml<SBINQOPS:as>l_lane<mode>_internal): Likewise. + (aarch64_sqdml<SBINQOPS:as>l2_lane<mode>_internal): Likewise. + (aarch64_sqdmull_lane<mode>_internal): Likewise. + (aarch64_sqdmull2_lane<mode>_internal): Likewise. + +2013-01-23 Alex Velenko <Alex.Velenko@arm.com> + + * config/aarch64/aarch64-simd.md + (aarch64_be_checked_get_lane<mode>): New define_expand. + * config/aarch64/aarch64-simd-builtins.def + (BUILTIN_VALL (GETLANE, be_checked_get_lane, 0)): + New builtin definition. + * config/aarch64/arm_neon.h: (__aarch64_vget_lane_any): + Use new safe be builtin. + +2014-01-23 Alex Velenko <Alex.Velenko@arm.com> + + * config/aarch64/aarch64-simd.md (aarch64_be_ld1<mode>): + New define_insn. + (aarch64_be_st1<mode>): Likewise. + (aarch_ld1<VALL:mode>): Define_expand modified. + (aarch_st1<VALL:mode>): Likewise. + * config/aarch64/aarch64.md (UNSPEC_LD1): New unspec definition. + (UNSPEC_ST1): Likewise. + +2014-01-23 David Holsgrove <david.holsgrove@xilinx.com> + + * config/microblaze/microblaze.md: Add trap insn and attribute + 2014-01-23 Dodji Seketeli <dodji@redhat.com> PR preprocessor/58580 @@ -79,8 +567,7 @@ PR rtl-optimization/59477 * lra-constraints.c (inherit_in_ebb): Process call for living hard - regs. Update reloads_num and potential_reload_hard_regs for all - insns. + regs. Update reloads_num and potential_reload_hard_regs for all insns. 2014-01-22 Tom Tromey <tromey@redhat.com> @@ -134,14 +621,13 @@ MAX_INLINE_INSNS_AUTO_LIMIT, INLINE_UNIT_GROWTH_LIMIT, RECURSIVE_INLINING, UNLIKELY_CALL, NOT_DECLARED_INLINED, OPTIMIZING_FOR_SIZE, ORIGINALLY_INDIRECT_CALL, - INDIRECT_UNKNOWN_CALL, USES_COMDAT_LOCAL. + INDIRECT_UNKNOWN_CALL, USES_COMDAT_LOCAL. Add CIF_FINAL_ERROR to UNSPECIFIED, BODY_NOT_AVAILABLE, FUNCTION_NOT_INLINABLE, OVERWRITABLE, MISMATCHED_ARGUMENTS, EH_PERSONALITY, NON_CALL_EXCEPTIONS, TARGET_OPTION_MISMATCH, OPTIMIZATION_MISMATCH. * tree-inline.c (expand_call_inline): Emit errors during - early_inlining if cgraph_inline_failed_type returns - CIF_FINAL_ERROR. + early_inlining if cgraph_inline_failed_type returns CIF_FINAL_ERROR. 2014-01-20 Uros Bizjak <ubizjak@gmail.com> diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 3a7526ef382..38d434f87e1 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20140123 +20140128 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 57998a697f9..2cb51c455f0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -761,7 +761,8 @@ BUILD_LINKERFLAGS = $(BUILD_CXXFLAGS) # Native linker and preprocessor flags. For x-fragment overrides. BUILD_LDFLAGS=@BUILD_LDFLAGS@ -BUILD_CPPFLAGS=$(ALL_CPPFLAGS) +BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ + -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS) # Actual name to use when installing a native compiler. GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 51f7ed64ba9..237c3e0aa0a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,942 @@ +2014-01-27 Robert Dewar <dewar@adacore.com> + + * sem_res.adb (Resolve_Comparison_Op): Add type name/location + to unordered msg. + (Resolve_Range): Add type name/location to unordered msg. + +2014-01-27 Claire Dross <dross@adacore.com> + + * a-cofove.adb/s (Copy): Add precondition so that Copy (Source, + Capacity) is only called with Capacity >= Length (Source) and + Capacity in Capacity_Range. + * a-cfdlli.adb/s, a-cfhase.adb/s, a-cfhama.adb/s, a-cforse.adb/s, + a-cforma.adb/s (Copy): Add precondition so that Copy (Source, Capacity) + is only called with Capacity >= Source.Capacity. Raise Capacity_Error + in the code is this is not the case. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * sem_ch4.adb (Analyze_Selected_Component): Fix handling of + selected component in an instance where the component of the + actual is not visibile at instantiation. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * sem_ch6.adb: sem_ch6.adb (Set_Actual_Subtypes): If the type + has a dynamic predicate, generate freeze node for Actual_Subtype + at once, because the declaration of the corresponding predicate + function will make reference to it. + +2014-01-27 Tristan Gingold <gingold@adacore.com> + + * exp_ch7.adb, exp_ch9.adb: Adjust comments. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * exp_ch4.adb (Expand_N_Op_Expon): Remove unsigned type test + for 2**X optimization. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * a-suenst.adb: strings.utf_encoding.strings (Decode): Check + explicitly whether value is in range of Character, because the + library is typically compiled with range checks disabled, and + we cannot rely on the implicit check on the argument of 'Val. + +2014-01-27 Vincent Celier <celier@adacore.com> + + * a-ciorma.adb, a-cihama.adb (Assign): Copy the Source to the Target, + not the Target to itself. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * vms_conv.ads, ali.adb, sem_ch6.ads, opt.ads, vms_cmds.ads: Minor + changes to avoid incorrect use of unordered enum types. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * sem_ch4.adb: Minor reformatting. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * scn.adb (Check_End_Of_Line): Removed. + (Error_Long_Line): Removed. + (Determine_License): Use versions of above routines from Scanner. + * scng.adb (Check_End_Of_Line): Moved to spec. + (Error_Long_Line): Removed, no longer used. + * scng.ads (Check_End_Of_Line): Moved here from body. + +2014-01-27 Tristan Gingold <gingold@adacore.com> + + * exp_ch7.adb (Build_Cleanup_Statements): Call + Build_Protected_Subprogram_Call_Cleanup to insert the cleanup + for protected body. + * exp_ch9.adb (Build_Protected_Subprogram_Body): Likewise. + Remove Service_Name variable. + (Build_Protected_SUbprogam_Call_Cleanup): New procedure that + factorize code from the above subprograms. + * exp_ch9.ads (Build_Protected_Subprogram_Call_Cleanup): New procedure. + +2014-01-27 Hristian Kirtchev <kirtchev@adacore.com> + + * einfo.adb (Has_Option): Reimplemented. + * sem_prag.adb (Analyze_Refinement_Clause): Add global + variables AR_Constit, AW_Constit, ER_Constit, EW_Constit, + External_Constit_Seen and State. Add local variables Body_Ref, + Body_Ref_Elmt and Extra_State. Reimplement part of the logic to + avoid a cumbersome while pool. Verify the legality of an external + state and relevant properties. + (Check_External_Property): New routine. + (Check_Matching_State): Remove parameter profile + and update comment on usage. + (Collect_Constituent): Store the + relevant external property of a constituent. + * sem_util.adb (Async_Readers_Enabled): Update the call to + Has_Enabled_Property. + (Async_Writers_Enabled): Update the call to Has_Enabled_Property. + (Effective_Reads_Enabled): Update the call to Has_Enabled_Property. + (Effective_Writes_Enabled): Update the call to Has_Enabled_Property. + (Has_Enabled_Property): Rename formal parameter Extern to State_Id. + Update comment on usage. Reimplement the logic to recognize the various + formats of properties. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * par-ch5.adb: Minor reformatting. + +2014-01-27 Tristan Gingold <gingold@adacore.com> + + * s-tposen.ads: Harmonize style and comments. + +2014-01-27 Vincent Celier <celier@adacore.com> + + * projects.texi: Document that shared library projects, by + default, cannot import projects that are not shared library + projects. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * sem_ch8.adb (Find_Selected_Component): Use Replace instead + of Rewrite. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * a-suenco.adb, a-suenst.adb (Decode): Raise encoding error if + any other exception is raised. + (Convert): If both Input_Scheme and Output_Scheme are UTF_8 it is + still necessary to perform a conversion in order to remove overlong + encodings. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * exp_smem.adb: Minor reformatting. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * a-calfor.ads: Fix incorrect reference to operator "-" in comment. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * sem_res.adb (Make_Call_Into_Operator): In ASIS mode, relocate + nodes for operands to the original node for the call, to preserve + Original_Node pointers within the resolved operands, given that + they may have been rewritten as well. Previous approach copied + the operands into a new tree and lost those pointers. + +2014-01-27 Claire Dross <dross@adacore.com> + + + * a-cofove.adb, a-cofove.ads: Add Strict_Equal function to the API. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Check_Internal_Protected_Use): A call through + an anonymous access parameter of the current protected function + is not a potential modification of the current object. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * a-cobove.adb (Reserve_Capacity): Procedure raises + Capacity_Error, not Constraint_Error, when request cannot be + satisfied. + +2014-01-27 Vincent Celier <celier@adacore.com> + + * a-coorma.adb, a-cohama.adb (Assign): Copy the Source to the Target, + not the Target to itself. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * exp_ch4.adb (Expand_Concatenate): If the target of the + concatenation is a library-level entity, always use the off-line + version of concatenation, regardless of optimization level. This + is space-efficient, and prevents linking problems when some + units are compiled with different optimization levels. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * sem_ch5.adb: Code clean up. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * par-ch5.adb (P_Iterator_Specification): Improve error recovery + when an array or container iterator includes a subtype indication, + which is only legal in an element iterator. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * exp_ch7.adb: Minor reformatting. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * opt.adb (SPARK_Mode): Default for library units is None rather + than Off. + * opt.ads: Remove AUTO from SPARK_Mode_Type SPARK_Mode_Type is + no longer ordered. + * sem_prag.adb (Analyze_Pragma, case SPARK_Mode): Remove AUTO + possibility. + * snames.ads-tmpl (Name_Auto): Removed, no longer used. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * par-ch5.adb (P_Sequence_Of_Statements): Make entry in + Suspicious_Labels table if we have identifier; followed by loop + or block. + * par-endh.adb (Evaluate_End_Entry): Search Suspicious_Labels table. + * par.adb (Suspicious_Labels): New table. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * exp_aggr.adb (Check_Bounds): Reason is range check, not + length check. + +2014-01-27 Yannick Moy <moy@adacore.com> + + * get_spark_xrefs.adb (Get_SPARK_Xrefs): Accept new type 'c' for + reference. + * lib-xref-spark_specific.adb (Is_Global_Constant): Remove useless + function now. + (Add_SPARK_Xrefs): Include references to constants. + * spark_xrefs.ads Document new character 'c' for references to + constants. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * exp_smem.adb (Add_Write_After): For a function call, insert write as + an after action in a transient scope. + +2014-01-27 Thomas Quinot <quinot@adacore.com> + + * exp_smem.adb (Expand_Shared_Passive_Variable): For a reference + to a shared variable as an OUT formal in a call to an init proc, + the 'Read call must be emitted after, not before, the call. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * gnat_rm.texi: Remove mention of AUTO mode for SPARK_Mode pragma. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * a-wichha.adb (Character_Set_Version): Change to output proper + value. + +2014-01-27 Hristian Kirtchev <kirtchev@adacore.com> + + * einfo.adb (Is_Input_Only_State): Removed. + (Is_Non_Volatile_State): Removed. + (Is_Output_State): Removed. + * einfo.ads (Is_Input_Only_State): Remove attribute and + subprogram. Update related entity. + (Is_Non_Volatile_State): + Remove attribute and subprogram. Update related entity. + (Is_Output_State): Removed attribute and subprogram. Update + related entity. + * exp_ch6.adb (Expand_Subprogram_Contract): Update comment on + generated code. + * sem_ch3.adb (Analyze_Declarations): Analyze the contract of + an object, not just variables. + (Analyze_Object_Contract): New routine. + (Analyze_Variable_Contract): Removed. + (Process_Discriminants): Detect an illegal use of volatile + discriminant in SPARK mode. + * sem_ch5.adb (Analyze_Iterator_Specification): + Detect an illegal use of volatile loop variable. + (Analyze_Loop_Parameter_Specification): Detect an illegal use + of volatile loop variable. + * sem_ch6.adb (Process_Formals): Update the volatile object + detection. Detect an illegal formal of mode IN OUT or OUT in + SPARK mode. Enhance the error messages with references. + * sem_ch12.adb (Instantiate_Object): Update the volatile object + detection. Enhance the error messages with references. + * sem_prag.adb (Analyze_Abstract_State): Enhance the error + messages with references. + (Analyze_Contract_Case): Enhance the error messages with references. + (Analyze_External_Property): Call Check_Duplicate_Property to process + an external property. + (Analyze_External_Property_In_Decl_Part): New routine. + (Analyze_External_State_In_Decl_Part): Removed. + (Analyze_Global_Item): Detect an illegal + use of a volatile constant. Detect an illegal use + of a variable with enabled Effective_Reads. Enhance + the error messages with references. Remove obsolete + checks concerning Input_Only and Output_Only states. + (Analyze_Initialization_Item): Enhance the error messages + with references. + (Analyze_Initializes_In_Decl_Part): Do not + collect the states and variables when the initialization list + is null. + (Analyze_Input_Item): Enhance the error messages with references. + (Analyze_Input_Output): Enhance the error messages with references. + (Analyze_Pragma): Enhance the error messages with references. + (Analyze_Refinement_Clause): Code reformatting. + (Analyze_Refined_Depends_In_Decl_Part): + Rename global variable Global to Reg_Global and update all + occurrences. Add local variables D7 and D8. Update the error + messages with references. Update the call to Collect_Global_Items. + (Analyze_Refined_Global_In_Decl_Part): Add local variables + Has_Proof_In_State, Proof_In_Constits and Proof_In_Items. Update + the call to Collect_Global_Items. Account for a Proof_In state + in null / useless refinement checks. Verify the coverage of + Proof_In states. + (Check_Dependency_Clause): Remove local variable + Out_Constits. Remove the retrieval and removal of constituents + for an Output_Only state. Remove the reporting of unused + Output_Only state constituents. + (Check_Duplicate_Mode): Enhance + the error message with a reference. + (Check_Duplicate_Property): New routine. + (Check_Duplicate_Option): Enhance the error message with a reference. + (Check_External_Properties): Enhance the error message with a reference. + (Check_Function_Return): Enhance the error message with a reference. + (Check_In_Out_States): Update + comment on usage. Add a specialized error message for Proof_In + constituents. Enhance the error message with a reference. + (Check_Input_States): Update comment on usage. Account for + possible Proof_In constituents. Enhance the error message + with a areference. + (Check_Matching_Constituent): Enhance the error message with a + reference. + (Check_Matching_State): Enchance the error message with a reference. + (Check_Mode): Add local variable From_Global. Update the call to + Find_Mode. Emit more precise error messages concerning extra items + (Check_Mode_Restriction_In_Enclosing_Context): Consider + pragma Refined_Global. Enhance the error message with a + reference. + (Check_Mode_Restriction_In_Function): Enhance the error message with + a reference. + (Check_Output_States): Update comment on usage. Add local variable + Posted. Account for possible Proof_In constituents. Produce a detailed + list of missing constituents. + (Check_Proof_In_States): New routine. + (Check_Refined_Global_Item): Handle Proof_In + constituents. Enchance the error message with a reference. + (Collect_Global_Items): Add formal parameters Proof_In_Items + and Has_Proof_In_State. Update the comment on usage. Account + for Proof_In items. + (Create_Or_Modify_Clause): Enchance + the error message with a reference. + (Find_Mode): Add + formal parameter From_Global. Update the comment on usage. + Detect when the mode is governed by pragma [Refined_]Global. + (Output_Constituents): Removed. + (Report_Extra_Constituents): + Report extra Proof_In constituents. + (Report_Unused_Constituents): Removed. + (Usage_Error): Code reformatting. Enhance the error + messages with reference. + * sem_prag.ads (Analyze_External_Property_In_Decl_Part): New routine. + (Analyze_External_State_In_Decl_Part): Removed. + * sem_res.adb (Resolve_Actuals): Update the volatile object + detection. Enhance the error message with a reference. + (Resolve_Entity_Name): Update the volatile object + detection. Enhance the error message with a reference. + * sem_util.adb (Is_Refined_State): Add a guard to avoid a crash. + (Is_SPARK_Volatile_Object): New routine. + (Has_Volatile_Component): New routine. + * sem_util.ads (Is_Delegate): Alphabetized. + (Is_SPARK_Volatile_Object): New routine. + (Has_Volatile_Component): New routine. + * snames.ads-tmpl: Remove names Name_Input_Only and Name_Output_Only. + +2014-01-27 Ed Schonberg <schonberg@adacore.com> + + * sem_attr.adb: Resolve fully prefix of 'Update. + +2014-01-27 Ben Brosgol <brosgol@adacore.com> + + * gnat_rm.texi: Minor clarifications. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * sem_elab.adb (Check_Internal_Call_Continue): Avoid complaining + about call that is generated as part of an Initial_Condition + check. + * sem_prag.adb: Minor spelling correction. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * sem_prag.adb (Set_Convention_From_Pragma): Check that + convention Ghost can only apply to functions. + * einfo.ads, einfo.adb (Is_Ghost_Subprogram): Add clarifying comment. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * gnat_ugn.texi: Add Short_Enums to documentation of + -gnatet/-gnateT. + +2014-01-27 Robert Dewar <dewar@adacore.com> + + * sem_prag.adb (Analyze_Input_Item): Correct check for input + item in same package. + * sem_util.ads, sem_util.adb (Within_Scope): New function. + +2014-01-26 Arnaud Charlet <charlet@adacore.com> + + * a-intnam-lynxos.ads, mlib-tgt-specific-lynxos.adb, + s-osinte-lynxos-3.adb, s-osinte-lynxos-3.ads, s-osinte-lynxos.adb, + s-osinte-lynxos.ads, s-taprop-lynxos.adb, s-tpopsp-lynxos.adb, + system-lynxos-ppc.ads, system-lynxos-x86.ads: Removed, no longer + maintained. + +2014-01-25 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/Makefile.in: Fix oversight. + +2014-01-25 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/utils.c (convert_to_fat_pointer): Un-obfuscate the + conversion from a thin pointer with a shifted value. + * gcc-interface/utils2.c (gnat_build_constructor): Propagate the + read-only flag from the values onto the result. + (gnat_invariant_expr): Accept read-only CONSTRUCTORs. + +2014-01-25 Tristan Gingold <gingold@adacore.com> + + * gcc-interface/decl.c (gnat_to_gnu_entity): Always build a variable + for E_Variable with a pragma Linker_Section. + +2014-01-25 Robert Dewar <dewar@adacore.com> + + * gcc-interface/decl.c (gnat_to_gnu_param): Make sure an Out parameter + with Default_Value aspect is passed in by copy. + +2014-01-24 Eric Botcazou <ebotcazou@adacore.com> + + * set_targ.adb: Set Short_Enums. + * gcc-interface/lang.opt (fshort-enums): New option. + * gcc-interface/misc.c (gnat_handle_option): Handle it. + (gnat_post_options): Do not modify the global settings. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * g-rannum.ads, g-rannum.adb (Random_Ordinary_Fixed): New generic + function. + (Random_Decimal_Fixed): New generic function. + * s-rannum.ads: Minor comment clarifications. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * back_end.adb: Remove Short_Enums handling (handled in + Ttypes/Get_Targ now) Minor added comments. + * freeze.adb: Change name Short_Enums_On_Target to + Target_Short_Enums. + * get_targ.ads, get_targ.adb (Get_Short_Enums): New function. + * opt.ads: Minor comment updates. + * sem_ch13.adb: Change name Short_Enums_On_Target to + Target_Short_Enums. + * set_targ.adb: Set Short_Enums from gcc back end. + * set_targ.ads (Short_Enums): New variable. + * targparm.ads, targparm.adb: Remove Short_Enums entries (handled in + Ttypes/Get_Targ now). + * ttypes.ads (Target_Short_Enums): New constant boolean switch + +2014-01-24 Pascal Obry <obry@adacore.com> + + * g-sercom-mingw.adb: Fix serial port name for port number > 10. + +2014-01-24 Gary Dismukes <dismukes@adacore.com> + + * exp_disp.adb (Expand_Dispatching_Call): Call Unqualify on Param when + comparing it with Ctrl_Arg, since Ctrl_Arg may have had qualification + stripped off. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sinfo.ads, make.adb, prj-env.adb: Minor reformatting. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj.adb (Add_Aggregated_Project): Do not add a project in + the list if it is already there. + +2014-01-24 Yannick Moy <moy@adacore.com> + + * lib-xref-spark_specific.adb (Enclosing_Subprogram_Or_Package): + Correct the search for a subrogram declaration to which a pragma is + attached. + +2014-01-24 Bob Duff <duff@adacore.com> + + * gnat_ugn.texi: Document --decimal-grouping and + --based-grouping switches in gnatpp. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sinfo.ads: Documentation update. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_ch3.adb (Constant_Redeclaration): New declaration is + illegal if previous one has an initial expression that is an + aggregate expanded into assignments. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Small + code reorganization to remove spurious warning on a loop with + an array element iterator that has a null range. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * make.adb (Binding_Phase): When setting the Ada paths, use + the library ALI dir, not the object dir in libraries. + +2014-01-24 Yannick Moy <moy@adacore.com> + + * sinfo.ads: Add documentation of check flag fields. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_res.adb (Resolve_Actuals): If an actual is a view + conversion of a discriminated object, and the formal type is + discriminated and constrained, apply a discriminant check to + the object itself. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * prj.adb, prj-env.adb, back_end.adb: Add comment, minor code clean ups. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_ch3.adb (Analyze_Declarations): At the end of an + appropriate declarative part, call Freeze_All from the first + declaration in the scope, not from the first unfrozen one. This + is necessary to apply visibility checks to entities with delayed + aspects. Otherwise, in the presence of instantiations and cleanups + that they may generate, the delayed aspects may be analyzed too + late and produce spurious visibility errors. + * sem_attr.adb: Place etype on range. + * sem_ch6.adb: Documentation expression functions. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * exp_ch7.adb: Minor change of Indices to Indexes (preferred + terminology in compiler). + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * scans.ads: Remove Tok_Raise from Sterm, Eterm, After_SM + categories, now that Ada 95 supports raise expressions. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * freeze.adb (Freeze_Enumeration_Type): Use new target parameter + Short_Enums_On_Target. + * sem_ch13.adb (Set_Enum_Esize): Take Short_Enums_On_Target + into account. + * targparm.ads, targparm.adb: Add new target parameter Short_Enums. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_ch5.adb (Analyze_Iterator_Specification): If subtype + indication is given explicity, check that it matches the array + component type or the container element type of the domain + of iteration. + +2014-01-24 Tristan Gingold <gingold@adacore.com> + + * back_end.adb (Scan_Compiler_Arguments): Set Short_Enums_On_Target. + * gcc-interface/misc.c (flag_short_enums): Declare. + (gnat_post_options): Set it. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj-env.adb (Ada_Objects_Path): Use Ada_Objects_Path_No_Libs + to cache the result when Including_Libraries is False. + * prj-env.ads (Ada_Objects_Path): Update documentation + * prj.adb (Free (Project_Id)): Also free Ada_Objects_Path_No_Libs + (Get_Object_Directory): Return the Library_Ali_Dir only when + when Including_Libraries is True. + * prj.ads (Get_Object_Directory): Fix and complete documentation + (Project_Data): New component Ada_Objects_Path_No_Libs + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * checks.adb (Expr_Known_Valid): Result of fpt operator never + considered valid. + +2014-01-24 Eric Botcazou <ebotcazou@adacore.com> + + * back_end.adb: Minor fix in comment. + +2014-01-24 Javier Miranda <miranda@adacore.com> + + * sem_ch3.adb (Check_Abstract_Overriding): Code reestructuration + required to report the error in case of task types. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_attr.adb: Additional index checking. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_attr.adb (Analyze_Attribute, case 'Update): Analyze + expressions in each component association, and for records note + the entity in each association choice, for subsequent resolution. + (Resolve_Attribute, case 'Update): Complete resolution of + expressions in each component association. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem.adb (Sem): Avoid premature reference to Current_Sem_Unit + (this was causing Is_Main_Unit_Or_Main_Unit_Spec to be set wrong, + leading to wrong handling of SPARK_Mode for library units). + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Set SPARK_Mode + on generic instances (do not consider them to be internally + generated) + +2014-01-24 Doug Rupp <rupp@adacore.com> + + * s-osinte-android.ads (pthread_sigmask): Import sigprocmask + vice pthread_sigmask. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj.adb (Debug_Output (Str, Str2)): Output if verbosity is + not default. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj-ext.adb (Add): Do not output anything when Silent is True, + whatever the verbosity. When Source is From_External_Attribute, + set the corresponding environment variable if it is not already set. + * prj-ext.ads (Add): New Boolean parameter Silent, defaulted + to False + * prj-proc.adb (Process_Expression_For_Associative_Array): + For attribute External, call Prj.Ext.Add with Silent set to + True for the child environment, to avoid useless output in non + default verbosity. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_res.adb (Set_Slice_Subtype): Handle properly a discrete + range given by a subtype indication, and force evaluation of + the bounds, as for a simple range. + * exp_util.adb (Evaluate_Slice_Bounds): Utility to force evaluation + of bounds of slice for various kinds of discrete ranges. + (Evaluate_Name, Evaluate_Subtype_From_Expr): use + Evaluate_Slice_Bounds. + +2014-01-24 Bob Duff <duff@adacore.com> + + * s-taskin.ads (Activator): Make this Atomic, because + Activation_Is_Complete reads it, and that can be called + from any task. Previously, this component was only + modified by the activator before activation, and by + Self after activation. + * a-taside.ads, a-taside.adb (Environment_Task, + Activation_Is_Complete): Implement these missing functions. + +2014-01-24 Doug Rupp <rupp@adacore.com> + + * init.c: Add a handler section for Android. + +2014-01-24 Arnaud Charlet <charlet@adacore.com> + + * i-cexten.ads (Unsigned_33..64, Unsigned_33..64): New types. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_ch4.adb (Operator_Check): If one operand is a + Raise_Expression, set its type to that of the other operand. + * sem_res.adb (Resolve_Raise_Expression): new procedure. + (Resolve_Actuals): For an actual that is a Raise_Expression, + set the type to that of the formal. + * sem_type.adb (Find_Unique_Type): If one of the operands is a + Raise_Expression, return type of the other operand. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_aggr.adb (Resolve_Record_Aggregate): If a scalar + component of the record has a type with a default aspect, and + the corresponding aggregate component is initiaized with a box, + use the default value in the rewritten aggregate. + +2014-01-24 Tristan Gingold <gingold@adacore.com> + + * s-interr.ads, s-interr.adb, s-interr-hwint.adb, s-interr-vms.adb, + s-interr-sigaction.adb, + s-interr-dummy.adb (Install_Restricted_Handlers): Add Prio parameter. + * exp_ch9.adb (Make_Initialize_Protection): Add Prio parameter + to the call to Install_Restricted_Handlers. + +2014-01-24 Emmanuel Briot <briot@adacore.com> + + * prj-nmsc.adb (Check_File): Add protection when the source is + not fully initialized. + +2014-01-24 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Is_Post_State): In a postcondition, a selected + component that denotes an implicit dereference is a reference + to the post state of the subprogram. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem_ch6.adb (Analyze_Subprogram_Body_Helper): SPARK_Mode OFF + for generated subprograms. + (Analyze_Subprogram_Specification): Ditto. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj-dect.adb (Check_Attribute_Allowed): Detect more forbidden + attributes in package Builder of aggregate and aggregate library + projects. + * prj-nmsc.adb (Process_Naming_Scheme.Check.Check_Aggregate): + Remove procedure (Process_Naming_Scheme.Check.Check_Aggregated): + Remove parameters. Change error message from "... externally + build library ..." to "... externally built project ...". + (Process_Naming_Scheme.Check): Do not do any check in aggregate + project, as attribute Library_Dir and Library_Name have already + been detected as forbidden. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * prj-env.adb (Find_Project): If cached project path is not in + project directory, look in current directory first and use cached + project path only if project is not found in project directory. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem_util.adb, lib-xref.adb: Correct false positive warnings. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * projects.texi: Document that aggregate projects are only + supported by gprbuild, but not by gnatmake. Document that the + only attribute Switches in package Binder of aggregate projects + will be ignored if its index is not others. Document that + attribute Global_Config_File is allowed in package Binder of + aggregate projects. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem_prag.adb: Minor code reorganization. + * sem_util.adb: Minor fix of potential latent bug in Is_LHS. + +2014-01-24 Pascal Obry <obry@adacore.com> + + * prj-attr.adb, projects.texi, snames.ads-tmpl: Add Excluded_Patterns + attribute definition. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * makeutl.adb (Queue.Insert_No_Roots): In gprbuild, do not put + in the Queue the same source (same path, same multi-source index) + from the same project file, to avoid compiling several times + the same source. + +2014-01-24 Eric Botcazou <ebotcazou@adacore.com> + + * einfo.ads (First_Rep_Item): Remove obsolete stuff. + (Has_Gigi_Rep_Item): Likewise. + * sem_prag.adb (Analyze_Pragma) <Pragma_Linker_Section>: Do not set + Has_Gigi_Rep_Item for objects. + * gcc-interface/decl.c (prepend_one_attribute_to): Rename into... + (prepend_one_attribute): ...this. + (prepend_one_attribute_pragma): New function extracted from... + (prepend_attributes): ...here. Swap the parameters for consistency. + (gnat_to_gnu_entity): Adjust calls to prepend_one_attribute_to and to + prepend_attributes. + <object>: Deal with a pragma Linker_Section on a constant + or variable. <E_Function>: Deal with a pragma Linker_Section + on a subprogram. + (get_minimal_subprog_decl): Adjust calls to prepend_one_attribute_to. + +2014-01-24 Vincent Celier <celier@adacore.com> + + * opt.ads: Minor comment update. + +2014-01-24 Robert Dewar <dewar@adacore.com> + + * sem_prag.adb (Analyze_Input_Output): Add missing error check + for junk operand. + * sem_util.adb (Is_Refined_State): Add defense against junk + tree from error. + +2014-01-24 Pascal Obry <obry@adacore.com> + + * projects.texi: Removes Build_Slaves attribute documentation. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * opt.adb (Register_Opt_Config_Switches): Save SPARK_Mode_Pragma + setting. + +2014-01-23 Ed Schonberg <schonberg@adacore.com> + + * sem_util.adb (Is_Potentially_Unevaluated): Predicate only + applies to expressions that come from source. + * sem_attr.adb (Analyze_Attribute, case 'Old): Improve error + message. + (Analyze_Attribute, case 'Loop_Entry): Apply SPARK 2014 legality + rule regarding potentially unevaluated expressions, to prefix + of attribute. + +2014-01-23 Ed Schonberg <schonberg@adacore.com> + + * exp_util.adb (Make_Invqriant_Call): If type of expression is + a private extension, get invariant from base type. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * sem_util.adb, sem_attr.adb: Minor reformatting. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * opt.adb (Save_Opt_Config_Switches): Save SPARK_Mode_Pragma + (Restore_Opt_Config_Switches): Restore SPARK_Mode_Pragma. + * sem.adb (Semantics): Remove save/restore of + SPARK_Mode[_Pragma]. Not needed since already done in + Save/Restore_Opt_Config_Switches. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * gnat_rm.texi, einfo.adb, einfo.ads, sem_prag.adb, gnat_ugn.texi, + freeze.adb, repinfo.adb, aspects.adb, aspects.ads, sem_ch13.adb: + Linker_Section enhancements. + +2014-01-23 Tristan Gingold <gingold@adacore.com> + + * gnat_rm.texi: Minor editing. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * opt.adb (Set_Opt_Config_Switches): Reset SPARK mode for + with'ed internal units. + * sem.adb (Semantics): Save and restore SPARK_Mode[_Pragma]. + +2014-01-23 Javier Miranda <miranda@adacore.com> + + * lib-xref.adb (Generate_Reference): As part of processing the + "end-of-spec" reference generate an extra reference to the first + private entity of the package. + * xr_tabls.adb (Add_Reference): No action needed for the extra + 'E' reference associated; similar to the processing of the + 'e' reference. + +2014-01-23 Bob Duff <duff@adacore.com> + + * gnat_ugn.texi: Change "--&pp off" to "--!pp off". + +2014-01-23 Ed Schonberg <schonberg@adacore.com> + + * sem_util.ads, sem_util.adb (Is_Potentially_Unevaluated): new + predicate to implement rule given in 6.1.1 (20/3). + * sem_attr.adb (Analyze_Attribute, case 'Old): Reject prefix of + 'Old in a postcondition, if it is potentially unevaluated and + it is not an entity name. + +2014-01-23 Bob Duff <duff@adacore.com> + + * gnat_ugn.texi: Document the new "--&pp off" feature of gnatpp. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * gnatlink.adb (Gnatlink): Fix problem of generating bad name + msg on VMS. + +2014-01-23 Bob Duff <duff@adacore.com> + + * g-dynhta.ads: Minor comment fix. + +2014-01-23 Yannick Moy <moy@adacore.com> + + * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Inherit SPARK_Mode + from spec on body only when not already inherited on spec. Set + SPARK_Mode from context on body without previous spec. * + * sem_prag.adb (Analyze_Pragma): Check placement of pragma on + library-level entities. Correct retrieval of entity from + declaration, for cases where the declaration is not a unit. + * sem_ch12.adb (Instantiate_Object): Avoid + calling Is_Volatile_Object on an empty node. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * gnatlink.adb (Gnatlink): Check for suspicious executable file + names on windows. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * a-ngelfu.ads: Remove bad uses of AND which should be AND THEN. + * sem_res.adb (Check_No_Direct_Boolean_Operators): Don't give + style errors in instances. + * g-dynhta.ads (Static_HTable): Comment updates. + +2014-01-23 Vincent Celier <celier@adacore.com> + + * prj-conf.adb (Get_Or_Create_Configuration_File): Do not attempt + to find a configuration project file when Config_File_Name is + No_Configuration_File. + * prj-conf.ads (No_Configuration_File): New constant String. + * prj-pars.adb (Parse): Call Get_Or_Create_Configuration_File + with Config_File_Name set to No_Configuration_File, so that + no existing configuration project file will be used, and the + configuration project will be only created in memory when + Add_Default_GNAT_Naming_Scheme is called. + * projects.texi: Minor reformatting. + +2014-01-23 Vincent Celier <celier@adacore.com> + + * prj-conf.adb (Get_Or_Create_Configuration_File): Never parse + a config project file if On_Load_Config is not null. + * prj-pars.adb: Minor comment changes. + +2014-01-23 Ed Schonberg <schonberg@adacore.com> + + * lib-xref.adb (Output_References): Output progenitors of + synchronized tagged types, for source navigation. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * exp_util.adb, sinfo.adb, sinfo.ads, sem.adb, sem_res.adb, + expander.adb, exp_ch11.adb, exp_ch11.ads, sem_ch11.adb, sem_ch11.ads, + sprint.adb, sprint.ads: Remove unused node N_Subprogram_Info. + +2014-01-23 Emmanuel Briot <briot@adacore.com> + + * prj-conf.adb (Get_Or_Create_Configuration_File): call + On_Load_Config later. + +2014-01-23 Hristian Kirtchev <kirtchev@adacore.com> + + * sem_ch3.adb (Analyze_Declarations): Do not + generate the spec of the late primitive in ASIS mode. Add two + comments to explain the special cases when the expansion is + not performed. + +2014-01-23 Robert Dewar <dewar@adacore.com> + + * sem_util.adb (Note_Possible_Modification): Fix error of + misbehaving for implicit dereference cases in -gnatc mode. + +2014-01-23 Emmanuel Briot <briot@adacore.com> + + * prj-pars.adb: Minor reformatting. + 2014-01-22 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (Analyze_Subprogram_Body_Helper): A subprogram diff --git a/gcc/ada/a-calfor.ads b/gcc/ada/a-calfor.ads index d5cc934b99e..8cfd6a403dc 100644 --- a/gcc/ada/a-calfor.ads +++ b/gcc/ada/a-calfor.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2005-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 2005-2013, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- @@ -70,7 +70,7 @@ package Ada.Calendar.Formatting is Sub_Second : Second_Duration := 0.0) return Day_Duration; -- Returns a Day_Duration value for the combination of the given Hour, -- Minute, Second, and Sub_Second. This value can be used in Ada.Calendar. - -- Time_Of as well as the argument to Calendar."+" and Calendar."–". If + -- Time_Of as well as the argument to Calendar."+" and Calendar."-". If -- Seconds_Of is called with a Sub_Second value of 1.0, the value returned -- is equal to the value of Seconds_Of for the next second with a Sub_ -- Second value of 0.0. diff --git a/gcc/ada/a-cfdlli.adb b/gcc/ada/a-cfdlli.adb index 34668bdd2d5..982c1b7d2f7 100644 --- a/gcc/ada/a-cfdlli.adb +++ b/gcc/ada/a-cfdlli.adb @@ -229,6 +229,10 @@ package body Ada.Containers.Formal_Doubly_Linked_Lists is P : List (C); begin + if 0 < Capacity and then Capacity < Source.Capacity then + raise Capacity_Error; + end if; + N := 1; while N <= Source.Capacity loop P.Nodes (N).Prev := Source.Nodes (N).Prev; diff --git a/gcc/ada/a-cfdlli.ads b/gcc/ada/a-cfdlli.ads index 660eb18e302..54f1886d297 100644 --- a/gcc/ada/a-cfdlli.ads +++ b/gcc/ada/a-cfdlli.ads @@ -84,7 +84,8 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is procedure Assign (Target : in out List; Source : List) with Pre => Target.Capacity >= Length (Source); - function Copy (Source : List; Capacity : Count_Type := 0) return List; + function Copy (Source : List; Capacity : Count_Type := 0) return List with + Pre => Capacity = 0 or else Capacity >= Source.Capacity; function Element (Container : List; diff --git a/gcc/ada/a-cfhama.adb b/gcc/ada/a-cfhama.adb index 3ab4af23e78..938423894c2 100644 --- a/gcc/ada/a-cfhama.adb +++ b/gcc/ada/a-cfhama.adb @@ -207,6 +207,10 @@ package body Ada.Containers.Formal_Hashed_Maps is Cu : Cursor; begin + if 0 < Capacity and then Capacity < Source.Capacity then + raise Capacity_Error; + end if; + Target.Length := Source.Length; Target.Free := Source.Free; diff --git a/gcc/ada/a-cfhama.ads b/gcc/ada/a-cfhama.ads index 5366655753e..71eed2b0e4d 100644 --- a/gcc/ada/a-cfhama.ads +++ b/gcc/ada/a-cfhama.ads @@ -100,7 +100,7 @@ package Ada.Containers.Formal_Hashed_Maps is (Source : Map; Capacity : Count_Type := 0) return Map with - Pre => Capacity >= Source.Capacity; + Pre => Capacity = 0 or else Capacity >= Source.Capacity; -- Copy returns a container stricty equal to Source. It must have -- the same cursors associated with each element. Therefore: -- - capacity=0 means use container.capacity as capacity of target diff --git a/gcc/ada/a-cfhase.adb b/gcc/ada/a-cfhase.adb index 451ec32a886..96f0d05c057 100644 --- a/gcc/ada/a-cfhase.adb +++ b/gcc/ada/a-cfhase.adb @@ -233,6 +233,10 @@ package body Ada.Containers.Formal_Hashed_Sets is Cu : Cursor; begin + if 0 < Capacity and then Capacity < Source.Capacity then + raise Capacity_Error; + end if; + Target.Length := Source.Length; Target.Free := Source.Free; diff --git a/gcc/ada/a-cfhase.ads b/gcc/ada/a-cfhase.ads index d470e1b8a9f..a3fc63dc036 100644 --- a/gcc/ada/a-cfhase.ads +++ b/gcc/ada/a-cfhase.ads @@ -106,7 +106,7 @@ package Ada.Containers.Formal_Hashed_Sets is (Source : Set; Capacity : Count_Type := 0) return Set with - Pre => Capacity >= Source.Capacity; + Pre => Capacity = 0 or else Capacity >= Source.Capacity; function Element (Container : Set; diff --git a/gcc/ada/a-cforma.adb b/gcc/ada/a-cforma.adb index ac763918283..33cd101badc 100644 --- a/gcc/ada/a-cforma.adb +++ b/gcc/ada/a-cforma.adb @@ -283,6 +283,10 @@ package body Ada.Containers.Formal_Ordered_Maps is N : Count_Type; begin + if 0 < Capacity and then Capacity < Source.Capacity then + raise Capacity_Error; + end if; + return Target : Map (Count_Type'Max (Source.Capacity, Capacity)) do if Length (Source) > 0 then Target.Length := Source.Length; diff --git a/gcc/ada/a-cforma.ads b/gcc/ada/a-cforma.ads index 00cd3989d52..a9426764560 100644 --- a/gcc/ada/a-cforma.ads +++ b/gcc/ada/a-cforma.ads @@ -92,7 +92,7 @@ package Ada.Containers.Formal_Ordered_Maps is Pre => Target.Capacity >= Length (Source); function Copy (Source : Map; Capacity : Count_Type := 0) return Map with - Pre => Capacity >= Source.Capacity; + Pre => Capacity = 0 or else Capacity >= Source.Capacity; function Key (Container : Map; Position : Cursor) return Key_Type with Pre => Has_Element (Container, Position); diff --git a/gcc/ada/a-cforse.adb b/gcc/ada/a-cforse.adb index 22e92220b9d..1b202f03b1b 100644 --- a/gcc/ada/a-cforse.adb +++ b/gcc/ada/a-cforse.adb @@ -320,6 +320,10 @@ package body Ada.Containers.Formal_Ordered_Sets is Target : Set (Count_Type'Max (Source.Capacity, Capacity)); begin + if 0 < Capacity and then Capacity < Source.Capacity then + raise Capacity_Error; + end if; + if Length (Source) > 0 then Target.Length := Source.Length; Target.Root := Source.Root; diff --git a/gcc/ada/a-cforse.ads b/gcc/ada/a-cforse.ads index 0116e8f2791..e935be5e457 100644 --- a/gcc/ada/a-cforse.ads +++ b/gcc/ada/a-cforse.ads @@ -94,7 +94,7 @@ package Ada.Containers.Formal_Ordered_Sets is Pre => Target.Capacity >= Length (Source); function Copy (Source : Set; Capacity : Count_Type := 0) return Set with - Pre => Capacity >= Source.Capacity; + Pre => Capacity = 0 or else Capacity >= Source.Capacity; function Element (Container : Set; diff --git a/gcc/ada/a-cihama.adb b/gcc/ada/a-cihama.adb index e3e3d5ee43d..4e4d240e394 100644 --- a/gcc/ada/a-cihama.adb +++ b/gcc/ada/a-cihama.adb @@ -169,7 +169,7 @@ package body Ada.Containers.Indefinite_Hashed_Maps is Target.Reserve_Capacity (Source.Length); end if; - Insert_Items (Target.HT); + Insert_Items (Source.HT); end Assign; -------------- diff --git a/gcc/ada/a-ciorma.adb b/gcc/ada/a-ciorma.adb index b836dc69fd0..1c6f6d737fc 100644 --- a/gcc/ada/a-ciorma.adb +++ b/gcc/ada/a-ciorma.adb @@ -313,7 +313,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is end if; Target.Clear; - Insert_Items (Target.Tree); + Insert_Items (Source.Tree); end Assign; ------------- diff --git a/gcc/ada/a-cobove.adb b/gcc/ada/a-cobove.adb index bcd6118e607..b2e75b58118 100644 --- a/gcc/ada/a-cobove.adb +++ b/gcc/ada/a-cobove.adb @@ -2390,7 +2390,7 @@ package body Ada.Containers.Bounded_Vectors is is begin if Capacity > Container.Capacity then - raise Constraint_Error with "Capacity is out of range"; + raise Capacity_Error with "Capacity is out of range"; end if; end Reserve_Capacity; diff --git a/gcc/ada/a-cofove.adb b/gcc/ada/a-cofove.adb index 240715dca75..93372e1c5cb 100644 --- a/gcc/ada/a-cofove.adb +++ b/gcc/ada/a-cofove.adb @@ -301,10 +301,10 @@ package body Ada.Containers.Formal_Vectors is begin if Capacity = 0 then C := LS; - elsif Capacity >= LS then + elsif Capacity >= LS and then Capacity in Capacity_Range then C := Capacity; else - raise Constraint_Error; + raise Capacity_Error; end if; return Target : Vector (C) do @@ -1506,6 +1506,19 @@ package body Ada.Containers.Formal_Vectors is end; end Set_Length; + ------------------ + -- Strict_Equal -- + ------------------ + + function Strict_Equal (Left, Right : Vector) return Boolean is + begin + -- On bounded vectors, cursors are indexes. As a consequence, two + -- vectors always have the same cursor at the same position and + -- Strict_Equal is simply = + + return Left = Right; + end Strict_Equal; + ---------- -- Swap -- ---------- diff --git a/gcc/ada/a-cofove.ads b/gcc/ada/a-cofove.ads index 1f9b94f7353..313165c49c6 100644 --- a/gcc/ada/a-cofove.ads +++ b/gcc/ada/a-cofove.ads @@ -45,8 +45,9 @@ -- which is not possible if cursors encapsulate an access to the underlying -- container. --- There are two new functions: +-- There are three new functions: +-- function Strict_Equal (Left, Right : Vector) return Boolean; -- function Left (Container : Vector; Position : Cursor) return Vector; -- function Right (Container : Vector; Position : Cursor) return Vector; @@ -124,7 +125,7 @@ package Ada.Containers.Formal_Vectors is (Source : Vector; Capacity : Count_Type := 0) return Vector with - Pre => Length (Source) <= Capacity; + Pre => Length (Source) <= Capacity and then Capacity in Capacity_Range; function To_Cursor (Container : Vector; @@ -349,6 +350,11 @@ package Ada.Containers.Formal_Vectors is end Generic_Sorting; + function Strict_Equal (Left, Right : Vector) return Boolean; + -- Strict_Equal returns True if the containers are physically equal, i.e. + -- they are structurally equal (function "=" returns True) and that they + -- have the same set of cursors. + function Left (Container : Vector; Position : Cursor) return Vector with Pre => Has_Element (Container, Position) or else Position = No_Element; function Right (Container : Vector; Position : Cursor) return Vector with diff --git a/gcc/ada/a-cohama.adb b/gcc/ada/a-cohama.adb index 6af16eec227..0616f4373ba 100644 --- a/gcc/ada/a-cohama.adb +++ b/gcc/ada/a-cohama.adb @@ -167,7 +167,7 @@ package body Ada.Containers.Hashed_Maps is Target.Reserve_Capacity (Source.Length); end if; - Insert_Items (Target.HT); + Insert_Items (Source.HT); end Assign; -------------- diff --git a/gcc/ada/a-coorma.adb b/gcc/ada/a-coorma.adb index 52025bb5c2c..e451ec628ff 100644 --- a/gcc/ada/a-coorma.adb +++ b/gcc/ada/a-coorma.adb @@ -274,7 +274,7 @@ package body Ada.Containers.Ordered_Maps is end if; Target.Clear; - Insert_Items (Target.Tree); + Insert_Items (Source.Tree); end Assign; ------------- diff --git a/gcc/ada/a-intnam-lynxos.ads b/gcc/ada/a-intnam-lynxos.ads deleted file mode 100644 index c4e714c8696..00000000000 --- a/gcc/ada/a-intnam-lynxos.ads +++ /dev/null @@ -1,166 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- A D A . I N T E R R U P T S . N A M E S -- --- -- --- S p e c -- --- -- --- Copyright (C) 1991-2011, Free Software Foundation, Inc. -- --- -- --- GNARL is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS version of this package - --- The following signals are reserved by the run time: - --- SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGTRAP, SIGABRT, SIGINT, --- SIGWAITING, SIGLWP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF, SIGSTOP, SIGKILL - --- The pragma Unreserve_All_Interrupts affects the following signal(s): - --- SIGINT: made available for Ada handler - -with System.OS_Interface; - -package Ada.Interrupts.Names is - - -- All identifiers in this unit are implementation defined - - pragma Implementation_Defined; - - -- Beware that the mapping of names to signals may be many-to-one. There - -- may be aliases. - - SIGHUP : constant Interrupt_ID := - System.OS_Interface.SIGHUP; -- hangup - - SIGINT : constant Interrupt_ID := - System.OS_Interface.SIGINT; -- interrupt (rubout) - - SIGQUIT : constant Interrupt_ID := - System.OS_Interface.SIGQUIT; -- quit (ASCD FS) - - SIGILL : constant Interrupt_ID := - System.OS_Interface.SIGILL; -- illegal instruction (not reset) - - SIGTRAP : constant Interrupt_ID := - System.OS_Interface.SIGTRAP; -- trace trap (not reset) - - SIGBRK : constant Interrupt_ID := - System.OS_Interface.SIGBRK; -- break - - SIGIOT : constant Interrupt_ID := - System.OS_Interface.SIGIOT; -- IOT instruction - - SIGABRT : constant Interrupt_ID := -- used by abort, - System.OS_Interface.SIGABRT; -- replace SIGIOT in the future - - SIGCORE : constant Interrupt_ID := - System.OS_Interface.SIGCORE; -- kill with core dump - - SIGEMT : constant Interrupt_ID := - System.OS_Interface.SIGEMT; -- EMT instruction - - SIGFPE : constant Interrupt_ID := - System.OS_Interface.SIGFPE; -- floating point exception - - SIGKILL : constant Interrupt_ID := - System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) - - SIGBUS : constant Interrupt_ID := - System.OS_Interface.SIGBUS; -- bus error - - SIGSEGV : constant Interrupt_ID := - System.OS_Interface.SIGSEGV; -- segmentation violation - - SIGSYS : constant Interrupt_ID := - System.OS_Interface.SIGSYS; -- bad argument to system call - - SIGPIPE : constant Interrupt_ID := -- write on a pipe with - System.OS_Interface.SIGPIPE; -- no one to read it - - SIGALRM : constant Interrupt_ID := - System.OS_Interface.SIGALRM; -- alarm clock - - SIGTERM : constant Interrupt_ID := - System.OS_Interface.SIGTERM; -- software termination signal from kill - - SIGURG : constant Interrupt_ID := - System.OS_Interface.SIGURG; -- urgent condition on IO channel - - SIGSTOP : constant Interrupt_ID := - System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) - - SIGTSTP : constant Interrupt_ID := - System.OS_Interface.SIGTSTP; -- user stop requested from tty - - SIGCONT : constant Interrupt_ID := - System.OS_Interface.SIGCONT; -- stopped process has been continued - - SIGCLD : constant Interrupt_ID := - System.OS_Interface.SIGCLD; -- child status change - - SIGCHLD : constant Interrupt_ID := - System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD - - SIGTTIN : constant Interrupt_ID := - System.OS_Interface.SIGTTIN; -- background tty read attempted - - SIGTTOU : constant Interrupt_ID := - System.OS_Interface.SIGTTOU; -- background tty write attempted - - SIGPOLL : constant Interrupt_ID := - System.OS_Interface.SIGPOLL; -- pollable event occurred - - SIGIO : constant Interrupt_ID := -- input/output possible, - System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) - - SIGXCPU : constant Interrupt_ID := - System.OS_Interface.SIGXCPU; -- CPU time limit exceeded - - SIGXFSZ : constant Interrupt_ID := - System.OS_Interface.SIGXFSZ; -- filesize limit exceeded - - SIGVTALRM : constant Interrupt_ID := - System.OS_Interface.SIGVTALRM; -- virtual timer expired - - SIGPROF : constant Interrupt_ID := - System.OS_Interface.SIGPROF; -- profiling timer expired - - SIGWINCH : constant Interrupt_ID := - System.OS_Interface.SIGWINCH; -- window size change - - SIGLOST : constant Interrupt_ID := - System.OS_Interface.SIGLOST; -- SUN 4.1 compatibility - - SIGUSR1 : constant Interrupt_ID := - System.OS_Interface.SIGUSR1; -- user defined signal 1 - - SIGUSR2 : constant Interrupt_ID := - System.OS_Interface.SIGUSR2; -- user defined signal 2 - - SIGPRIO : constant Interrupt_ID := - System.OS_Interface.SIGPRIO; - -- sent to a process with its priority - -- or group is changed -end Ada.Interrupts.Names; diff --git a/gcc/ada/a-ngelfu.ads b/gcc/ada/a-ngelfu.ads index 91e1cf7cf51..0d551015711 100644 --- a/gcc/ada/a-ngelfu.ads +++ b/gcc/ada/a-ngelfu.ads @@ -103,27 +103,27 @@ package Ada.Numerics.Generic_Elementary_Functions is (Y : Float_Type'Base; X : Float_Type'Base := 1.0) return Float_Type'Base with - Post => (if X > 0.0 and Y = 0.0 then Arctan'Result = 0.0); + Post => (if X > 0.0 and then Y = 0.0 then Arctan'Result = 0.0); function Arctan (Y : Float_Type'Base; X : Float_Type'Base := 1.0; Cycle : Float_Type'Base) return Float_Type'Base with - Post => (if X > 0.0 and Y = 0.0 then Arctan'Result = 0.0); + Post => (if X > 0.0 and then Y = 0.0 then Arctan'Result = 0.0); function Arccot (X : Float_Type'Base; Y : Float_Type'Base := 1.0) return Float_Type'Base with - Post => (if X > 0.0 and Y = 0.0 then Arccot'Result = 0.0); + Post => (if X > 0.0 and then Y = 0.0 then Arccot'Result = 0.0); function Arccot (X : Float_Type'Base; Y : Float_Type'Base := 1.0; Cycle : Float_Type'Base) return Float_Type'Base with - Post => (if X > 0.0 and Y = 0.0 then Arccot'Result = 0.0); + Post => (if X > 0.0 and then Y = 0.0 then Arccot'Result = 0.0); function Sinh (X : Float_Type'Base) return Float_Type'Base with Post => (if X = 0.0 then Sinh'Result = 0.0); diff --git a/gcc/ada/a-suenco.adb b/gcc/ada/a-suenco.adb index d824bb444af..ea83123878b 100644 --- a/gcc/ada/a-suenco.adb +++ b/gcc/ada/a-suenco.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2010-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2010-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -41,9 +41,12 @@ package body Ada.Strings.UTF_Encoding.Conversions is Output_BOM : Boolean := False) return UTF_String is begin - -- Nothing to do if identical schemes + -- Nothing to do if identical schemes, but for UTF_8 we need to + -- exclude overlong encodings, so need to do the full conversion. - if Input_Scheme = Output_Scheme then + if Input_Scheme = Output_Scheme + and then Input_Scheme /= UTF_8 + then return Item; -- For remaining cases, one or other of the operands is UTF-16BE/LE diff --git a/gcc/ada/a-suenst.adb b/gcc/ada/a-suenst.adb index a51c3a066e8..2ed5c2c0c6c 100644 --- a/gcc/ada/a-suenst.adb +++ b/gcc/ada/a-suenst.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2010-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2010-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -154,6 +154,15 @@ package body Ada.Strings.UTF_Encoding.Strings is end if; Len := Len + 1; + + -- The value may still be out of range of Standard.Character. We make + -- the check explicit because the library is typically compiled with + -- range checks disabled. + + if R > Character'Pos (Character'Last) then + Raise_Encoding_Error (Iptr - 1); + end if; + Result (Len) := Character'Val (R); end loop; diff --git a/gcc/ada/a-taside.adb b/gcc/ada/a-taside.adb index 4c7eb0a8cd5..520a7dfc1c9 100644 --- a/gcc/ada/a-taside.adb +++ b/gcc/ada/a-taside.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -83,6 +83,16 @@ package body Ada.Task_Identification is end if; end Abort_Task; + ---------------------------- + -- Activation_Is_Complete -- + ---------------------------- + + function Activation_Is_Complete (T : Task_Id) return Boolean is + use type System.Tasking.Task_Id; + begin + return Convert_Ids (T).Common.Activator = null; + end Activation_Is_Complete; + ----------------- -- Convert_Ids -- ----------------- @@ -106,6 +116,15 @@ package body Ada.Task_Identification is return Convert_Ids (System.Task_Primitives.Operations.Self); end Current_Task; + ---------------------- + -- Environment_Task -- + ---------------------- + + function Environment_Task return Task_Id is + begin + return Convert_Ids (System.Task_Primitives.Operations.Environment_Task); + end Environment_Task; + ----------- -- Image -- ----------- diff --git a/gcc/ada/a-taside.ads b/gcc/ada/a-taside.ads index 7466f964db7..e53ff04ac28 100644 --- a/gcc/ada/a-taside.ads +++ b/gcc/ada/a-taside.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -53,6 +53,9 @@ package Ada.Task_Identification is function Current_Task return Task_Id; pragma Inline (Current_Task); + function Environment_Task return Task_Id; + pragma Inline (Environment_Task); + procedure Abort_Task (T : Task_Id); pragma Inline (Abort_Task); -- Note: parameter is mode IN, not IN OUT, per AI-00101 @@ -63,6 +66,8 @@ package Ada.Task_Identification is function Is_Callable (T : Task_Id) return Boolean; pragma Inline (Is_Callable); + function Activation_Is_Complete (T : Task_Id) return Boolean; + private type Task_Id is new System.Tasking.Task_Id; diff --git a/gcc/ada/a-wichha.adb b/gcc/ada/a-wichha.adb index 6692cbf445f..8d02236111c 100644 --- a/gcc/ada/a-wichha.adb +++ b/gcc/ada/a-wichha.adb @@ -33,9 +33,13 @@ with Ada.Wide_Characters.Unicode; use Ada.Wide_Characters.Unicode; package body Ada.Wide_Characters.Handling is + --------------------------- + -- Character_Set_Version -- + --------------------------- + function Character_Set_Version return String is begin - return "Unicode 6.2"; + return "Unicode 4.0"; end Character_Set_Version; --------------------- diff --git a/gcc/ada/ali.adb b/gcc/ada/ali.adb index aff6740f405..87cb61d4f54 100644 --- a/gcc/ada/ali.adb +++ b/gcc/ada/ali.adb @@ -1290,7 +1290,7 @@ package body ALI is begin R := Restriction_Id'First; - while R < Not_A_Restriction_Id loop + while R /= Not_A_Restriction_Id loop if Restriction_Id'Image (R) = RN then goto R_Found; end if; diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb index 64a239ad23d..e3ff78d0bc0 100644 --- a/gcc/ada/aspects.adb +++ b/gcc/ada/aspects.adb @@ -516,6 +516,7 @@ package body Aspects is Aspect_Invariant => Aspect_Invariant, Aspect_Iterator_Element => Aspect_Iterator_Element, Aspect_Link_Name => Aspect_Link_Name, + Aspect_Linker_Section => Aspect_Linker_Section, Aspect_Lock_Free => Aspect_Lock_Free, Aspect_Machine_Radix => Aspect_Machine_Radix, Aspect_No_Return => Aspect_No_Return, diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads index c5d76320ee3..5b76f6a6562 100644 --- a/gcc/ada/aspects.ads +++ b/gcc/ada/aspects.ads @@ -103,6 +103,7 @@ package Aspects is Aspect_Invariant, -- GNAT Aspect_Iterator_Element, Aspect_Link_Name, + Aspect_Linker_Section, -- GNAT Aspect_Machine_Radix, Aspect_Object_Size, -- GNAT Aspect_Output, @@ -325,6 +326,7 @@ package Aspects is Aspect_Invariant => Expression, Aspect_Iterator_Element => Name, Aspect_Link_Name => Expression, + Aspect_Linker_Section => Expression, Aspect_Machine_Radix => Expression, Aspect_Object_Size => Expression, Aspect_Output => Name, @@ -420,6 +422,7 @@ package Aspects is Aspect_Invariant => Name_Invariant, Aspect_Iterator_Element => Name_Iterator_Element, Aspect_Link_Name => Name_Link_Name, + Aspect_Linker_Section => Name_Linker_Section, Aspect_Lock_Free => Name_Lock_Free, Aspect_Machine_Radix => Name_Machine_Radix, Aspect_No_Return => Name_No_Return, @@ -624,6 +627,7 @@ package Aspects is Aspect_Invariant => Always_Delay, Aspect_Iterator_Element => Always_Delay, Aspect_Link_Name => Always_Delay, + Aspect_Linker_Section => Always_Delay, Aspect_Lock_Free => Always_Delay, Aspect_No_Return => Always_Delay, Aspect_Output => Always_Delay, diff --git a/gcc/ada/back_end.adb b/gcc/ada/back_end.adb index 0b8920db0b3..a466686527e 100644 --- a/gcc/ada/back_end.adb +++ b/gcc/ada/back_end.adb @@ -51,7 +51,7 @@ package body Back_End is flag_stack_check : Int; pragma Import (C, flag_stack_check); - -- Indicates if stack checking is enabled, imported from decl.c + -- Indicates if stack checking is enabled, imported from misc.c save_argc : Nat; pragma Import (C, save_argc); @@ -258,7 +258,10 @@ package body Back_End is -- Start of processing for Scan_Compiler_Arguments begin - -- Acquire stack checking mode directly from GCC + -- Acquire stack checking mode directly from GCC. The reason we do this + -- is to make sure that the indication of stack checking being enabled + -- is the same in the front end and the back end. This status obtained + -- from gcc is affected by more than just the switch -fstack-check. Opt.Stack_Checking_Enabled := (flag_stack_check /= 0); diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index cdbe34e3a90..51acd293a91 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -5308,22 +5308,26 @@ package body Checks is elsif Nkind_In (Expr, N_Type_Conversion, N_Qualified_Expression) then return Expr_Known_Valid (Expression (Expr)); - -- The result of any operator is always considered valid, since we - -- assume the necessary checks are done by the operator. For operators - -- on floating-point operations, we must also check when the operation - -- is the right-hand side of an assignment, or is an actual in a call. - - elsif Nkind (Expr) in N_Op then - if Is_Floating_Point_Type (Typ) - and then Validity_Check_Floating_Point - and then (Nkind_In (Parent (Expr), N_Assignment_Statement, - N_Function_Call, - N_Parameter_Association)) - then - return False; - else - return True; - end if; + -- Case of expression is a non-floating-point operator. In this case we + -- can assume the result is valid the generated code for the operator + -- will include whatever checks are needed (e.g. range checks) to ensure + -- validity. This assumption does not hold for the floating-point case, + -- since floating-point operators can generate Infinite or NaN results + -- which are considered invalid. + + -- Historical note: in older versions, the exemption of floating-point + -- types from this assumption was done only in cases where the parent + -- was an assignment, function call or parameter association. Presumably + -- the idea was that in other contexts, the result would be checked + -- elsewhere, but this list of cases was missing tests (at least the + -- N_Object_Declaration case, as shown by a reported missing validity + -- check), and it is not clear why function calls but not procedure + -- calls were tested for. It really seems more accurate and much + -- safer to recognize that expressions which are the result of a + -- floating-point operator can never be assumed to be valid. + + elsif Nkind (Expr) in N_Op and then not Is_Floating_Point_Type (Typ) then + return True; -- The result of a membership test is always valid, since it is true or -- false, there are no other possibilities. diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb index 88643b8ec94..8d81ce8ff26 100644 --- a/gcc/ada/einfo.adb +++ b/gcc/ada/einfo.adb @@ -249,6 +249,7 @@ package body Einfo is -- SPARK_Pragma Node32 + -- Linker_Section_Pragma Node33 -- SPARK_Aux_Pragma Node33 -- Contract Node34 @@ -588,10 +589,10 @@ package body Einfo is ----------------------- function Has_Option - (State : Entity_Id; - Opt_Nam : Name_Id) return Boolean; - -- Determine whether abstract state State has a particular option denoted - -- by the name Opt_Nam. + (State_Id : Entity_Id; + Option_Nam : Name_Id) return Boolean; + -- Determine whether abstract state State_Id has particular option denoted + -- by the name Option_Nam. --------------- -- Float_Rep -- @@ -608,32 +609,55 @@ package body Einfo is ---------------- function Has_Option - (State : Entity_Id; - Opt_Nam : Name_Id) return Boolean + (State_Id : Entity_Id; + Option_Nam : Name_Id) return Boolean is - Par : constant Node_Id := Parent (State); - Opt : Node_Id; + Decl : constant Node_Id := Parent (State_Id); + Opt : Node_Id; + Opt_Nam : Node_Id; begin - pragma Assert (Ekind (State) = E_Abstract_State); + pragma Assert (Ekind (State_Id) = E_Abstract_State); - -- States with options appear as extension aggregates in the tree + -- The declaration of abstract states with options appear as an + -- extension aggregate. If this is not the case, the option is not + -- available. - if Nkind (Par) = N_Extension_Aggregate then - if Opt_Nam = Name_Part_Of then - return Present (Component_Associations (Par)); + if Nkind (Decl) /= N_Extension_Aggregate then + return False; + end if; - else - Opt := First (Expressions (Par)); - while Present (Opt) loop - if Chars (Opt) = Opt_Nam then - return True; - end if; + -- Simple options - Next (Opt); - end loop; + Opt := First (Expressions (Decl)); + while Present (Opt) loop + + -- Currently the only simple option allowed is External + + if Nkind (Opt) = N_Identifier + and then Chars (Opt) = Name_External + and then Chars (Opt) = Option_Nam + then + return True; end if; - end if; + + Next (Opt); + end loop; + + -- Complex options with various specifiers + + Opt := First (Component_Associations (Decl)); + while Present (Opt) loop + Opt_Nam := First (Choices (Opt)); + + if Nkind (Opt_Nam) = N_Identifier + and then Chars (Opt_Nam) = Option_Nam + then + return True; + end if; + + Next (Opt); + end loop; return False; end Has_Option; @@ -2387,6 +2411,13 @@ package body Einfo is return Node23 (Id); end Limited_View; + function Linker_Section_Pragma (Id : E) return N is + begin + pragma Assert + (Is_Type (Id) or else Is_Object (Id) or else Is_Subprogram (Id)); + return Node33 (Id); + end Linker_Section_Pragma; + function Lit_Indexes (Id : E) return E is begin pragma Assert (Is_Enumeration_Type (Id)); @@ -5095,6 +5126,14 @@ package body Einfo is Set_Node23 (Id, V); end Set_Limited_View; + procedure Set_Linker_Section_Pragma (Id : E; V : N) is + begin + pragma Assert (Is_Type (Id) + or else Ekind_In (Id, E_Constant, E_Variable) + or else Is_Subprogram (Id)); + Set_Node33 (Id, V); + end Set_Linker_Section_Pragma; + procedure Set_Lit_Indexes (Id : E; V : E) is begin pragma Assert (Is_Enumeration_Type (Id) and then Root_Type (Id) = Id); @@ -6870,6 +6909,10 @@ package body Einfo is -- Is_Ghost_Entity -- --------------------- + -- Note: coding below allows for ghost variables. They are not currently + -- implemented, so we will always get False for variables, but that is + -- expected to change in the future. + function Is_Ghost_Entity (Id : E) return B is begin if Present (Id) and then Ekind (Id) = E_Variable then @@ -6892,28 +6935,6 @@ package body Einfo is end if; end Is_Ghost_Subprogram; - ------------------------- - -- Is_Input_Only_State -- - ------------------------- - - function Is_Input_Only_State (Id : E) return B is - begin - return - Ekind (Id) = E_Abstract_State - and then Has_Option (Id, Name_Input_Only); - end Is_Input_Only_State; - - --------------------------- - -- Is_Non_Volatile_State -- - --------------------------- - - function Is_Non_Volatile_State (Id : E) return B is - begin - return - Ekind (Id) = E_Abstract_State - and then Has_Option (Id, Name_Non_Volatile); - end Is_Non_Volatile_State; - ------------------- -- Is_Null_State -- ------------------- @@ -6924,17 +6945,6 @@ package body Einfo is Ekind (Id) = E_Abstract_State and then Nkind (Parent (Id)) = N_Null; end Is_Null_State; - --------------------- - -- Is_Output_State -- - --------------------- - - function Is_Output_Only_State (Id : E) return B is - begin - return - Ekind (Id) = E_Abstract_State - and then Has_Option (Id, Name_Output_Only); - end Is_Output_Only_State; - ----------------------------------- -- Is_Package_Or_Generic_Package -- ----------------------------------- @@ -9453,6 +9463,12 @@ package body Einfo is E_Package_Body => Write_Str ("SPARK_Aux_Pragma"); + when E_Constant | + E_Variable | + Subprogram_Kind | + Type_Kind => + Write_Str ("Linker_Section_Pragma"); + when others => Write_Str ("Field33??"); end case; diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 75995743c04..352574311c0 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -1290,7 +1290,6 @@ package Einfo is -- -- Machine_Attribute pragma -- Link_Alias pragma --- Linker_Section pragma -- Linker_Constructor pragma -- Linker_Destructor pragma -- Weak_External pragma @@ -1555,7 +1554,6 @@ package Einfo is -- -- Machine_Attribute pragma -- Linker_Alias pragma --- Linker_Section pragma -- Linker_Constructor pragma -- Linker_Destructor pragma -- Weak_External pragma @@ -1564,7 +1562,7 @@ package Einfo is -- If this flag is set, then Gigi should scan the rep item chain to -- process any of these items that appear. At least one such item will -- be present. - +-- -- Has_Homonym (Flag56) -- Defined in all entities. Set if an entity has a homonym in the same -- scope. Used by Gigi to generate unique names for such entities. @@ -2345,11 +2343,15 @@ package Einfo is -- Is_Ghost_Entity (synthesized) -- Applies to all entities. Yields True for a subprogram or a whole --- object that has convention Ghost. +-- object that has convention Ghost. For now only functions can have +-- Ghost convention, so this will be false for other than functions, +-- but we expect that to change in the future. -- Is_Ghost_Subprogram (synthesized) -- Applies to all entities. Yields True for a subprogram that has a Ghost --- convention. +-- convention. Note: for now, only ghost functions are allowed, so this +-- will always be false for procedures, but that is expected to change in +-- the future. -- Is_Hidden (Flag57) -- Defined in all entities. Set for all entities declared in the @@ -2398,10 +2400,6 @@ package Einfo is -- inherited by their instances. It is also set on the body entities -- of inlined subprograms. See also Has_Pragma_Inline. --- Is_Input_Only_State (synthesized) --- Applies to all entities, true for abstract states that are subject to --- option Input_Only. - -- Is_Instantiated (Flag126) -- Defined in generic packages and generic subprograms. Set if the unit -- is instantiated from somewhere in the extended main source unit. This @@ -2591,10 +2589,6 @@ package Einfo is -- set right, at which point, these comments can be removed, and the -- tests for static subtypes greatly simplified. --- Is_Non_Volatile_State (synthesized) --- Applies to all entities, true for abstract states that are subject to --- option Non_Volatile. - -- Is_Null_Init_Proc (Flag178) -- Defined in procedure entities. Set for generated init proc procedures -- (used to initialize composite types), if the code for the procedure @@ -2635,10 +2629,6 @@ package Einfo is -- Applies to all entities, true for ordinary fixed point types and -- subtypes. --- Is_Output_Only_State (synthesized) --- Applies to all entities, true for abstract states that are subject to --- option Output_Only. - -- Is_Package_Or_Generic_Package (synthesized) -- Applies to all entities. True for packages and generic packages. -- False for all other entities. @@ -3055,7 +3045,14 @@ package Einfo is -- fide package with the limited-view list through the first_entity and -- first_private attributes. The elements of this list are the shadow -- entities created for the types and local packages that are declared --- in a package appearing in a limited_with clause (Ada 2005: AI-50217) +-- in a package appearing in a limited_with clause (Ada 2005: AI-50217). + +-- Linker_Section_Pragma (Node33) +-- Present in constant, variable, type and subprogram entities. Points +-- to a linker section pragma that applies to the entity, or is Empty if +-- no such pragma applies. Note that for constants and variables, this +-- field may be set as a result of a linker section pragma applied to the +-- type of the object. -- Lit_Indexes (Node15) -- Defined in enumeration types and subtypes. Non-empty only for the @@ -3906,9 +3903,9 @@ package Einfo is -- or a copy of the low bound of the index base type if not. -- Subprograms_For_Type (Node29) --- Defined in all type entities, and in subprogram entities. This is used --- to hold a list of subprogram entities for subprograms associated with --- the type, linked through the Subprogram_List field of the subprogram +-- Defined in all type and subprogram entities. This is used to hold +-- a list of subprogram entities for subprograms associated with the +-- type, linked through the Subprograms_For_Type field of the subprogram -- entity. Basically this is a way of multiplexing the single field to -- hold more than one entity (since we ran out of space in some type -- entities). This is currently used for Invariant_Procedure and also @@ -5067,6 +5064,7 @@ package Einfo is -- Related_Expression (Node24) -- Current_Use_Clause (Node27) -- Subprograms_For_Type (Node29) + -- Linker_Section_Pragma (Node33) -- Depends_On_Private (Flag14) -- Discard_Names (Flag88) @@ -5157,10 +5155,7 @@ package Einfo is -- Has_Non_Null_Refinement (synth) -- Has_Null_Refinement (synth) -- Is_External_State (synth) - -- Is_Input_Only_State (synth) -- Is_Null_State (synth) - -- Is_Output_Only_State (synth) - -- Is_Non_Volatile_State (synth) -- E_Access_Protected_Subprogram_Type -- Equivalent_Type (Node18) @@ -5301,6 +5296,7 @@ package Einfo is -- Interface_Name (Node21) (constants only) -- Related_Type (Node27) (constants only) -- Initialization_Statements (Node28) + -- Linker_Section_Pragma (Node33) -- Has_Alignment_Clause (Flag46) -- Has_Atomic_Components (Flag86) -- Has_Biased_Representation (Flag139) @@ -5480,6 +5476,7 @@ package Einfo is -- Corresponding_Equality (Node30) (implicit /= only) -- Thunk_Entity (Node31) (thunk case only) -- SPARK_Pragma (Node32) + -- Linker_Section_Pragma (Node33) -- Contract (Node34) -- Body_Needed_For_SAL (Flag40) -- Elaboration_Entity_Required (Flag174) @@ -5633,6 +5630,7 @@ package Einfo is -- Last_Entity (Node20) -- Overridden_Operation (Node26) -- Subprograms_For_Type (Node29) + -- Linker_Section_Pragma (Node33) -- Contract (Node34) -- Has_Invariants (Flag232) -- Has_Postconditions (Flag240) @@ -5767,6 +5765,7 @@ package Einfo is -- Static_Initialization (Node30) (init_proc only) -- Thunk_Entity (Node31) (thunk case only) -- SPARK_Pragma (Node32) + -- Linker_Section_Pragma (Node33) -- Contract (Node34) -- Body_Needed_For_SAL (Flag40) -- Delay_Cleanups (Flag114) @@ -6001,6 +6000,7 @@ package Einfo is -- Last_Assignment (Node26) -- Related_Type (Node27) -- Initialization_Statements (Node28) + -- Linker_Section_Pragma (Node33) -- Contract (Node34) -- Has_Alignment_Clause (Flag46) -- Has_Atomic_Components (Flag86) @@ -6566,6 +6566,7 @@ package Einfo is function Last_Assignment (Id : E) return N; function Last_Entity (Id : E) return E; function Limited_View (Id : E) return E; + function Linker_Section_Pragma (Id : E) return N; function Lit_Indexes (Id : E) return E; function Lit_Strings (Id : E) return E; function Low_Bound_Tested (Id : E) return B; @@ -6771,10 +6772,7 @@ package Einfo is function Is_Finalizer (Id : E) return B; function Is_Ghost_Entity (Id : E) return B; function Is_Ghost_Subprogram (Id : E) return B; - function Is_Input_Only_State (Id : E) return B; - function Is_Non_Volatile_State (Id : E) return B; function Is_Null_State (Id : E) return B; - function Is_Output_Only_State (Id : E) return B; function Is_Package_Or_Generic_Package (Id : E) return B; function Is_Prival (Id : E) return B; function Is_Protected_Component (Id : E) return B; @@ -7192,6 +7190,7 @@ package Einfo is procedure Set_Last_Assignment (Id : E; V : N); procedure Set_Last_Entity (Id : E; V : E); procedure Set_Limited_View (Id : E; V : E); + procedure Set_Linker_Section_Pragma (Id : E; V : N); procedure Set_Lit_Indexes (Id : E; V : E); procedure Set_Lit_Strings (Id : E; V : E); procedure Set_Low_Bound_Tested (Id : E; V : B := True); @@ -7960,6 +7959,7 @@ package Einfo is pragma Inline (Last_Assignment); pragma Inline (Last_Entity); pragma Inline (Limited_View); + pragma Inline (Linker_Section_Pragma); pragma Inline (Lit_Indexes); pragma Inline (Lit_Strings); pragma Inline (Low_Bound_Tested); @@ -8386,6 +8386,7 @@ package Einfo is pragma Inline (Set_Last_Assignment); pragma Inline (Set_Last_Entity); pragma Inline (Set_Limited_View); + pragma Inline (Set_Linker_Section_Pragma); pragma Inline (Set_Lit_Indexes); pragma Inline (Set_Lit_Strings); pragma Inline (Set_Low_Bound_Tested); diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 6c5104bac6a..6518e5bb950 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4141,7 +4141,7 @@ package body Exp_Aggr is Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Cond, - Reason => CE_Length_Check_Failed)); + Reason => CE_Range_Check_Failed)); end if; end Check_Bounds; diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 8be585c7725..db729a62291 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1882,27 +1882,6 @@ package body Exp_Ch11 is end; end Possible_Local_Raise; - ------------------------------ - -- Expand_N_Subprogram_Info -- - ------------------------------ - - procedure Expand_N_Subprogram_Info (N : Node_Id) is - Loc : constant Source_Ptr := Sloc (N); - - begin - -- For now, we replace an Expand_N_Subprogram_Info node with an - -- attribute reference that gives the address of the procedure. - -- This is because gigi does not yet recognize this node, and - -- for the initial targets, this is the right value anyway. - - Rewrite (N, - Make_Attribute_Reference (Loc, - Prefix => Identifier (N), - Attribute_Name => Name_Code_Address)); - - Analyze_And_Resolve (N, RTE (RE_Code_Loc)); - end Expand_N_Subprogram_Info; - ------------------------ -- Find_Local_Handler -- ------------------------ diff --git a/gcc/ada/exp_ch11.ads b/gcc/ada/exp_ch11.ads index 5f2f6b5f0a8..5fd123e025f 100644 --- a/gcc/ada/exp_ch11.ads +++ b/gcc/ada/exp_ch11.ads @@ -35,7 +35,6 @@ package Exp_Ch11 is procedure Expand_N_Raise_Program_Error (N : Node_Id); procedure Expand_N_Raise_Statement (N : Node_Id); procedure Expand_N_Raise_Storage_Error (N : Node_Id); - procedure Expand_N_Subprogram_Info (N : Node_Id); -- Data structures for gathering information to build exception tables -- See runtime routine Ada.Exceptions for full details on the format and diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 97368c09acc..6952665ce21 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -3043,6 +3043,16 @@ package body Exp_Ch4 is -- Local Declarations + Lib_Level_Target : constant Boolean := + Nkind (Parent (Cnode)) = N_Object_Declaration + and then + Is_Library_Level_Entity (Defining_Identifier (Parent (Cnode))); + + -- If the concatenation declares a library level entity, we call the + -- built-in concatenation routines to prevent code bloat, regardless + -- of optimization level. This is space-efficient, and prevent linking + -- problems when units are compiled with different optimizations. + Opnd_Typ : Entity_Id; Ent : Entity_Id; Len : Uint; @@ -3571,8 +3581,10 @@ package body Exp_Ch4 is if Atyp = Standard_String and then NN in 2 .. 9 - and then (Opt.Optimization_Level = 0 or else Debug_Flag_Dot_CC) - and then not Debug_Flag_Dot_C + and then (Lib_Level_Target + or else + ((Opt.Optimization_Level = 0 or else Debug_Flag_Dot_CC) + and then not Debug_Flag_Dot_C)) then declare RR : constant array (Nat range 2 .. 9) of RE_Id := @@ -7457,12 +7469,16 @@ package body Exp_Ch4 is -- a non-binary modulus in the multiplication case, since we get a wrong -- result if the shift causes an overflow before the modular reduction. + -- Note: we used to check that Exptyp was an unsigned type. But that is + -- an unnecessary check, since if Exp is negative, we have a run-time + -- error that is either caught (so we get the right result) or we have + -- suppressed the check, in which case the code is erroneous anyway. + if Nkind (Base) = N_Integer_Literal and then CRT_Safe_Compile_Time_Known_Value (Base) and then Expr_Value (Base) = Uint_2 and then Is_Integer_Type (Root_Type (Exptyp)) and then Esize (Root_Type (Exptyp)) <= Esize (Standard_Integer) - and then Is_Unsigned_Type (Exptyp) and then not Ovflo then -- First the multiply and divide cases diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index d43d02b379e..8e1e9547072 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -9477,7 +9477,7 @@ package body Exp_Ch6 is -- <postconditions from body> -- <postconditions from spec> -- <inherited postconditions> - -- <contract cases> + -- <contract case consequences> -- <invariant check of function result (if applicable)> -- <invariant and predicate checks of parameters> -- end _Postconditions; @@ -9486,6 +9486,7 @@ package body Exp_Ch6 is -- <preconditions from spec> -- <preconditions from body> -- <refined preconditions from body> + -- <contract case conditions> -- <source declarations> -- begin diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 591606e6d84..ddf6d7ea819 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -511,7 +511,6 @@ package body Exp_Ch7 is declare Spec : constant Node_Id := Parent (Corresponding_Spec (N)); Conc_Typ : Entity_Id; - Nam : Node_Id; Param : Node_Id; Param_Typ : Entity_Id; @@ -532,81 +531,12 @@ package body Exp_Ch7 is pragma Assert (Present (Param)); - -- If the associated protected object has entries, a protected - -- procedure has to service entry queues. In this case generate: + -- Historical note: In earlier versions of GNAT, there was code + -- at this point to generate stuff to service entry queues. It is + -- now abstracted in Build_Protected_Subprogram_Call_Cleanup. - -- Service_Entries (_object._object'Access); - - if Nkind (Specification (N)) = N_Procedure_Specification - and then Has_Entries (Conc_Typ) - then - case Corresponding_Runtime_Package (Conc_Typ) is - when System_Tasking_Protected_Objects_Entries => - Nam := New_Reference_To (RTE (RE_Service_Entries), Loc); - - when System_Tasking_Protected_Objects_Single_Entry => - Nam := New_Reference_To (RTE (RE_Service_Entry), Loc); - - when others => - raise Program_Error; - end case; - - Append_To (Stmts, - Make_Procedure_Call_Statement (Loc, - Name => Nam, - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => New_Reference_To ( - Defining_Identifier (Param), Loc), - Selector_Name => - Make_Identifier (Loc, Name_uObject)), - Attribute_Name => Name_Unchecked_Access)))); - - else - -- Generate: - -- Unlock (_object._object'Access); - - case Corresponding_Runtime_Package (Conc_Typ) is - when System_Tasking_Protected_Objects_Entries => - Nam := New_Reference_To (RTE (RE_Unlock_Entries), Loc); - - when System_Tasking_Protected_Objects_Single_Entry => - Nam := New_Reference_To (RTE (RE_Unlock_Entry), Loc); - - when System_Tasking_Protected_Objects => - Nam := New_Reference_To (RTE (RE_Unlock), Loc); - - when others => - raise Program_Error; - end case; - - Append_To (Stmts, - Make_Procedure_Call_Statement (Loc, - Name => Nam, - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => - New_Reference_To - (Defining_Identifier (Param), Loc), - Selector_Name => - Make_Identifier (Loc, Name_uObject)), - Attribute_Name => Name_Unchecked_Access)))); - end if; - - -- Generate: - -- Abort_Undefer; - - if Abort_Allowed then - Append_To (Stmts, - Make_Procedure_Call_Statement (Loc, - Name => - New_Reference_To (RTE (RE_Abort_Undefer), Loc), - Parameter_Associations => Empty_List)); - end if; + Build_Protected_Subprogram_Call_Cleanup + (Specification (N), Conc_Typ, Loc, Stmts); end; -- Add a call to Expunge_Unactivated_Tasks for dynamically allocated @@ -3612,7 +3542,7 @@ package body Exp_Ch7 is -- This procedure is called each time a transient block has to be inserted -- that is to say for each call to a function with unconstrained or tagged -- result. It creates a new scope on the stack scope in order to enclose - -- all transient variables generated + -- all transient variables generated. procedure Establish_Transient_Scope (N : Node_Id; Sec_Stack : Boolean) is Loc : constant Source_Ptr := Sloc (N); @@ -5157,14 +5087,14 @@ package body Exp_Ch7 is Exceptions_OK : constant Boolean := not Restriction_Active (No_Exception_Propagation); - procedure Build_Indices; - -- Generate the indices used in the dimension loops + procedure Build_Indexes; + -- Generate the indexes used in the dimension loops ------------------- - -- Build_Indices -- + -- Build_Indexes -- ------------------- - procedure Build_Indices is + procedure Build_Indexes is begin -- Generate the following identifiers: -- Jnn - for initialization @@ -5173,14 +5103,14 @@ package body Exp_Ch7 is Append_To (Index_List, Make_Defining_Identifier (Loc, New_External_Name ('J', Dim))); end loop; - end Build_Indices; + end Build_Indexes; -- Start of processing for Build_Adjust_Or_Finalize_Statements begin Finalizer_Decls := New_List; - Build_Indices; + Build_Indexes; Build_Object_Declarations (Finalizer_Data, Finalizer_Decls, Loc); Comp_Ref := @@ -5335,8 +5265,8 @@ package body Exp_Ch7 is function Build_Finalization_Call return Node_Id; -- Generate a deep finalization call for an array element - procedure Build_Indices; - -- Generate the initialization and finalization indices used in the + procedure Build_Indexes; + -- Generate the initialization and finalization indexes used in the -- dimension loops. function Build_Initialization_Call return Node_Id; @@ -5411,10 +5341,10 @@ package body Exp_Ch7 is end Build_Finalization_Call; ------------------- - -- Build_Indices -- + -- Build_Indexes -- ------------------- - procedure Build_Indices is + procedure Build_Indexes is begin -- Generate the following identifiers: -- Jnn - for initialization @@ -5427,7 +5357,7 @@ package body Exp_Ch7 is Append_To (Final_List, Make_Defining_Identifier (Loc, New_External_Name ('F', Dim))); end loop; - end Build_Indices; + end Build_Indexes; ------------------------------- -- Build_Initialization_Call -- @@ -5454,7 +5384,7 @@ package body Exp_Ch7 is Counter_Id := Make_Temporary (Loc, 'C'); Finalizer_Decls := New_List; - Build_Indices; + Build_Indexes; Build_Object_Declarations (Finalizer_Data, Finalizer_Decls, Loc); -- Generate the block which houses the finalization call, the index diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index a03778ef30d..b85dd015f45 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -4150,7 +4150,6 @@ package body Exp_Ch9 is Sub_Body : Node_Id; Lock_Name : Node_Id; Lock_Stmt : Node_Id; - Service_Name : Node_Id; R : Node_Id; Return_Stmt : Node_Id := Empty; -- init to avoid gcc 3 warning Pre_Stmts : List_Id := No_List; -- init to avoid gcc 3 warning @@ -4235,15 +4234,12 @@ package body Exp_Ch9 is case Corresponding_Runtime_Package (Pid) is when System_Tasking_Protected_Objects_Entries => Lock_Name := New_Reference_To (RTE (RE_Lock_Entries), Loc); - Service_Name := New_Reference_To (RTE (RE_Service_Entries), Loc); when System_Tasking_Protected_Objects_Single_Entry => Lock_Name := New_Reference_To (RTE (RE_Lock_Entry), Loc); - Service_Name := New_Reference_To (RTE (RE_Service_Entry), Loc); when System_Tasking_Protected_Objects => Lock_Name := New_Reference_To (RTE (Lock_Kind), Loc); - Service_Name := New_Reference_To (RTE (RE_Unlock), Loc); when others => raise Program_Error; @@ -4282,20 +4278,11 @@ package body Exp_Ch9 is Append (Unprot_Call, Stmts); end if; - Append ( - Make_Procedure_Call_Statement (Loc, - Name => Service_Name, - Parameter_Associations => - New_List (New_Copy_Tree (Object_Parm))), - Stmts); + -- Historical note: Previously, call the the cleanup was inserted + -- here. This is now done by Build_Protected_Subprogram_Call_Cleanup, + -- which is also shared by the 'not Exc_Safe' path. - if Abort_Allowed then - Append ( - Make_Procedure_Call_Statement (Loc, - Name => New_Reference_To (RTE (RE_Abort_Undefer), Loc), - Parameter_Associations => Empty_List), - Stmts); - end if; + Build_Protected_Subprogram_Call_Cleanup (Op_Spec, Pid, Loc, Stmts); if Nkind (Op_Spec) = N_Function_Specification then Append (Return_Stmt, Stmts); @@ -4315,6 +4302,10 @@ package body Exp_Ch9 is Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts)); + -- Mark this subprogram as a protected subprogram body so that the + -- cleanup will be inserted. This is done only in the 'not Exc_Safe' + -- path as otherwise the cleanup has already been inserted. + if not Exc_Safe then Set_Is_Protected_Subprogram_Body (Sub_Body); end if; @@ -4388,6 +4379,91 @@ package body Exp_Ch9 is end if; end Build_Protected_Subprogram_Call; + --------------------------------------------- + -- Build_Protected_Subprogram_Call_Cleanup -- + --------------------------------------------- + + procedure Build_Protected_Subprogram_Call_Cleanup + (Op_Spec : Node_Id; + Conc_Typ : Node_Id; + Loc : Source_Ptr; + Stmts : List_Id) + is + Nam : Node_Id; + + begin + -- If the associated protected object has entries, a protected + -- procedure has to service entry queues. In this case generate: + + -- Service_Entries (_object._object'Access); + + if Nkind (Op_Spec) = N_Procedure_Specification + and then Has_Entries (Conc_Typ) + then + case Corresponding_Runtime_Package (Conc_Typ) is + when System_Tasking_Protected_Objects_Entries => + Nam := New_Reference_To (RTE (RE_Service_Entries), Loc); + + when System_Tasking_Protected_Objects_Single_Entry => + Nam := New_Reference_To (RTE (RE_Service_Entry), Loc); + + when others => + raise Program_Error; + end case; + + Append_To (Stmts, + Make_Procedure_Call_Statement (Loc, + Name => Nam, + Parameter_Associations => New_List ( + Make_Attribute_Reference (Loc, + Prefix => + Make_Selected_Component (Loc, + Prefix => Make_Identifier (Loc, Name_uObject), + Selector_Name => Make_Identifier (Loc, Name_uObject)), + Attribute_Name => Name_Unchecked_Access)))); + + else + -- Generate: + -- Unlock (_object._object'Access); + + case Corresponding_Runtime_Package (Conc_Typ) is + when System_Tasking_Protected_Objects_Entries => + Nam := New_Reference_To (RTE (RE_Unlock_Entries), Loc); + + when System_Tasking_Protected_Objects_Single_Entry => + Nam := New_Reference_To (RTE (RE_Unlock_Entry), Loc); + + when System_Tasking_Protected_Objects => + Nam := New_Reference_To (RTE (RE_Unlock), Loc); + + when others => + raise Program_Error; + end case; + + Append_To (Stmts, + Make_Procedure_Call_Statement (Loc, + Name => Nam, + Parameter_Associations => New_List ( + Make_Attribute_Reference (Loc, + Prefix => + Make_Selected_Component (Loc, + Prefix => Make_Identifier (Loc, Name_uObject), + Selector_Name => Make_Identifier (Loc, Name_uObject)), + Attribute_Name => Name_Unchecked_Access)))); + end if; + + -- Generate: + -- Abort_Undefer; + + if Abort_Allowed then + Append_To (Stmts, + Make_Procedure_Call_Statement (Loc, + Name => + New_Reference_To (RTE (RE_Abort_Undefer), Loc), + Parameter_Associations => Empty_List)); + end if; + end Build_Protected_Subprogram_Call_Cleanup; + ------------------------- -- Build_Selected_Name -- ------------------------- @@ -13451,6 +13527,7 @@ package body Exp_Ch9 is L : constant List_Id := New_List; Has_Entry : constant Boolean := Has_Entries (Ptyp); Prio_Type : Entity_Id; + Prio_Var : Entity_Id := Empty; Restricted : constant Boolean := Restricted_Profile; begin @@ -13509,7 +13586,6 @@ package body Exp_Ch9 is (Ptyp, Name_Priority, Check_Parents => False); Prio : Node_Id; - Temp : Entity_Id; begin -- Pragma Priority @@ -13539,37 +13615,21 @@ package body Exp_Ch9 is Prio := Expression (Prio_Clause); end if; - -- If priority is a static expression, then we can duplicate it - -- with no problem and simply append it to the argument list. - -- However, it has only be pre-analyzed, so we need to check - -- now that it is in the bounds of the priority type. + -- Always create a locale variable to capture the priority. + -- The priority is also passed to Install_Restriced_Handlers. + -- Note that it is really necessary to create this variable + -- explicitly. It might be thought that removing side effects + -- would the appropriate approach, but that could generate + -- declarations improperly placed in the enclosing scope. - if Is_Static_Expression (Prio) then - Set_Analyzed (Prio, False); - Append_To (Args, - Make_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Prio_Type, Loc), - Expression => Duplicate_Subexpr (Prio))); - - -- Otherwise, the priority may be a per-object expression, if - -- it depends on a discriminant of the type. In this case, - -- create local variable to capture the expression. Note that - -- it is really necessary to create this variable explicitly. - -- It might be thought that removing side effects would the - -- appropriate approach, but that could generate declarations - -- improperly placed in the enclosing scope. + Prio_Var := Make_Temporary (Loc, 'R', Prio); + Append_To (L, + Make_Object_Declaration (Loc, + Defining_Identifier => Prio_Var, + Object_Definition => New_Occurrence_Of (Prio_Type, Loc), + Expression => Relocate_Node (Prio))); - else - Temp := Make_Temporary (Loc, 'R', Prio); - Append_To (L, - Make_Object_Declaration (Loc, - Defining_Identifier => Temp, - Object_Definition => - New_Occurrence_Of (Prio_Type, Loc), - Expression => Relocate_Node (Prio))); - - Append_To (Args, New_Occurrence_Of (Temp, Loc)); - end if; + Append_To (Args, New_Occurrence_Of (Prio_Var, Loc)); end; -- When no priority is specified but an xx_Handler pragma is, we @@ -13714,7 +13774,7 @@ package body Exp_Ch9 is -- or, in the case of Ravenscar: -- Install_Restricted_Handlers - -- ((Expr1, Proc1'access), ...., (ExprN, ProcN'access)); + -- (Prio, (Expr1, Proc1'access), ...., (ExprN, ProcN'access)); declare Args : constant List_Id := New_List; @@ -13722,6 +13782,24 @@ package body Exp_Ch9 is Ritem : Node_Id := First_Rep_Item (Ptyp); begin + -- Build the Priority parameter (only for ravenscar) + + if Restricted then + + -- Priority comes from a pragma + + if Present (Prio_Var) then + Append_To (Args, New_Occurrence_Of (Prio_Var, Loc)); + + -- Priority is the default one + + else + Append_To (Args, + New_Reference_To + (RTE (RE_Default_Interrupt_Priority), Loc)); + end if; + end if; + -- Build the Attach_Handler table argument while Present (Ritem) loop diff --git a/gcc/ada/exp_ch9.ads b/gcc/ada/exp_ch9.ads index 65b0c195302..db1e6904c72 100644 --- a/gcc/ada/exp_ch9.ads +++ b/gcc/ada/exp_ch9.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -112,6 +112,16 @@ package Exp_Ch9 is -- External is False if the call is to another protected subprogram within -- the same object. + procedure Build_Protected_Subprogram_Call_Cleanup + (Op_Spec : Node_Id; + Conc_Typ : Node_Id; + Loc : Source_Ptr; + Stmts : List_Id); + -- Append to Stmts the cleanups after a call to a protected subprogram + -- whose specification is Op_Spec. Conc_Typ is the concurrent type and Loc + -- the sloc for appended statements. The cleanup will either unlock the + -- protected object or serve pending entries. + procedure Build_Task_Activation_Call (N : Node_Id); -- This procedure is called for constructs that can be task activators, -- i.e. task bodies, subprogram bodies, package bodies and blocks. If the diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index b4c56accb0f..1f84738985f 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -777,11 +777,12 @@ package body Exp_Disp is Param := First_Actual (Call_Node); while Present (Param) loop - -- Cases in which we may have generated runtime checks - if Param = Ctrl_Arg - or else Subp = Eq_Prim_Op - then + -- Cases in which we may have generated run-time checks. Note that + -- we strip any qualification from Param before comparing with the + -- already-stripped controlling argument. + + if Unqualify (Param) = Ctrl_Arg or else Subp = Eq_Prim_Op then Append_To (New_Params, Duplicate_Subexpr_Move_Checks (Param)); diff --git a/gcc/ada/exp_smem.adb b/gcc/ada/exp_smem.adb index 1f23ac1f946..8ee67027421 100644 --- a/gcc/ada/exp_smem.adb +++ b/gcc/ada/exp_smem.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -25,7 +25,9 @@ with Atree; use Atree; with Einfo; use Einfo; +with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; +with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Nmake; use Nmake; with Namet; use Namet; @@ -49,36 +51,40 @@ package body Exp_Smem is -- Local Subprograms -- ----------------------- - procedure Add_Read_Before (N : Node_Id); - -- Insert a Shared_Var_ROpen call for variable before node N + procedure Add_Read (N : Node_Id; Call : Node_Id := Empty); + -- Insert a Shared_Var_ROpen call for variable before node N, unless + -- Call is a call to an init-proc, in which case the call is inserted + -- after Call. procedure Add_Write_After (N : Node_Id); - -- Insert a Shared_Var_WOpen call for variable after the node - -- Insert_Node, as recorded by On_Lhs_Of_Assignment (where it points - -- to the assignment statement) or Is_Out_Actual (where it points to - -- the procedure call statement). + -- Insert a Shared_Var_WOpen call for variable after the node Insert_Node, + -- as recorded by On_Lhs_Of_Assignment (where it points to the assignment + -- statement) or Is_Out_Actual (where it points to the subprogram call). + -- When Insert_Node is a function call, establish a transient scope around + -- the expression, and insert the write as an after-action of the transient + -- scope. procedure Build_Full_Name (E : Entity_Id; N : out String_Id); -- Build the fully qualified string name of a shared variable function On_Lhs_Of_Assignment (N : Node_Id) return Boolean; - -- Determines if N is on the left hand of the assignment. This means - -- that either it is a simple variable, or it is a record or array - -- variable with a corresponding selected or indexed component on - -- the left side of an assignment. If the result is True, then - -- Insert_Node is set to point to the assignment + -- Determines if N is on the left hand of the assignment. This means that + -- either it is a simple variable, or it is a record or array variable with + -- a corresponding selected or indexed component on the left side of an + -- assignment. If the result is True, then Insert_Node is set to point + -- to the assignment function Is_Out_Actual (N : Node_Id) return Boolean; - -- In a similar manner, this function determines if N appears as an - -- OUT or IN OUT parameter to a procedure call. If the result is - -- True, then Insert_Node is set to point to the call. + -- In a similar manner, this function determines if N appears as an OUT + -- or IN OUT parameter to a procedure call. If the result is True, then + -- Insert_Node is set to point to the call. function Build_Shared_Var_Proc_Call (Loc : Source_Ptr; E : Node_Id; N : Name_Id) return Node_Id; - -- Build a call to support procedure N for shared object E (provided by - -- the instance of System.Shared_Storage.Shared_Var_Procs associated to E). + -- Build a call to support procedure N for shared object E (provided by the + -- instance of System.Shared_Storage.Shared_Var_Procs associated to E). -------------------------------- -- Build_Shared_Var_Proc_Call -- @@ -87,7 +93,8 @@ package body Exp_Smem is function Build_Shared_Var_Proc_Call (Loc : Source_Ptr; E : Entity_Id; - N : Name_Id) return Node_Id is + N : Name_Id) return Node_Id + is begin return Make_Procedure_Call_Statement (Loc, Name => Make_Selected_Component (Loc, @@ -96,18 +103,26 @@ package body Exp_Smem is Selector_Name => Make_Identifier (Loc, N))); end Build_Shared_Var_Proc_Call; - --------------------- - -- Add_Read_Before -- - --------------------- + -------------- + -- Add_Read -- + -------------- - procedure Add_Read_Before (N : Node_Id) is + procedure Add_Read (N : Node_Id; Call : Node_Id := Empty) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Node_Id := Entity (N); + SVC : Node_Id; + begin if Present (Shared_Var_Procs_Instance (Ent)) then - Insert_Action (N, Build_Shared_Var_Proc_Call (Loc, Ent, Name_Read)); + SVC := Build_Shared_Var_Proc_Call (Loc, Ent, Name_Read); + + if Present (Call) and then Is_Init_Proc (Name (Call)) then + Insert_After_And_Analyze (Call, SVC); + else + Insert_Action (N, SVC); + end if; end if; - end Add_Read_Before; + end Add_Read; ------------------------------- -- Add_Shared_Var_Lock_Procs -- @@ -121,10 +136,10 @@ package body Exp_Smem is begin -- We have to add Shared_Var_Lock and Shared_Var_Unlock calls around - -- the procedure or function call node. First we locate the right - -- place to do the insertion, which is the call itself in the - -- procedure call case, or else the nearest non subexpression - -- node that contains the function call. + -- the procedure or function call node. First we locate the right place + -- to do the insertion, which is the call itself in the procedure call + -- case, or else the nearest non subexpression node that contains the + -- function call. Inode := N; while Nkind (Inode) /= N_Procedure_Call_Statement @@ -135,11 +150,11 @@ package body Exp_Smem is -- Now insert the Lock and Unlock calls and the read/write calls - -- Two concerns here. First we are not dealing with the exception - -- case, really we need some kind of cleanup routine to do the - -- Unlock. Second, these lock calls should be inside the protected - -- object processing, not outside, otherwise they can be done at - -- the wrong priority, resulting in dead lock situations ??? + -- Two concerns here. First we are not dealing with the exception case, + -- really we need some kind of cleanup routine to do the Unlock. Second, + -- these lock calls should be inside the protected object processing, + -- not outside, otherwise they can be done at the wrong priority, + -- resulting in dead lock situations ??? Build_Full_Name (Obj, Vnm); @@ -171,7 +186,6 @@ package body Exp_Smem is Insert_After_And_Analyze (Inode, Build_Shared_Var_Proc_Call (Loc, Obj, Name_Write)); end if; - end Add_Shared_Var_Lock_Procs; --------------------- @@ -180,12 +194,18 @@ package body Exp_Smem is procedure Add_Write_After (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); - Ent : constant Node_Id := Entity (N); - + Ent : constant Entity_Id := Entity (N); + Par : constant Node_Id := Insert_Node; begin if Present (Shared_Var_Procs_Instance (Ent)) then - Insert_After_And_Analyze (Insert_Node, - Build_Shared_Var_Proc_Call (Loc, Ent, Name_Write)); + if Nkind (Insert_Node) = N_Function_Call then + Establish_Transient_Scope (Insert_Node, Sec_Stack => False); + Store_After_Actions_In_Scope (New_List ( + Build_Shared_Var_Proc_Call (Loc, Ent, Name_Write))); + else + Insert_After_And_Analyze (Par, + Build_Shared_Var_Proc_Call (Loc, Ent, Name_Write)); + end if; end if; end Add_Write_After; @@ -235,23 +255,41 @@ package body Exp_Smem is if Is_Limited_Type (Typ) or else Is_Concurrent_Type (Typ) then return; - -- If we are on the left hand side of an assignment, then we add - -- the write call after the assignment. + -- If we are on the left hand side of an assignment, then we add the + -- write call after the assignment. elsif On_Lhs_Of_Assignment (N) then Add_Write_After (N); - -- If we are a parameter for an out or in out formal, then put - -- the read before and the write after. + -- If we are a parameter for an out or in out formal, then in general + -- we do: + + -- read + -- call + -- write + + -- but in the special case of a call to an init proc, we need to first + -- call the init proc (to set discriminants), then read (to possibly + -- set other components), then write (to record the updated components + -- to the backing store): + + -- init-proc-call + -- read + -- write elsif Is_Out_Actual (N) then - Add_Read_Before (N); + + -- Note: For an init proc call, Add_Read inserts just after the + -- call node, and we want to have first the read, then the write, + -- so we need to first Add_Write_After, then Add_Read. + Add_Write_After (N); + Add_Read (N, Call => Insert_Node); -- All other cases are simple reads else - Add_Read_Before (N); + Add_Read (N); end if; end Expand_Shared_Passive_Variable; @@ -297,8 +335,7 @@ package body Exp_Smem is SVP_Instance : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Ent), 'G')); - -- Instance of System.Shared_Storage.Shared_Var_Procs associated - -- with Ent. + -- Instance of Shared_Storage.Shared_Var_Procs associated with Ent Instantiation : Node_Id; -- Package instantiation node for SVP_Instance @@ -308,9 +345,9 @@ package body Exp_Smem is begin Build_Full_Name (Ent, Vnm); - -- We turn off Shared_Passive during construction and analysis of - -- the generic package instantiation, to avoid improper attempts to - -- process the variable references within these instantiation. + -- We turn off Shared_Passive during construction and analysis of the + -- generic package instantiation, to avoid improper attempts to process + -- the variable references within these instantiation. Set_Is_Shared_Passive (Ent, False); @@ -376,9 +413,7 @@ package body Exp_Smem is return False; end if; - elsif (Nkind (P) = N_Indexed_Component - or else - Nkind (P) = N_Selected_Component) + elsif Nkind_In (P, N_Indexed_Component, N_Selected_Component) and then N = Prefix (P) then return On_Lhs_Of_Assignment (P); diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 1c5c63c373a..52626277cb4 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -106,6 +106,10 @@ package body Exp_Util is -- record with task components, or for a dynamically created task that is -- assigned to a selected component. + procedure Evaluate_Slice_Bounds (Slice : Node_Id); + -- Force evaluation of bounds of a slice, which may be given by a range + -- or by a subtype indication with or without a constraint. + function Make_CW_Equivalent_Type (T : Entity_Id; E : Node_Id) return Entity_Id; @@ -1835,28 +1839,7 @@ package body Exp_Util is elsif K = N_Slice then Evaluate_Name (Prefix (Nam)); - - declare - DR : constant Node_Id := Discrete_Range (Nam); - Constr : Node_Id; - Rexpr : Node_Id; - - begin - if Nkind (DR) = N_Range then - Force_Evaluation (Low_Bound (DR)); - Force_Evaluation (High_Bound (DR)); - - elsif Nkind (DR) = N_Subtype_Indication then - Constr := Constraint (DR); - - if Nkind (Constr) = N_Range_Constraint then - Rexpr := Range_Expression (Constr); - - Force_Evaluation (Low_Bound (Rexpr)); - Force_Evaluation (High_Bound (Rexpr)); - end if; - end if; - end; + Evaluate_Slice_Bounds (Nam); -- For a type conversion, the expression of the conversion must be the -- name of an object, and we simply need to evaluate this name. @@ -1878,6 +1861,32 @@ package body Exp_Util is end if; end Evaluate_Name; + --------------------------- + -- Evaluate_Slice_Bounds -- + --------------------------- + + procedure Evaluate_Slice_Bounds (Slice : Node_Id) is + DR : constant Node_Id := Discrete_Range (Slice); + Constr : Node_Id; + Rexpr : Node_Id; + + begin + if Nkind (DR) = N_Range then + Force_Evaluation (Low_Bound (DR)); + Force_Evaluation (High_Bound (DR)); + + elsif Nkind (DR) = N_Subtype_Indication then + Constr := Constraint (DR); + + if Nkind (Constr) = N_Range_Constraint then + Rexpr := Range_Expression (Constr); + + Force_Evaluation (Low_Bound (Rexpr)); + Force_Evaluation (High_Bound (Rexpr)); + end if; + end if; + end Evaluate_Slice_Bounds; + --------------------- -- Evolve_And_Then -- --------------------- @@ -2067,8 +2076,7 @@ package body Exp_Util is -- we better make sure that if a variable was used as a bound of -- of the original slice, its value is frozen. - Force_Evaluation (Low_Bound (Scalar_Range (Slice_Type))); - Force_Evaluation (High_Bound (Scalar_Range (Slice_Type))); + Evaluate_Slice_Bounds (Exp); end; elsif Ekind (Exp_Typ) = E_String_Literal_Subtype then @@ -3829,7 +3837,6 @@ package body Exp_Util is N_Single_Protected_Declaration | N_Slice | N_String_Literal | - N_Subprogram_Info | N_Subtype_Indication | N_Subunit | N_Task_Definition | @@ -5567,11 +5574,12 @@ package body Exp_Util is Typ := Etype (Expr); -- Subtypes may be subject to invariants coming from their respective - -- base types. + -- base types. The subtype may be fully or partially private. if Ekind_In (Typ, E_Array_Subtype, E_Private_Subtype, - E_Record_Subtype) + E_Record_Subtype, + E_Record_Subtype_With_Private) then Typ := Base_Type (Typ); end if; diff --git a/gcc/ada/expander.adb b/gcc/ada/expander.adb index 760c26457dd..869c16c899b 100644 --- a/gcc/ada/expander.adb +++ b/gcc/ada/expander.adb @@ -433,9 +433,6 @@ package body Expander is when N_Subprogram_Declaration => Expand_N_Subprogram_Declaration (N); - when N_Subprogram_Info => - Expand_N_Subprogram_Info (N); - when N_Task_Body => Expand_N_Task_Body (N); diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 310511f5275..4dd7347eebc 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2283,7 +2283,6 @@ package body Freeze is -- Start of processing for Alias_Atomic_Check begin - -- If object size of component type isn't known, we cannot -- be sure so we defer to the back end. @@ -4046,6 +4045,19 @@ package body Freeze is Set_Is_Public (E); end if; + -- For source objects that are not Imported and are library + -- level, if no linker section pragma was given inherit the + -- appropriate linker section from the corresponding type. + + if Comes_From_Source (E) + and then not Is_Imported (E) + and then Is_Library_Level_Entity (E) + and then No (Linker_Section_Pragma (E)) + then + Set_Linker_Section_Pragma + (E, Linker_Section_Pragma (Etype (E))); + end if; + -- For convention C objects of an enumeration type, warn if -- the size is not integer size and no explicit size given. -- Skip warning for Boolean, and Character, assume programmer @@ -5263,10 +5275,16 @@ package body Freeze is and then not Has_Size_Clause (Typ) and then not Has_Size_Clause (Base_Type (Typ)) and then Esize (Typ) < Standard_Integer_Size + + -- Don't do this if Short_Enums on target + + and then not Target_Short_Enums then Init_Esize (Typ, Standard_Integer_Size); Set_Alignment (Typ, Alignment (Standard_Integer)); + -- Normal Ada case or size clause present or not Long_C_Enums on target + else -- If the enumeration type interfaces to C, and it has a size clause -- that specifies less than int size, it warrants a warning. The @@ -5280,6 +5298,10 @@ package body Freeze is and then Esize (Typ) /= Esize (Standard_Integer) and then not Is_Boolean_Type (Typ) and then not Is_Character_Type (Typ) + + -- Don't do this if Short_Enums on target + + and then not Target_Short_Enums then Error_Msg_N ("C enum types have the size of a C int??", Size_Clause (Typ)); diff --git a/gcc/ada/g-dynhta.ads b/gcc/ada/g-dynhta.ads index 4c238afa239..e731ed359b3 100644 --- a/gcc/ada/g-dynhta.ads +++ b/gcc/ada/g-dynhta.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1995-2010, AdaCore -- +-- Copyright (C) 1995-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -54,12 +54,11 @@ package GNAT.Dynamic_HTables is ------------------- -- A low-level Hash-Table abstraction, not as easy to instantiate as - -- Simple_HTable but designed to allow complete control over the - -- allocation of necessary data structures. Particularly useful when - -- dynamic allocation is not desired. The model is that each Element - -- contains its own Key that can be retrieved by Get_Key. Furthermore, - -- Element provides a link that can be used by the HTable for linking - -- elements with same hash codes: + -- Simple_HTable. This mirrors the interface of GNAT.HTable.Static_HTable, + -- but does require dynamic allocation (since we allow multiple instances + -- of the table). The model is that each Element contains its own Key that + -- can be retrieved by Get_Key. Furthermore, Element provides a link that + -- can be used by the HTable for linking elements with same hash codes: -- Element @@ -133,11 +132,9 @@ package GNAT.Dynamic_HTables is -- elements of the Htable will be traversed. private - type Instance_Data; type Instance is access all Instance_Data; Nil : constant Instance := null; - end Static_HTable; ------------------- diff --git a/gcc/ada/g-rannum.adb b/gcc/ada/g-rannum.adb index e35c86cb281..a868f08123e 100644 --- a/gcc/ada/g-rannum.adb +++ b/gcc/ada/g-rannum.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -30,8 +30,9 @@ ------------------------------------------------------------------------------ with Ada.Numerics.Long_Elementary_Functions; -use Ada.Numerics.Long_Elementary_Functions; +use Ada.Numerics.Long_Elementary_Functions; with Ada.Unchecked_Conversion; + with System.Random_Numbers; use System.Random_Numbers; package body GNAT.Random_Numbers is @@ -87,6 +88,40 @@ package body GNAT.Random_Numbers is return F (Gen.Rep, Min, Max); end Random_Discrete; + -------------------------- + -- Random_Decimal_Fixed -- + -------------------------- + + function Random_Decimal_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype + is + subtype IntV is Integer_64 range + Integer_64'Integer_Value (Min) .. + Integer_64'Integer_Value (Max); + function R is new Random_Discrete (Integer_64, IntV'First); + begin + return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last)); + end Random_Decimal_Fixed; + + --------------------------- + -- Random_Ordinary_Fixed -- + --------------------------- + + function Random_Ordinary_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype + is + subtype IntV is Integer_64 range + Integer_64'Integer_Value (Min) .. + Integer_64'Integer_Value (Max); + function R is new Random_Discrete (Integer_64, IntV'First); + begin + return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last)); + end Random_Ordinary_Fixed; + ------------ -- Random -- ------------ @@ -137,7 +172,7 @@ package body GNAT.Random_Numbers is -- Random_Float -- ------------------ - function Random_Float (Gen : Generator) return Result_Subtype is + function Random_Float (Gen : Generator) return Result_Subtype is function F is new System.Random_Numbers.Random_Float (Result_Subtype); begin return F (Gen.Rep); diff --git a/gcc/ada/g-rannum.ads b/gcc/ada/g-rannum.ads index 353e21cd0f1..010c21c6cde 100644 --- a/gcc/ada/g-rannum.ads +++ b/gcc/ada/g-rannum.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -79,9 +79,27 @@ package GNAT.Random_Numbers is -- Returns pseudo-random numbers uniformly distributed on Min .. Max generic + type Result_Subtype is delta <>; + Default_Min : Result_Subtype := 0.0; + function Random_Ordinary_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype; + -- Returns pseudo-random numbers uniformly distributed on Min .. Max + + generic + type Result_Subtype is delta <> digits <>; + Default_Min : Result_Subtype := 0.0; + function Random_Decimal_Fixed + (Gen : Generator; + Min : Result_Subtype := Default_Min; + Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype; + -- Returns pseudo-random numbers uniformly distributed on Min .. Max + + generic type Result_Subtype is digits <>; function Random_Float (Gen : Generator) return Result_Subtype; - -- Returns pseudo-random numbers uniformly distributed on [0 .. 1) + -- Returns pseudo-random numbers uniformly distributed on [0.0 .. 1.0) function Random_Gaussian (Gen : Generator) return Long_Float; function Random_Gaussian (Gen : Generator) return Float; diff --git a/gcc/ada/g-sercom-mingw.adb b/gcc/ada/g-sercom-mingw.adb index afc4d4773be..0a868c7dc7b 100644 --- a/gcc/ada/g-sercom-mingw.adb +++ b/gcc/ada/g-sercom-mingw.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2007-2012, AdaCore -- +-- Copyright (C) 2007-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -31,8 +31,8 @@ -- This is the Windows implementation of this package -with Ada.Unchecked_Deallocation; use Ada; with Ada.Streams; use Ada.Streams; +with Ada.Unchecked_Deallocation; use Ada; with System; use System; with System.Communication; use System.Communication; @@ -90,7 +90,12 @@ package body GNAT.Serial_Communications is function Name (Number : Positive) return Port_Name is N_Img : constant String := Positive'Image (Number); begin - return Port_Name ("COM" & N_Img (N_Img'First + 1 .. N_Img'Last) & ':'); + if Number > 9 then + return Port_Name ("\\.\COM" & N_Img (N_Img'First + 1 .. N_Img'Last)); + else + return Port_Name + ("COM" & N_Img (N_Img'First + 1 .. N_Img'Last) & ':'); + end if; end Name; ---------- diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index f60cd2ae110..01e2c148e7a 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -1741,7 +1741,6 @@ ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(target_os))),) s-win32.o s-winext.o g-regist.o g-sse.o g-ssvety.o EXTRA_GNATRTL_TASKING_OBJS = a-exetim.o EXTRA_LIBGNAT_SRCS+=mingw32.h - MISCLIB = -lws2_32 # ??? This will be replaced by gnatlib-shared-dual-win32 when GNAT diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 5259ad4297a..4180e59f6d8 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -130,9 +130,10 @@ static GTY ((if_marked ("tree_int_map_marked_p"), param_is (struct tree_int_map))) htab_t annotate_value_cache; static bool allocatable_size_p (tree, bool); -static void prepend_one_attribute_to (struct attrib **, - enum attr_type, tree, tree, Node_Id); -static void prepend_attributes (Entity_Id, struct attrib **); +static void prepend_one_attribute (struct attrib **, + enum attr_type, tree, tree, Node_Id); +static void prepend_one_attribute_pragma (struct attrib **, Node_Id); +static void prepend_attributes (struct attrib **, Entity_Id); static tree elaborate_expression (Node_Id, Entity_Id, tree, bool, bool, bool); static bool type_has_variable_size (tree); static tree elaborate_expression_1 (tree, Entity_Id, tree, bool, bool); @@ -363,7 +364,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Handle any attributes directly attached to the entity. */ if (Has_Gigi_Rep_Item (gnat_entity)) - prepend_attributes (gnat_entity, &attr_list); + prepend_attributes (&attr_list, gnat_entity); /* Do some common processing for types. */ if (is_type) @@ -377,8 +378,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (Base_Type (gnat_entity) != gnat_entity && !Is_First_Subtype (gnat_entity) && Has_Gigi_Rep_Item (First_Subtype (Base_Type (gnat_entity)))) - prepend_attributes (First_Subtype (Base_Type (gnat_entity)), - &attr_list); + prepend_attributes (&attr_list, + First_Subtype (Base_Type (gnat_entity))); /* Compute a default value for the size of an elementary type. */ if (Known_Esize (gnat_entity) && Is_Elementary_Type (gnat_entity)) @@ -574,9 +575,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Simple variables, loop variables, Out parameters and exceptions. */ object: { + /* Always create a variable for volatile objects and variables seen + constant but with a Linker_Section pragma. */ bool const_flag = ((kind == E_Constant || kind == E_Variable) && Is_True_Constant (gnat_entity) + && !(kind == E_Variable + && Present (Linker_Section_Pragma (gnat_entity))) && !Treat_As_Volatile (gnat_entity) && (((Nkind (Declaration_Node (gnat_entity)) == N_Object_Declaration) @@ -1470,6 +1475,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) (TREE_TYPE (TYPE_FIELDS (gnu_type)))))) static_p = true; + /* Deal with a pragma Linker_Section on a constant or variable. */ + if ((kind == E_Constant || kind == E_Variable) + && Present (Linker_Section_Pragma (gnat_entity))) + prepend_one_attribute_pragma (&attr_list, + Linker_Section_Pragma (gnat_entity)); + /* Now create the variable or the constant and set various flags. */ gnu_decl = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type, @@ -4575,27 +4586,34 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) } } + /* Deal with platform-specific calling conventions. */ if (Has_Stdcall_Convention (gnat_entity)) - prepend_one_attribute_to + prepend_one_attribute (&attr_list, ATTR_MACHINE_ATTRIBUTE, get_identifier ("stdcall"), NULL_TREE, gnat_entity); else if (Has_Thiscall_Convention (gnat_entity)) - prepend_one_attribute_to + prepend_one_attribute (&attr_list, ATTR_MACHINE_ATTRIBUTE, get_identifier ("thiscall"), NULL_TREE, gnat_entity); /* If we should request stack realignment for a foreign convention - subprogram, do so. Note that this applies to task entry points in - particular. */ + subprogram, do so. Note that this applies to task entry points + in particular. */ if (FOREIGN_FORCE_REALIGN_STACK && Has_Foreign_Convention (gnat_entity)) - prepend_one_attribute_to + prepend_one_attribute (&attr_list, ATTR_MACHINE_ATTRIBUTE, get_identifier ("force_align_arg_pointer"), NULL_TREE, gnat_entity); + /* Deal with a pragma Linker_Section on a subprogram. */ + if ((kind == E_Function || kind == E_Procedure) + && Present (Linker_Section_Pragma (gnat_entity))) + prepend_one_attribute_pragma (&attr_list, + Linker_Section_Pragma (gnat_entity)); + /* The lists have been built in reverse. */ gnu_param_list = nreverse (gnu_param_list); if (has_stub) @@ -5456,13 +5474,13 @@ get_minimal_subprog_decl (Entity_Id gnat_entity) gnu_ext_name = create_concat_name (gnat_entity, NULL); if (Has_Stdcall_Convention (gnat_entity)) - prepend_one_attribute_to (&attr_list, ATTR_MACHINE_ATTRIBUTE, - get_identifier ("stdcall"), NULL_TREE, - gnat_entity); + prepend_one_attribute (&attr_list, ATTR_MACHINE_ATTRIBUTE, + get_identifier ("stdcall"), NULL_TREE, + gnat_entity); else if (Has_Thiscall_Convention (gnat_entity)) - prepend_one_attribute_to (&attr_list, ATTR_MACHINE_ATTRIBUTE, - get_identifier ("thiscall"), NULL_TREE, - gnat_entity); + prepend_one_attribute (&attr_list, ATTR_MACHINE_ATTRIBUTE, + get_identifier ("thiscall"), NULL_TREE, + gnat_entity); if (No (Interface_Name (gnat_entity)) && gnu_ext_name == gnu_entity_name) gnu_ext_name = NULL_TREE; @@ -5828,7 +5846,8 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech, Out parameters with discriminants or implicit initial values to be handled like In Out parameters. These type are normally built as aggregates, hence passed by reference, except for some packed arrays - which end up encoded in special integer types. + which end up encoded in special integer types. Note that scalars can + be given implicit initial values using the Default_Value aspect. The exception we need to make is then for packed arrays of records with discriminants or implicit initial values. We have no light/easy @@ -5842,7 +5861,8 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech, || (mech != By_Descriptor && mech != By_Short_Descriptor && !POINTER_TYPE_P (gnu_param_type) - && !AGGREGATE_TYPE_P (gnu_param_type))) + && !AGGREGATE_TYPE_P (gnu_param_type) + && !Has_Default_Aspect (Etype (gnat_param)))) && !(Is_Array_Type (Etype (gnat_param)) && Is_Packed (Etype (gnat_param)) && Is_Composite_Type (Component_Type (Etype (gnat_param))))) @@ -6071,11 +6091,11 @@ allocatable_size_p (tree gnu_size, bool static_p) NAME, ARGS and ERROR_POINT. */ static void -prepend_one_attribute_to (struct attrib ** attr_list, - enum attr_type attr_type, - tree attr_name, - tree attr_args, - Node_Id attr_error_point) +prepend_one_attribute (struct attrib **attr_list, + enum attr_type attr_type, + tree attr_name, + tree attr_args, + Node_Id attr_error_point) { struct attrib * attr = (struct attrib *) xmalloc (sizeof (struct attrib)); @@ -6088,100 +6108,103 @@ prepend_one_attribute_to (struct attrib ** attr_list, *attr_list = attr; } -/* Prepend to ATTR_LIST the list of attributes for GNAT_ENTITY, if any. */ +/* Prepend to ATTR_LIST an entry for an attribute provided by GNAT_PRAGMA. */ static void -prepend_attributes (Entity_Id gnat_entity, struct attrib ** attr_list) +prepend_one_attribute_pragma (struct attrib **attr_list, Node_Id gnat_pragma) { - Node_Id gnat_temp; - - /* Attributes are stored as Representation Item pragmas. */ + const Node_Id gnat_arg = Pragma_Argument_Associations (gnat_pragma); + tree gnu_arg0 = NULL_TREE, gnu_arg1 = NULL_TREE; + enum attr_type etype; - for (gnat_temp = First_Rep_Item (gnat_entity); Present (gnat_temp); - gnat_temp = Next_Rep_Item (gnat_temp)) - if (Nkind (gnat_temp) == N_Pragma) - { - tree gnu_arg0 = NULL_TREE, gnu_arg1 = NULL_TREE; - Node_Id gnat_assoc = Pragma_Argument_Associations (gnat_temp); - enum attr_type etype; + /* Map the pragma at hand. Skip if this isn't one we know how to handle. */ + switch (Get_Pragma_Id (Chars (Pragma_Identifier (gnat_pragma)))) + { + case Pragma_Machine_Attribute: + etype = ATTR_MACHINE_ATTRIBUTE; + break; - /* Map the kind of pragma at hand. Skip if this is not one - we know how to handle. */ + case Pragma_Linker_Alias: + etype = ATTR_LINK_ALIAS; + break; - switch (Get_Pragma_Id (Chars (Pragma_Identifier (gnat_temp)))) - { - case Pragma_Machine_Attribute: - etype = ATTR_MACHINE_ATTRIBUTE; - break; + case Pragma_Linker_Section: + etype = ATTR_LINK_SECTION; + break; - case Pragma_Linker_Alias: - etype = ATTR_LINK_ALIAS; - break; + case Pragma_Linker_Constructor: + etype = ATTR_LINK_CONSTRUCTOR; + break; - case Pragma_Linker_Section: - etype = ATTR_LINK_SECTION; - break; + case Pragma_Linker_Destructor: + etype = ATTR_LINK_DESTRUCTOR; + break; - case Pragma_Linker_Constructor: - etype = ATTR_LINK_CONSTRUCTOR; - break; + case Pragma_Weak_External: + etype = ATTR_WEAK_EXTERNAL; + break; - case Pragma_Linker_Destructor: - etype = ATTR_LINK_DESTRUCTOR; - break; + case Pragma_Thread_Local_Storage: + etype = ATTR_THREAD_LOCAL_STORAGE; + break; - case Pragma_Weak_External: - etype = ATTR_WEAK_EXTERNAL; - break; + default: + return; + } - case Pragma_Thread_Local_Storage: - etype = ATTR_THREAD_LOCAL_STORAGE; - break; + /* See what arguments we have and turn them into GCC trees for attribute + handlers. These expect identifier for strings. We handle at most two + arguments and static expressions only. */ + if (Present (gnat_arg) && Present (First (gnat_arg))) + { + Node_Id gnat_arg0 = Next (First (gnat_arg)); + Node_Id gnat_arg1 = Empty; - default: - continue; - } + if (Present (gnat_arg0) && Is_Static_Expression (Expression (gnat_arg0))) + { + gnu_arg0 = gnat_to_gnu (Expression (gnat_arg0)); - /* See what arguments we have and turn them into GCC trees for - attribute handlers. These expect identifier for strings. We - handle at most two arguments, static expressions only. */ + if (TREE_CODE (gnu_arg0) == STRING_CST) + { + gnu_arg0 = get_identifier (TREE_STRING_POINTER (gnu_arg0)); + if (IDENTIFIER_LENGTH (gnu_arg0) == 0) + return; + } - if (Present (gnat_assoc) && Present (First (gnat_assoc))) - { - Node_Id gnat_arg0 = Next (First (gnat_assoc)); - Node_Id gnat_arg1 = Empty; + gnat_arg1 = Next (gnat_arg0); + } - if (Present (gnat_arg0) - && Is_Static_Expression (Expression (gnat_arg0))) - { - gnu_arg0 = gnat_to_gnu (Expression (gnat_arg0)); + if (Present (gnat_arg1) && Is_Static_Expression (Expression (gnat_arg1))) + { + gnu_arg1 = gnat_to_gnu (Expression (gnat_arg1)); - if (TREE_CODE (gnu_arg0) == STRING_CST) - gnu_arg0 = get_identifier (TREE_STRING_POINTER (gnu_arg0)); + if (TREE_CODE (gnu_arg1) == STRING_CST) + gnu_arg1 = get_identifier (TREE_STRING_POINTER (gnu_arg1)); + } + } - gnat_arg1 = Next (gnat_arg0); - } + /* Prepend to the list. Make a list of the argument we might have, as GCC + expects it. */ + prepend_one_attribute (attr_list, etype, gnu_arg0, + gnu_arg1 + ? build_tree_list (NULL_TREE, gnu_arg1) : NULL_TREE, + Present (Next (First (gnat_arg))) + ? Expression (Next (First (gnat_arg))) : gnat_pragma); +} - if (Present (gnat_arg1) - && Is_Static_Expression (Expression (gnat_arg1))) - { - gnu_arg1 = gnat_to_gnu (Expression (gnat_arg1)); +/* Prepend to ATTR_LIST the list of attributes for GNAT_ENTITY, if any. */ - if (TREE_CODE (gnu_arg1) == STRING_CST) - gnu_arg1 = get_identifier (TREE_STRING_POINTER (gnu_arg1)); - } - } +static void +prepend_attributes (struct attrib **attr_list, Entity_Id gnat_entity) +{ + Node_Id gnat_temp; - /* Prepend to the list now. Make a list of the argument we might - have, as GCC expects it. */ - prepend_one_attribute_to - (attr_list, - etype, gnu_arg0, - (gnu_arg1 != NULL_TREE) - ? build_tree_list (NULL_TREE, gnu_arg1) : NULL_TREE, - Present (Next (First (gnat_assoc))) - ? Expression (Next (First (gnat_assoc))) : gnat_temp); - } + /* Attributes are stored as Representation Item pragmas. */ + for (gnat_temp = First_Rep_Item (gnat_entity); + Present (gnat_temp); + gnat_temp = Next_Rep_Item (gnat_temp)) + if (Nkind (gnat_temp) == N_Pragma) + prepend_one_attribute_pragma (attr_list, gnat_temp); } /* Given a GNAT tree GNAT_EXPR, for an expression which is a value within a diff --git a/gcc/ada/gcc-interface/lang.opt b/gcc/ada/gcc-interface/lang.opt index debeff660e0..004388ba26a 100644 --- a/gcc/ada/gcc-interface/lang.opt +++ b/gcc/ada/gcc-interface/lang.opt @@ -1,6 +1,5 @@ ; Options for the Ada front end. -; Copyright (C) 2003, 2007, 2008, 2010, 2011, 2012 -; Free Software Foundation, Inc. +; Copyright (C) 2003-2013 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -18,7 +17,6 @@ ; along with GCC; see the file COPYING3. If not see ; <http://www.gnu.org/licenses/>. - ; See the GCC internals manual for a description of this file's format. ; Please try to keep this file in ASCII collating order. @@ -74,6 +72,10 @@ fRTS= Ada AdaWhy AdaSCIL Joined RejectNegative Select the runtime +fshort-enums +Ada AdaWhy AdaSCIL +Use the narrowest integer type possible for enumeration types + gant Ada AdaWhy AdaSCIL Joined Undocumented Catch typos diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index fc74be28fb8..5f135a063b2 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -151,6 +151,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value, /* These are handled by the front-end. */ break; + case OPT_fshort_enums: + /* This is handled by the middle-end. */ + break; + default: gcc_unreachable (); } @@ -224,10 +228,12 @@ gnat_init_options (unsigned int decoded_options_count, #undef optimize #undef optimize_size #undef flag_compare_debug +#undef flag_short_enums #undef flag_stack_check int optimize; int optimize_size; int flag_compare_debug; +int flag_short_enums; enum stack_check_type flag_stack_check = NO_STACK_CHECK; /* Settings adjustments after switches processing by the back-end. @@ -257,6 +263,13 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED) optimize_size = global_options.x_optimize_size; flag_compare_debug = global_options.x_flag_compare_debug; flag_stack_check = global_options.x_flag_stack_check; + flag_short_enums = global_options.x_flag_short_enums; + + /* Unfortunately the post_options hook is called before the value of + flag_short_enums is autodetected, if need be. Mimic the process + for our private flag_short_enums. */ + if (flag_short_enums == 2) + flag_short_enums = targetm.default_short_enums (); return false; } diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 69ea026e6d3..014fe361b76 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -4352,7 +4352,7 @@ convert_to_fat_pointer (tree type, tree expr) tree template_type = TREE_TYPE (TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)))); tree p_array_type = TREE_TYPE (TYPE_FIELDS (type)); tree etype = TREE_TYPE (expr); - tree template_tree; + tree template_addr; vec<constructor_elt, va_gc> *v; vec_alloc (v, 2); @@ -4395,31 +4395,43 @@ convert_to_fat_pointer (tree type, tree expr) tree field = TYPE_FIELDS (TREE_TYPE (etype)); expr = gnat_protect_expr (expr); - if (TREE_CODE (expr) == ADDR_EXPR) - expr = TREE_OPERAND (expr, 0); - else + + /* If we have a TYPE_UNCONSTRAINED_ARRAY attached to the RECORD_TYPE, + the thin pointer value has been shifted so we shift it back to get + the template address. */ + if (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype))) { - /* If we have a TYPE_UNCONSTRAINED_ARRAY attached to the RECORD_TYPE, - the thin pointer value has been shifted so we first need to shift - it back to get the template address. */ - if (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype))) - expr - = build_binary_op (POINTER_PLUS_EXPR, etype, expr, - fold_build1 (NEGATE_EXPR, sizetype, - byte_position - (DECL_CHAIN (field)))); - expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr); + template_addr + = build_binary_op (POINTER_PLUS_EXPR, etype, expr, + fold_build1 (NEGATE_EXPR, sizetype, + byte_position + (DECL_CHAIN (field)))); + template_addr + = fold_convert (TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type))), + template_addr); } - template_tree = build_component_ref (expr, NULL_TREE, field, false); - expr = build_unary_op (ADDR_EXPR, NULL_TREE, - build_component_ref (expr, NULL_TREE, - DECL_CHAIN (field), false)); + /* Otherwise we explicitly take the address of the fields. */ + else + { + expr = build_unary_op (INDIRECT_REF, NULL_TREE, expr); + template_addr + = build_unary_op (ADDR_EXPR, NULL_TREE, + build_component_ref (expr, NULL_TREE, field, + false)); + expr = build_unary_op (ADDR_EXPR, NULL_TREE, + build_component_ref (expr, NULL_TREE, + DECL_CHAIN (field), + false)); + } } /* Otherwise, build the constructor for the template. */ else - template_tree = build_template (template_type, TREE_TYPE (etype), expr); + template_addr + = build_unary_op (ADDR_EXPR, NULL_TREE, + build_template (template_type, TREE_TYPE (etype), + expr)); /* The final result is a constructor for the fat pointer. @@ -4433,11 +4445,8 @@ convert_to_fat_pointer (tree type, tree expr) Note that the call to "build_template" above is still fine because it will only refer to the provided TEMPLATE_TYPE in this case. */ - CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type), - convert (p_array_type, expr)); - CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (type)), - build_unary_op (ADDR_EXPR, NULL_TREE, - template_tree)); + CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type), convert (p_array_type, expr)); + CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (type)), template_addr); return gnat_build_constructor (type, v); } diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 224a87d8777..e716bdcf02b 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2013, Free Software Foundation, Inc. * + * Copyright (C) 1992-2014, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -1850,6 +1850,7 @@ tree gnat_build_constructor (tree type, vec<constructor_elt, va_gc> *v) { bool allconstant = (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST); + bool read_only = true; bool side_effects = false; tree result, obj, val; unsigned int n_elmts; @@ -1867,6 +1868,9 @@ gnat_build_constructor (tree type, vec<constructor_elt, va_gc> *v) || !initializer_constant_valid_p (val, TREE_TYPE (val))) allconstant = false; + if (!TREE_READONLY (val)) + read_only = false; + if (TREE_SIDE_EFFECTS (val)) side_effects = true; } @@ -1881,7 +1885,7 @@ gnat_build_constructor (tree type, vec<constructor_elt, va_gc> *v) CONSTRUCTOR_NO_CLEARING (result) = 1; TREE_CONSTANT (result) = TREE_STATIC (result) = allconstant; TREE_SIDE_EFFECTS (result) = side_effects; - TREE_READONLY (result) = TYPE_READONLY (type) || allconstant; + TREE_READONLY (result) = TYPE_READONLY (type) || read_only || allconstant; return result; } @@ -2814,7 +2818,7 @@ object: if (!TREE_READONLY (t)) return NULL_TREE; - if (TREE_CODE (t) == PARM_DECL) + if (TREE_CODE (t) == CONSTRUCTOR || TREE_CODE (t) == PARM_DECL) return fold_convert (type, expr); if (TREE_CODE (t) == VAR_DECL diff --git a/gcc/ada/get_spark_xrefs.adb b/gcc/ada/get_spark_xrefs.adb index 92964b31379..ea1f1b45a0b 100644 --- a/gcc/ada/get_spark_xrefs.adb +++ b/gcc/ada/get_spark_xrefs.adb @@ -455,6 +455,7 @@ begin pragma Assert (Rtype = 'r' or else + Rtype = 'c' or else Rtype = 'm' or else Rtype = 's'); diff --git a/gcc/ada/get_targ.adb b/gcc/ada/get_targ.adb index a2f7370f8e5..661f95b5ab3 100644 --- a/gcc/ada/get_targ.adb +++ b/gcc/ada/get_targ.adb @@ -23,6 +23,8 @@ -- -- ------------------------------------------------------------------------------ +-- Version for use with gcc + package body Get_Targ is -- Functions returning individual runtime. For the standard (GCC) back @@ -232,6 +234,17 @@ package body Get_Targ is return C_Get_Bits_BE; end Get_Bits_BE; + --------------------- + -- Get_Short_Enums -- + --------------------- + + function Get_Short_Enums return Int is + flag_short_enums : Int; + pragma Import (C, flag_short_enums); + begin + return flag_short_enums; + end Get_Short_Enums; + -------------------------- -- Get_Strict_Alignment -- -------------------------- diff --git a/gcc/ada/get_targ.ads b/gcc/ada/get_targ.ads index 08af7f33855..19f5385e12f 100644 --- a/gcc/ada/get_targ.ads +++ b/gcc/ada/get_targ.ads @@ -108,6 +108,13 @@ package Get_Targ is -- Alignment required for Long_Long_Integer or larger integer types -- or 0 if no special requirement. + function Get_Short_Enums return Int; + -- Returns non-zero if we are in short enums mode, where foreign convention + -- (in particular C and C++) enumeration types will be sized as in Ada, + -- using the shortest possibility from 8,16,32 bits, signed or unsigned. + -- A zero value means Short_Enums are not in use, and in this case all + -- foreign convention enumeration types are given the same size as c int. + -- Other subprograms function Get_Max_Unaligned_Field return Pos; diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index adf4ec20a9d..6f04498d4f9 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -26,8 +26,6 @@ included in the section entitled ``GNU Free Documentation License''. @end copying @set EDITION GNAT -@set DEFAULTLANGUAGEVERSION Ada 2005 -@set NONDEFAULTLANGUAGEVERSION Ada 95 @settitle GNAT Reference Manual @@ -294,6 +292,7 @@ Implementation Defined Aspects * Aspect Initializes:: * Aspect Inline_Always:: * Aspect Invariant:: +* Aspect Linker_Section:: * Aspect Object_Size:: * Aspect Persistent_BSS:: * Aspect Predicate:: @@ -696,15 +695,15 @@ This manual contains useful information in writing programs using the characteristics of @value{EDITION}, including all the information required by Annex M of the Ada language standard. -@value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in -Ada 83 compatibility mode. -By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION}, +@value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be +invoked in Ada 83 compatibility mode. +By default, @value{EDITION} assumes Ada 2012, but you can override with a compiler switch to explicitly specify the language version. (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn, @value{EDITION} User's Guide}, for details on these switches.) Throughout this manual, references to ``Ada'' without a year suffix -apply to both the Ada 95 and Ada 2005 versions of the language. +apply to all the Ada versions of the language. Ada is designed to be highly portable. In general, a program will have the same effect even when compiled by @@ -2971,11 +2970,11 @@ You can use this pragma either to access a predefined @code{System} extension supplied with the compiler, for example @code{Aux_DEC} or you can construct your own extension unit following the above definition. Note that such a package is a child of @code{System} -and thus is considered part of the implementation. To compile -it you will have to use the appropriate switch for compiling -system units. -@xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide}, -for details. +and thus is considered part of the implementation. +To compile it you will have to use the @option{-gnatg} switch, +or the @option{/GNAT_INTERNAL} qualifier on OpenVMS, +for compiling System units, as explained in the +@value{EDITION} User's Guide. @node Pragma Extensions_Allowed @unnumberedsec Pragma Extensions_Allowed @@ -4249,14 +4248,33 @@ pragma Linker_Section ( @end smallexample @noindent -@var{LOCAL_NAME} must refer to an object that is declared at the library -level. This pragma specifies the name of the linker section for the given -entity. It is equivalent to @code{__attribute__((section))} in GNU C and -causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION} -section of the executable (assuming the linker doesn't rename the section). +@var{LOCAL_NAME} must refer to an object, type, or subprogram that is +declared at the library level. This pragma specifies the name of the +linker section for the given entity. It is equivalent to +@code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to +be placed in the @var{static_string_EXPRESSION} section of the +executable (assuming the linker doesn't rename the section). +GNAT also provides an implementation defined aspect of the same name. + +In the case of specifying this aspect for a type, the effect is to +specify the corresponding for all library level objects of the type which +do not have an explicit linker section set. Note that this only applies to +whole objects, not to components of composite objects. + +In the case of a subprogram, the linker section applies to all previously +declared matching overloaded subprograms in the current declarative part +which do not already have a linker section assigned. The linker section +aspect is useful in this case for specifying different linker sections +for different elements of such an overloaded set. + +Note that an empty string specifies that no linker section is specified. +This is not quite the same as omitting the pragma or aspect, since it +can be used to specify that one element of an overloaded set of subprograms +has the default linker section, or that one object of a type for which a +linker section is specified should has the default linker section. -The compiler normally places library-level objects in standard sections -depending on their type: procedures and functions generally go in the +The compiler normally places library-level entities in standard sections +depending on the class: procedures and functions generally go in the @code{.text} section, initialized variables in the @code{.data} section and uninitialized variables in the @code{.bss} section. @@ -4282,6 +4300,12 @@ package IO_Card is Port_B : Integer; pragma Volatile (Port_B); pragma Linker_Section (Port_B, ".bss.port_b"); + + type Port_Type is new Integer with Linker_Section => ".bss"; + PA : Port_Type with Linker_Section => ".bss.PA"; + PB : Port_Type; -- ends up in linker section ".bss" + + procedure Q with Linker_Section => "Qsection"; end IO_Card; @end smallexample @@ -6281,7 +6305,7 @@ is needed for error messages issued by all phases of the compiler. Syntax: @smallexample @c ada -pragma SPARK_Mode [ (On | Off | Auto) ] ; +pragma SPARK_Mode [(On | Off)] ; @end smallexample @noindent @@ -6291,16 +6315,14 @@ language. The pragma is intended for use with formal verification tools and has no effect on the generated code. The SPARK_Mode pragma is used to specify the value of the SPARK_Mode aspect -(a three-valued aspect having values of On, Off, or Auto) of an entity. +(either Off or On) of an entity. More precisely, it is used to specify the aspect value of a ``section'' of an entity (the term ``section'' is defined below). If a Spark_Mode pragma's (optional) argument is omitted, an implicit argument of On is assumed. A SPARK_Mode pragma may be used as a configuration pragma and then has the -semantics described below. A SPARK_Mode pragma which is not used as a -configuration pragma (or an equivalent SPARK_Mode aspect_specification) -shall not have an argument of Auto. +semantics described below. A SPARK_Mode pragma can be used as a local pragma only in the following contexts: @@ -6350,8 +6372,7 @@ completion is defined to have 2 ``sections'': its declaration and its completion. Any other construct is defined to have 1 section. The SPARK_Mode aspect value of an arbitrary section of an arbitrary Ada entity -or construct is then defined to be the following value (except if this yields -a result of Auto for a non-package; see below): +or construct is then defined to be the following value: @itemize @@ -6368,7 +6389,7 @@ else for any of the visible part or body declarations of a library unit package or either section of a library unit subprogram, if there is an applicable SPARK_Mode configuration pragma then the value specified by the pragma; if no such configuration pragma applies, then an implicit -specification of Auto is assumed; +specification of Off is assumed; @item else for any subsequent (i.e., not the first) section of a library unit @@ -6380,12 +6401,11 @@ or subprogram; @end itemize -If the above computation yields a result of Auto for any construct other than -one of the four sections of a package, then a result of On or Off is -determined instead based on the legality (with respect to the rules of -SPARK 2014) of the construct. The construct's SPARK_Mode is On if and only -if the construct is in SPARK 2014. [A SPARK_Mode of -Auto is therefore only possible for sections of a package.] +If the above computation does not specify a SPARK_Mode setting for any +construct other than one of the four sections of a package, then a result of On +or Off is determined instead based on the legality (with respect to the rules +of SPARK 2014) of the construct. The construct's SPARK_Mode is On if and only +if the construct is in SPARK 2014. If an earlier section of an entity has a Spark_Mode of Off, then the Spark_Mode aspect of any later section of that entity shall not be @@ -7630,6 +7650,7 @@ clause. * Aspect Initializes:: * Aspect Inline_Always:: * Aspect Invariant:: +* Aspect Linker_Section:: * Aspect Lock_Free:: * Aspect Object_Size:: * Aspect Persistent_BSS:: @@ -7823,6 +7844,12 @@ This aspect is equivalent to pragma @code{Invariant}. It is a synonym for the language defined aspect @code{Type_Invariant} except that it is separately controllable using pragma @code{Assertion_Policy}. +@node Aspect Linker_Section +@unnumberedsec Aspect Linker_Section +@findex Linker_Section +@noindent +This aspect is equivalent to an @code{Linker_Section} pragma. + @node Aspect Lock_Free @unnumberedsec Aspect Lock_Free @findex Lock_Free @@ -12441,7 +12468,7 @@ See A.3.5(3). @end cartouche @noindent @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns -the string "Unicode 6.2", referring to version 6.2.x of the +the string "Unicode 4.0", referring to version 4.0 of the Unicode specification. @sp 1 diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 36491499696..17983ef9d64 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -3869,6 +3869,7 @@ Long_Size : Pos; -- Standard.Long_Integer'Size Maximum_Alignment : Pos; -- Maximum permitted alignment Max_Unaligned_Field : Pos; -- Maximum size for unaligned bit field Pointer_Size : Pos; -- System.Address'Size +Short_Enums : Nat; -- Short foreign convention enums? Short_Size : Pos; -- Standard.Short_Integer'Size Strict_Alignment : Nat; -- Strict alignment? System_Allocator_Alignment : Nat; -- Alignment for malloc calls @@ -7430,7 +7431,12 @@ the @option{-gnatR} switch). For @option{-gnatR1} (which is the default, so @option{-gnatR} with no parameter has the same effect), size and alignment information is listed for declared array and record types. For @option{-gnatR2}, size and alignment information is listed for all -declared types and objects. Finally @option{-gnatR3} includes symbolic +declared types and objects. The @code{Linker_Section} is also listed for any +entity for which the @code{Linker_Section} is set explicitly or implicitly (the +latter case occurs for objects of a type for which a @code{Linker_Section} +is set). + +Finally @option{-gnatR3} includes symbolic expressions for values that are computed at run time for variant records. These symbolic expressions have a mostly obvious format with #n being used to represent the value of the n'th @@ -14319,9 +14325,23 @@ line indentation is also 1) @noindent These switches control the inclusion of missing end/exit labels, and -the indentation level in @b{case} statements. +the indentation level in @b{case} statements, etc. @table @option +@item --decimal-grouping=@var{n} +@cindex @option{--decimal-grouping} @command{gnatpp} +Put underscores in decimal literals (numeric literals without a base) +every @var{n} characters. If a literal already has one or more +underscores, it is not modified. For example, with +@code{--decimal-grouping=3}, @code{1000000} will be changed to +@code{1_000_000}. + +@item --based-grouping=@var{n} +@cindex @option{--based-grouping} @command{gnatpp} +Same as @code{--decimal-grouping}, but for based literals. For +example, with @code{--based-grouping=4}, @code{16#0001FFFE#} will be +changed to @code{16#0001_FFFE#}. + @item ^-e^/NO_MISSED_LABELS^ @cindex @option{^-e^/NO_MISSED_LABELS^} (@command{gnatpp}) Do not insert missing end/exit labels. An end label is the name of @@ -14501,6 +14521,16 @@ Display Copyright and version, then exit disregarding all other options. @cindex @option{--help} @command{gnatpp} Display usage, then exit disregarding all other options. +@item --pp-off=@var{xxx} +@cindex @option{--pp-off} @command{gnatpp} +Use @code{--xxx} as the command to turn off pretty printing, instead +of the default @code{--!pp off}. + +@item --pp-on=@var{xxx} +@cindex @option{--pp-on} @command{gnatpp} +Use @code{--xxx} as the command to turn pretty printing back on, instead +of the default @code{--!pp on}. + @item --pp-old @cindex @option{--pp-old} @command{gnatpp} Use the old formatting algorithms. @@ -14535,12 +14565,53 @@ comments, program layout, and name casing. They provide the detailed descriptions of the switches shown above. @menu +* Disabling Pretty Printing:: * White Space and Empty Lines:: * Formatting Comments:: * Construct Layout:: * Name Casing:: @end menu +@node Disabling Pretty Printing +@subsection Disabling Pretty Printing + +@noindent +Pretty printing is highly heuristic in nature, and sometimes doesn't +do exactly what you want. If you wish to format a certain region of +code by hand, you can turn off pretty printing in that region by +surrounding it with special comments that start with @code{--!pp off} +and @code{--!pp on}. The text in that region will then be reproduced +verbatim in the output with no formatting. + +To disable pretty printing for the whole file, put @code{--!pp off} at +the top, with no following @code{--!pp on}. + +The comments must appear on a line by themselves, with nothing +preceding except spaces. The initial text of the comment must be +exactly @code{--!pp off} or @code{--!pp on} (case sensitive), but may +be followed by arbitrary additional text. For example: + +@smallexample @c ada +@cartouche +package Interrupts is + --!pp off -- turn off pretty printing so "Interrupt_Kind" lines up + type Interrupt_Kind is + (Asynchronous_Interrupt_Kind, + Synchronous_Interrupt_Kind, + Green_Interrupt_Kind); + --!pp on -- reenable pretty printing + + ... +@end cartouche +@end smallexample + +You can specify different comment strings using the gnatpp +@code{--pp-off} and @code{--pp-on} switches. For example, if you say +@code{gnatpp --pp-off=' pp-' *.ad?} then gnatpp will recognize +comments of the form @code{-- pp-} instead of @code{--!pp off} for +disabling pretty printing. Note that the leading @code{--} of the +comment is not included in the argument to these switches. + @node White Space and Empty Lines @subsection White Space and Empty Lines diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index 68262f447e4..ea679d9d25c 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -294,8 +294,9 @@ procedure Gnatlink is for J in Units.Table'First .. Units.Last loop Sfile := Units.Table (J).Sfile; if Sfile = Efile then - Exit_With_Error ("executable name """ & File_Name & """ matches " - & "source file name """ & Get_Name_String (Sfile) & """"); + Exit_With_Error + ("executable name """ & File_Name & """ matches " + & "source file name """ & Get_Name_String (Sfile) & """"); end if; end loop; @@ -1100,9 +1101,9 @@ procedure Gnatlink is -- The following test needs comments, why is it VMS specific. -- The above comment looks out of date ??? - elsif not (OpenVMS_On_Target - and then - Is_Option_Present (Next_Line (Nfirst .. Nlast))) + elsif not + (OpenVMS_On_Target + and then Is_Option_Present (Next_Line (Nfirst .. Nlast))) then if Nlast > Nfirst + 2 and then Next_Line (Nfirst .. Nfirst + 1) = "-L" @@ -1779,15 +1780,66 @@ begin -- on Unix. On non-Unix systems executables have a suffix, so the warning -- will not appear. However, do not warn in the case of a cross compiler. - -- Assume this is a cross tool if the executable name is not gnatlink + -- Assume this is a cross tool if the executable name is not gnatlink. + -- Note that the executable name is also gnatlink on windows, but in that + -- case the output file name will be test.exe rather than test. if Base_Command_Name.all = "gnatlink" and then Output_File_Name.all = "test" then Error_Msg ("warning: executable name """ & Output_File_Name.all - & """ may conflict with shell command"); + & """ may conflict with shell command"); end if; + -- Special warnings for worrisome file names on windows + + -- Windows-7 will not allow an executable file whose name contains any + -- of the substrings "install", "setup", or "update" to load without + -- special administration privileges. This rather incredible behavior + -- is Microsoft's idea of a useful security precaution. + + Bad_File_Names_On_Windows : declare + FN : String := Output_File_Name.all; + + procedure Check_File_Name (S : String); + -- Warn if file name has the substring S + + procedure Check_File_Name (S : String) is + begin + for J in 1 .. FN'Length - (S'Length - 1) loop + if FN (J .. J + (S'Length - 1)) = S then + Error_Msg + ("warning: possible problem with executable name """ + & Output_File_Name.all & '"'); + Error_Msg + ("file name contains substring """ & S & '"'); + Error_Msg + ("admin privileges may be required on Windows 7 " + & "to load this file"); + end if; + end loop; + end Check_File_Name; + + -- Start of processing for Bad_File_Names_On_Windows + + begin + for J in FN'Range loop + FN (J) := Csets.Fold_Lower (FN (J)); + end loop; + + -- For now we detect windows by an output executable name ending with + -- the suffix .exe (excluding VMS which might use that same name). + + if FN'Length > 5 + and then FN (FN'Last - 3 .. FN'Last) = ".exe" + and then not OpenVMS_On_Target + then + Check_File_Name ("install"); + Check_File_Name ("setup"); + Check_File_Name ("update"); + end if; + end Bad_File_Names_On_Windows; + -- If -M switch was specified, add the switches to create the map file if Create_Map_File then diff --git a/gcc/ada/i-cexten.ads b/gcc/ada/i-cexten.ads index 6be6f23ebe2..e256dec22ba 100644 --- a/gcc/ada/i-cexten.ads +++ b/gcc/ada/i-cexten.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -170,6 +170,102 @@ package Interfaces.C.Extensions is type Unsigned_32 is mod 2 ** 32; for Unsigned_32'Size use 32; + type Unsigned_33 is mod 2 ** 33; + for Unsigned_33'Size use 33; + + type Unsigned_34 is mod 2 ** 34; + for Unsigned_34'Size use 34; + + type Unsigned_35 is mod 2 ** 35; + for Unsigned_35'Size use 35; + + type Unsigned_36 is mod 2 ** 36; + for Unsigned_36'Size use 36; + + type Unsigned_37 is mod 2 ** 37; + for Unsigned_37'Size use 37; + + type Unsigned_38 is mod 2 ** 38; + for Unsigned_38'Size use 38; + + type Unsigned_39 is mod 2 ** 39; + for Unsigned_39'Size use 39; + + type Unsigned_40 is mod 2 ** 40; + for Unsigned_40'Size use 40; + + type Unsigned_41 is mod 2 ** 41; + for Unsigned_41'Size use 41; + + type Unsigned_42 is mod 2 ** 42; + for Unsigned_42'Size use 42; + + type Unsigned_43 is mod 2 ** 43; + for Unsigned_43'Size use 43; + + type Unsigned_44 is mod 2 ** 44; + for Unsigned_44'Size use 44; + + type Unsigned_45 is mod 2 ** 45; + for Unsigned_45'Size use 45; + + type Unsigned_46 is mod 2 ** 46; + for Unsigned_46'Size use 46; + + type Unsigned_47 is mod 2 ** 47; + for Unsigned_47'Size use 47; + + type Unsigned_48 is mod 2 ** 48; + for Unsigned_48'Size use 48; + + type Unsigned_49 is mod 2 ** 49; + for Unsigned_49'Size use 49; + + type Unsigned_50 is mod 2 ** 50; + for Unsigned_50'Size use 50; + + type Unsigned_51 is mod 2 ** 51; + for Unsigned_51'Size use 51; + + type Unsigned_52 is mod 2 ** 52; + for Unsigned_52'Size use 52; + + type Unsigned_53 is mod 2 ** 53; + for Unsigned_53'Size use 53; + + type Unsigned_54 is mod 2 ** 54; + for Unsigned_54'Size use 54; + + type Unsigned_55 is mod 2 ** 55; + for Unsigned_55'Size use 55; + + type Unsigned_56 is mod 2 ** 56; + for Unsigned_56'Size use 56; + + type Unsigned_57 is mod 2 ** 57; + for Unsigned_57'Size use 57; + + type Unsigned_58 is mod 2 ** 58; + for Unsigned_58'Size use 58; + + type Unsigned_59 is mod 2 ** 59; + for Unsigned_59'Size use 59; + + type Unsigned_60 is mod 2 ** 60; + for Unsigned_60'Size use 60; + + type Unsigned_61 is mod 2 ** 61; + for Unsigned_61'Size use 61; + + type Unsigned_62 is mod 2 ** 62; + for Unsigned_62'Size use 62; + + type Unsigned_63 is mod 2 ** 63; + for Unsigned_63'Size use 63; + + type Unsigned_64 is mod 2 ** 64; + for Unsigned_64'Size use 64; + type Signed_2 is range -2 ** 1 .. 2 ** 1 - 1; for Signed_2'Size use 2; @@ -263,4 +359,100 @@ package Interfaces.C.Extensions is type Signed_32 is range -2 ** 31 .. 2 ** 31 - 1; for Signed_32'Size use 32; + type Signed_33 is range -2 ** 32 .. 2 ** 32 - 1; + for Signed_33'Size use 33; + + type Signed_34 is range -2 ** 33 .. 2 ** 33 - 1; + for Signed_34'Size use 34; + + type Signed_35 is range -2 ** 34 .. 2 ** 34 - 1; + for Signed_35'Size use 35; + + type Signed_36 is range -2 ** 35 .. 2 ** 35 - 1; + for Signed_36'Size use 36; + + type Signed_37 is range -2 ** 36 .. 2 ** 36 - 1; + for Signed_37'Size use 37; + + type Signed_38 is range -2 ** 37 .. 2 ** 37 - 1; + for Signed_38'Size use 38; + + type Signed_39 is range -2 ** 38 .. 2 ** 38 - 1; + for Signed_39'Size use 39; + + type Signed_40 is range -2 ** 39 .. 2 ** 39 - 1; + for Signed_40'Size use 40; + + type Signed_41 is range -2 ** 40 .. 2 ** 40 - 1; + for Signed_41'Size use 41; + + type Signed_42 is range -2 ** 41 .. 2 ** 41 - 1; + for Signed_42'Size use 42; + + type Signed_43 is range -2 ** 42 .. 2 ** 42 - 1; + for Signed_43'Size use 43; + + type Signed_44 is range -2 ** 43 .. 2 ** 43 - 1; + for Signed_44'Size use 44; + + type Signed_45 is range -2 ** 44 .. 2 ** 44 - 1; + for Signed_45'Size use 45; + + type Signed_46 is range -2 ** 45 .. 2 ** 45 - 1; + for Signed_46'Size use 46; + + type Signed_47 is range -2 ** 46 .. 2 ** 46 - 1; + for Signed_47'Size use 47; + + type Signed_48 is range -2 ** 47 .. 2 ** 47 - 1; + for Signed_48'Size use 48; + + type Signed_49 is range -2 ** 48 .. 2 ** 48 - 1; + for Signed_49'Size use 49; + + type Signed_50 is range -2 ** 49 .. 2 ** 49 - 1; + for Signed_50'Size use 50; + + type Signed_51 is range -2 ** 50 .. 2 ** 50 - 1; + for Signed_51'Size use 51; + + type Signed_52 is range -2 ** 51 .. 2 ** 51 - 1; + for Signed_52'Size use 52; + + type Signed_53 is range -2 ** 52 .. 2 ** 52 - 1; + for Signed_53'Size use 53; + + type Signed_54 is range -2 ** 53 .. 2 ** 53 - 1; + for Signed_54'Size use 54; + + type Signed_55 is range -2 ** 54 .. 2 ** 54 - 1; + for Signed_55'Size use 55; + + type Signed_56 is range -2 ** 55 .. 2 ** 55 - 1; + for Signed_56'Size use 56; + + type Signed_57 is range -2 ** 56 .. 2 ** 56 - 1; + for Signed_57'Size use 57; + + type Signed_58 is range -2 ** 57 .. 2 ** 57 - 1; + for Signed_58'Size use 58; + + type Signed_59 is range -2 ** 58 .. 2 ** 58 - 1; + for Signed_59'Size use 59; + + type Signed_60 is range -2 ** 59 .. 2 ** 59 - 1; + for Signed_60'Size use 60; + + type Signed_61 is range -2 ** 60 .. 2 ** 60 - 1; + for Signed_61'Size use 61; + + type Signed_62 is range -2 ** 61 .. 2 ** 61 - 1; + for Signed_62'Size use 62; + + type Signed_63 is range -2 ** 62 .. 2 ** 62 - 1; + for Signed_63'Size use 63; + + type Signed_64 is range -2 ** 63 .. 2 ** 63 - 1; + for Signed_64'Size use 64; + end Interfaces.C.Extensions; diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 7f8b3a3e58c..e943837d07a 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2320,6 +2320,83 @@ __gnat_install_handler (void) __gnat_handler_installed = 1; } +#elif defined(__ANDROID__) + +/*******************/ +/* Android Section */ +/*******************/ + +#include <signal.h> +#include <stdlib.h> + +static void +__gnat_error_handler (int sig, + siginfo_t *si ATTRIBUTE_UNUSED, + void *ucontext ATTRIBUTE_UNUSED) +{ + struct Exception_Data *exception; + const char *msg; + + switch (sig) + { + case SIGSEGV: + exception = &storage_error; + msg = "stack overflow or erroneous memory access"; + break; + + case SIGBUS: + exception = &constraint_error; + msg = "SIGBUS"; + break; + + case SIGFPE: + exception = &constraint_error; + msg = "SIGFPE"; + break; + + default: + exception = &program_error; + msg = "unhandled signal"; + } + + Raise_From_Signal_Handler (exception, msg); +} + +/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */ +char __gnat_alternate_stack[16 * 1024]; + +void +__gnat_install_handler (void) +{ + struct sigaction act; + + /* Set up signal handler to map synchronous signals to appropriate + exceptions. Make sure that the handler isn't interrupted by another + signal that might cause a scheduling event! Also setup an alternate + stack region for the handler execution so that stack overflows can be + handled properly, avoiding a SEGV generation from stack usage by the + handler itself. */ + + stack_t stack; + stack.ss_sp = __gnat_alternate_stack; + stack.ss_size = sizeof (__gnat_alternate_stack); + stack.ss_flags = 0; + sigaltstack (&stack, NULL); + + act.sa_sigaction = __gnat_error_handler; + act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO; + sigemptyset (&act.sa_mask); + + sigaction (SIGABRT, &act, NULL); + sigaction (SIGFPE, &act, NULL); + sigaction (SIGILL, &act, NULL); + sigaction (SIGBUS, &act, NULL); + act.sa_flags |= SA_ONSTACK; + sigaction (SIGSEGV, &act, NULL); + + __gnat_handler_installed = 1; +} + #else /* For all other versions of GNAT, the handler does nothing. */ diff --git a/gcc/ada/lib-xref-spark_specific.adb b/gcc/ada/lib-xref-spark_specific.adb index 849ff0e2dbf..0b32aada218 100644 --- a/gcc/ada/lib-xref-spark_specific.adb +++ b/gcc/ada/lib-xref-spark_specific.adb @@ -334,10 +334,6 @@ package body SPARK_Specific is S : Scope_Index) return Boolean; -- Check whether entity E is in SPARK_Scope_Table at index S or higher - function Is_Global_Constant (E : Entity_Id) return Boolean; - -- Return True if E is a global constant for which we should ignore - -- reads in SPARK. - function Lt (Op1 : Natural; Op2 : Natural) return Boolean; -- Comparison function for Sort call @@ -440,14 +436,6 @@ package body SPARK_Specific is if Ekind (E) in Overloadable_Kind then return Typ = 's'; - -- References to constant objects are not considered in SPARK - -- section, as these will be translated as constants in the - -- intermediate language for formal verification, and should - -- therefore never appear in frame conditions. - - elsif Is_Constant_Object (E) then - return False; - -- Objects of Task type or protected type are not SPARK references elsif Present (Etype (E)) @@ -526,16 +514,6 @@ package body SPARK_Specific is return False; end Is_Future_Scope_Entity; - ------------------------ - -- Is_Global_Constant -- - ------------------------ - - function Is_Global_Constant (E : Entity_Id) return Boolean is - begin - return Ekind (E) = E_Constant - and then Ekind_In (Scope (E), E_Package, E_Package_Body); - end Is_Global_Constant; - -------- -- Lt -- -------- @@ -726,7 +704,6 @@ package body SPARK_Specific is and then SPARK_References (Ref.Typ) and then Is_SPARK_Scope (Ref.Ent_Scope) and then Is_SPARK_Scope (Ref.Ref_Scope) - and then not Is_Global_Constant (Ref.Ent) and then Is_SPARK_Reference (Ref.Ent, Ref.Typ) -- Discard references from unknown scopes, e.g. generic scopes @@ -805,6 +782,7 @@ package body SPARK_Specific is declare Ref_Entry : Xref_Entry renames Xrefs.Table (Rnums (Refno)); Ref : Xref_Key renames Ref_Entry.Key; + Typ : Character; begin -- If this assertion fails, the scope which we are looking for is @@ -844,6 +822,17 @@ package body SPARK_Specific is Col := Int (Get_Column_Number (Ref_Entry.Def)); end if; + -- References to constant objects are considered specially in + -- SPARK section, because these will be translated as constants in + -- the intermediate language for formal verification, and should + -- therefore never appear in frame conditions. + + if Is_Constant_Object (Ref.Ent) then + Typ := 'c'; + else + Typ := Ref.Typ; + end if; + SPARK_Xref_Table.Append ( (Entity_Name => Ref_Name, Entity_Line => Line, @@ -852,7 +841,7 @@ package body SPARK_Specific is File_Num => Dependency_Num (Ref.Lun), Scope_Num => Get_Scope_Num (Ref.Ref_Scope), Line => Int (Get_Logical_Line_Number (Ref.Loc)), - Rtype => Ref.Typ, + Rtype => Typ, Col => Int (Get_Column_Number (Ref.Loc)))); end; end loop; @@ -1023,25 +1012,18 @@ package body SPARK_Specific is when N_Pragma => -- The enclosing subprogram for a precondition, postcondition, - -- or contract case should be the subprogram to which the - -- pragma is attached, which can be found by following - -- previous elements in the list to which the pragma belongs. - - if Get_Pragma_Id (Result) = Pragma_Precondition - or else - Get_Pragma_Id (Result) = Pragma_Postcondition - or else - Get_Pragma_Id (Result) = Pragma_Contract_Cases - then - if Is_List_Member (Result) - and then Present (Prev (Result)) - then - Result := Prev (Result); - else - Result := Parent (Result); - end if; - - else + -- or contract case should be the declaration preceding the + -- pragma (skipping any other pragmas between this pragma and + -- this declaration. + + while Nkind (Result) = N_Pragma + and then Is_List_Member (Result) + and then Present (Prev (Result)) + loop + Result := Prev (Result); + end loop; + + if Nkind (Result) = N_Pragma then Result := Parent (Result); end if; diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 409e736aee0..67739211abc 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -432,6 +432,7 @@ package body Lib.Xref is -- ??? There are several routines here and there that perform a similar -- (but subtly different) computation, which should be factored: + -- Sem_Util.Is_LHS -- Sem_Util.May_Be_Lvalue -- Sem_Util.Known_To_Be_Assigned -- Exp_Ch2.Expand_Entry_Parameter.In_Assignment_Context @@ -473,20 +474,27 @@ package body Lib.Xref is -- ??? case of a slice assignment? - -- ??? Note that in some cases this is called too early - -- (see comments in Sem_Ch8.Find_Direct_Name), at a point where - -- the tree is not fully typed yet. In that case we may lack - -- an Etype for N, and we must disable the check for an implicit - -- dereference. If the dereference is on an LHS, this causes a - -- false positive. - elsif (K = N_Selected_Component or else K = N_Indexed_Component) and then Prefix (P) = N - and then not (Present (Etype (N)) - and then - Is_Access_Type (Etype (N))) then - N := P; + -- Check for access type. First a kludge, In some cases this is + -- called too early (see comments in Sem_Ch8.Find_Direct_Name), + -- at a point where the tree is not fully typed yet. In that + -- case we may lack an Etype for N, and we can't check the + -- Etype. For now, we always return False in such a case, + -- but this is clearly not right in all cases ??? + + if No (Etype (N)) then + return False; + + elsif Is_Access_Type (Etype (N)) then + return False; + + -- Access type case dealt with, keep going + + else + N := P; + end if; -- All other cases, definitely not on left side @@ -1069,6 +1077,27 @@ package body Lib.Xref is Ref_Scope => Empty, Ent_Scope => Empty), Ent_Scope_File => No_Unit); + + -- Generate reference to the first private entity + + if Typ = 'e' + and then Comes_From_Source (E) + and then Nkind (Ent) = N_Defining_Identifier + and then (Is_Package_Or_Generic_Package (Ent) + or else Is_Concurrent_Type (Ent)) + and then Present (First_Private_Entity (E)) + and then In_Extended_Main_Source_Unit (N) + then + Add_Entry + ((Ent => Ent, + Loc => Sloc (First_Private_Entity (E)), + Typ => 'E', + Eun => Get_Source_Unit (Def), + Lun => Get_Source_Unit (Ref), + Ref_Scope => Empty, + Ent_Scope => Empty), + Ent_Scope_File => No_Unit); + end if; end if; end if; end Generate_Reference; @@ -1309,22 +1338,6 @@ package body Lib.Xref is Right := '>'; end if; - -- For a synchronized type that implements an interface, we - -- treat the first progenitor as the parent. This is only - -- needed when compiling a package declaration on its own, - -- if the body is present interfaces are handled properly. - - elsif Is_Concurrent_Type (Tref) - and then Is_Tagged_Type (Tref) - and then not Expander_Active - then - if Left /= '(' then - Left := '<'; - Right := '>'; - end if; - - Tref := Entity (First (Interface_List (Parent (Tref)))); - -- If the completion of a private type is itself a derived -- type, we need the parent of the full view. @@ -2430,25 +2443,42 @@ package body Lib.Xref is Check_Type_Reference (XE.Key.Ent, False); - -- Additional information for types with progenitors + -- Additional information for types with progenitors, + -- including synchronized tagged types. - if Is_Record_Type (XE.Key.Ent) - and then Present (Interfaces (XE.Key.Ent)) - then - declare - Elmt : Elmt_Id := - First_Elmt (Interfaces (XE.Key.Ent)); - begin - while Present (Elmt) loop - Check_Type_Reference (Node (Elmt), True); - Next_Elmt (Elmt); - end loop; - end; + declare + Typ : constant Entity_Id := XE.Key.Ent; + Elmt : Elmt_Id; + + begin + if Is_Record_Type (Typ) + and then Present (Interfaces (Typ)) + then + Elmt := First_Elmt (Interfaces (Typ)); + + elsif Is_Concurrent_Type (Typ) + and then Present (Corresponding_Record_Type (Typ)) + and then Present ( + Interfaces (Corresponding_Record_Type (Typ))) + then + Elmt := + First_Elmt ( + Interfaces (Corresponding_Record_Type (Typ))); + + else + Elmt := No_Elmt; + end if; + + while Present (Elmt) loop + Check_Type_Reference (Node (Elmt), True); + Next_Elmt (Elmt); + end loop; + end; -- For array types, list index types as well. (This is -- not C, indexes have distinct types). - elsif Is_Array_Type (XE.Key.Ent) then + if Is_Array_Type (XE.Key.Ent) then declare Indx : Node_Id; begin diff --git a/gcc/ada/lib-xref.ads b/gcc/ada/lib-xref.ads index baa07daade9..a0d5370d575 100644 --- a/gcc/ada/lib-xref.ads +++ b/gcc/ada/lib-xref.ads @@ -175,6 +175,7 @@ package Lib.Xref is -- d = discriminant of type -- D = object definition -- e = end of spec + -- E = first private entity -- H = abstract type -- i = implicit reference -- k = implicit reference to parent unit in child unit diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index 84b7a3b64e0..c8c605313e1 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -4556,14 +4556,13 @@ package body Make is if Main_Project /= No_Project then - -- Put all the source directories in ADA_INCLUDE_PATH, - -- and all the object directories in ADA_OBJECTS_PATH, - -- except those of library projects. + -- Put all the source directories in ADA_INCLUDE_PATH, and all the + -- object directories in ADA_OBJECTS_PATH. Prj.Env.Set_Ada_Paths (Project => Main_Project, In_Tree => Project_Tree, - Including_Libraries => False, + Including_Libraries => True, Include_Path => Use_Include_Path_File); -- If switch -C was specified, create a binder mapping file diff --git a/gcc/ada/makeutl.adb b/gcc/ada/makeutl.adb index aef82cba856..4a8f8a8758d 100644 --- a/gcc/ada/makeutl.adb +++ b/gcc/ada/makeutl.adb @@ -2485,6 +2485,24 @@ package body Makeutl is return False; end if; + -- For gprbuild, check if a source has already been inserted in the + -- queue from the same project in a different project tree. + + if Source.Format = Format_Gprbuild then + for J in 1 .. Q.Last loop + if Source.Id.Path.Name = Q.Table (J).Info.Id.Path.Name + and then Source.Id.Index = Q.Table (J).Info.Id.Index + and then Source.Id.Project.Path.Name = + Q.Table (J).Info.Id.Project.Path.Name + then + -- No need to insert this source in the queue, but still + -- return True as we may need to insert its roots. + + return True; + end if; + end loop; + end if; + if Current_Verbosity = High then Write_Str ("Adding """); Debug_Display (Source); diff --git a/gcc/ada/mlib-tgt-specific-lynxos.adb b/gcc/ada/mlib-tgt-specific-lynxos.adb deleted file mode 100644 index cb1f8772e1d..00000000000 --- a/gcc/ada/mlib-tgt-specific-lynxos.adb +++ /dev/null @@ -1,149 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT COMPILER COMPONENTS -- --- -- --- M L I B . T G T . S P E C I F I C -- --- (LynxOS Version) -- --- -- --- B o d y -- --- -- --- Copyright (C) 2003-2008, Free Software Foundation, Inc. -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- --- for more details. You should have received a copy of the GNU General -- --- Public License distributed with GNAT; see file COPYING3. If not, go to -- --- http://www.gnu.org/licenses for a complete copy of the license. -- --- -- --- GNAT was originally developed by the GNAT team at New York University. -- --- Extensive contributions were provided by Ada Core Technologies Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is the LynxOS version of the body - -package body MLib.Tgt.Specific is - - -- Non default subprograms - - procedure Build_Dynamic_Library - (Ofiles : Argument_List; - Options : Argument_List; - Interfaces : Argument_List; - Lib_Filename : String; - Lib_Dir : String; - Symbol_Data : Symbol_Record; - Driver_Name : Name_Id := No_Name; - Lib_Version : String := ""; - Auto_Init : Boolean := False); - - function DLL_Ext return String; - - function Dynamic_Option return String; - - function PIC_Option return String; - - function Library_Major_Minor_Id_Supported return Boolean; - - function Standalone_Library_Auto_Init_Is_Supported return Boolean; - - function Support_For_Libraries return Library_Support; - - --------------------------- - -- Build_Dynamic_Library -- - --------------------------- - - procedure Build_Dynamic_Library - (Ofiles : Argument_List; - Options : Argument_List; - Interfaces : Argument_List; - Lib_Filename : String; - Lib_Dir : String; - Symbol_Data : Symbol_Record; - Driver_Name : Name_Id := No_Name; - Lib_Version : String := ""; - Auto_Init : Boolean := False) - is - pragma Unreferenced (Ofiles); - pragma Unreferenced (Options); - pragma Unreferenced (Interfaces); - pragma Unreferenced (Lib_Filename); - pragma Unreferenced (Lib_Dir); - pragma Unreferenced (Symbol_Data); - pragma Unreferenced (Driver_Name); - pragma Unreferenced (Lib_Version); - pragma Unreferenced (Auto_Init); - - begin - null; - end Build_Dynamic_Library; - - ------------- - -- DLL_Ext -- - ------------- - - function DLL_Ext return String is - begin - return ""; - end DLL_Ext; - - -------------------- - -- Dynamic_Option -- - -------------------- - - function Dynamic_Option return String is - begin - return ""; - end Dynamic_Option; - - -------------------------------------- - -- Library_Major_Minor_Id_Supported -- - -------------------------------------- - - function Library_Major_Minor_Id_Supported return Boolean is - begin - return False; - end Library_Major_Minor_Id_Supported; - - ---------------- - -- PIC_Option -- - ---------------- - - function PIC_Option return String is - begin - return ""; - end PIC_Option; - - ----------------------------------------------- - -- Standalone_Library_Auto_Init_Is_Supported -- - ----------------------------------------------- - - function Standalone_Library_Auto_Init_Is_Supported return Boolean is - begin - return False; - end Standalone_Library_Auto_Init_Is_Supported; - - --------------------------- - -- Support_For_Libraries -- - --------------------------- - - function Support_For_Libraries return Library_Support is - begin - return Static_Only; - end Support_For_Libraries; - -begin - Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access; - DLL_Ext_Ptr := DLL_Ext'Access; - Dynamic_Option_Ptr := Dynamic_Option'Access; - Library_Major_Minor_Id_Supported_Ptr := - Library_Major_Minor_Id_Supported'Access; - PIC_Option_Ptr := PIC_Option'Access; - Standalone_Library_Auto_Init_Is_Supported_Ptr := - Standalone_Library_Auto_Init_Is_Supported'Access; - Support_For_Libraries_Ptr := Support_For_Libraries'Access; -end MLib.Tgt.Specific; diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb index ce23faacaab..30623ea5720 100644 --- a/gcc/ada/opt.adb +++ b/gcc/ada/opt.adb @@ -64,6 +64,7 @@ package body Opt is Polling_Required_Config := Polling_Required; Short_Descriptors_Config := Short_Descriptors; SPARK_Mode_Config := SPARK_Mode; + SPARK_Mode_Pragma_Config := SPARK_Mode_Pragma; Use_VADS_Size_Config := Use_VADS_Size; -- Reset the indication that Optimize_Alignment was set locally, since @@ -100,6 +101,7 @@ package body Opt is Polling_Required := Save.Polling_Required; Short_Descriptors := Save.Short_Descriptors; SPARK_Mode := Save.SPARK_Mode; + SPARK_Mode_Pragma := Save.SPARK_Mode_Pragma; Use_VADS_Size := Save.Use_VADS_Size; -- Update consistently the value of Init_Or_Norm_Scalars. The value of @@ -137,6 +139,7 @@ package body Opt is Save.Polling_Required := Polling_Required; Save.Short_Descriptors := Short_Descriptors; Save.SPARK_Mode := SPARK_Mode; + Save.SPARK_Mode_Pragma := SPARK_Mode_Pragma; Save.Use_VADS_Size := Use_VADS_Size; end Save_Opt_Config_Switches; @@ -167,20 +170,24 @@ package body Opt is Persistent_BSS_Mode := False; Use_VADS_Size := False; Optimize_Alignment_Local := True; - SPARK_Mode := Auto; -- For an internal unit, assertions/debug pragmas are off unless this -- is the main unit and they were explicitly enabled. We also make - -- sure we do not assume that values are necessarily valid. + -- sure we do not assume that values are necessarily valid and that + -- SPARK_Mode is set to its configuration value. if Main_Unit then Assertions_Enabled := Assertions_Enabled_Config; Assume_No_Invalid_Values := Assume_No_Invalid_Values_Config; Check_Policy_List := Check_Policy_List_Config; + SPARK_Mode := SPARK_Mode_Config; + SPARK_Mode_Pragma := SPARK_Mode_Pragma_Config; else Assertions_Enabled := False; Assume_No_Invalid_Values := False; Check_Policy_List := Empty; + SPARK_Mode := None; + SPARK_Mode_Pragma := Empty; end if; -- Case of non-internal unit @@ -203,6 +210,7 @@ package body Opt is Optimize_Alignment_Local := False; Persistent_BSS_Mode := Persistent_BSS_Mode_Config; SPARK_Mode := SPARK_Mode_Config; + SPARK_Mode_Pragma := SPARK_Mode_Pragma_Config; Use_VADS_Size := Use_VADS_Size_Config; -- Update consistently the value of Init_Or_Norm_Scalars. The value diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 8f0fa52ae2c..f5349f55b2d 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -1064,6 +1064,7 @@ package Opt is -- object directory, if project files are used. type Operating_Mode_Type is (Check_Syntax, Check_Semantics, Generate_Code); + pragma Ordered (Operating_Mode_Type); Operating_Mode : Operating_Mode_Type := Generate_Code; -- GNAT -- Indicates the operating mode of the compiler. The default is generate @@ -1072,7 +1073,8 @@ package Opt is -- only mode. Operating_Mode can also be modified as a result of detecting -- errors during the compilation process. In particular if any serious -- error is detected then this flag is reset from Generate_Code to - -- Check_Semantics after generating an error message. + -- Check_Semantics after generating an error message. This is an ordered + -- type with the semantics that each value does more than the previous one. Optimize_Alignment : Character := 'O'; -- Setting of Optimize_Alignment, set to T/S/O for time/space/off. Can @@ -1264,9 +1266,9 @@ package Opt is -- GNAT -- Set True if a pragma Short_Descriptors applies to the current unit. - type SPARK_Mode_Type is (None, Off, Auto, On); - pragma Ordered (SPARK_Mode_Type); - -- Possible legal modes that can be set by aspect/pragma SPARK_Mode + type SPARK_Mode_Type is (None, Off, On); + -- Possible legal modes that can be set by aspect/pragma SPARK_Mode, as + -- well as the value None, which indicates no such pragma/aspect applies. SPARK_Mode : SPARK_Mode_Type := None; -- GNAT @@ -1290,17 +1292,14 @@ package Opt is Sprint_Line_Limit : Nat := 72; -- GNAT - -- Limit values for chopping long lines in Sprint output, can be reset - -- by use of NNN parameter with -gnatG or -gnatD switches. + -- Limit values for chopping long lines in Sprint output, can be reset by + -- use of NNN parameter with -gnatG or -gnatD switches. - Stack_Checking_Enabled : Boolean; + Stack_Checking_Enabled : Boolean := False; -- GNAT - -- Set to indicate if -fstack-check switch is set for the compilation. True - -- means that the switch is set, so that stack checking is enabled. False - -- means that the switch is not set (no stack checking). This value is - -- obtained from the external imported value flag_stack_check in the gcc - -- backend (see Frontend) and may be referenced throughout the compilation - -- phases. + -- Set to indicate if stack checking is enabled for the compilation. This + -- is set directly from the value in the gcc back end in the body of the + -- gcc version of back_end.adb. Style_Check : Boolean := False; -- GNAT @@ -1956,7 +1955,7 @@ package Opt is procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type); -- This procedure restores a set of switch values previously saved by a - -- call to Save_Opt_Switches. + -- call to Save_Opt_Config_Switches (Save). procedure Register_Opt_Config_Switches; -- This procedure is called after processing the gnat.adc file and other diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb index e20cf11a685..779acc34ae9 100644 --- a/gcc/ada/par-ch5.adb +++ b/gcc/ada/par-ch5.adb @@ -506,6 +506,24 @@ package body Ch5 is Scan; -- past semicolon Statement_Required := False; + -- Here is the special test for a suspicious label, more + -- accurately a suspicious name, which we think perhaps + -- should have been a label. If next token is one of + -- LOOP, FOR, WHILE, DECLARE, BEGIN, then make an entry + -- in the suspicious label table. + + if Token = Tok_Loop or else + Token = Tok_For or else + Token = Tok_While or else + Token = Tok_Declare or else + Token = Tok_Begin + then + Suspicious_Labels.Append + ((Proc_Call => Id_Node, + Semicolon_Loc => Prev_Token_Ptr, + Start_Token => Token_Ptr)); + end if; + -- Check for case of "go to" in place of "goto" elsif Token = Tok_Identifier @@ -1718,6 +1736,18 @@ package body Ch5 is elsif Token = Tok_In then Scan; -- past IN + elsif Prev_Token = Tok_In + and then Present (Subtype_Indication (Node1)) + then + -- Simplest recovery is to transform it into an element iterator. + -- Error message on 'in" has already been emitted when parsing the + -- optional constraint. + + Set_Of_Present (Node1); + Error_Msg_N + ("subtype indication is only legal on an element iterator", + Subtype_Indication (Node1)); + else return Error; end if; diff --git a/gcc/ada/par-endh.adb b/gcc/ada/par-endh.adb index e6d4e19d6ac..e41e7a31ba4 100644 --- a/gcc/ada/par-endh.adb +++ b/gcc/ada/par-endh.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -711,17 +711,67 @@ package body Endh is ------------------------ procedure Evaluate_End_Entry (SS_Index : Nat) is + STE : Scope_Table_Entry renames Scope.Table (SS_Index); + begin - Column_OK := (End_Column = Scope.Table (SS_Index).Ecol); + Column_OK := (End_Column = STE.Ecol); - Token_OK := (End_Type = Scope.Table (SS_Index).Etyp or else - (End_Type = E_Name and then - Scope.Table (SS_Index).Etyp >= E_Name)); + Token_OK := (End_Type = STE.Etyp + or else (End_Type = E_Name and then STE.Etyp >= E_Name)); Label_OK := End_Labl_Present - and then - (Same_Label (End_Labl, Scope.Table (SS_Index).Labl) - or else Scope.Table (SS_Index).Labl = Error); + and then (Same_Label (End_Labl, STE.Labl) + or else STE.Labl = Error); + + -- Special case to consider. Suppose we have the suspicious label case, + -- e.g. a situation like: + + -- My_Label; + -- declare + -- ... + -- begin + -- ... + -- end My_Label; + + -- This is the case where we want to use the entry in the suspicous + -- label table to flag the semicolon saying it should be a colon. + + -- Label_OK will be false because the label does not match (we have + -- My_Label on the end line, and the generated name for the scope). Also + -- End_Labl_Present will be True. + + if not Label_OK + and then End_Labl_Present + and then not Comes_From_Source (Scope.Table (SS_Index).Labl) + then + -- Here is where we will search the suspicious labels table + + for J in 1 .. Suspicious_Labels.Last loop + declare + SLE : Suspicious_Label_Entry renames + Suspicious_Labels.Table (J); + begin + -- See if character name of label matches + + if Chars (Name (SLE.Proc_Call)) = Chars (End_Labl) + + -- And first token of loop/block identifies this entry + + and then SLE.Start_Token = STE.Sloc + then + -- We have the special case, issue the error message + + Error_Msg -- CODEFIX + (""";"" should be "":""", SLE.Semicolon_Loc); + + -- And indicate we consider the Label OK after all + + Label_OK := True; + exit; + end if; + end; + end loop; + end if; -- Compute setting of Syntax_OK. We definitely have a syntax error -- if the Token does not match properly or if P_End_Scan detected diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index 6788692864e..7e69166ddc0 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -535,6 +535,66 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is Table_Increment => 100, Table_Name => "Scope"); + ------------------------------------------ + -- Table for Handling Suspicious Labels -- + ------------------------------------------ + + -- This is a special data structure which is used to deal very spefifically + -- with the following error case + + -- label; + -- loop + -- ... + -- end loop label; + + -- Similar cases apply to FOR, WHILE, DECLARE, or BEGIN + + -- In each case the opening line looks like a procedure call because of + -- the semicolon. And the end line looks illegal because of an unexpected + -- label. If we did nothing special, we would just diagnose the label on + -- the end as unexpected. But that does not help point to the real error + -- which is that the semicolon after label should be a colon. + + -- To deal with this, we build an entry in the Suspicious_Labels table + -- whenever we encounter an identifier followed by a semicolon, followed + -- by one of LOOP, FOR, WHILE, DECLARE, BEGIN. Then this entry is used to + -- issue the right message when we hit the END that confirms that this was + -- a bad label. + + type Suspicious_Label_Entry is record + Proc_Call : Node_Id; + -- Node for the procedure call statement built for the label; construct + + Semicolon_Loc : Source_Ptr; + -- Location of the possibly wrong semicolon + + Start_Token : Source_Ptr; + -- Source location of the LOOP, FOR, WHILE, DECLARE, BEGIN token + end record; + + package Suspicious_Labels is new Table.Table ( + Table_Component_Type => Suspicious_Label_Entry, + Table_Index_Type => Int, + Table_Low_Bound => 1, + Table_Initial => 50, + Table_Increment => 100, + Table_Name => "Suspicious_Labels"); + + -- Now when we are about to issue a message complaining about an END label + -- that should not be there because it appears to end a construct that has + -- no label, we first search the suspicious labels table entry, using the + -- source location stored in the scope table as a key. If we find a match, + -- then we check that the label on the end matches the name in the call, + -- and if so, we issue a message saying the semicolon should be a colon. + + -- Quite a bit of work, but really helpful in the case where it helps, and + -- the need for this is based on actual experience with tracking down this + -- kind of error (the eye often easily mistakes semicolon for colon!) + + -- Note: we actually have enough information to patch up the tree, but + -- this may not be worth the effort! Also we could deal with the same + -- situation for EXIT with a label, but for now don't bother with that! + --------------------------------- -- Parsing Routines by Chapter -- --------------------------------- diff --git a/gcc/ada/prj-attr.adb b/gcc/ada/prj-attr.adb index 4f818f84717..297d49b6790 100644 --- a/gcc/ada/prj-attr.adb +++ b/gcc/ada/prj-attr.adb @@ -369,6 +369,7 @@ package body Prj.Attr is "Premote#" & "SVroot_dir#" & + "LVexcluded_patterns#" & -- package Stack diff --git a/gcc/ada/prj-conf.adb b/gcc/ada/prj-conf.adb index f16509b18ab..dc569627b88 100644 --- a/gcc/ada/prj-conf.adb +++ b/gcc/ada/prj-conf.adb @@ -1372,19 +1372,27 @@ package body Prj.Conf is Get_Project_Target; Check_Builder_Switches; - if Conf_File_Name'Length > 0 then - Config_File_Path := Locate_Config_File (Conf_File_Name.all); + -- Do not attempt to find a configuration project file when + -- Config_File_Name is No_Configuration_File. + + if Config_File_Name = No_Configuration_File then + Config_File_Path := null; + else - Config_File_Path := Locate_Config_File (Default_File_Name); - end if; + if Conf_File_Name'Length > 0 then + Config_File_Path := Locate_Config_File (Conf_File_Name.all); + else + Config_File_Path := Locate_Config_File (Default_File_Name); + end if; - if Config_File_Path = null then - if not Allow_Automatic_Generation - and then Conf_File_Name'Length > 0 - then - Raise_Invalid_Config - ("could not locate main configuration project " - & Conf_File_Name.all); + if Config_File_Path = null then + if not Allow_Automatic_Generation + and then Conf_File_Name'Length > 0 + then + Raise_Invalid_Config + ("could not locate main configuration project " + & Conf_File_Name.all); + end if; end if; end if; @@ -1415,7 +1423,8 @@ package body Prj.Conf is and then On_Load_Config = null then Write_Line - ("warning: --RTS is taken into account only in auto-configuration"); + ("warning: " & + "--RTS is taken into account only in auto-configuration"); end if; -- Parse the configuration file @@ -1425,12 +1434,7 @@ package body Prj.Conf is Write_Line (Config_File_Path.all); end if; - if On_Load_Config /= null then - On_Load_Config - (Config_File => Config_Project_Node, - Project_Node_Tree => Project_Node_Tree); - - elsif Config_File_Path /= null then + if Config_File_Path /= null then Prj.Part.Parse (In_Tree => Project_Node_Tree, Project => Config_Project_Node, @@ -1444,6 +1448,12 @@ package body Prj.Conf is Config_Project_Node := Empty_Node; end if; + if On_Load_Config /= null then + On_Load_Config + (Config_File => Config_Project_Node, + Project_Node_Tree => Project_Node_Tree); + end if; + if Config_Project_Node /= Empty_Node then Prj.Proc.Process_Project_Tree_Phase_1 (In_Tree => Project_Tree, diff --git a/gcc/ada/prj-conf.ads b/gcc/ada/prj-conf.ads index 1c72fa769ba..467d9741e03 100644 --- a/gcc/ada/prj-conf.ads +++ b/gcc/ada/prj-conf.ads @@ -40,6 +40,12 @@ package Prj.Conf is -- is set to Empty_Node when this procedure is called. You can then decide -- to create a new config file if you need. + No_Configuration_File : constant String := "/"; + -- When specified as a parameter Config_File_Name in the procedures below, + -- no existing configuration project file is parsed. This is used by + -- gnatmake, gnatclean and the GNAT driver to avoid parsing an existing + -- default configuration project file. + procedure Parse_Project_And_Apply_Config (Main_Project : out Prj.Project_Id; User_Project_Node : out Prj.Tree.Project_Node_Id; @@ -68,6 +74,10 @@ package Prj.Conf is -- happened while parsing the project itself (i.e. creating the tree), -- User_Project_Node is also set to Empty_Node. -- + -- If Config_File_Name is No_Configuration_File, then no configuration + -- project file is parsed. Normally, in this case On_Load_Config is not + -- null, and it is used to create a configuration project file in memory. + -- -- Autoconf_Specified indicates whether the user has specified --autoconf. -- If this is the case, the config file might be (re)generated, as -- appropriate, to match languages and target if the one specified doesn't diff --git a/gcc/ada/prj-dect.adb b/gcc/ada/prj-dect.adb index b1a1738412c..2ce031046ee 100644 --- a/gcc/ada/prj-dect.adb +++ b/gcc/ada/prj-dect.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -253,6 +253,16 @@ package body Prj.Dect is or else Name = Snames.Name_Exec_Dir or else Name = Snames.Name_Source_Dirs or else Name = Snames.Name_Inherit_Source_Path + or else + (Qualif = Aggregate and then Name = Snames.Name_Library_Dir) + or else + (Qualif = Aggregate and then Name = Snames.Name_Library_Name) + or else Name = Snames.Name_Main + or else Name = Snames.Name_Roots + or else Name = Snames.Name_Externally_Built + or else Name = Snames.Name_Executable + or else Name = Snames.Name_Executable_Suffix + or else Name = Snames.Name_Default_Switches then Error_Msg_Name_1 := Name; Error_Msg diff --git a/gcc/ada/prj-env.adb b/gcc/ada/prj-env.adb index 67b077f372f..b50481e0d2f 100644 --- a/gcc/ada/prj-env.adb +++ b/gcc/ada/prj-env.adb @@ -40,7 +40,7 @@ with GNAT.Directory_Operations; use GNAT.Directory_Operations; package body Prj.Env is Buffer_Initial : constant := 1_000; - -- Initial size of Buffer + -- Initial arbitrary size of buffers Uninitialized_Prefix : constant String := '#' & Path_Separator; -- Prefix to indicate that the project path has not been initialized yet. @@ -147,11 +147,11 @@ package body Prj.Env is begin if Recursive then - -- If it is the first time we call this function for - -- this project, compute the source path + -- If it is the first time we call this function for this project, + -- compute the source path if Project.Ada_Include_Path = null then - Buffer := new String (1 .. 4096); + Buffer := new String (1 .. Buffer_Initial); For_All_Projects (Project, In_Tree, Dummy, Include_Aggregated => True); Project.Ada_Include_Path := new String'(Buffer (1 .. Buffer_Last)); @@ -161,7 +161,7 @@ package body Prj.Env is return Project.Ada_Include_Path.all; else - Buffer := new String (1 .. 4096); + Buffer := new String (1 .. Buffer_Initial); Add_To_Path (Project.Source_Dirs, In_Tree.Shared, Buffer, Buffer_Last); @@ -219,21 +219,36 @@ package body Prj.Env is Dummy : Boolean := False; + Result : String_Access; + -- Start of processing for Ada_Objects_Path begin -- If it is the first time we call this function for -- this project, compute the objects path - if Project.Ada_Objects_Path = null then - Buffer := new String (1 .. 4096); - For_All_Projects (Project, In_Tree, Dummy); + if Including_Libraries and then Project.Ada_Objects_Path /= null then + return Project.Ada_Objects_Path; - Project.Ada_Objects_Path := new String'(Buffer (1 .. Buffer_Last)); + elsif not Including_Libraries + and then Project.Ada_Objects_Path_No_Libs /= null + then + return Project.Ada_Objects_Path_No_Libs; + + else + Buffer := new String (1 .. Buffer_Initial); + For_All_Projects (Project, In_Tree, Dummy); + Result := new String'(Buffer (1 .. Buffer_Last)); Free (Buffer); - end if; - return Project.Ada_Objects_Path; + if Including_Libraries then + Project.Ada_Objects_Path := Result; + else + Project.Ada_Objects_Path_No_Libs := Result; + end if; + + return Result; + end if; end Ada_Objects_Path; ------------------- @@ -2229,19 +2244,20 @@ package body Prj.Env is Directory : String; Path : out Namet.Path_Name_Type) is + Result : String_Access; + Has_Dot : Boolean := False; + Key : Name_Id; + File : constant String := Project_File_Name; -- Have to do a copy, in case the parameter is Name_Buffer, which we - -- modify below - - function Try_Path_Name is new Find_Name_In_Path - (Check_Filename => Is_Regular_File); - -- Find a file in the project search path + -- modify below. - -- Local Declarations + Cached_Path : Namet.Path_Name_Type; + -- This should be commented rather than making us guess from the name??? - Result : String_Access; - Has_Dot : Boolean := False; - Key : Name_Id; + function Try_Path_Name is new + Find_Name_In_Path (Check_Filename => Is_Regular_File); + -- Find a file in the project search path -- Start of processing for Find_Project @@ -2259,12 +2275,7 @@ package body Prj.Env is Name_Len := File'Length; Name_Buffer (1 .. Name_Len) := File; Key := Name_Find; - Path := Projects_Paths.Get (Self.Cache, Key); - - if Path /= No_Path then - Debug_Decrease_Indent; - return; - end if; + Cached_Path := Projects_Paths.Get (Self.Cache, Key); -- Check if File contains an extension (a dot before a -- directory separator). If it is the case we do not try project file @@ -2283,13 +2294,42 @@ package body Prj.Env is if not Is_Absolute_Path (File) then + -- If we have found project in the cache, check if in the directory + + if Cached_Path /= No_Path then + declare + Cached : constant String := Get_Name_String (Cached_Path); + begin + if (not Has_Dot + and then Cached = + GNAT.OS_Lib.Normalize_Pathname + (File & Project_File_Extension, + Directory => Directory, + Resolve_Links => Opt.Follow_Links_For_Files, + Case_Sensitive => True)) + or else + Cached = + GNAT.OS_Lib.Normalize_Pathname + (File, + Directory => Directory, + Resolve_Links => Opt.Follow_Links_For_Files, + Case_Sensitive => True) + then + Path := Cached_Path; + Debug_Decrease_Indent; + return; + end if; + end; + end if; + -- First we try <directory>/<file_name>.<extension> if not Has_Dot then - Result := Try_Path_Name - (Self, - Directory & Directory_Separator & - File & Project_File_Extension); + Result := + Try_Path_Name + (Self, + Directory & Directory_Separator & + File & Project_File_Extension); end if; -- Then we try <directory>/<file_name> @@ -2300,6 +2340,14 @@ package body Prj.Env is end if; end if; + -- If we found the path in the cache, this is the one + + if Result = null and then Cached_Path /= No_Path then + Path := Cached_Path; + Debug_Decrease_Indent; + return; + end if; + -- Then we try <file_name>.<extension> if Result = null and then not Has_Dot then diff --git a/gcc/ada/prj-env.ads b/gcc/ada/prj-env.ads index 39d805c2bc6..831ce8c4a2b 100644 --- a/gcc/ada/prj-env.ads +++ b/gcc/ada/prj-env.ads @@ -90,9 +90,12 @@ package Prj.Env is (Project : Project_Id; In_Tree : Project_Tree_Ref; Including_Libraries : Boolean := True) return String_Access; - -- Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute - -- it and cache it. When Including_Libraries is False, do not include the - -- object directories of the library projects, and do not cache the result. + -- Get the ADA_OBJECTS_PATH of a Project file. For the first call with the + -- exact same parameters, compute it and cache it. When Including_Libraries + -- is False, the object directory of a library project is replaced with the + -- library ALI directory of this project (usually the library directory of + -- the project, except when attribute Library_ALI_Dir is declared) except + -- when the library ALI directory does not contain any ALI file. procedure Set_Ada_Paths (Project : Project_Id; diff --git a/gcc/ada/prj-ext.adb b/gcc/ada/prj-ext.adb index 5d49fa4438a..5f134008b1c 100644 --- a/gcc/ada/prj-ext.adb +++ b/gcc/ada/prj-ext.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2000-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2000-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -66,12 +66,39 @@ package body Prj.Ext is (Self : External_References; External_Name : String; Value : String; - Source : External_Source := External_Source'First) + Source : External_Source := External_Source'First; + Silent : Boolean := False) is Key : Name_Id; N : Name_To_Name_Ptr; begin + -- For external attribute, set the environment variable + + if Source = From_External_Attribute and then External_Name /= "" then + declare + Env_Var : String_Access := Getenv (External_Name); + + begin + if Env_Var = null or else Env_Var.all = "" then + Setenv (Name => External_Name, Value => Value); + + if not Silent then + Debug_Output + ("Environment variable """ & External_Name + & """ = """ & Value & '"'); + end if; + + elsif not Silent then + Debug_Output + ("Not overriding existing environment variable """ + & External_Name & """, value is """ & Env_Var.all & '"'); + end if; + + Free (Env_Var); + end; + end if; + Name_Len := External_Name'Length; Name_Buffer (1 .. Name_Len) := External_Name; Canonical_Case_Env_Var_Name (Name_Buffer (1 .. Name_Len)); @@ -87,11 +114,13 @@ package body Prj.Ext is if External_Source'Pos (N.Source) < External_Source'Pos (Source) then - if Current_Verbosity = High then + if not Silent then Debug_Output - ("Not overridding existing variable '" & External_Name - & "', value was defined in " & N.Source'Img); + ("Not overridding existing external reference '" + & External_Name & "', value was defined in " + & N.Source'Img); end if; + return; end if; end if; @@ -105,7 +134,7 @@ package body Prj.Ext is Value => Name_Find, Next => null); - if Current_Verbosity = High then + if not Silent then Debug_Output ("Add external (" & External_Name & ") is", N.Value); end if; diff --git a/gcc/ada/prj-ext.ads b/gcc/ada/prj-ext.ads index 01719cf45fb..ca01959789e 100644 --- a/gcc/ada/prj-ext.ads +++ b/gcc/ada/prj-ext.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2000-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2000-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -68,11 +68,13 @@ package Prj.Ext is (Self : External_References; External_Name : String; Value : String; - Source : External_Source := External_Source'First); + Source : External_Source := External_Source'First; + Silent : Boolean := False); -- Add an external reference (or modify an existing one). No overriding is -- done if the Source's priority is less than the one used to previously -- set the value of the variable. The default for Source is such that - -- overriding always occurs. + -- overriding always occurs. When Silent is True, nothing is output even + -- with non default verbosity. function Value_Of (Self : External_References; diff --git a/gcc/ada/prj-nmsc.adb b/gcc/ada/prj-nmsc.adb index eb647df1492..e6a1f4c601b 100644 --- a/gcc/ada/prj-nmsc.adb +++ b/gcc/ada/prj-nmsc.adb @@ -7051,7 +7051,9 @@ package body Prj.Nmsc is -- Check if it is OK to have the same file name in several -- source directories. - if Source_Dir_Rank = Name_Loc.Source.Source_Dir_Rank then + if Name_Loc.Source /= No_Source + and then Source_Dir_Rank = Name_Loc.Source.Source_Dir_Rank + then Error_Msg_File_1 := File_Name; Error_Msg (Data.Flags, @@ -8395,71 +8397,14 @@ package body Prj.Nmsc is In_Aggregate_Lib : Boolean; Data : in out Tree_Processing_Data) is - procedure Check_Aggregate - (Project : Project_Id; - Data : in out Tree_Processing_Data); - -- Check the aggregate project attributes, reject any not supported - -- attributes. - - procedure Check_Aggregated - (Project : Project_Id; - Data : in out Tree_Processing_Data); - -- Check aggregated projects which should not be externally built. - -- What is Data??? if same as outer Data, why passed??? - -- What exact check is performed here??? Seems a bad idea to have - -- two procedures with such close names ??? - - --------------------- - -- Check_Aggregate -- - --------------------- - - procedure Check_Aggregate - (Project : Project_Id; - Data : in out Tree_Processing_Data) - is - procedure Check_Not_Defined (Name : Name_Id); - -- Report an error if Var is defined - - ----------------------- - -- Check_Not_Defined -- - ----------------------- - - procedure Check_Not_Defined (Name : Name_Id) is - Var : constant Prj.Variable_Value := - Prj.Util.Value_Of - (Name, Project.Decl.Attributes, Data.Tree.Shared); - begin - if not Var.Default then - Error_Msg_Name_1 := Name; - Error_Msg - (Data.Flags, "wrong attribute %% in aggregate library", - Var.Location, Project); - end if; - end Check_Not_Defined; - - -- Start of processing for Check_Aggregate - - begin - Check_Not_Defined (Snames.Name_Library_Dir); - Check_Not_Defined (Snames.Name_Library_Interface); - Check_Not_Defined (Snames.Name_Library_Name); - Check_Not_Defined (Snames.Name_Library_Ali_Dir); - Check_Not_Defined (Snames.Name_Library_Src_Dir); - Check_Not_Defined (Snames.Name_Library_Options); - Check_Not_Defined (Snames.Name_Library_Standalone); - Check_Not_Defined (Snames.Name_Library_Kind); - Check_Not_Defined (Snames.Name_Leading_Library_Options); - Check_Not_Defined (Snames.Name_Library_Version); - end Check_Aggregate; + procedure Check_Aggregated; + -- Check aggregated projects which should not be externally built ---------------------- -- Check_Aggregated -- ---------------------- - procedure Check_Aggregated - (Project : Project_Id; - Data : in out Tree_Processing_Data) - is + procedure Check_Aggregated is L : Aggregated_Project_List; begin @@ -8478,7 +8423,7 @@ package body Prj.Nmsc is Error_Msg_Name_1 := L.Project.Display_Name; Error_Msg (Data.Flags, - "cannot aggregate externally build library %%", + "cannot aggregate externally built project %%", Var.Location, Project); end if; end; @@ -8504,10 +8449,10 @@ package body Prj.Nmsc is case Project.Qualifier is when Aggregate => - Check_Aggregated (Project, Data); + Check_Aggregated; when Aggregate_Library => - Check_Aggregated (Project, Data); + Check_Aggregated; if Project.Object_Directory = No_Path_Information then Project.Object_Directory := Project.Directory; @@ -8532,12 +8477,7 @@ package body Prj.Nmsc is Check_Configuration (Project, Data); - -- For aggregate project check no library attributes are defined - - if Project.Qualifier = Aggregate then - Check_Aggregate (Project, Data); - - else + if Project.Qualifier /= Aggregate then Check_Library_Attributes (Project, Data); Check_Package_Naming (Project, Data); diff --git a/gcc/ada/prj-pars.adb b/gcc/ada/prj-pars.adb index b76a77f1066..7fbce49fa9a 100644 --- a/gcc/ada/prj-pars.adb +++ b/gcc/ada/prj-pars.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -80,13 +80,13 @@ package body Prj.Pars is if Project_Node /= Empty_Node then begin -- No config file should be read from the disk for gnatmake. - -- However, we will simulate one that only contains the - -- default GNAT naming scheme. + -- However, we will simulate one that only contains the default + -- GNAT naming scheme. Process_Project_And_Apply_Config (Main_Project => The_Project, User_Project_Node => Project_Node, - Config_File_Name => "", + Config_File_Name => No_Configuration_File, Autoconf_Specified => False, Project_Tree => In_Tree, Project_Node_Tree => Project_Node_Tree, diff --git a/gcc/ada/prj-proc.adb b/gcc/ada/prj-proc.adb index fe4c252b06e..43a0f87571b 100644 --- a/gcc/ada/prj-proc.adb +++ b/gcc/ada/prj-proc.adb @@ -1969,7 +1969,8 @@ package body Prj.Proc is Add (Env.External, External_Name => Get_Name_String (Index_Name), Value => Get_Name_String (New_Value.Value), - Source => From_External_Attribute); + Source => From_External_Attribute, + Silent => True); else if Current_Verbosity = High then Debug_Output diff --git a/gcc/ada/prj.adb b/gcc/ada/prj.adb index b98f711c5e7..d7e2bc74a6b 100644 --- a/gcc/ada/prj.adb +++ b/gcc/ada/prj.adb @@ -1083,8 +1083,24 @@ package body Prj is ---------------------------- procedure Add_Aggregated_Project - (Project : Project_Id; Path : Path_Name_Type) is + (Project : Project_Id; + Path : Path_Name_Type) + is + Aggregated : Aggregated_Project_List; + begin + -- Check if the project is already in the aggregated project list. If it + -- is, do not add it again. + + Aggregated := Project.Aggregated_Projects; + while Aggregated /= null loop + if Path = Aggregated.Path then + return; + else + Aggregated := Aggregated.Next; + end if; + end loop; + Project.Aggregated_Projects := new Aggregated_Project' (Path => Path, Project => No_Project, @@ -1105,6 +1121,7 @@ package body Prj is Free (Project.Ada_Include_Path); Free (Project.Objects_Path); Free (Project.Ada_Objects_Path); + Free (Project.Ada_Objects_Path_No_Libs); Free_List (Project.Imported_Projects, Free_Project => False); Free_List (Project.All_Imported_Projects, Free_Project => False); Free_List (Project.Languages); @@ -1485,7 +1502,10 @@ package body Prj is if Project.Library then if Project.Object_Directory = No_Path_Information - or else Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name) + or else + (Including_Libraries + and then + Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name)) then return Project.Library_ALI_Dir.Display_Name; else @@ -1838,7 +1858,7 @@ package body Prj is procedure Debug_Output (Str : String; Str2 : Name_Id) is begin - if Current_Verbosity = High then + if Current_Verbosity > Default then Debug_Indent; Set_Standard_Error; Write_Str (Str); diff --git a/gcc/ada/prj.ads b/gcc/ada/prj.ads index 089d0c76c0d..bcfb6d01182 100644 --- a/gcc/ada/prj.ads +++ b/gcc/ada/prj.ads @@ -973,11 +973,12 @@ package Prj is Only_If_Ada : Boolean := False) return Path_Name_Type; -- Return the object directory to use for the project. This depends on -- whether we have a library project or a standard project. This function - -- might return No_Name when no directory applies. - -- If we have a library project file and Including_Libraries is True then - -- the library dir is returned instead of the object dir. - -- If Only_If_Ada is True, then No_Name will be returned when the project - -- doesn't Ada sources. + -- might return No_Name when no directory applies. If the project is a + -- library project file and Including_Libraries is True then the library + -- ALI dir is returned instead of the object dir, except when there is no + -- ALI files in the Library ALI dir and the object directory exists. If + -- Only_If_Ada is True, then No_Name is returned when the project doesn't + -- include any Ada source. procedure Compute_All_Imported_Projects (Root_Project : Project_Id; @@ -1400,9 +1401,14 @@ package Prj is ------------------- Ada_Objects_Path : String_Access := null; - -- The cached value of ADA_OBJECTS_PATH for this project file. Do not - -- use this field directly outside of the compiler, use - -- Prj.Env.Ada_Objects_Path instead. + -- The cached value of ADA_OBJECTS_PATH for this project file, with + -- library ALI directories for library projects instead of object + -- directories. Do not use this field directly outside of the + -- compiler, use Prj.Env.Ada_Objects_Path instead. + + Ada_Objects_Path_No_Libs : String_Access := null; + -- The cached value of ADA_OBJECTS_PATH for this project file with all + -- object directories (no library ALI dir for library projects). Libgnarl_Needed : Yes_No_Unknown := Unknown; -- Set to True when libgnarl is needed to link diff --git a/gcc/ada/projects.texi b/gcc/ada/projects.texi index 8253477fce4..af3387492cc 100644 --- a/gcc/ada/projects.texi +++ b/gcc/ada/projects.texi @@ -1616,6 +1616,10 @@ implementation part of the library implies minimal post-compilation actions on the complete system and potentially no action at all for the rest of the system in the case of dynamic SALs. +There is a restriction on shared library projects: by default, they are only +allowed to import other shared library projects. They are not allowed to +import non library projects or static library projects. + The GNAT Project Manager takes complete care of the library build, rebuild and installation tasks, including recompilation of the source files for which objects do not exist or are not up to date, assembly of the library archive, and @@ -2365,6 +2369,9 @@ aggregate project, you will need to add "p.gpr" in the list of project files for the aggregate project, or the main will not be built when building the aggregate project. +Aggregate projects are only supported with @command{gprbuild}, but not with +@command{gnatmake}. + @c --------------------------------------------------------- @node Building a set of projects with a single command @subsection Building a set of projects with a single command @@ -2404,8 +2411,8 @@ with Annex E. @subsection Define a build environment @c --------------------------------------------- -The environment variables at the time you launch @command{gprbuild} or -@command{gnatmake} will influence the view these tools have of the project +The environment variables at the time you launch @command{gprbuild} +will influence the view these tools have of the project (PATH to find the compiler, ADA_PROJECT_PATH or GPR_PROJECT_PATH to find the projects, environment variables that are referenced in project files through the "external" statement,...). Several command line switches @@ -2462,12 +2469,12 @@ end MyProject; @subsection Performance improvements in builder @c -------------------------------------------- -The loading of aggregate projects is optimized in @command{gprbuild} and -@command{gnatmake}, so that all files are searched for only once on the disk +The loading of aggregate projects is optimized in @command{gprbuild}, +so that all files are searched for only once on the disk (thus reducing the number of system calls and contributing to faster compilation times especially on systems with sources on remote -servers). As part of the loading, @command{gprbuild} and @command{gnatmake} -compute how and where a source file should be compiled, and even if it is found +servers). As part of the loading, @command{gprbuild} +computes how and where a source file should be compiled, and even if it is found several times in the aggregated projects it will be compiled only once. @@ -2663,15 +2670,15 @@ These override the value given by the attribute, so that users can override the value set in the (presumably shared with others in his team) aggregate project. -@item The -X command line switch to @command{gprbuild} and @command{gnatmake} +@item The -X command line switch to @command{gprbuild} This always takes precedence. @end itemize This attribute is only taken into account in the main aggregate -project (i.e. the one specified on the command line to @command{gprbuild} or -@command{gnatmake}), and ignored in other aggregate projects. It is invalid +project (i.e. the one specified on the command line to @command{gprbuild}), +and ignored in other aggregate projects. It is invalid in standard projects. The goal is to have a consistent value in all projects that are built through the aggregate, which would not @@ -2695,13 +2702,15 @@ are valid: @table @asis @item @b{^Switches^Switches^}: @cindex @code{^Switches^Switches^} -This attribute gives the list of switches to use for the builder -(@command{gprbuild} or @command{gnatmake}), depending on the language of the -main file. For instance, +This attribute gives the list of switches to use for @command{gprbuild}. +Because no mains can be specified for aggregate projects, the only possible +index for attribute @code{Switches} is @code{others}. All other indexes will +be ignored. + +Example: @smallexample @c projectfile -for ^Switches^Switches^ ("Ada") use ("-d", "-p"); -for ^Switches^Switches^ ("C") use ("-p"); +for ^Switches^Switches^ (other) use ("-v", "-k", "-j8"); @end smallexample These switches are only read from the main aggregate project (the @@ -2797,7 +2806,7 @@ B), the switches used by the compiler are unambiguous. @cindex @code{Global_Configuration_Pragmas} This attribute can be used to specify a file containing -configuration pragmas, to be passed to the compiler. Since we +configuration pragmas, to be passed to the Ada compiler. Since we ignore the package Builder in other aggregate projects and projects, only those pragmas defined in the main aggregate project will be taken into account. @@ -2805,6 +2814,13 @@ taken into account. Projects can locally add to those by using the @code{Compiler.Local_Configuration_Pragmas} attribute if they need. +@item @b{Global_Config_File} +@cindex @code{Global_Config_File} + +This attribute, indexed with a language name, can be used to specify a config +when compiling sources of the language. For Ada, these files are configuration +pragmas files. + @end table For projects that are built through the aggregate, the package Builder @@ -4384,11 +4400,11 @@ Index is a language name. Indicates the kind of the language, either file based or unit based. Only authorized case-insensitive values are "unit_based" and "file_based" (the default). -@item @b{Dependency_Kind}: : single, indexed, case-insensitive index +@item @b{Dependency_Kind}: single, indexed, case-insensitive index Index is a language name. Indicates how the dependencies are handled for the language. Only authorized case-insensitive values are "makefile", "ali_file", -"ali_closure" or "none" (the default. +"ali_closure" or "none" (the default). @item @b{Required_Switches}: list, indexed, case-insensitive index @@ -4963,10 +4979,12 @@ invoking @code{gnatpp} for the source. @itemize @bullet -@item @b{Build_Slaves}: list +@item @b{Excluded_Patterns}: list -Value is the list of machine names that are to be used in distributed -compilation. +Set of patterns to ignore when synchronizing sources from the build +master to the slaves. A set of predefined patterns are supported +(e.g. *.o, *.ali, *.exe, etc.), this attributes make it possible to +add some more patterns. @item @b{Root_Dir}: single diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index a907c7b9d18..11b92e62c38 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -36,6 +36,7 @@ with Debug; use Debug; with Einfo; use Einfo; with Lib; use Lib; with Namet; use Namet; +with Nlists; use Nlists; with Opt; use Opt; with Output; use Output; with Sem_Aux; use Sem_Aux; @@ -43,6 +44,7 @@ with Sinfo; use Sinfo; with Sinput; use Sinput; with Snames; use Snames; with Stand; use Stand; +with Stringt; use Stringt; with Table; use Table; with Uname; use Uname; with Urealp; use Urealp; @@ -147,6 +149,10 @@ package body Repinfo is procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean); -- List representation info for array type Ent + procedure List_Linker_Section (Ent : Entity_Id); + -- List linker section for Ent (caller has checked that Ent is an entity + -- for which the Linker_Section_Pragma field is defined). + procedure List_Mechanisms (Ent : Entity_Id); -- List mechanism information for parameters of Ent, which is subprogram, -- subprogram type, or an entry or entry family. @@ -352,8 +358,8 @@ package body Repinfo is if List_Representation_Info_Mechanisms and then (Is_Subprogram (Ent) - or else Ekind (Ent) = E_Entry - or else Ekind (Ent) = E_Entry_Family) + or else Ekind (Ent) = E_Entry + or else Ekind (Ent) = E_Entry_Family) then Need_Blank_Line := True; List_Mechanisms (Ent); @@ -374,13 +380,16 @@ package body Repinfo is and then Present (Full_View (E)))) or else Debug_Flag_AA then - if Is_Subprogram (E) - or else - Ekind (E) = E_Entry - or else - Ekind (E) = E_Entry_Family - or else - Ekind (E) = E_Subprogram_Type + if Is_Subprogram (E) then + List_Linker_Section (E); + + if List_Representation_Info_Mechanisms then + List_Mechanisms (E); + end if; + + elsif Ekind_In (E, E_Entry, + E_Entry_Family, + E_Subprogram_Type) then if List_Representation_Info_Mechanisms then List_Mechanisms (E); @@ -391,24 +400,28 @@ package body Repinfo is List_Record_Info (E, Bytes_Big_Endian); end if; + List_Linker_Section (E); + elsif Is_Array_Type (E) then if List_Representation_Info >= 1 then List_Array_Info (E, Bytes_Big_Endian); end if; + List_Linker_Section (E); + elsif Is_Type (E) then if List_Representation_Info >= 2 then List_Type_Info (E); + List_Linker_Section (E); end if; - elsif Ekind (E) = E_Variable - or else - Ekind (E) = E_Constant - or else - Ekind (E) = E_Loop_Parameter - or else - Is_Formal (E) - then + elsif Ekind_In (E, E_Variable, E_Constant) then + if List_Representation_Info >= 2 then + List_Object_Info (E); + List_Linker_Section (E); + end if; + + elsif Ekind (E) = E_Loop_Parameter or else Is_Formal (E) then if List_Representation_Info >= 2 then List_Object_Info (E); end if; @@ -425,17 +438,12 @@ package body Repinfo is -- Recurse into bodies - elsif Ekind (E) = E_Protected_Type - or else - Ekind (E) = E_Task_Type - or else - Ekind (E) = E_Subprogram_Body - or else - Ekind (E) = E_Package_Body - or else - Ekind (E) = E_Task_Body - or else - Ekind (E) = E_Protected_Body + elsif Ekind_In (E, E_Protected_Type, + E_Task_Type, + E_Subprogram_Body, + E_Package_Body, + E_Task_Body, + E_Protected_Body) then List_Entities (E, Bytes_Big_Endian); @@ -633,6 +641,34 @@ package body Repinfo is end if; end List_GCC_Expression; + ------------------------- + -- List_Linker_Section -- + ------------------------- + + procedure List_Linker_Section (Ent : Entity_Id) is + Arg : Node_Id; + + begin + if Present (Linker_Section_Pragma (Ent)) then + Write_Str ("pragma Linker_Section ("); + List_Name (Ent); + Write_Str (", """); + + Arg := + Last (Pragma_Argument_Associations (Linker_Section_Pragma (Ent))); + + if Nkind (Arg) = N_Pragma_Argument_Association then + Arg := Expression (Arg); + end if; + + pragma Assert (Nkind (Arg) = N_String_Literal); + String_To_Name_Buffer (Strval (Arg)); + Write_Str (Name_Buffer (1 .. Name_Len)); + Write_Str (""");"); + Write_Eol; + end if; + end List_Linker_Section; + --------------------- -- List_Mechanisms -- --------------------- diff --git a/gcc/ada/s-interr-dummy.adb b/gcc/ada/s-interr-dummy.adb index 4e1828f71d9..87ed21d0367 100644 --- a/gcc/ada/s-interr-dummy.adb +++ b/gcc/ada/s-interr-dummy.adb @@ -7,7 +7,7 @@ -- B o d y -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2010, AdaCore -- +-- Copyright (C) 1995-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -187,7 +187,10 @@ package body System.Interrupts is -- Install_Restricted_Handlers -- --------------------------------- - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array) is + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array) + is begin Unimplemented; end Install_Restricted_Handlers; diff --git a/gcc/ada/s-interr-hwint.adb b/gcc/ada/s-interr-hwint.adb index 1a43c952840..5cb38ea941c 100644 --- a/gcc/ada/s-interr-hwint.adb +++ b/gcc/ada/s-interr-hwint.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -476,7 +476,11 @@ package body System.Interrupts is -- Install_Restricted_Handlers -- --------------------------------- - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array) is + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array) + is + pragma Unreferenced (Prio); begin for N in Handlers'Range loop Attach_Handler (Handlers (N).Handler, Handlers (N).Interrupt, True); diff --git a/gcc/ada/s-interr-sigaction.adb b/gcc/ada/s-interr-sigaction.adb index 46d38f39be0..233fdc38f28 100644 --- a/gcc/ada/s-interr-sigaction.adb +++ b/gcc/ada/s-interr-sigaction.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2013, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -292,7 +292,11 @@ package body System.Interrupts is -- Install_Restricted_Handlers -- --------------------------------- - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array) is + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array) + is + pragma Unreferenced (Prio); begin for N in Handlers'Range loop Attach_Handler (Handlers (N).Handler, Handlers (N).Interrupt, True); diff --git a/gcc/ada/s-interr-vms.adb b/gcc/ada/s-interr-vms.adb index c43b043685a..16dc88103c2 100644 --- a/gcc/ada/s-interr-vms.adb +++ b/gcc/ada/s-interr-vms.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1098,7 +1098,11 @@ package body System.Interrupts is -- Install_Restricted_Handlers -- --------------------------------- - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array) is + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array) + is + pragma Unreferenced (Prio); begin for N in Handlers'Range loop Attach_Handler (Handlers (N).Handler, Handlers (N).Interrupt, True); diff --git a/gcc/ada/s-interr.adb b/gcc/ada/s-interr.adb index 3d33f6c9e13..7b7b7bd160e 100644 --- a/gcc/ada/s-interr.adb +++ b/gcc/ada/s-interr.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -469,7 +469,11 @@ package body System.Interrupts is -- Install_Restricted_Handlers -- --------------------------------- - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array) is + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array) + is + pragma Unreferenced (Prio); begin for N in Handlers'Range loop Attach_Handler (Handlers (N).Handler, Handlers (N).Interrupt, True); diff --git a/gcc/ada/s-interr.ads b/gcc/ada/s-interr.ads index a771db6f8a3..7c3ed56f9dc 100644 --- a/gcc/ada/s-interr.ads +++ b/gcc/ada/s-interr.ads @@ -266,11 +266,13 @@ package System.Interrupts is -- Store the old handlers in Object.Previous_Handlers and install -- the new static handlers. - procedure Install_Restricted_Handlers (Handlers : New_Handler_Array); - -- Install the static Handlers for the given interrupts and do not store - -- previously installed handlers. This procedure is used when the Ravenscar - -- restrictions are in place since in that case there are only - -- library-level protected handlers that will be installed at - -- initialization and never be replaced. + procedure Install_Restricted_Handlers + (Prio : Any_Priority; + Handlers : New_Handler_Array); + -- Install the static Handlers for the given interrupts and do not + -- store previously installed handlers. This procedure is used when + -- the Ravenscar restrictions are in place since in that case there + -- are only library-level protected handlers that will be installed + -- at initialization and never be replaced. end System.Interrupts; diff --git a/gcc/ada/s-osinte-android.ads b/gcc/ada/s-osinte-android.ads index bdcf4c7495b..2b94f3f05a1 100644 --- a/gcc/ada/s-osinte-android.ads +++ b/gcc/ada/s-osinte-android.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -354,7 +354,10 @@ package System.OS_Interface is (how : int; set : access sigset_t; oset : access sigset_t) return int; - pragma Import (C, pthread_sigmask, "pthread_sigmask"); + pragma Import (C, pthread_sigmask, "sigprocmask"); + -- pthread_sigmask maybe be broken due to mismatch between sigset_t and + -- kernel_sigset_t, substitute sigprocmask temporarily. ??? + -- pragma Import (C, pthread_sigmask, "pthread_sigmask"); -------------------------- -- POSIX.1c Section 11 -- diff --git a/gcc/ada/s-osinte-lynxos-3.adb b/gcc/ada/s-osinte-lynxos-3.adb deleted file mode 100644 index 0a4a3deb463..00000000000 --- a/gcc/ada/s-osinte-lynxos-3.adb +++ /dev/null @@ -1,575 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- S Y S T E M . O S _ I N T E R F A C E -- --- -- --- B o d y -- --- -- --- Copyright (C) 1999-2009, Free Software Foundation, Inc. -- --- -- --- GNARL is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS (Native) version of this package - -pragma Polling (Off); --- Turn off polling, we do not want ATC polling to take place during --- tasking operations. It causes infinite loops and other problems. - -package body System.OS_Interface is - - use Interfaces.C; - - ------------------- - -- clock_gettime -- - ------------------- - - function clock_gettime - (clock_id : clockid_t; - tp : access timespec) - return int - is - function clock_gettime_base - (clock_id : clockid_t; - tp : access timespec) - return int; - pragma Import (C, clock_gettime_base, "clock_gettime"); - - begin - if clock_gettime_base (clock_id, tp) /= 0 then - return errno; - end if; - - return 0; - end clock_gettime; - - ----------------- - -- To_Duration -- - ----------------- - - function To_Duration (TS : timespec) return Duration is - begin - return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; - end To_Duration; - - ------------------------ - -- To_Target_Priority -- - ------------------------ - - function To_Target_Priority - (Prio : System.Any_Priority) return Interfaces.C.int - is - begin - return Interfaces.C.int (Prio); - end To_Target_Priority; - - ----------------- - -- To_Timespec -- - ----------------- - - function To_Timespec (D : Duration) return timespec is - S : time_t; - F : Duration; - - begin - S := time_t (Long_Long_Integer (D)); - F := D - Duration (S); - - -- If F has negative value due to a round-up, adjust for positive F - -- value. - - if F < 0.0 then - S := S - 1; - F := F + 1.0; - end if; - - return timespec'(tv_sec => S, - tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); - end To_Timespec; - - ------------------------- - -- POSIX.1c Section 3 -- - ------------------------- - - function sigwait - (set : access sigset_t; - sig : access Signal) - return int - is - function sigwait_base - (set : access sigset_t; - value : System.Address) - return Signal; - pragma Import (C, sigwait_base, "sigwait"); - - begin - sig.all := sigwait_base (set, Null_Address); - - if sig.all = -1 then - return errno; - end if; - - return 0; - end sigwait; - - -------------------------- - -- POSIX.1c Section 11 -- - -------------------------- - - -- For all the following functions, LynxOS threads has the POSIX Draft 4 - -- behavior; it sets errno but the standard Posix requires it to be - -- returned. - - function pthread_mutexattr_init - (attr : access pthread_mutexattr_t) - return int - is - function pthread_mutexattr_create - (attr : access pthread_mutexattr_t) - return int; - pragma Import (C, pthread_mutexattr_create, "pthread_mutexattr_create"); - - begin - if pthread_mutexattr_create (attr) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutexattr_init; - - function pthread_mutexattr_destroy - (attr : access pthread_mutexattr_t) - return int - is - function pthread_mutexattr_delete - (attr : access pthread_mutexattr_t) - return int; - pragma Import (C, pthread_mutexattr_delete, "pthread_mutexattr_delete"); - - begin - if pthread_mutexattr_delete (attr) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutexattr_destroy; - - function pthread_mutex_init - (mutex : access pthread_mutex_t; - attr : access pthread_mutexattr_t) - return int - is - function pthread_mutex_init_base - (mutex : access pthread_mutex_t; - attr : pthread_mutexattr_t) - return int; - pragma Import (C, pthread_mutex_init_base, "pthread_mutex_init"); - - begin - if pthread_mutex_init_base (mutex, attr.all) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutex_init; - - function pthread_mutex_destroy - (mutex : access pthread_mutex_t) - return int - is - function pthread_mutex_destroy_base - (mutex : access pthread_mutex_t) - return int; - pragma Import (C, pthread_mutex_destroy_base, "pthread_mutex_destroy"); - - begin - if pthread_mutex_destroy_base (mutex) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutex_destroy; - - function pthread_mutex_lock - (mutex : access pthread_mutex_t) - return int - is - function pthread_mutex_lock_base - (mutex : access pthread_mutex_t) - return int; - pragma Import (C, pthread_mutex_lock_base, "pthread_mutex_lock"); - - begin - if pthread_mutex_lock_base (mutex) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutex_lock; - - function pthread_mutex_unlock - (mutex : access pthread_mutex_t) - return int - is - function pthread_mutex_unlock_base - (mutex : access pthread_mutex_t) - return int; - pragma Import (C, pthread_mutex_unlock_base, "pthread_mutex_unlock"); - - begin - if pthread_mutex_unlock_base (mutex) /= 0 then - return errno; - end if; - - return 0; - end pthread_mutex_unlock; - - function pthread_condattr_init - (attr : access pthread_condattr_t) - return int - is - function pthread_condattr_create - (attr : access pthread_condattr_t) - return int; - pragma Import (C, pthread_condattr_create, "pthread_condattr_create"); - - begin - if pthread_condattr_create (attr) /= 0 then - return errno; - end if; - - return 0; - end pthread_condattr_init; - - function pthread_condattr_destroy - (attr : access pthread_condattr_t) - return int - is - function pthread_condattr_delete - (attr : access pthread_condattr_t) - return int; - pragma Import (C, pthread_condattr_delete, "pthread_condattr_delete"); - - begin - if pthread_condattr_delete (attr) /= 0 then - return errno; - end if; - - return 0; - end pthread_condattr_destroy; - - function pthread_cond_init - (cond : access pthread_cond_t; - attr : access pthread_condattr_t) - return int - is - function pthread_cond_init_base - (cond : access pthread_cond_t; - attr : pthread_condattr_t) - return int; - pragma Import (C, pthread_cond_init_base, "pthread_cond_init"); - - begin - if pthread_cond_init_base (cond, attr.all) /= 0 then - return errno; - end if; - - return 0; - end pthread_cond_init; - - function pthread_cond_destroy - (cond : access pthread_cond_t) - return int - is - function pthread_cond_destroy_base - (cond : access pthread_cond_t) - return int; - pragma Import (C, pthread_cond_destroy_base, "pthread_cond_destroy"); - - begin - if pthread_cond_destroy_base (cond) /= 0 then - return errno; - end if; - - return 0; - end pthread_cond_destroy; - - function pthread_cond_signal - (cond : access pthread_cond_t) - return int - is - function pthread_cond_signal_base - (cond : access pthread_cond_t) - return int; - pragma Import (C, pthread_cond_signal_base, "pthread_cond_signal"); - - begin - if pthread_cond_signal_base (cond) /= 0 then - return errno; - end if; - - return 0; - end pthread_cond_signal; - - function pthread_cond_wait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t) - return int - is - function pthread_cond_wait_base - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t) - return int; - pragma Import (C, pthread_cond_wait_base, "pthread_cond_wait"); - - begin - if pthread_cond_wait_base (cond, mutex) /= 0 then - return errno; - end if; - - return 0; - end pthread_cond_wait; - - function pthread_cond_timedwait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t; - reltime : access timespec) return int - is - function pthread_cond_timedwait_base - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t; - reltime : access timespec) return int; - pragma Import (C, pthread_cond_timedwait_base, "pthread_cond_timedwait"); - - begin - if pthread_cond_timedwait_base (cond, mutex, reltime) /= 0 then - if errno = EAGAIN then - return ETIMEDOUT; - end if; - - return errno; - end if; - - return 0; - end pthread_cond_timedwait; - - -------------------------- - -- POSIX.1c Section 13 -- - -------------------------- - - function pthread_setschedparam - (thread : pthread_t; - policy : int; - param : access struct_sched_param) - return int - is - function pthread_setscheduler - (thread : pthread_t; - policy : int; - prio : int) - return int; - pragma Import (C, pthread_setscheduler, "pthread_setscheduler"); - - begin - if pthread_setscheduler (thread, policy, param.sched_priority) = -1 then - return errno; - end if; - - return 0; - end pthread_setschedparam; - - function pthread_mutexattr_setprotocol - (attr : access pthread_mutexattr_t; - protocol : int) - return int - is - pragma Unreferenced (attr, protocol); - begin - return 0; - end pthread_mutexattr_setprotocol; - - function pthread_mutexattr_setprioceiling - (attr : access pthread_mutexattr_t; - prioceiling : int) - return int - is - pragma Unreferenced (attr, prioceiling); - begin - return 0; - end pthread_mutexattr_setprioceiling; - - function pthread_attr_setscope - (attr : access pthread_attr_t; - contentionscope : int) - return int - is - pragma Unreferenced (attr, contentionscope); - begin - return 0; - end pthread_attr_setscope; - - function sched_yield return int is - procedure pthread_yield; - pragma Import (C, pthread_yield, "pthread_yield"); - - begin - pthread_yield; - return 0; - end sched_yield; - - ----------------------------- - -- P1003.1c - Section 16 -- - ----------------------------- - - function pthread_attr_setdetachstate - (attr : access pthread_attr_t; - detachstate : int) - return int - is - pragma Unreferenced (attr, detachstate); - begin - return 0; - end pthread_attr_setdetachstate; - - function pthread_create - (thread : access pthread_t; - attributes : access pthread_attr_t; - start_routine : Thread_Body; - arg : System.Address) - return int - is - -- The LynxOS pthread_create doesn't seems to work. - -- Workaround : We're using st_new instead. - -- - -- function pthread_create_base - -- (thread : access pthread_t; - -- attributes : pthread_attr_t; - -- start_routine : Thread_Body; - -- arg : System.Address) - -- return int; - -- pragma Import (C, pthread_create_base, "pthread_create"); - - St : aliased st_t := attributes.st; - - function st_new - (start_routine : Thread_Body; - arg : System.Address; - attributes : access st_t; - thread : access pthread_t) - return int; - pragma Import (C, st_new, "st_new"); - - begin - -- Following code would be used if above commented function worked - - -- if pthread_create_base - -- (thread, attributes.all, start_routine, arg) /= 0 then - - if st_new (start_routine, arg, St'Access, thread) /= 0 then - return errno; - end if; - - return 0; - end pthread_create; - - function pthread_detach (thread : pthread_t) return int is - aliased_thread : aliased pthread_t := thread; - - function pthread_detach_base (thread : access pthread_t) return int; - pragma Import (C, pthread_detach_base, "pthread_detach"); - - begin - if pthread_detach_base (aliased_thread'Access) /= 0 then - return errno; - end if; - - return 0; - end pthread_detach; - - -------------------------- - -- POSIX.1c Section 17 -- - -------------------------- - - function pthread_setspecific - (key : pthread_key_t; - value : System.Address) - return int - is - function pthread_setspecific_base - (key : pthread_key_t; - value : System.Address) - return int; - pragma Import (C, pthread_setspecific_base, "pthread_setspecific"); - - begin - if pthread_setspecific_base (key, value) /= 0 then - return errno; - end if; - - return 0; - end pthread_setspecific; - - function pthread_getspecific (key : pthread_key_t) return System.Address is - procedure pthread_getspecific_base - (key : pthread_key_t; - value : access System.Address); - pragma Import (C, pthread_getspecific_base, "pthread_getspecific"); - - value : aliased System.Address := System.Null_Address; - - begin - pthread_getspecific_base (key, value'Unchecked_Access); - return value; - end pthread_getspecific; - - function Get_Stack_Base (thread : pthread_t) return Address is - pragma Warnings (Off, thread); - - begin - return Null_Address; - end Get_Stack_Base; - - function pthread_key_create - (key : access pthread_key_t; - destructor : destructor_pointer) - return int - is - function pthread_keycreate - (key : access pthread_key_t; - destructor : destructor_pointer) - return int; - pragma Import (C, pthread_keycreate, "pthread_keycreate"); - - begin - if pthread_keycreate (key, destructor) /= 0 then - return errno; - end if; - - return 0; - end pthread_key_create; - - procedure pthread_init is - begin - null; - end pthread_init; - -end System.OS_Interface; diff --git a/gcc/ada/s-osinte-lynxos-3.ads b/gcc/ada/s-osinte-lynxos-3.ads deleted file mode 100644 index e8288d9f6dd..00000000000 --- a/gcc/ada/s-osinte-lynxos-3.ads +++ /dev/null @@ -1,552 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME COMPONENTS -- --- -- --- S Y S T E M . O S _ I N T E R F A C E -- --- -- --- S p e c -- --- -- --- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNAT was originally developed by the GNAT team at New York University. -- --- Extensive contributions were provided by Ada Core Technologies Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS (Native) version of this package - --- This package encapsulates all direct interfaces to OS services --- that are needed by the tasking run-time (libgnarl). - --- PLEASE DO NOT add any with-clauses to this package or remove the pragma --- Preelaborate. This package is designed to be a bottom-level (leaf) package. - -with Ada.Unchecked_Conversion; - -with Interfaces.C; - -package System.OS_Interface is - pragma Preelaborate; - - pragma Linker_Options ("-mthreads"); - - subtype int is Interfaces.C.int; - subtype char is Interfaces.C.char; - subtype short is Interfaces.C.short; - subtype long is Interfaces.C.long; - subtype unsigned is Interfaces.C.unsigned; - subtype unsigned_short is Interfaces.C.unsigned_short; - subtype unsigned_long is Interfaces.C.unsigned_long; - subtype unsigned_char is Interfaces.C.unsigned_char; - subtype plain_char is Interfaces.C.plain_char; - subtype size_t is Interfaces.C.size_t; - - ----------- - -- Errno -- - ----------- - - function errno return int; - pragma Import (C, errno, "__get_errno"); - - EAGAIN : constant := 11; - EINTR : constant := 4; - EINVAL : constant := 22; - ENOMEM : constant := 12; - ETIMEDOUT : constant := 60; - - ------------- - -- Signals -- - ------------- - - Max_Interrupt : constant := 63; - type Signal is new int range 0 .. Max_Interrupt; - for Signal'Size use int'Size; - - SIGHUP : constant := 1; -- hangup - SIGINT : constant := 2; -- interrupt (rubout) - SIGQUIT : constant := 3; -- quit (ASCD FS) - SIGILL : constant := 4; -- illegal instruction (not reset) - SIGTRAP : constant := 5; -- trace trap (not reset) - SIGBRK : constant := 6; -- break - SIGIOT : constant := 6; -- IOT instruction - SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future - SIGCORE : constant := 7; -- kill with core dump - SIGEMT : constant := 7; -- EMT instruction - SIGFPE : constant := 8; -- floating point exception - SIGKILL : constant := 9; -- kill (cannot be caught or ignored) - SIGBUS : constant := 10; -- bus error - SIGSEGV : constant := 11; -- segmentation violation - SIGSYS : constant := 12; -- bad argument to system call - SIGPIPE : constant := 13; -- write on a pipe with no one to read it - SIGALRM : constant := 14; -- alarm clock - SIGTERM : constant := 15; -- software termination signal from kill - SIGURG : constant := 16; -- urgent condition on IO channel - SIGSTOP : constant := 17; -- stop (cannot be caught or ignored) - SIGTSTP : constant := 18; -- user stop requested from tty - SIGCONT : constant := 19; -- stopped process has been continued - SIGCLD : constant := 20; -- alias for SIGCHLD - SIGCHLD : constant := 20; -- child status change - SIGTTIN : constant := 21; -- background tty read attempted - SIGTTOU : constant := 22; -- background tty write attempted - SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias) - SIGPOLL : constant := 23; -- pollable event occurred - SIGXCPU : constant := 24; -- CPU time limit exceeded - SIGXFSZ : constant := 25; -- filesize limit exceeded - SIGVTALRM : constant := 26; -- virtual timer expired - SIGPROF : constant := 27; -- profiling timer expired - SIGWINCH : constant := 28; -- window size change - SIGLOST : constant := 29; -- SUN 4.1 compatibility - SIGUSR1 : constant := 30; -- user defined signal 1 - SIGUSR2 : constant := 31; -- user defined signal 2 - SIGPRIO : constant := 32; -- sent to a process with its priority or - -- group is changed - - SIGADAABORT : constant := SIGABRT; - -- Change this if you want to use another signal for task abort. - -- SIGTERM might be a good one. - - type Signal_Set is array (Natural range <>) of Signal; - - Unmasked : constant Signal_Set := - (SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF); - Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGPRIO); - - type sigset_t is private; - - function sigaddset (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigaddset, "sigaddset"); - - function sigdelset (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigdelset, "sigdelset"); - - function sigfillset (set : access sigset_t) return int; - pragma Import (C, sigfillset, "sigfillset"); - - function sigismember (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigismember, "sigismember"); - - function sigemptyset (set : access sigset_t) return int; - pragma Import (C, sigemptyset, "sigemptyset"); - - type struct_sigaction is record - sa_handler : System.Address; - sa_mask : sigset_t; - sa_flags : int; - end record; - pragma Convention (C, struct_sigaction); - type struct_sigaction_ptr is access all struct_sigaction; - - SA_SIGINFO : constant := 16#80#; - - SIG_BLOCK : constant := 0; - SIG_UNBLOCK : constant := 1; - SIG_SETMASK : constant := 2; - - SIG_DFL : constant := 0; - SIG_IGN : constant := 1; - - function sigaction - (sig : Signal; - act : struct_sigaction_ptr; - oact : struct_sigaction_ptr) return int; - pragma Import (C, sigaction, "sigaction"); - - ---------- - -- Time -- - ---------- - - Time_Slice_Supported : constant Boolean := True; - -- Indicates whether time slicing is supported - - type timespec is private; - - type clockid_t is new int; - - function clock_gettime - (clock_id : clockid_t; - tp : access timespec) return int; - pragma Inline (clock_gettime); - -- LynxOS has non standard clock_gettime - - function To_Duration (TS : timespec) return Duration; - pragma Inline (To_Duration); - - function To_Timespec (D : Duration) return timespec; - pragma Inline (To_Timespec); - - type struct_timezone is record - tz_minuteswest : int; - tz_dsttime : int; - end record; - pragma Convention (C, struct_timezone); - type struct_timezone_ptr is access all struct_timezone; - - ------------------------- - -- Priority Scheduling -- - ------------------------- - - SCHED_FIFO : constant := 16#00200000#; - SCHED_RR : constant := 16#00100000#; - SCHED_OTHER : constant := 16#00400000#; - - function To_Target_Priority - (Prio : System.Any_Priority) return Interfaces.C.int; - -- Maps System.Any_Priority to a POSIX priority - - ------------- - -- Process -- - ------------- - - type pid_t is private; - - function kill (pid : pid_t; sig : Signal) return int; - pragma Import (C, kill, "kill"); - - function getpid return pid_t; - pragma Import (C, getpid, "getpid"); - - --------- - -- LWP -- - --------- - - function lwp_self return System.Address; - -- lwp_self does not exist on this thread library, revert to pthread_self - -- which is the closest approximation (with getpid). This function is - -- needed to share 7staprop.adb across POSIX-like targets. - pragma Import (C, lwp_self, "pthread_self"); - - ------------- - -- Threads -- - ------------- - - type Thread_Body is access - function (arg : System.Address) return System.Address; - pragma Convention (C, Thread_Body); - - function Thread_Body_Access is new - Ada.Unchecked_Conversion (System.Address, Thread_Body); - - type pthread_t is private; - subtype Thread_Id is pthread_t; - - type pthread_mutex_t is limited private; - type pthread_cond_t is limited private; - type st_t is limited private; - type pthread_attr_t is limited private; - type pthread_mutexattr_t is limited private; - type pthread_condattr_t is limited private; - type pthread_key_t is private; - - PTHREAD_CREATE_DETACHED : constant := 0; - - PTHREAD_SCOPE_PROCESS : constant := 0; - PTHREAD_SCOPE_SYSTEM : constant := 1; - - ----------- - -- Stack -- - ----------- - - Alternate_Stack_Size : constant := 0; - -- No alternate signal stack is used on this platform - - Stack_Base_Available : constant Boolean := False; - -- Indicates whether the stack base is available on this target - - function Get_Stack_Base (thread : pthread_t) return Address; - pragma Inline (Get_Stack_Base); - -- returns the stack base of the specified thread. - -- Only call this function when Stack_Base_Available is True. - - function Get_Page_Size return size_t; - function Get_Page_Size return Address; - pragma Import (C, Get_Page_Size, "getpagesize"); - -- returns the size of a page, or 0 if this is not relevant on this - -- target - - PROT_NONE : constant := 0; - PROT_READ : constant := 1; - PROT_WRITE : constant := 2; - PROT_EXEC : constant := 4; - PROT_USER : constant := 8; - PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC + PROT_USER; - - PROT_ON : constant := PROT_READ; - PROT_OFF : constant := PROT_ALL; - - function mprotect (addr : Address; len : size_t; prot : int) return int; - pragma Import (C, mprotect); - - ------------------------- - -- POSIX.1c Section 3 -- - ------------------------- - - function sigwait - (set : access sigset_t; - sig : access Signal) return int; - pragma Inline (sigwait); - -- LynxOS has non standard sigwait - - function pthread_kill (thread : pthread_t; sig : Signal) return int; - pragma Import (C, pthread_kill, "pthread_kill"); - - function pthread_sigmask - (how : int; - set : access sigset_t; - oset : access sigset_t) return int; - pragma Import (C, pthread_sigmask, "sigprocmask"); - - -------------------------- - -- POSIX.1c Section 11 -- - -------------------------- - - function pthread_mutexattr_init - (attr : access pthread_mutexattr_t) return int; - pragma Inline (pthread_mutexattr_init); - -- LynxOS has a nonstandard pthread_mutexattr_init - - function pthread_mutexattr_destroy - (attr : access pthread_mutexattr_t) return int; - pragma Inline (pthread_mutexattr_destroy); - -- Lynxos has a nonstandard pthread_mutexattr_destroy - - function pthread_mutex_init - (mutex : access pthread_mutex_t; - attr : access pthread_mutexattr_t) return int; - pragma Inline (pthread_mutex_init); - -- LynxOS has a nonstandard pthread_mutex_init - - function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; - pragma Inline (pthread_mutex_destroy); - -- LynxOS has a nonstandard pthread_mutex_destroy - - function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; - pragma Inline (pthread_mutex_lock); - -- LynxOS has a nonstandard pthread_mutex_lock - - function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; - pragma Inline (pthread_mutex_unlock); - -- LynxOS has a nonstandard pthread_mutex_unlock - - function pthread_condattr_init - (attr : access pthread_condattr_t) return int; - pragma Inline (pthread_condattr_init); - -- LynxOS has a nonstandard pthread_condattr_init - - function pthread_condattr_destroy - (attr : access pthread_condattr_t) return int; - pragma Inline (pthread_condattr_destroy); - -- LynxOS has a nonstandard pthread_condattr_destroy - - function pthread_cond_init - (cond : access pthread_cond_t; - attr : access pthread_condattr_t) return int; - pragma Inline (pthread_cond_init); - -- LynxOS has a non standard pthread_cond_init - - function pthread_cond_destroy (cond : access pthread_cond_t) return int; - pragma Inline (pthread_cond_destroy); - -- LynxOS has a nonstandard pthread_cond_destroy - - function pthread_cond_signal (cond : access pthread_cond_t) return int; - pragma Inline (pthread_cond_signal); - -- LynxOS has a nonstandard pthread_cond_signal - - function pthread_cond_wait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t) return int; - pragma Inline (pthread_cond_wait); - -- LynxOS has a nonstandard pthread_cond_wait - - function pthread_cond_timedwait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t; - reltime : access timespec) return int; - pragma Inline (pthread_cond_timedwait); - -- LynxOS has a nonstandard pthread_cond_timedwait - - Relative_Timed_Wait : constant Boolean := True; - -- pthread_cond_timedwait requires a relative delay time - - -------------------------- - -- POSIX.1c Section 13 -- - -------------------------- - - PTHREAD_PRIO_NONE : constant := 0; - PTHREAD_PRIO_INHERIT : constant := 0; - PTHREAD_PRIO_PROTECT : constant := 0; - - type struct_sched_param is record - sched_priority : int; -- scheduling priority - end record; - - function pthread_setschedparam - (thread : pthread_t; - policy : int; - param : access struct_sched_param) return int; - pragma Inline (pthread_setschedparam); - -- LynxOS doesn't have pthread_setschedparam. - -- Instead, use pthread_setscheduler - - function pthread_mutexattr_setprotocol - (attr : access pthread_mutexattr_t; - protocol : int) return int; - pragma Inline (pthread_mutexattr_setprotocol); - -- LynxOS doesn't have pthread_mutexattr_setprotocol - - function pthread_mutexattr_setprioceiling - (attr : access pthread_mutexattr_t; - prioceiling : int) return int; - pragma Inline (pthread_mutexattr_setprioceiling); - -- LynxOS doesn't have pthread_mutexattr_setprioceiling - - function pthread_attr_setscope - (attr : access pthread_attr_t; - contentionscope : int) return int; - -- LynxOS doesn't have pthread_attr_setscope: all threads have system scope - pragma Inline (pthread_attr_setscope); - - function pthread_attr_setschedpolicy - (attr : access pthread_attr_t; - policy : int) return int; - pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched"); - - function sched_yield return int; - -- pragma Import (C, sched_yield, "sched_yield"); - pragma Inline (sched_yield); - - --------------------------- - -- P1003.1c - Section 16 -- - --------------------------- - - function pthread_attr_init (attributes : access pthread_attr_t) return int; - pragma Import (C, pthread_attr_init, "pthread_attr_create"); - - function pthread_attr_destroy - (attributes : access pthread_attr_t) return int; - pragma Import (C, pthread_attr_destroy, "pthread_attr_delete"); - - function pthread_attr_setdetachstate - (attr : access pthread_attr_t; - detachstate : int) return int; - pragma Inline (pthread_attr_setdetachstate); - -- LynxOS doesn't have pthread_attr_setdetachstate - - function pthread_attr_setstacksize - (attr : access pthread_attr_t; - stacksize : size_t) return int; - pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize"); - - function pthread_create - (thread : access pthread_t; - attributes : access pthread_attr_t; - start_routine : Thread_Body; - arg : System.Address) return int; - pragma Inline (pthread_create); - -- LynxOS has a non standard pthread_create - - function pthread_detach (thread : pthread_t) return int; - pragma Inline (pthread_detach); - - procedure pthread_exit (status : System.Address); - pragma Import (C, pthread_exit, "pthread_exit"); - - function pthread_self return pthread_t; - pragma Import (C, pthread_self, "pthread_self"); - - -------------------------- - -- POSIX.1c Section 17 -- - -------------------------- - - function pthread_setspecific - (key : pthread_key_t; - value : System.Address) return int; - pragma Inline (pthread_setspecific); - -- LynxOS has a non standard pthread_setspecific - - function pthread_getspecific (key : pthread_key_t) return System.Address; - pragma Inline (pthread_getspecific); - -- LynxOS has a non standard pthread_getspecific - - type destructor_pointer is access procedure (arg : System.Address); - pragma Convention (C, destructor_pointer); - - function pthread_key_create - (key : access pthread_key_t; - destructor : destructor_pointer) return int; - pragma Inline (pthread_key_create); - -- LynxOS has a non standard pthread_keycreate - - procedure pthread_init; - -- This is a dummy procedure to share some GNULLI files - -private - - type sigbit_array is array (1 .. 2) of long; - type sigset_t is record - sa_sigbits : sigbit_array; - end record; - pragma Convention (C_Pass_By_Copy, sigset_t); - - type pid_t is new long; - - type time_t is new long; - - type timespec is record - tv_sec : time_t; - tv_nsec : long; - end record; - pragma Convention (C, timespec); - - type st_t is record - stksize : int; - prio : int; - inheritsched : int; - state : int; - sched : int; - end record; - pragma Convention (C, st_t); - - type pthread_attr_t is record - st : st_t; - pthread_attr_scope : int; -- ignored - end record; - pragma Convention (C, pthread_attr_t); - - type pthread_condattr_t is new int; - - type pthread_mutexattr_t is new int; - - type tid_t is new short; - type pthread_t is new tid_t; - - type synch_ptr is access all pthread_mutex_t; - type pthread_mutex_t is record - w_count : int; - mut_owner : int; - id : unsigned; - next : synch_ptr; - end record; - pragma Convention (C, pthread_mutex_t); - - type pthread_cond_t is new pthread_mutex_t; - - type pthread_key_t is new int; - -end System.OS_Interface; diff --git a/gcc/ada/s-osinte-lynxos.adb b/gcc/ada/s-osinte-lynxos.adb deleted file mode 100644 index 4b9957d4a27..00000000000 --- a/gcc/ada/s-osinte-lynxos.adb +++ /dev/null @@ -1,119 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- S Y S T E M . O S _ I N T E R F A C E -- --- -- --- B o d y -- --- -- --- Copyright (C) 2001-2010, AdaCore -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS (POSIX Threads) version of this package - -pragma Polling (Off); --- Turn off polling, we do not want ATC polling to take place during --- tasking operations. It causes infinite loops and other problems. - -package body System.OS_Interface is - - use Interfaces.C; - - ----------------- - -- To_Duration -- - ----------------- - - function To_Duration (TS : timespec) return Duration is - begin - return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; - end To_Duration; - - ----------------- - -- To_Timespec -- - ----------------- - - function To_Timespec (D : Duration) return timespec is - S : time_t; - F : Duration; - - begin - S := time_t (Long_Long_Integer (D)); - F := D - Duration (S); - - -- If F has negative value due to a round-up, adjust for positive F - -- value. - - if F < 0.0 then - S := S - 1; - F := F + 1.0; - end if; - - return timespec'(tv_sec => S, - tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); - end To_Timespec; - - ------------- - -- sigwait -- - ------------- - - function sigwait - (set : access sigset_t; - sig : access Signal) - return int - is - function sigwaitinfo - (set : access sigset_t; - info : System.Address) return Signal; - pragma Import (C, sigwaitinfo, "sigwaitinfo"); - - begin - sig.all := sigwaitinfo (set, Null_Address); - - if sig.all = -1 then - return errno; - end if; - - return 0; - end sigwait; - - -------------------- - -- Get_Stack_Base -- - -------------------- - - function Get_Stack_Base (thread : pthread_t) return Address is - pragma Warnings (Off, thread); - - begin - return Null_Address; - end Get_Stack_Base; - - ------------------ - -- pthread_init -- - ------------------ - - procedure pthread_init is - begin - null; - end pthread_init; - -end System.OS_Interface; diff --git a/gcc/ada/s-osinte-lynxos.ads b/gcc/ada/s-osinte-lynxos.ads deleted file mode 100644 index 7bcbab6072e..00000000000 --- a/gcc/ada/s-osinte-lynxos.ads +++ /dev/null @@ -1,578 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- S Y S T E M . O S _ I N T E R F A C E -- --- -- --- S p e c -- --- -- --- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS (POSIX Threads) version of this package - --- This package encapsulates all direct interfaces to OS services --- that are needed by the tasking run-time (libgnarl). - --- PLEASE DO NOT add any with-clauses to this package or remove the pragma --- Preelaborate. This package is designed to be a bottom-level (leaf) package. - -with Ada.Unchecked_Conversion; - -with Interfaces.C; - -package System.OS_Interface is - pragma Preelaborate; - - pragma Linker_Options ("-mthreads"); - -- Selects the POSIX 1.c runtime, rather than the non-threading runtime - -- or the deprecated legacy threads library. The -mthreads flag is - -- defined in patch.LynxOS and matches the definition for Lynx's gcc. - - subtype int is Interfaces.C.int; - subtype short is Interfaces.C.short; - subtype long is Interfaces.C.long; - subtype unsigned is Interfaces.C.unsigned; - subtype unsigned_short is Interfaces.C.unsigned_short; - subtype unsigned_long is Interfaces.C.unsigned_long; - subtype unsigned_char is Interfaces.C.unsigned_char; - subtype plain_char is Interfaces.C.plain_char; - subtype size_t is Interfaces.C.size_t; - - ----------- - -- Errno -- - ----------- - - function errno return int; - pragma Import (C, errno, "__get_errno"); - - EAGAIN : constant := 11; - EINTR : constant := 4; - EINVAL : constant := 22; - ENOMEM : constant := 12; - ETIMEDOUT : constant := 60; - - ------------- - -- Signals -- - ------------- - - Max_Interrupt : constant := 63; - - -- Max_Interrupt is the number of OS signals, as defined in: - -- - -- /usr/include/sys/signal.h - -- - -- - -- The lowest numbered signal is 1, but 0 is a valid argument to some - -- library functions, e.g. kill(2). However, 0 is not just another - -- signal: For instance 'I in Signal' and similar should be used with - -- caution. - - type Signal is new int range 0 .. Max_Interrupt; - for Signal'Size use int'Size; - - SIGHUP : constant := 1; -- hangup - SIGINT : constant := 2; -- interrupt (rubout) - SIGQUIT : constant := 3; -- quit (ASCD FS) - SIGILL : constant := 4; -- illegal instruction (not reset) - SIGTRAP : constant := 5; -- trace trap (not reset) - SIGBRK : constant := 6; -- break - SIGIOT : constant := 6; -- IOT instruction - SIGABRT : constant := 6; -- used by abort, replace SIGIOT in future - SIGCORE : constant := 7; -- kill with core dump - SIGEMT : constant := 7; -- EMT instruction - SIGFPE : constant := 8; -- floating point exception - SIGKILL : constant := 9; -- kill (cannot be caught or ignored) - SIGBUS : constant := 10; -- bus error - SIGSEGV : constant := 11; -- segmentation violation - SIGSYS : constant := 12; -- bad argument to system call - SIGPIPE : constant := 13; -- write on a pipe with no one to read it - SIGALRM : constant := 14; -- alarm clock - SIGTERM : constant := 15; -- software termination signal from kill - SIGURG : constant := 16; -- urgent condition on IO channel - SIGSTOP : constant := 17; -- stop (cannot be caught or ignored) - SIGTSTP : constant := 18; -- user stop requested from tty - SIGCONT : constant := 19; -- stopped process has been continued - SIGCLD : constant := 20; -- alias for SIGCHLD - SIGCHLD : constant := 20; -- child status change - SIGTTIN : constant := 21; -- background tty read attempted - SIGTTOU : constant := 22; -- background tty write attempted - SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias) - SIGPOLL : constant := 23; -- pollable event occurred - SIGTHREADKILL : constant := 24; -- Reserved by LynxOS runtime - SIGXCPU : constant := 24; -- CPU time limit exceeded - SIGXFSZ : constant := 25; -- filesize limit exceeded - SIGVTALRM : constant := 26; -- virtual timer expired - SIGPROF : constant := 27; -- profiling timer expired - SIGWINCH : constant := 28; -- window size change - SIGLOST : constant := 29; -- SUN 4.1 compatibility - SIGUSR1 : constant := 30; -- user defined signal 1 - SIGUSR2 : constant := 31; -- user defined signal 2 - - SIGPRIO : constant := 32; - -- sent to a process with its priority or group is changed - - SIGADAABORT : constant := SIGABRT; - -- Change this if you want to use another signal for task abort. - -- SIGTERM might be a good one. - - type Signal_Set is array (Natural range <>) of Signal; - - Unmasked : constant Signal_Set := - (SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF, SIGTHREADKILL); - Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGPRIO); - - type sigset_t is private; - - function sigaddset (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigaddset, "sigaddset"); - - function sigdelset (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigdelset, "sigdelset"); - - function sigfillset (set : access sigset_t) return int; - pragma Import (C, sigfillset, "sigfillset"); - - function sigismember (set : access sigset_t; sig : Signal) return int; - pragma Import (C, sigismember, "sigismember"); - - function sigemptyset (set : access sigset_t) return int; - pragma Import (C, sigemptyset, "sigemptyset"); - - type struct_sigaction is record - sa_handler : System.Address; - sa_mask : sigset_t; - sa_flags : int; - end record; - pragma Convention (C, struct_sigaction); - type struct_sigaction_ptr is access all struct_sigaction; - - SA_SIGINFO : constant := 16#80#; - - SA_ONSTACK : constant := 16#00#; - -- SA_ONSTACK is not defined on LynxOS, but it is referred to in the POSIX - -- implementation of System.Interrupt_Management. Therefore we define a - -- dummy value of zero here so that setting this flag is a nop. - - SIG_BLOCK : constant := 0; - SIG_UNBLOCK : constant := 1; - SIG_SETMASK : constant := 2; - - SIG_DFL : constant := 0; - SIG_IGN : constant := 1; - - function sigaction - (sig : Signal; - act : struct_sigaction_ptr; - oact : struct_sigaction_ptr) return int; - pragma Import (C, sigaction, "sigaction"); - - ---------- - -- Time -- - ---------- - - Time_Slice_Supported : constant Boolean := True; - -- Indicates whether time slicing is supported - - type timespec is private; - - type clockid_t is new int; - - function clock_gettime - (clock_id : clockid_t; - tp : access timespec) return int; - pragma Import (C, clock_gettime, "clock_gettime"); - - function clock_getres - (clock_id : clockid_t; - res : access timespec) return int; - pragma Import (C, clock_getres, "clock_getres"); - - function To_Duration (TS : timespec) return Duration; - pragma Inline (To_Duration); - - function To_Timespec (D : Duration) return timespec; - pragma Inline (To_Timespec); - - type struct_timezone is record - tz_minuteswest : int; - tz_dsttime : int; - end record; - pragma Convention (C, struct_timezone); - type struct_timezone_ptr is access all struct_timezone; - - ------------------------- - -- Priority Scheduling -- - ------------------------- - - SCHED_FIFO : constant := 16#200000#; - SCHED_RR : constant := 16#100000#; - SCHED_OTHER : constant := 16#400000#; - - ------------- - -- Process -- - ------------- - - type pid_t is private; - - function kill (pid : pid_t; sig : Signal) return int; - pragma Import (C, kill, "kill"); - - function getpid return pid_t; - pragma Import (C, getpid, "getpid"); - - --------- - -- LWP -- - --------- - - function lwp_self return System.Address; - pragma Import (C, lwp_self, "pthread_self"); - - ------------- - -- Threads -- - ------------- - - type Thread_Body is access - function (arg : System.Address) return System.Address; - pragma Convention (C, Thread_Body); - - function Thread_Body_Access is new - Ada.Unchecked_Conversion (System.Address, Thread_Body); - - type pthread_t is private; - subtype Thread_Id is pthread_t; - - type pthread_mutex_t is limited private; - type pthread_cond_t is limited private; - type pthread_attr_t is limited private; - type pthread_mutexattr_t is limited private; - type pthread_condattr_t is limited private; - type pthread_key_t is private; - - PTHREAD_CREATE_DETACHED : constant := 1; - PTHREAD_CREATE_JOINABLE : constant := 0; - - ----------- - -- Stack -- - ----------- - - Alternate_Stack_Size : constant := 0; - -- No alternate signal stack is used on this platform - - Stack_Base_Available : constant Boolean := False; - -- Indicates whether the stack base is available on this target - - function Get_Stack_Base (thread : pthread_t) return Address; - pragma Inline (Get_Stack_Base); - -- Returns the stack base of the specified thread. - -- Only call this function when Stack_Base_Available is True. - - function Get_Page_Size return size_t; - function Get_Page_Size return Address; - pragma Import (C, Get_Page_Size, "getpagesize"); - -- Returns the size of a page, or 0 if this is not relevant on this - -- target - - PROT_NONE : constant := 1; - PROT_READ : constant := 2; - PROT_WRITE : constant := 4; - PROT_EXEC : constant := 8; - PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC; - - PROT_ON : constant := PROT_READ; - PROT_OFF : constant := PROT_ALL; - - function mprotect (addr : Address; len : size_t; prot : int) return int; - pragma Import (C, mprotect); - - --------------------------------------- - -- Nonstandard Thread Initialization -- - --------------------------------------- - - procedure pthread_init; - -- This is a dummy procedure to share some GNULLI files - - ------------------------- - -- POSIX.1c Section 3 -- - ------------------------- - - function sigwait - (set : access sigset_t; - sig : access Signal) return int; - pragma Inline (sigwait); - -- LynxOS has non standard sigwait - - function pthread_kill - (thread : pthread_t; - sig : Signal) return int; - pragma Import (C, pthread_kill, "pthread_kill"); - - function pthread_sigmask - (how : int; - set : access sigset_t; - oset : access sigset_t) return int; - pragma Import (C, pthread_sigmask, "pthread_sigmask"); - -- The behavior of pthread_sigmask on LynxOS requires - -- further investigation. - - ---------------------------- - -- POSIX.1c Section 11 -- - ---------------------------- - - function pthread_mutexattr_init - (attr : access pthread_mutexattr_t) return int; - pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init"); - - function pthread_mutexattr_destroy - (attr : access pthread_mutexattr_t) return int; - pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy"); - - function pthread_mutex_init - (mutex : access pthread_mutex_t; - attr : access pthread_mutexattr_t) return int; - pragma Import (C, pthread_mutex_init, "pthread_mutex_init"); - - function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; - pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy"); - - function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; - pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock"); - - function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; - pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock"); - - function pthread_condattr_init - (attr : access pthread_condattr_t) return int; - pragma Import (C, pthread_condattr_init, "pthread_condattr_init"); - - function pthread_condattr_destroy - (attr : access pthread_condattr_t) return int; - pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy"); - - function pthread_cond_init - (cond : access pthread_cond_t; - attr : access pthread_condattr_t) return int; - pragma Import (C, pthread_cond_init, "pthread_cond_init"); - - function pthread_cond_destroy (cond : access pthread_cond_t) return int; - pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy"); - - function pthread_cond_signal (cond : access pthread_cond_t) return int; - pragma Import (C, pthread_cond_signal, "pthread_cond_signal"); - - function pthread_cond_wait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t) return int; - pragma Import (C, pthread_cond_wait, "pthread_cond_wait"); - - function pthread_cond_timedwait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t; - abstime : access timespec) return int; - pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - - -------------------------- - -- POSIX.1c Section 13 -- - -------------------------- - - PTHREAD_PRIO_NONE : constant := 0; - PTHREAD_PRIO_INHERIT : constant := 1; - PTHREAD_PRIO_PROTECT : constant := 2; - - function pthread_mutexattr_setprotocol - (attr : access pthread_mutexattr_t; - protocol : int) return int; - pragma Import (C, pthread_mutexattr_setprotocol); - - function pthread_mutexattr_setprioceiling - (attr : access pthread_mutexattr_t; - prioceiling : int) return int; - pragma Import (C, pthread_mutexattr_setprioceiling); - - type struct_sched_param is record - sched_priority : int; - end record; - - function pthread_setschedparam - (thread : pthread_t; - policy : int; - param : access struct_sched_param) return int; - pragma Import (C, pthread_setschedparam, "pthread_setschedparam"); - - function pthread_attr_setscope - (attr : access pthread_attr_t; - contentionscope : int) return int; - pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope"); - - function pthread_attr_setinheritsched - (attr : access pthread_attr_t; - inheritsched : int) return int; - pragma Import (C, pthread_attr_setinheritsched); - - function pthread_attr_setschedpolicy - (attr : access pthread_attr_t; - policy : int) return int; - pragma Import (C, pthread_attr_setschedpolicy); - - function sched_yield return int; - pragma Import (C, sched_yield, "sched_yield"); - - -------------------------- - -- P1003.1c Section 16 -- - -------------------------- - - function pthread_attr_init (attributes : access pthread_attr_t) return int; - pragma Import (C, pthread_attr_init, "pthread_attr_init"); - - function pthread_attr_destroy - (attributes : access pthread_attr_t) return int; - pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy"); - - function pthread_attr_setdetachstate - (attr : access pthread_attr_t; - detachstate : int) return int; - pragma Import (C, pthread_attr_setdetachstate); - - function pthread_attr_setstacksize - (attr : access pthread_attr_t; - stacksize : size_t) return int; - pragma Import (C, pthread_attr_setstacksize); - - function pthread_create - (thread : access pthread_t; - attributes : access pthread_attr_t; - start_routine : Thread_Body; - arg : System.Address) return int; - pragma Import (C, pthread_create, "pthread_create"); - - procedure pthread_exit (status : System.Address); - pragma Import (C, pthread_exit, "pthread_exit"); - - function pthread_self return pthread_t; - pragma Import (C, pthread_self, "pthread_self"); - - -------------------------- - -- POSIX.1c Section 17 -- - -------------------------- - - function st_setspecific - (key : pthread_key_t; - value : System.Address) return int; - pragma Import (C, st_setspecific, "st_setspecific"); - - function st_getspecific - (key : pthread_key_t; - retval : System.Address) return int; - pragma Import (C, st_getspecific, "st_getspecific"); - - type destructor_pointer is access procedure (arg : System.Address); - pragma Convention (C, destructor_pointer); - - function st_keycreate - (destructor : destructor_pointer; - key : access pthread_key_t) return int; - pragma Import (C, st_keycreate, "st_keycreate"); - -private - - type sigset_t is record - X1, X2 : long; - end record; - pragma Convention (C, sigset_t); - - type pid_t is new long; - - type time_t is new long; - - type timespec is record - tv_sec : time_t; - tv_nsec : long; - end record; - pragma Convention (C, timespec); - - type st_attr_t is record - stksize : int; - prio : int; - inheritsched : int; - state : int; - sched : int; - detachstate : int; - guardsize : int; - end record; - pragma Convention (C, st_attr_t); - - type pthread_attr_t is record - pthread_attr_magic : unsigned; - st : st_attr_t; - pthread_attr_scope : int; - end record; - pragma Convention (C, pthread_attr_t); - - type pthread_condattr_t is record - cv_magic : unsigned; - cv_pshared : unsigned; - end record; - pragma Convention (C, pthread_condattr_t); - - type pthread_mutexattr_t is record - m_flags : unsigned; - m_prio_c : int; - m_pshared : int; - end record; - pragma Convention (C, pthread_mutexattr_t); - - type tid_t is new short; - type pthread_t is new tid_t; - - type block_obj_t is new System.Address; - -- typedef struct _block_obj_s { - -- struct st_entry *b_head; - -- } block_obj_t; - - type pthread_mutex_t is record - m_flags : unsigned; - m_owner : tid_t; - m_wait : block_obj_t; - m_prio_c : int; - m_oldprio : int; - m_count : int; - m_referenced : int; - end record; - pragma Convention (C, pthread_mutex_t); - type pthread_mutex_t_ptr is access all pthread_mutex_t; - - type pthread_cond_t is record - cv_magic : unsigned; - cv_wait : block_obj_t; - cv_mutex : pthread_mutex_t_ptr; - cv_refcnt : int; - end record; - pragma Convention (C, pthread_cond_t); - - type pthread_key_t is new int; - -end System.OS_Interface; diff --git a/gcc/ada/s-rannum.ads b/gcc/ada/s-rannum.ads index 0d2a7e9dee7..a412b9c85c9 100644 --- a/gcc/ada/s-rannum.ads +++ b/gcc/ada/s-rannum.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2007-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2007-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -56,12 +56,16 @@ with Interfaces; package System.Random_Numbers is type Generator is limited private; + -- Generator encodes the current state of a random number stream, it is + -- provided as input to produce the next random number, and updated so + -- that it is ready to produce the next one. + type State is private; -- A non-limited version of a Generator's internal state function Random (Gen : Generator) return Float; function Random (Gen : Generator) return Long_Float; - -- Return pseudo-random numbers uniformly distributed on [0 .. 1) + -- Return pseudo-random numbers uniformly distributed on [0.0 .. 1.0) function Random (Gen : Generator) return Interfaces.Unsigned_32; function Random (Gen : Generator) return Interfaces.Unsigned_64; diff --git a/gcc/ada/s-taprop-lynxos.adb b/gcc/ada/s-taprop-lynxos.adb deleted file mode 100644 index d553f1e69ab..00000000000 --- a/gcc/ada/s-taprop-lynxos.adb +++ /dev/null @@ -1,1423 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- --- -- --- B o d y -- --- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- --- -- --- GNARL is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS version of this file, adapted to make SCHED_FIFO and --- ceiling locking (Annex D compliance) work properly. - --- This package contains all the GNULL primitives that interface directly with --- the underlying OS. - -pragma Polling (Off); --- Turn off polling, we do not want ATC polling to take place during tasking --- operations. It causes infinite loops and other problems. - -with Ada.Unchecked_Deallocation; - -with Interfaces.C; - -with System.Tasking.Debug; -with System.Interrupt_Management; -with System.OS_Primitives; -with System.Task_Info; - -with System.Soft_Links; --- We use System.Soft_Links instead of System.Tasking.Initialization --- because the later is a higher level package that we shouldn't depend on. --- For example when using the restricted run time, it is replaced by --- System.Tasking.Restricted.Stages. - -package body System.Task_Primitives.Operations is - - package SSL renames System.Soft_Links; - - use System.Tasking.Debug; - use System.Tasking; - use Interfaces.C; - use System.OS_Interface; - use System.Parameters; - use System.OS_Primitives; - - ---------------- - -- Local Data -- - ---------------- - - -- The followings are logically constants, but need to be initialized - -- at run time. - - Single_RTS_Lock : aliased RTS_Lock; - -- This is a lock to allow only one thread of control in the RTS at - -- a time; it is used to execute in mutual exclusion from all other tasks. - -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List - - ATCB_Key : aliased pthread_key_t; - -- Key used to find the Ada Task_Id associated with a thread - - Environment_Task_Id : Task_Id; - -- A variable to hold Task_Id for the environment task - - Locking_Policy : Character; - pragma Import (C, Locking_Policy, "__gl_locking_policy"); - -- Value of the pragma Locking_Policy: - -- 'C' for Ceiling_Locking - -- 'I' for Inherit_Locking - -- ' ' for none. - - Unblocked_Signal_Mask : aliased sigset_t; - -- The set of signals that should unblocked in all tasks - - -- The followings are internal configuration constants needed - - Next_Serial_Number : Task_Serial_Number := 100; - -- We start at 100, to reserve some special values for - -- using in error checking. - - Time_Slice_Val : Integer; - pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); - - Dispatching_Policy : Character; - pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); - - Foreign_Task_Elaborated : aliased Boolean := True; - -- Used to identified fake tasks (i.e., non-Ada Threads) - - -------------------- - -- Local Packages -- - -------------------- - - package Specific is - - procedure Initialize (Environment_Task : Task_Id); - pragma Inline (Initialize); - -- Initialize various data needed by this package - - function Is_Valid_Task return Boolean; - pragma Inline (Is_Valid_Task); - -- Does the current thread have an ATCB? - - procedure Set (Self_Id : Task_Id); - pragma Inline (Set); - -- Set the self id for the current task - - function Self return Task_Id; - pragma Inline (Self); - -- Return a pointer to the Ada Task Control Block of the calling task - - end Specific; - - package body Specific is separate; - -- The body of this package is target specific - - --------------------------------- - -- Support for foreign threads -- - --------------------------------- - - function Register_Foreign_Thread (Thread : Thread_Id) return Task_Id; - -- Allocate and Initialize a new ATCB for the current Thread - - function Register_Foreign_Thread - (Thread : Thread_Id) return Task_Id is separate; - - ----------------------- - -- Local Subprograms -- - ----------------------- - - procedure Abort_Handler (Sig : Signal); - -- Signal handler used to implement asynchronous abort - - procedure Set_OS_Priority (T : Task_Id; Prio : System.Any_Priority); - -- This procedure calls the scheduler of the OS to set thread's priority - - ------------------- - -- Abort_Handler -- - ------------------- - - procedure Abort_Handler (Sig : Signal) is - pragma Unreferenced (Sig); - - T : constant Task_Id := Self; - Result : Interfaces.C.int; - Old_Set : aliased sigset_t; - - begin - -- It is not safe to raise an exception when using ZCX and the GCC - -- exception handling mechanism. - - if ZCX_By_Default and then GCC_ZCX_Support then - return; - end if; - - if T.Deferral_Level = 0 - and then T.Pending_ATC_Level < T.ATC_Nesting_Level - and then not T.Aborting - then - T.Aborting := True; - - -- Make sure signals used for RTS internal purpose are unmasked - - Result := - pthread_sigmask - (SIG_UNBLOCK, - Unblocked_Signal_Mask'Access, - Old_Set'Access); - pragma Assert (Result = 0); - - raise Standard'Abort_Signal; - end if; - end Abort_Handler; - - ----------------- - -- Stack_Guard -- - ----------------- - - procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is - Stack_Base : constant Address := Get_Stack_Base (T.Common.LL.Thread); - Guard_Page_Address : Address; - - Res : Interfaces.C.int; - - begin - if Stack_Base_Available then - - -- Compute the guard page address - - Guard_Page_Address := - Stack_Base - (Stack_Base mod Get_Page_Size) + Get_Page_Size; - - if On then - Res := mprotect (Guard_Page_Address, Get_Page_Size, PROT_ON); - else - Res := mprotect (Guard_Page_Address, Get_Page_Size, PROT_OFF); - end if; - - pragma Assert (Res = 0); - end if; - end Stack_Guard; - - -------------------- - -- Get_Thread_Id -- - -------------------- - - function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is - begin - return T.Common.LL.Thread; - end Get_Thread_Id; - - ---------- - -- Self -- - ---------- - - function Self return Task_Id renames Specific.Self; - - --------------------- - -- Initialize_Lock -- - --------------------- - - procedure Initialize_Lock - (Prio : System.Any_Priority; - L : not null access Lock) - is - Attributes : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; - - begin - Result := pthread_mutexattr_init (Attributes'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - raise Storage_Error; - end if; - - if Locking_Policy = 'C' then - L.Ceiling := Prio; - end if; - - Result := pthread_mutex_init (L.Mutex'Access, Attributes'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - raise Storage_Error; - end if; - - Result := pthread_mutexattr_destroy (Attributes'Access); - pragma Assert (Result = 0); - end Initialize_Lock; - - procedure Initialize_Lock - (L : not null access RTS_Lock; - Level : Lock_Level) - is - pragma Unreferenced (Level); - - Attributes : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; - - begin - Result := pthread_mutexattr_init (Attributes'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - raise Storage_Error; - end if; - - Result := pthread_mutex_init (L, Attributes'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - Result := pthread_mutexattr_destroy (Attributes'Access); - raise Storage_Error; - end if; - - Result := pthread_mutexattr_destroy (Attributes'Access); - pragma Assert (Result = 0); - end Initialize_Lock; - - ------------------- - -- Finalize_Lock -- - ------------------- - - procedure Finalize_Lock (L : not null access Lock) is - Result : Interfaces.C.int; - begin - Result := pthread_mutex_destroy (L.Mutex'Access); - pragma Assert (Result = 0); - end Finalize_Lock; - - procedure Finalize_Lock (L : not null access RTS_Lock) is - Result : Interfaces.C.int; - begin - Result := pthread_mutex_destroy (L); - pragma Assert (Result = 0); - end Finalize_Lock; - - ---------------- - -- Write_Lock -- - ---------------- - - procedure Write_Lock - (L : not null access Lock; - Ceiling_Violation : out Boolean) - is - Result : Interfaces.C.int; - T : constant Task_Id := Self; - - begin - if Locking_Policy = 'C' then - if T.Common.Current_Priority > L.Ceiling then - Ceiling_Violation := True; - return; - end if; - - L.Saved_Priority := T.Common.Current_Priority; - - if T.Common.Current_Priority < L.Ceiling then - Set_OS_Priority (T, L.Ceiling); - end if; - end if; - - Result := pthread_mutex_lock (L.Mutex'Access); - - -- Assume that the cause of EINVAL is a priority ceiling violation - - Ceiling_Violation := (Result = EINVAL); - pragma Assert (Result = 0 or else Result = EINVAL); - end Write_Lock; - - -- No tricks on RTS_Locks - - procedure Write_Lock - (L : not null access RTS_Lock; - Global_Lock : Boolean := False) - is - Result : Interfaces.C.int; - begin - if not Single_Lock or else Global_Lock then - Result := pthread_mutex_lock (L); - pragma Assert (Result = 0); - end if; - end Write_Lock; - - procedure Write_Lock (T : Task_Id) is - Result : Interfaces.C.int; - begin - if not Single_Lock then - Result := pthread_mutex_lock (T.Common.LL.L'Access); - pragma Assert (Result = 0); - end if; - end Write_Lock; - - --------------- - -- Read_Lock -- - --------------- - - procedure Read_Lock - (L : not null access Lock; - Ceiling_Violation : out Boolean) - is - begin - Write_Lock (L, Ceiling_Violation); - end Read_Lock; - - ------------ - -- Unlock -- - ------------ - - procedure Unlock (L : not null access Lock) is - Result : Interfaces.C.int; - T : constant Task_Id := Self; - - begin - Result := pthread_mutex_unlock (L.Mutex'Access); - pragma Assert (Result = 0); - - if Locking_Policy = 'C' then - if T.Common.Current_Priority > L.Saved_Priority then - Set_OS_Priority (T, L.Saved_Priority); - end if; - end if; - end Unlock; - - procedure Unlock - (L : not null access RTS_Lock; - Global_Lock : Boolean := False) - is - Result : Interfaces.C.int; - begin - if not Single_Lock or else Global_Lock then - Result := pthread_mutex_unlock (L); - pragma Assert (Result = 0); - end if; - end Unlock; - - procedure Unlock (T : Task_Id) is - Result : Interfaces.C.int; - begin - if not Single_Lock then - Result := pthread_mutex_unlock (T.Common.LL.L'Access); - pragma Assert (Result = 0); - end if; - end Unlock; - - ----------------- - -- Set_Ceiling -- - ----------------- - - -- Dynamic priority ceilings are not supported by the underlying system - - procedure Set_Ceiling - (L : not null access Lock; - Prio : System.Any_Priority) - is - pragma Unreferenced (L, Prio); - begin - null; - end Set_Ceiling; - - ----------- - -- Sleep -- - ----------- - - procedure Sleep - (Self_ID : Task_Id; - Reason : System.Tasking.Task_States) - is - pragma Unreferenced (Reason); - Result : Interfaces.C.int; - - begin - if Single_Lock then - Result := - pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); - else - Result := - pthread_cond_wait - (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); - end if; - - -- EINTR is not considered a failure - - pragma Assert (Result = 0 or else Result = EINTR); - end Sleep; - - ----------------- - -- Timed_Sleep -- - ----------------- - - -- This is for use within the run-time system, so abort is - -- assumed to be already deferred, and the caller should be - -- holding its own ATCB lock. - - procedure Timed_Sleep - (Self_ID : Task_Id; - Time : Duration; - Mode : ST.Delay_Modes; - Reason : Task_States; - Timedout : out Boolean; - Yielded : out Boolean) - is - pragma Unreferenced (Reason); - - Base_Time : constant Duration := Monotonic_Clock; - Check_Time : Duration := Base_Time; - Rel_Time : Duration; - Abs_Time : Duration; - Request : aliased timespec; - Result : Interfaces.C.int; - - begin - Timedout := True; - Yielded := False; - - if Mode = Relative then - Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; - - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time); - end if; - - else - Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time); - - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time); - end if; - end if; - - if Abs_Time > Check_Time then - if Relative_Timed_Wait then - Request := To_Timespec (Rel_Time); - else - Request := To_Timespec (Abs_Time); - end if; - - loop - exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; - - if Single_Lock then - Result := - pthread_cond_timedwait - (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, - Request'Access); - - else - Result := - pthread_cond_timedwait - (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, - Request'Access); - end if; - - Check_Time := Monotonic_Clock; - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - - if Result = 0 or Result = EINTR then - - -- Somebody may have called Wakeup for us - - Timedout := False; - exit; - end if; - - pragma Assert (Result = ETIMEDOUT); - end loop; - end if; - end Timed_Sleep; - - ----------------- - -- Timed_Delay -- - ----------------- - - -- This is for use in implementing delay statements, so we assume - -- the caller is abort-deferred but is holding no locks. - - procedure Timed_Delay - (Self_ID : Task_Id; - Time : Duration; - Mode : ST.Delay_Modes) - is - Base_Time : constant Duration := Monotonic_Clock; - Check_Time : Duration := Base_Time; - Abs_Time : Duration; - Rel_Time : Duration; - Request : aliased timespec; - - Result : Interfaces.C.int; - pragma Warnings (Off, Result); - - begin - if Single_Lock then - Lock_RTS; - end if; - - -- Comments needed in code below ??? - - Write_Lock (Self_ID); - - if Mode = Relative then - Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; - - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time); - end if; - - else - Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time); - - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time); - end if; - end if; - - if Abs_Time > Check_Time then - if Relative_Timed_Wait then - Request := To_Timespec (Rel_Time); - else - Request := To_Timespec (Abs_Time); - end if; - - Self_ID.Common.State := Delay_Sleep; - - loop - exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; - - if Single_Lock then - Result := - pthread_cond_timedwait - (Self_ID.Common.LL.CV'Access, - Single_RTS_Lock'Access, - Request'Access); - else - Result := - pthread_cond_timedwait - (Self_ID.Common.LL.CV'Access, - Self_ID.Common.LL.L'Access, - Request'Access); - end if; - - Check_Time := Monotonic_Clock; - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - - pragma Assert (Result = 0 or else - Result = ETIMEDOUT or else - Result = EINTR); - end loop; - - Self_ID.Common.State := Runnable; - end if; - - Unlock (Self_ID); - - if Single_Lock then - Unlock_RTS; - end if; - - Result := sched_yield; - end Timed_Delay; - - --------------------- - -- Monotonic_Clock -- - --------------------- - - function Monotonic_Clock return Duration is - TS : aliased timespec; - Result : Interfaces.C.int; - begin - Result := - clock_gettime - (clock_id => CLOCK_REALTIME, tp => TS'Unchecked_Access); - pragma Assert (Result = 0); - return To_Duration (TS); - end Monotonic_Clock; - - ------------------- - -- RT_Resolution -- - ------------------- - - function RT_Resolution return Duration is - Res : aliased timespec; - Result : Interfaces.C.int; - begin - Result := - clock_getres - (clock_id => CLOCK_REALTIME, res => Res'Unchecked_Access); - pragma Assert (Result = 0); - return To_Duration (Res); - end RT_Resolution; - - ------------ - -- Wakeup -- - ------------ - - procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is - pragma Unreferenced (Reason); - Result : Interfaces.C.int; - begin - Result := pthread_cond_signal (T.Common.LL.CV'Access); - pragma Assert (Result = 0); - end Wakeup; - - ----------- - -- Yield -- - ----------- - - procedure Yield (Do_Yield : Boolean := True) is - Result : Interfaces.C.int; - pragma Unreferenced (Result); - begin - if Do_Yield then - Result := sched_yield; - end if; - end Yield; - - ------------------ - -- Set_Priority -- - ------------------ - - procedure Set_OS_Priority (T : Task_Id; Prio : System.Any_Priority) is - Result : Interfaces.C.int; - Param : aliased struct_sched_param; - - function Get_Policy (Prio : System.Any_Priority) return Character; - pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching"); - -- Get priority specific dispatching policy - - Priority_Specific_Policy : constant Character := Get_Policy (Prio); - -- Upper case first character of the policy name corresponding to the - -- task as set by a Priority_Specific_Dispatching pragma. - - begin - Param.sched_priority := Interfaces.C.int (Prio); - - if Time_Slice_Supported - and then (Dispatching_Policy = 'R' - or else Priority_Specific_Policy = 'R' - or else Time_Slice_Val > 0) - then - Result := - pthread_setschedparam - (T.Common.LL.Thread, SCHED_RR, Param'Access); - - elsif Dispatching_Policy = 'F' - or else Priority_Specific_Policy = 'F' - or else Time_Slice_Val = 0 - then - Result := - pthread_setschedparam - (T.Common.LL.Thread, SCHED_FIFO, Param'Access); - - else - Result := - pthread_setschedparam - (T.Common.LL.Thread, SCHED_OTHER, Param'Access); - end if; - - pragma Assert (Result = 0); - end Set_OS_Priority; - - type Prio_Array_Type is array (System.Any_Priority) of Integer; - pragma Atomic_Components (Prio_Array_Type); - Prio_Array : Prio_Array_Type; - -- Comments needed for these declarations ??? - - procedure Set_Priority - (T : Task_Id; - Prio : System.Any_Priority; - Loss_Of_Inheritance : Boolean := False) - is - Array_Item : Integer; - - begin - Set_OS_Priority (T, Prio); - - if Locking_Policy = 'C' then - - -- Annex D requirements: loss of inheritance puts task at the start - -- of the queue for that prio; copied from 5ztaprop (VxWorks). - - if Loss_Of_Inheritance - and then Prio < T.Common.Current_Priority then - - Array_Item := Prio_Array (T.Common.Base_Priority) + 1; - Prio_Array (T.Common.Base_Priority) := Array_Item; - - loop - Yield; - exit when Array_Item = Prio_Array (T.Common.Base_Priority) - or else Prio_Array (T.Common.Base_Priority) = 1; - end loop; - - Prio_Array (T.Common.Base_Priority) := - Prio_Array (T.Common.Base_Priority) - 1; - end if; - end if; - - T.Common.Current_Priority := Prio; - end Set_Priority; - - ------------------ - -- Get_Priority -- - ------------------ - - function Get_Priority (T : Task_Id) return System.Any_Priority is - begin - return T.Common.Current_Priority; - end Get_Priority; - - ---------------- - -- Enter_Task -- - ---------------- - - procedure Enter_Task (Self_ID : Task_Id) is - begin - Self_ID.Common.LL.Thread := pthread_self; - Self_ID.Common.LL.LWP := lwp_self; - - Specific.Set (Self_ID); - - Lock_RTS; - - for J in Known_Tasks'Range loop - if Known_Tasks (J) = null then - Known_Tasks (J) := Self_ID; - Self_ID.Known_Tasks_Index := J; - exit; - end if; - end loop; - - Unlock_RTS; - end Enter_Task; - - -------------- - -- New_ATCB -- - -------------- - - function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is - begin - return new Ada_Task_Control_Block (Entry_Num); - end New_ATCB; - - ------------------- - -- Is_Valid_Task -- - ------------------- - - function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task; - - ----------------------------- - -- Register_Foreign_Thread -- - ----------------------------- - - function Register_Foreign_Thread return Task_Id is - begin - if Is_Valid_Task then - return Self; - else - return Register_Foreign_Thread (pthread_self); - end if; - end Register_Foreign_Thread; - - -------------------- - -- Initialize_TCB -- - -------------------- - - procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is - Mutex_Attr : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; - Cond_Attr : aliased pthread_condattr_t; - - begin - -- Give the task a unique serial number - - Self_ID.Serial_Number := Next_Serial_Number; - Next_Serial_Number := Next_Serial_Number + 1; - pragma Assert (Next_Serial_Number /= 0); - - if not Single_Lock then - Result := pthread_mutexattr_init (Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = 0 then - Result := - pthread_mutex_init - (Self_ID.Common.LL.L'Access, Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - end if; - - if Result /= 0 then - Succeeded := False; - return; - end if; - - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - end if; - - Result := pthread_condattr_init (Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = 0 then - Result := - pthread_cond_init (Self_ID.Common.LL.CV'Access, Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - end if; - - if Result = 0 then - Succeeded := True; - else - if not Single_Lock then - Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); - pragma Assert (Result = 0); - end if; - - Succeeded := False; - end if; - - Result := pthread_condattr_destroy (Cond_Attr'Access); - pragma Assert (Result = 0); - end Initialize_TCB; - - ----------------- - -- Create_Task -- - ----------------- - - procedure Create_Task - (T : Task_Id; - Wrapper : System.Address; - Stack_Size : System.Parameters.Size_Type; - Priority : System.Any_Priority; - Succeeded : out Boolean) - is - Attributes : aliased pthread_attr_t; - Adjusted_Stack_Size : Interfaces.C.size_t; - Result : Interfaces.C.int; - - use System.Task_Info; - - begin - Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size); - - if Stack_Base_Available then - - -- If Stack Checking is supported then allocate 2 additional pages: - - -- In the worst case, stack is allocated at something like - -- N * Get_Page_Size - epsilon, we need to add the size for 2 pages - -- to be sure the effective stack size is greater than what - -- has been asked. - - Adjusted_Stack_Size := Adjusted_Stack_Size + 2 * Get_Page_Size; - end if; - - Result := pthread_attr_init (Attributes'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result /= 0 then - Succeeded := False; - return; - end if; - - Result := - pthread_attr_setdetachstate - (Attributes'Access, PTHREAD_CREATE_DETACHED); - pragma Assert (Result = 0); - - Result := - pthread_attr_setstacksize - (Attributes'Access, Adjusted_Stack_Size); - pragma Assert (Result = 0); - - if T.Common.Task_Info /= Default_Scope then - - -- We are assuming that Scope_Type has the same values than the - -- corresponding C macros - - Result := - pthread_attr_setscope - (Attributes'Access, Task_Info_Type'Pos (T.Common.Task_Info)); - pragma Assert (Result = 0); - end if; - - -- Since the initial signal mask of a thread is inherited from the - -- creator, and the Environment task has all its signals masked, we - -- do not need to manipulate caller's signal mask at this point. - -- All tasks in RTS will have All_Tasks_Mask initially. - - Result := - pthread_create - (T.Common.LL.Thread'Access, - Attributes'Access, - Thread_Body_Access (Wrapper), - To_Address (T)); - pragma Assert (Result = 0 or else Result = EAGAIN); - - Succeeded := Result = 0; - - Result := pthread_attr_destroy (Attributes'Access); - pragma Assert (Result = 0); - - if Succeeded then - Set_Priority (T, Priority); - end if; - end Create_Task; - - ------------------ - -- Finalize_TCB -- - ------------------ - - procedure Finalize_TCB (T : Task_Id) is - Result : Interfaces.C.int; - Tmp : Task_Id := T; - Is_Self : constant Boolean := T = Self; - - procedure Free is new - Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id); - - begin - if not Single_Lock then - Result := pthread_mutex_destroy (T.Common.LL.L'Access); - pragma Assert (Result = 0); - end if; - - Result := pthread_cond_destroy (T.Common.LL.CV'Access); - pragma Assert (Result = 0); - - if T.Known_Tasks_Index /= -1 then - Known_Tasks (T.Known_Tasks_Index) := null; - end if; - - Free (Tmp); - - if Is_Self then - Result := st_setspecific (ATCB_Key, System.Null_Address); - pragma Assert (Result = 0); - end if; - end Finalize_TCB; - - --------------- - -- Exit_Task -- - --------------- - - procedure Exit_Task is - begin - Specific.Set (null); - end Exit_Task; - - ---------------- - -- Abort_Task -- - ---------------- - - procedure Abort_Task (T : Task_Id) is - Result : Interfaces.C.int; - begin - Result := - pthread_kill - (T.Common.LL.Thread, - Signal (System.Interrupt_Management.Abort_Task_Interrupt)); - pragma Assert (Result = 0); - end Abort_Task; - - ---------------- - -- Initialize -- - ---------------- - - procedure Initialize (S : in out Suspension_Object) is - Mutex_Attr : aliased pthread_mutexattr_t; - Cond_Attr : aliased pthread_condattr_t; - Result : Interfaces.C.int; - - begin - -- Initialize internal state (always to False (RM D.10(6))) - - S.State := False; - S.Waiting := False; - - -- Initialize internal mutex - - Result := pthread_mutexattr_init (Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - raise Storage_Error; - end if; - - Result := pthread_mutex_init (S.L'Access, Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = ENOMEM then - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - - raise Storage_Error; - end if; - - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - - -- Initialize internal condition variable - - Result := pthread_condattr_init (Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result /= 0 then - Result := pthread_mutex_destroy (S.L'Access); - pragma Assert (Result = 0); - - if Result = ENOMEM then - raise Storage_Error; - end if; - end if; - - Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result /= 0 then - Result := pthread_mutex_destroy (S.L'Access); - pragma Assert (Result = 0); - - if Result = ENOMEM then - Result := pthread_condattr_destroy (Cond_Attr'Access); - pragma Assert (Result = 0); - - raise Storage_Error; - end if; - end if; - - Result := pthread_condattr_destroy (Cond_Attr'Access); - pragma Assert (Result = 0); - end Initialize; - - -------------- - -- Finalize -- - -------------- - - procedure Finalize (S : in out Suspension_Object) is - Result : Interfaces.C.int; - - begin - -- Destroy internal mutex - - Result := pthread_mutex_destroy (S.L'Access); - pragma Assert (Result = 0); - - -- Destroy internal condition variable - - Result := pthread_cond_destroy (S.CV'Access); - pragma Assert (Result = 0); - end Finalize; - - ------------------- - -- Current_State -- - ------------------- - - function Current_State (S : Suspension_Object) return Boolean is - begin - -- We do not want to use lock on this read operation. State is marked - -- as Atomic so that we ensure that the value retrieved is correct. - - return S.State; - end Current_State; - - --------------- - -- Set_False -- - --------------- - - procedure Set_False (S : in out Suspension_Object) is - Result : Interfaces.C.int; - - begin - SSL.Abort_Defer.all; - - Result := pthread_mutex_lock (S.L'Access); - pragma Assert (Result = 0); - - S.State := False; - - Result := pthread_mutex_unlock (S.L'Access); - pragma Assert (Result = 0); - - SSL.Abort_Undefer.all; - end Set_False; - - -------------- - -- Set_True -- - -------------- - - procedure Set_True (S : in out Suspension_Object) is - Result : Interfaces.C.int; - - begin - SSL.Abort_Defer.all; - - Result := pthread_mutex_lock (S.L'Access); - pragma Assert (Result = 0); - - -- If there is already a task waiting on this suspension object then - -- we resume it, leaving the state of the suspension object to False, - -- as specified in (RM D.10(9)). Otherwise, just leave state set True. - - if S.Waiting then - S.Waiting := False; - S.State := False; - - Result := pthread_cond_signal (S.CV'Access); - pragma Assert (Result = 0); - - else - S.State := True; - end if; - - Result := pthread_mutex_unlock (S.L'Access); - pragma Assert (Result = 0); - - SSL.Abort_Undefer.all; - end Set_True; - - ------------------------ - -- Suspend_Until_True -- - ------------------------ - - procedure Suspend_Until_True (S : in out Suspension_Object) is - Result : Interfaces.C.int; - - begin - SSL.Abort_Defer.all; - - Result := pthread_mutex_lock (S.L'Access); - pragma Assert (Result = 0); - - if S.Waiting then - - -- Program_Error must be raised upon calling Suspend_Until_True - -- if another task is already waiting on that suspension object - -- (RM D.10 (10)). - - Result := pthread_mutex_unlock (S.L'Access); - pragma Assert (Result = 0); - - SSL.Abort_Undefer.all; - - raise Program_Error; - - else - -- Suspend the task if the state is False. Otherwise, the task - -- continues its execution, and the state of the suspension object - -- is set to False (RM D.10(9)). - - if S.State then - S.State := False; - else - S.Waiting := True; - Result := pthread_cond_wait (S.CV'Access, S.L'Access); - end if; - - Result := pthread_mutex_unlock (S.L'Access); - pragma Assert (Result = 0); - - SSL.Abort_Undefer.all; - end if; - end Suspend_Until_True; - - ---------------- - -- Check_Exit -- - ---------------- - - -- Dummy version - - function Check_Exit (Self_ID : ST.Task_Id) return Boolean is - pragma Unreferenced (Self_ID); - begin - return True; - end Check_Exit; - - -------------------- - -- Check_No_Locks -- - -------------------- - - function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is - pragma Unreferenced (Self_ID); - begin - return True; - end Check_No_Locks; - - ---------------------- - -- Environment_Task -- - ---------------------- - - function Environment_Task return Task_Id is - begin - return Environment_Task_Id; - end Environment_Task; - - -------------- - -- Lock_RTS -- - -------------- - - procedure Lock_RTS is - begin - Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); - end Lock_RTS; - - ---------------- - -- Unlock_RTS -- - ---------------- - - procedure Unlock_RTS is - begin - Unlock (Single_RTS_Lock'Access, Global_Lock => True); - end Unlock_RTS; - - ------------------ - -- Suspend_Task -- - ------------------ - - function Suspend_Task - (T : ST.Task_Id; - Thread_Self : Thread_Id) return Boolean - is - pragma Unreferenced (T); - pragma Unreferenced (Thread_Self); - begin - return False; - end Suspend_Task; - - ----------------- - -- Resume_Task -- - ----------------- - - function Resume_Task - (T : ST.Task_Id; - Thread_Self : Thread_Id) return Boolean - is - pragma Unreferenced (T); - pragma Unreferenced (Thread_Self); - begin - return False; - end Resume_Task; - - -------------------- - -- Stop_All_Tasks -- - -------------------- - - procedure Stop_All_Tasks is - begin - null; - end Stop_All_Tasks; - - --------------- - -- Stop_Task -- - --------------- - - function Stop_Task (T : ST.Task_Id) return Boolean is - pragma Unreferenced (T); - begin - return False; - end Stop_Task; - - ------------------- - -- Continue_Task -- - ------------------- - - function Continue_Task (T : ST.Task_Id) return Boolean is - pragma Unreferenced (T); - begin - return False; - end Continue_Task; - - ---------------- - -- Initialize -- - ---------------- - - procedure Initialize (Environment_Task : Task_Id) is - act : aliased struct_sigaction; - old_act : aliased struct_sigaction; - Tmp_Set : aliased sigset_t; - Result : Interfaces.C.int; - - function State - (Int : System.Interrupt_Management.Interrupt_ID) return Character; - pragma Import (C, State, "__gnat_get_interrupt_state"); - -- Get interrupt state. Defined in a-init.c - -- The input argument is the interrupt number, - -- and the result is one of the following: - - Default : constant Character := 's'; - -- 'n' this interrupt not set by any Interrupt_State pragma - -- 'u' Interrupt_State pragma set state to User - -- 'r' Interrupt_State pragma set state to Runtime - -- 's' Interrupt_State pragma set state to System (use "default" - -- system handler) - - begin - Environment_Task_Id := Environment_Task; - - Interrupt_Management.Initialize; - - -- Prepare the set of signals that should unblocked in all tasks - - Result := sigemptyset (Unblocked_Signal_Mask'Access); - pragma Assert (Result = 0); - - for J in Interrupt_Management.Interrupt_ID loop - if System.Interrupt_Management.Keep_Unmasked (J) then - Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J)); - pragma Assert (Result = 0); - end if; - end loop; - - -- Initialize the lock used to synchronize chain of all ATCBs - - Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); - - Specific.Initialize (Environment_Task); - - Enter_Task (Environment_Task); - - -- Install the abort-signal handler - - if State - (System.Interrupt_Management.Abort_Task_Interrupt) /= Default - then - act.sa_flags := 0; - act.sa_handler := Abort_Handler'Address; - - Result := sigemptyset (Tmp_Set'Access); - pragma Assert (Result = 0); - act.sa_mask := Tmp_Set; - - Result := - sigaction - (Signal (System.Interrupt_Management.Abort_Task_Interrupt), - act'Unchecked_Access, - old_act'Unchecked_Access); - - pragma Assert (Result = 0); - end if; - end Initialize; - -end System.Task_Primitives.Operations; diff --git a/gcc/ada/s-taskin.ads b/gcc/ada/s-taskin.ads index 26cfabb8aee..ab9e89edb8b 100644 --- a/gcc/ada/s-taskin.ads +++ b/gcc/ada/s-taskin.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -615,12 +615,14 @@ package System.Tasking is -- Protection: Only used by Activator Activator : Task_Id; + pragma Atomic (Activator); -- The task that created this task, either by declaring it as a task -- object or by executing a task allocator. The value is null iff Self -- has completed activation. -- - -- Protection: Set by Activator before Self is activated, and only read - -- and modified by Self after that. + -- Protection: Set by Activator before Self is activated, and + -- only modified by Self after that. Can be read by any task via + -- Ada.Task_Identification.Activation_Is_Complete; hence Atomic. Wait_Count : Natural; -- This count is used by a task that is waiting for other tasks. At all diff --git a/gcc/ada/s-tpopsp-lynxos.adb b/gcc/ada/s-tpopsp-lynxos.adb deleted file mode 100644 index bc98b11fabd..00000000000 --- a/gcc/ada/s-tpopsp-lynxos.adb +++ /dev/null @@ -1,111 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- --- -- --- SYSTEM.TASK_PRIMITIVES.OPERATIONS.SPECIFIC -- --- -- --- B o d y -- --- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- --- -- --- GNARL is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNARL was developed by the GNARL team at Florida State University. -- --- Extensive contributions were provided by Ada Core Technologies, Inc. -- --- -- ------------------------------------------------------------------------------- - --- This is a LynxOS version of this package. - -separate (System.Task_Primitives.Operations) -package body Specific is - - ---------------- - -- Initialize -- - ---------------- - - procedure Initialize (Environment_Task : Task_Id) is - pragma Warnings (Off, Environment_Task); - Result : Interfaces.C.int; - - begin - Result := st_keycreate (null, ATCB_Key'Access); - pragma Assert (Result = 0); - end Initialize; - - ------------------- - -- Is_Valid_Task -- - ------------------- - - function Is_Valid_Task return Boolean is - Result : Interfaces.C.int; - Value : aliased System.Address; - begin - Result := st_getspecific (ATCB_Key, Value'Address); - pragma Assert (Result = 0); - return (Value /= System.Null_Address); - end Is_Valid_Task; - - --------- - -- Set -- - --------- - - procedure Set (Self_Id : Task_Id) is - Result : Interfaces.C.int; - - begin - Result := st_setspecific (ATCB_Key, To_Address (Self_Id)); - pragma Assert (Result = 0); - end Set; - - ---------- - -- Self -- - ---------- - - -- To make Ada tasks and C threads interoperate better, we have added some - -- functionality to Self. Suppose a C main program (with threads) calls an - -- Ada procedure and the Ada procedure calls the tasking runtime system. - -- Eventually, a call will be made to self. Since the call is not coming - -- from an Ada task, there will be no corresponding ATCB. - - -- What we do in Self is to catch references that do not come from - -- recognized Ada tasks, and create an ATCB for the calling thread. - - -- The new ATCB will be "detached" from the normal Ada task master - -- hierarchy, much like the existing implicitly created signal-server - -- tasks. - - function Self return Task_Id is - Value : aliased System.Address; - - Result : Interfaces.C.int; - pragma Unreferenced (Result); - - begin - Result := st_getspecific (ATCB_Key, Value'Address); - -- Is it OK not to check this result??? - - -- If the key value is Null, then it is a non-Ada task. - - if Value /= System.Null_Address then - return To_Task_Id (Value); - else - return Register_Foreign_Thread; - end if; - end Self; - -end Specific; diff --git a/gcc/ada/s-tposen.ads b/gcc/ada/s-tposen.ads index 4bba48b81e3..c5b832ce214 100644 --- a/gcc/ada/s-tposen.ads +++ b/gcc/ada/s-tposen.ads @@ -1,14 +1,14 @@ ------------------------------------------------------------------------------ -- -- --- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- --- SYSTEM.TASKING.PROTECTED_OBJECTS.SINGLE_ENTRY -- +-- SYSTEM.TASKING.PROTECTED_OBJECTS.SINGLE_ENTRY -- -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- --- GNARL is free software; you can redistribute it and/or modify it under -- +-- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- @@ -31,7 +31,7 @@ -- This package provides an optimized version of Protected_Objects.Operations -- and Protected_Objects.Entries making the following assumptions: --- + -- PO have only one entry -- There is only one caller at a time (No_Entry_Queue) -- There is no dynamic priority support (No_Dynamic_Priorities) @@ -39,17 +39,17 @@ -- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0) -- PO are at library level -- None of the tasks will terminate (no need for finalization) --- --- This interface is intended to be used in the ravenscar profile, the + +-- This interface is intended to be used in the Ravenscar profile, the -- compiler is responsible for ensuring that the conditions mentioned above -- are respected, except for the No_Entry_Queue restriction that is checked -- dynamically in this package, since the check cannot be performed at compile -- time, and is relatively cheap (see body). --- + -- This package is part of the high level tasking interface used by the -- compiler to expand Ada 95 tasking constructs into simpler run time calls -- (aka GNARLI, GNU Ada Run-time Library Interface) --- + -- Note: the compiler generates direct calls to this interface, via Rtsfind. -- Any changes to this interface may require corresponding compiler changes -- in exp_ch9.adb and possibly exp_ch7.adb @@ -191,34 +191,34 @@ package System.Tasking.Protected_Objects.Single_Entry is -- to keep track of the runtime state of a protected object. procedure Lock_Entry (Object : Protection_Entry_Access); - -- Lock a protected object for write access. Upon return, the caller - -- owns the lock to this object, and no other call to Lock or - -- Lock_Read_Only with the same argument will return until the - -- corresponding call to Unlock has been made by the caller. + -- Lock a protected object for write access. Upon return, the caller owns + -- the lock to this object, and no other call to Lock or Lock_Read_Only + -- with the same argument will return until the corresponding call to + -- Unlock has been made by the caller. procedure Lock_Read_Only_Entry (Object : Protection_Entry_Access); - -- Lock a protected object for read access. Upon return, the caller - -- owns the lock for read access, and no other calls to Lock - -- with the same argument will return until the corresponding call - -- to Unlock has been made by the caller. Other calls to Lock_Read_Only - -- may (but need not) return before the call to Unlock, and the - -- corresponding callers will also own the lock for read access. + -- Lock a protected object for read access. Upon return, the caller owns + -- the lock for read access, and no other calls to Lock with the same + -- argument will return until the corresponding call to Unlock has been + -- made by the caller. Other calls to Lock_Read_Only may (but need not) + -- return before the call to Unlock, and the corresponding callers will + -- also own the lock for read access. procedure Unlock_Entry (Object : Protection_Entry_Access); - -- Relinquish ownership of the lock for the object represented by - -- the Object parameter. If this ownership was for write access, or - -- if it was for read access where there are no other read access - -- locks outstanding, one (or more, in the case of Lock_Read_Only) - -- of the tasks waiting on this lock (if any) will be given the - -- lock and allowed to return from the Lock or Lock_Read_Only call. + -- Relinquish ownership of the lock for the object represented by the + -- Object parameter. If this ownership was for write access, or if it was + -- for read access where there are no other read access locks outstanding, + -- one (or more, in the case of Lock_Read_Only) of the tasks waiting on + -- this lock (if any) will be given the lock and allowed to return from + -- the Lock or Lock_Read_Only call. procedure Service_Entry (Object : Protection_Entry_Access); -- Service the entry queue of the specified object, executing the -- corresponding body of any queued entry call that is waiting on True -- barrier. This is used when the state of a protected object may have - -- changed, in particular after the execution of the statement sequence of - -- a protected procedure. + -- changed, in particular after the execution of the statement sequence + -- of a protected procedure. -- -- This must be called with abort deferred and with the corresponding -- object locked. Object is unlocked on return. @@ -227,9 +227,10 @@ package System.Tasking.Protected_Objects.Single_Entry is (Object : Protection_Entry_Access; Uninterpreted_Data : System.Address; Mode : Call_Modes); - -- Make a protected entry call to the specified object. - -- Pend a protected entry call on the protected object represented - -- by Object. A pended call is not queued; it may be executed immediately + -- Make a protected entry call to the specified object + -- + -- Pend a protected entry call on the protected object represented by + -- Object. A pended call is not queued; it may be executed immediately -- or queued, depending on the state of the entry barrier. -- -- Uninterpreted_Data @@ -258,19 +259,18 @@ package System.Tasking.Protected_Objects.Single_Entry is procedure Exceptional_Complete_Single_Entry_Body (Object : Protection_Entry_Access; Ex : Ada.Exceptions.Exception_Id); - -- Perform all of the functions of Complete_Entry_Body. In addition, - -- report in Ex the exception whose propagation terminated the entry - -- body to the runtime system. + -- Perform all of the functions of Complete_Entry_Body. In addition, report + -- in Ex the exception whose propagation terminated the entry body to the + -- runtime system. - function Protected_Count_Entry (Object : Protection_Entry) - return Natural; + function Protected_Count_Entry (Object : Protection_Entry) return Natural; -- Return the number of entry calls on Object (0 or 1) - function Protected_Single_Entry_Caller (Object : Protection_Entry) - return Task_Id; - -- Return value of E'Caller, where E is the protected entry currently - -- being handled. This will only work if called from within an - -- entry body, as required by the LRM (C.7.1(14)). + function Protected_Single_Entry_Caller + (Object : Protection_Entry) return Task_Id; + -- Return value of E'Caller, where E is the protected entry currently being + -- handled. This will only work if called from within an entry body, as + -- required by the LRM (C.7.1(14)). private type Protection_Entry is record diff --git a/gcc/ada/scans.ads b/gcc/ada/scans.ads index c0e589d6a31..ff05953d2c5 100644 --- a/gcc/ada/scans.ads +++ b/gcc/ada/scans.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -82,6 +82,15 @@ package Scans is Tok_Others, -- OTHERS Tok_Null, -- NULL + -- Note: Tok_Raise is in no categories now, it used to be Cterm, Eterm, + -- After_SM, but now that Ada 2012 has added raise expressions, the + -- raise token can appear anywhere. Note in particular that Tok_Raise + -- being in Eterm stopped the parser from recognizing "return raise + -- exception-name". This degrades error recovery slightly, and perhaps + -- we could do better, but not worth the effort. + + Tok_Raise, -- RAISE + Tok_Dot, -- . Namext Tok_Apostrophe, -- ' Namext @@ -148,7 +157,6 @@ package Scans is Tok_Goto, -- GOTO Eterm, Sterm, After_SM Tok_If, -- IF Eterm, Sterm, After_SM Tok_Pragma, -- PRAGMA Eterm, Sterm, After_SM - Tok_Raise, -- RAISE Eterm, Sterm, After_SM Tok_Requeue, -- REQUEUE Eterm, Sterm, After_SM Tok_Return, -- RETURN Eterm, Sterm, After_SM Tok_Select, -- SELECT Eterm, Sterm, After_SM diff --git a/gcc/ada/scn.adb b/gcc/ada/scn.adb index 9f8ce2078d4..cc88ab9c125 100644 --- a/gcc/ada/scn.adb +++ b/gcc/ada/scn.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -25,7 +25,6 @@ with Atree; use Atree; with Csets; use Csets; -with Hostparm; use Hostparm; with Namet; use Namet; with Opt; use Opt; with Restrict; use Restrict; @@ -44,32 +43,11 @@ package body Scn is -- make sure that we only post an error message for incorrect use of a -- keyword as an identifier once for a given keyword). - procedure Check_End_Of_Line; - -- Called when end of line encountered. Checks that line is not too long, - -- and that other style checks for the end of line are met. - function Determine_License return License_Type; -- Scan header of file and check that it has an appropriate GNAT-style -- header with a proper license statement. Returns GPL, Unrestricted, -- or Modified_GPL depending on header. If none of these, returns Unknown. - procedure Error_Long_Line; - -- Signal error of excessively long line - - ----------------------- - -- Check_End_Of_Line -- - ----------------------- - - procedure Check_End_Of_Line is - Len : constant Int := Int (Scan_Ptr) - Int (Current_Line_Start); - begin - if Style_Check then - Style.Check_Line_Terminator (Len); - elsif Len > Max_Line_Length then - Error_Long_Line; - end if; - end Check_End_Of_Line; - ----------------------- -- Determine_License -- ----------------------- @@ -182,7 +160,7 @@ package body Scn is Skip_EOL; - Check_End_Of_Line; + Scanner.Check_End_Of_Line; if Source (Scan_Ptr) /= EOF then @@ -219,17 +197,6 @@ package body Scn is return Scanner.Determine_Token_Casing; end Determine_Token_Casing; - --------------------- - -- Error_Long_Line -- - --------------------- - - procedure Error_Long_Line is - begin - Error_Msg - ("this line is too long", - Current_Line_Start + Source_Ptr (Max_Line_Length)); - end Error_Long_Line; - ------------------------ -- Initialize_Scanner -- ------------------------ diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index ef3d665554a..8b08949601a 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -259,6 +259,82 @@ package body Scng is end case; end Accumulate_Token_Checksum_GNAT_5_03; + ----------------------- + -- Check_End_Of_Line -- + ----------------------- + + procedure Check_End_Of_Line is + Len : constant Int := + Int (Scan_Ptr) - + Int (Current_Line_Start) - + Wide_Char_Byte_Count; + + -- Start of processing for Check_End_Of_Line + + begin + if Style_Check then + Style.Check_Line_Terminator (Len); + end if; + + -- Deal with checking maximum line length + + if Style_Check and Style_Check_Max_Line_Length then + Style.Check_Line_Max_Length (Len); + + -- If style checking is inactive, check maximum line length against + -- standard value. + + elsif Len > Max_Line_Length then + Error_Msg + ("this line is too long", + Current_Line_Start + Source_Ptr (Max_Line_Length)); + end if; + + -- Now one more checking circuit. Normally we are only enforcing a limit + -- of physical characters, with tabs counting as one character. But if + -- after tab expansion we would have a total line length that exceeded + -- 32766, that would really cause trouble, because column positions + -- would exceed the maximum we allow for a column count. Note: the limit + -- is 32766 rather than 32767, since we use a value of 32767 for special + -- purposes (see Sinput). Now we really do not want to go messing with + -- tabs in the normal case, so what we do is to check for a line that + -- has more than 4096 physical characters. Any shorter line could not + -- be a problem, even if it was all tabs. + + if Len >= 4096 then + declare + Col : Natural; + Ptr : Source_Ptr; + + begin + Col := 1; + Ptr := Current_Line_Start; + loop + exit when Ptr = Scan_Ptr; + + if Source (Ptr) = ASCII.HT then + Col := (Col - 1 + 8) / 8 * 8 + 1; + else + Col := Col + 1; + end if; + + if Col > 32766 then + Error_Msg + ("this line is longer than 32766 characters", + Current_Line_Start); + raise Unrecoverable_Error; + end if; + + Ptr := Ptr + 1; + end loop; + end; + end if; + + -- Reset wide character byte count for next line + + Wide_Char_Byte_Count := 0; + end Check_End_Of_Line; + ---------------------------- -- Determine_Token_Casing -- ---------------------------- @@ -336,10 +412,6 @@ package body Scng is Wptr : Source_Ptr; -- Used to remember start of last wide character scanned - procedure Check_End_Of_Line; - -- Called when end of line encountered. Checks that line is not too - -- long, and that other style checks for the end of line are met. - function Double_Char_Token (C : Character) return Boolean; -- This function is used for double character tokens like := or <>. It -- checks if the character following Source (Scan_Ptr) is C, and if so @@ -359,9 +431,6 @@ package body Scng is -- past the illegal character, which may still leave us pointing to -- junk, not much we can do if the escape sequence is messed up! - procedure Error_Long_Line; - -- Signal error of excessively long line - procedure Error_No_Double_Underline; -- Signal error of two underline or punctuation characters in a row. -- Called with Scan_Ptr pointing to second underline/punctuation char. @@ -389,78 +458,6 @@ package body Scng is -- character sequence, does not modify the scan pointer in any case. ----------------------- - -- Check_End_Of_Line -- - ----------------------- - - procedure Check_End_Of_Line is - Len : constant Int := - Int (Scan_Ptr) - - Int (Current_Line_Start) - - Wide_Char_Byte_Count; - - begin - if Style_Check then - Style.Check_Line_Terminator (Len); - end if; - - -- Deal with checking maximum line length - - if Style_Check and Style_Check_Max_Line_Length then - Style.Check_Line_Max_Length (Len); - - -- If style checking is inactive, check maximum line length against - -- standard value. - - elsif Len > Max_Line_Length then - Error_Long_Line; - end if; - - -- Now one more checking circuit. Normally we are only enforcing a - -- limit of physical characters, with tabs counting as one character. - -- But if after tab expansion we would have a total line length that - -- exceeded 32766, that would really cause trouble, because column - -- positions would exceed the maximum we allow for a column count. - -- Note: the limit is 32766 rather than 32767, since we use a value - -- of 32767 for special purposes (see Sinput). Now we really do not - -- want to go messing with tabs in the normal case, so what we do is - -- to check for a line that has more than 4096 physical characters. - -- Any shorter line could not be a problem, even if it was all tabs. - - if Len >= 4096 then - declare - Col : Natural; - Ptr : Source_Ptr; - - begin - Col := 1; - Ptr := Current_Line_Start; - loop - exit when Ptr = Scan_Ptr; - - if Source (Ptr) = ASCII.HT then - Col := (Col - 1 + 8) / 8 * 8 + 1; - else - Col := Col + 1; - end if; - - if Col > 32766 then - Error_Msg - ("this line is longer than 32766 characters", - Current_Line_Start); - raise Unrecoverable_Error; - end if; - - Ptr := Ptr + 1; - end loop; - end; - end if; - - -- Reset wide character byte count for next line - - Wide_Char_Byte_Count := 0; - end Check_End_Of_Line; - - ----------------------- -- Double_Char_Token -- ----------------------- @@ -505,17 +502,6 @@ package body Scng is Error_Msg ("illegal wide character", Wptr); end Error_Illegal_Wide_Character; - --------------------- - -- Error_Long_Line -- - --------------------- - - procedure Error_Long_Line is - begin - Error_Msg - ("this line is too long", - Current_Line_Start + Source_Ptr (Max_Line_Length)); - end Error_Long_Line; - ------------------------------- -- Error_No_Double_Underline -- ------------------------------- diff --git a/gcc/ada/scng.ads b/gcc/ada/scng.ads index d9035119f4b..32ecc67d0ad 100644 --- a/gcc/ada/scng.ads +++ b/gcc/ada/scng.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -56,6 +56,10 @@ generic package Scng is + procedure Check_End_Of_Line; + -- Called when end of line encountered. Checks that line is not too long, + -- and that other style checks for the end of line are met. + procedure Initialize_Scanner (Index : Source_File_Index); -- Initialize lexical scanner for scanning a new file referenced by Index. -- Initialize_Scanner does not call Scan. diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 3e66a0e0563..94ee841b7dc 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -530,9 +530,6 @@ package body Sem is when N_Subprogram_Declaration => Analyze_Subprogram_Declaration (N); - when N_Subprogram_Info => - Analyze_Subprogram_Info (N); - when N_Subprogram_Renaming_Declaration => Analyze_Subprogram_Renaming (N); @@ -1315,18 +1312,19 @@ package body Sem is S_Outer_Gen_Scope : constant Entity_Id := Outer_Generic_Scope; S_Style_Check : constant Boolean := Style_Check; + Curunit : constant Unit_Number_Type := Get_Cunit_Unit_Number (Comp_Unit); + -- New value of Current_Sem_Unit + Generic_Main : constant Boolean := - Nkind (Unit (Cunit (Main_Unit))) - in N_Generic_Declaration; + Nkind (Unit (Cunit (Main_Unit))) in N_Generic_Declaration; -- If the main unit is generic, every compiled unit, including its -- context, is compiled with expansion disabled. Is_Main_Unit_Or_Main_Unit_Spec : constant Boolean := - Current_Sem_Unit = Main_Unit + Curunit = Main_Unit or else (Nkind (Unit (Cunit (Main_Unit))) = N_Package_Body - and then Library_Unit (Cunit (Main_Unit)) = - Cunit (Current_Sem_Unit)); + and then Library_Unit (Cunit (Main_Unit)) = Cunit (Curunit)); -- Configuration flags have special settings when compiling a predefined -- file as a main unit. This applies to its spec as well. @@ -1396,7 +1394,7 @@ package body Sem is end if; Compiler_State := Analyzing; - Current_Sem_Unit := Get_Cunit_Unit_Number (Comp_Unit); + Current_Sem_Unit := Curunit; -- Compile predefined units with GNAT_Mode set to True, to properly -- process the categorization stuff. However, do not set GNAT_Mode @@ -1421,7 +1419,6 @@ package body Sem is Inside_A_Generic := False; In_Assertion_Expr := 0; In_Spec_Expression := False; - Set_Comes_From_Source_Default (False); -- Save current config switches and reset then appropriately diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 03930f5e3cf..374bb7b9081 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -4204,6 +4204,17 @@ package body Sem_Aggr is end; end if; + -- Ada 2012: If component is scalar with default value, use it + + elsif Is_Scalar_Type (Ctyp) + and then Has_Default_Aspect (Ctyp) + then + Add_Association + (Component => Component, + Expr => Default_Aspect_Value + (First_Subtype (Underlying_Type (Ctyp))), + Assoc_List => New_Assoc_List); + elsif Has_Non_Null_Base_Init_Proc (Ctyp) or else not Expander_Active then diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 5727e6d0990..ee1841196ff 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -3994,13 +3994,23 @@ package body Sem_Attr is Check_References_In_Prefix (Loop_Id); -- The prefix must denote a static entity if the pragma does not - -- apply to the innermost enclosing loop statement. + -- apply to the innermost enclosing loop statement, or if it appears + -- within a potentially unevaluated epxression. - if Present (Enclosing_Loop) - and then Entity (Identifier (Enclosing_Loop)) /= Loop_Id - and then not Is_Entity_Name (P) + if Is_Entity_Name (P) + or else Nkind (Parent (P)) = N_Object_Renaming_Declaration + then + null; + + elsif Present (Enclosing_Loop) + and then Entity (Identifier (Enclosing_Loop)) /= Loop_Id then - Error_Attr_P ("prefix of attribute % must denote an entity"); + Error_Attr_P ("prefix of attribute % that applies to " + & "outer loop must denote an entity"); + + elsif Is_Potentially_Unevaluated (P) then + Error_Attr_P ("prefix of attribute % that is potentially " + & "unevaluated must denote an entity"); end if; end Loop_Entry; @@ -4337,6 +4347,8 @@ package body Sem_Attr is -- During pre-analysis, Prag is the enclosing pragma node if any begin + Prag := Empty; + -- Find enclosing scopes, excluding loops CS := Current_Scope; @@ -4515,6 +4527,18 @@ package body Sem_Attr is ("??attribute Old applied to constant has no effect", P); end if; + -- Check that the prefix of 'Old is an entity, when it appears in + -- a postcondition and may be potentially unevaluated (6.1.1 (27/3)). + + if Present (Prag) + and then Get_Pragma_Id (Prag) = Pragma_Postcondition + and then Is_Potentially_Unevaluated (N) + and then not Is_Entity_Name (P) + then + Error_Attr_P ("prefix of attribute % that is potentially " + & "unevaluated must denote an entity"); + end if; + -- The attribute appears within a pre/postcondition, but refers to -- an entity in the enclosing subprogram. If it is a component of -- a formal its expansion might generate actual subtypes that may @@ -5989,6 +6013,11 @@ package body Sem_Attr is Comp_Or_Discr := First_Entity (Typ); while Present (Comp_Or_Discr) loop if Chars (Comp_Or_Discr) = Comp_Name then + + -- Record component entity in the given aggregate choice, + -- for subsequent resolution. + + Set_Entity (Comp, Comp_Or_Discr); exit; end if; @@ -6035,6 +6064,7 @@ package body Sem_Attr is begin Check_E1; + Check_Ada_2012_Attribute; if not Is_Object_Reference (P) then Error_Attr_P ("prefix of attribute % must denote an object"); @@ -6062,11 +6092,61 @@ package body Sem_Attr is Assoc := First (Component_Associations (E1)); while Present (Assoc) loop Comp := First (Choices (Assoc)); + Analyze (Expression (Assoc)); while Present (Comp) loop if Nkind (Comp) = N_Others_Choice then Error_Attr ("others choice not allowed in attribute %", Comp); + elsif Is_Array_Type (P_Type) then + declare + Index : Node_Id; + Index_Type : Entity_Id; + + begin + if Nkind (First (Choices (Assoc))) /= N_Aggregate then + + -- Choices denote separate components of one- + -- dimensional array. + + Index_Type := First_Index (P_Type); + + Index := First (Choices (Assoc)); + while Present (Index) loop + if Nkind (Index) = N_Range then + Analyze_And_Resolve + (Low_Bound (Index), Etype (Index_Type)); + Analyze_And_Resolve + (High_Bound (Index), Etype (Index_Type)); + Set_Etype (Index, Etype (Index_Type)); + + else + Analyze_And_Resolve (Index, Etype (Index_Type)); + end if; + + Next (Index); + end loop; + + -- Choice is a sequence of indexes for each dimension + + else + Index_Type := First_Index (P_Type); + Index := First (Expressions (First (Choices (Assoc)))); + while Present (Index_Type) + and then Present (Index) + loop + Analyze_And_Resolve (Index, Etype (Index_Type)); + Next_Index (Index_Type); + Next (Index); + end loop; + + if Present (Index) or else Present (Index_Type) then + Error_Msg_N + ("dimension mismatch in index list", Assoc); + end if; + end if; + end; + elsif Is_Record_Type (P_Type) then Check_Component_Reference (Comp, P_Type); end if; @@ -8802,12 +8882,8 @@ package body Sem_Attr is -- Attribute Update is never static - ------------ - -- Update -- - ------------ - when Attribute_Update => - null; + return; --------------- -- VADS_Size -- @@ -10385,6 +10461,60 @@ package body Sem_Attr is -- Processing is shared with Access + ------------ + -- Update -- + ------------ + + -- Resolve aggregate components in component associations + + when Attribute_Update => + declare + Aggr : constant Node_Id := First (Expressions (N)); + Typ : constant Entity_Id := Etype (Prefix (N)); + Assoc : Node_Id; + Comp : Node_Id; + + begin + -- Set the Etype of the aggregate to that of the prefix, even + -- though the aggregate may not be a proper representation of a + -- value of the type (missing or duplicated associations, etc.) + -- Complete resolution of the prefix. Note that in Ada 2012 it + -- can be a qualified expression that is e.g. an aggregate. + + Set_Etype (Aggr, Typ); + Resolve (Prefix (N), Typ); + + -- For an array type, resolve expressions with the component + -- type of the array. + + if Is_Array_Type (Typ) then + Assoc := First (Component_Associations (Aggr)); + while Present (Assoc) loop + Resolve (Expression (Assoc), Component_Type (Typ)); + Next (Assoc); + end loop; + + -- For a record type, use type of each component, which is + -- recorded during analysis. + + else + Assoc := First (Component_Associations (Aggr)); + while Present (Assoc) loop + Comp := First (Choices (Assoc)); + if Nkind (Comp) /= N_Others_Choice + and then not Error_Posted (Comp) + then + Resolve (Expression (Assoc), Etype (Entity (Comp))); + end if; + Next (Assoc); + end loop; + end if; + end; + + -- Premature return requires comment ??? + + return; + --------- -- Val -- --------- diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index f0898bfa0df..353bbbcb367 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -737,13 +737,4 @@ package body Sem_Ch11 is end if; end Analyze_Raise_xxx_Error; - ----------------------------- - -- Analyze_Subprogram_Info -- - ----------------------------- - - procedure Analyze_Subprogram_Info (N : Node_Id) is - begin - Set_Etype (N, RTE (RE_Code_Loc)); - end Analyze_Subprogram_Info; - end Sem_Ch11; diff --git a/gcc/ada/sem_ch11.ads b/gcc/ada/sem_ch11.ads index 656f12d8cc3..c732499f0f0 100644 --- a/gcc/ada/sem_ch11.ads +++ b/gcc/ada/sem_ch11.ads @@ -30,7 +30,6 @@ package Sem_Ch11 is procedure Analyze_Raise_Expression (N : Node_Id); procedure Analyze_Raise_Statement (N : Node_Id); procedure Analyze_Raise_xxx_Error (N : Node_Id); - procedure Analyze_Subprogram_Info (N : Node_Id); procedure Analyze_Exception_Handlers (L : List_Id); -- Analyze list of exception handlers of a handled statement sequence diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 6b9c5feffc7..565df4edf07 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -9844,10 +9844,13 @@ package body Sem_Ch12 is -- The following check is only relevant when SPARK_Mode is on as it is -- not a standard Ada legality rule. - if SPARK_Mode = On and then Is_Volatile_Object (Actual) then + if SPARK_Mode = On + and then Present (Actual) + and then Is_SPARK_Volatile_Object (Actual) + then Error_Msg_N ("volatile object cannot act as actual in generic instantiation " - & "(SPARK RM 7.1.3(4))", Actual); + & "(SPARK RM 7.1.3(8))", Actual); end if; return List; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index dbfc215378d..61db885924c 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1633,10 +1633,11 @@ package body Sem_Ch13 is -- referring to the entity, and the second argument is the -- aspect definition expression. - -- Suppress/Unsuppress + -- Linker_Section/Suppress/Unsuppress - when Aspect_Suppress | - Aspect_Unsuppress => + when Aspect_Linker_Section | + Aspect_Suppress | + Aspect_Unsuppress => Make_Aitem_Pragma (Pragma_Argument_Associations => New_List ( @@ -7941,6 +7942,9 @@ package body Sem_Ch13 is Aspect_Value_Size => T := Any_Integer; + when Aspect_Linker_Section => + T := Standard_String; + when Aspect_Synchronization => return; @@ -10786,6 +10790,10 @@ package body Sem_Ch13 is if Has_Foreign_Convention (T) and then Esize (T) < Standard_Integer_Size + + -- Don't do this if Short_Enums on target + + and then not Target_Short_Enums then Init_Esize (T, Standard_Integer_Size); else diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 58bac3570ed..56bd43a0037 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -91,10 +91,10 @@ package body Sem_Ch3 is -- abstract interface types implemented by a record type or a derived -- record type. - procedure Analyze_Variable_Contract (Var_Id : Entity_Id); - -- Analyze all delayed aspects chained on the contract of variable Var_Id - -- as if they appeared at the end of the declarative region. The aspects - -- to be considered are: + procedure Analyze_Object_Contract (Obj_Id : Entity_Id); + -- Analyze all delayed aspects chained on the contract of object Obj_Id as + -- if they appeared at the end of the declarative region. The aspects to be + -- considered are: -- Async_Readers -- Async_Writers -- Effective_Reads @@ -2333,8 +2333,14 @@ package body Sem_Ch3 is Freeze_From := First_Entity (Current_Scope); end if; + -- There may have been several freezing points previously, + -- for example object declarations or subprogram bodies, but + -- at the end of a declarative part we check freezing from + -- the beginning, even though entities may already be frozen, + -- in order to perform visibility checks on delayed aspects. + Adjust_Decl; - Freeze_All (Freeze_From, Decl); + Freeze_All (First_Entity (Current_Scope), Decl); Freeze_From := Last_Entity (Current_Scope); elsif Scope (Current_Scope) /= Standard_Standard @@ -2348,7 +2354,7 @@ package body Sem_Ch3 is or else Is_Empty_List (Private_Declarations (Parent (L))) then Adjust_Decl; - Freeze_All (Freeze_From, Decl); + Freeze_All (First_Entity (Current_Scope), Decl); Freeze_From := Last_Entity (Current_Scope); end if; @@ -2378,10 +2384,22 @@ package body Sem_Ch3 is -- This ensures that the primitive will override its inherited -- counterpart before the freeze takes place. + -- If the declaration we just processed is a body, do not attempt + -- to examine Next_Decl as the late primitive idiom can only apply + -- to the first encountered body. + + -- The spec of the late primitive is not generated in ASIS mode to + -- ensure a consistent list of primitives that indicates the true + -- semantic structure of the program (which is not relevant when + -- generating executable code. + -- ??? a cleaner approach may be possible and/or this solution -- could be extended to general-purpose late primitives, TBD. - if not Body_Seen and then not Is_Body (Decl) then + if not ASIS_Mode + and then not Body_Seen + and then not Is_Body (Decl) + then Body_Seen := True; if Nkind (Next_Decl) = N_Subprogram_Body then @@ -2460,10 +2478,8 @@ package body Sem_Ch3 is elsif Nkind (Decl) = N_Subprogram_Declaration then Analyze_Subprogram_Contract (Defining_Entity (Decl)); - elsif Nkind (Decl) = N_Object_Declaration - and then Ekind (Defining_Entity (Decl)) = E_Variable - then - Analyze_Variable_Contract (Defining_Entity (Decl)); + elsif Nkind (Decl) = N_Object_Declaration then + Analyze_Object_Contract (Defining_Entity (Decl)); end if; Next (Decl); @@ -3053,6 +3069,106 @@ package body Sem_Ch3 is end if; end Analyze_Number_Declaration; + ----------------------------- + -- Analyze_Object_Contract -- + ----------------------------- + + procedure Analyze_Object_Contract (Obj_Id : Entity_Id) is + AR_Val : Boolean := False; + AW_Val : Boolean := False; + ER_Val : Boolean := False; + EW_Val : Boolean := False; + Items : Node_Id; + Nam : Name_Id; + Prag : Node_Id; + Seen : Boolean := False; + + begin + if Ekind (Obj_Id) = E_Constant then + + -- A constant cannot be volatile. This check is only relevant when + -- SPARK_Mode is on as it is not standard Ada legality rule. Do not + -- flag internally-generated constants that map generic formals to + -- actuals in instantiations. + + if SPARK_Mode = On + and then Is_SPARK_Volatile_Object (Obj_Id) + and then No (Corresponding_Generic_Association (Parent (Obj_Id))) + then + Error_Msg_N + ("constant cannot be volatile (SPARK RM 7.1.3(4))", Obj_Id); + end if; + + else pragma Assert (Ekind (Obj_Id) = E_Variable); + + -- The following checks are only relevant when SPARK_Mode is on as + -- they are not standard Ada legality rules. + + if SPARK_Mode = On then + + -- A non-volatile object cannot have volatile components + + if not Is_SPARK_Volatile_Object (Obj_Id) + and then Has_Volatile_Component (Etype (Obj_Id)) + then + Error_Msg_N + ("non-volatile variable & cannot have volatile components " + & "(SPARK RM 7.1.3(6))", Obj_Id); + + -- The declaration of a volatile object must appear at the library + -- level. + + elsif Is_SPARK_Volatile_Object (Obj_Id) + and then not Is_Library_Level_Entity (Obj_Id) + then + Error_Msg_N + ("volatile variable & must be declared at library level " + & "(SPARK RM 7.1.3(5))", Obj_Id); + end if; + end if; + + -- Examine the contract + + Items := Contract (Obj_Id); + + if Present (Items) then + + -- Analyze classification pragmas + + Prag := Classifications (Items); + while Present (Prag) loop + Nam := Pragma_Name (Prag); + + if Nam = Name_Async_Readers then + Analyze_External_Property_In_Decl_Part (Prag, AR_Val); + Seen := True; + + elsif Nam = Name_Async_Writers then + Analyze_External_Property_In_Decl_Part (Prag, AW_Val); + Seen := True; + + elsif Nam = Name_Effective_Reads then + Analyze_External_Property_In_Decl_Part (Prag, ER_Val); + Seen := True; + + else pragma Assert (Nam = Name_Effective_Writes); + Analyze_External_Property_In_Decl_Part (Prag, EW_Val); + Seen := True; + end if; + + Prag := Next_Pragma (Prag); + end loop; + end if; + + -- Once all external properties have been processed, verify their + -- mutual interaction. + + if Seen then + Check_External_Properties (Obj_Id, AR_Val, AW_Val, ER_Val, EW_Val); + end if; + end if; + end Analyze_Object_Contract; + -------------------------------- -- Analyze_Object_Declaration -- -------------------------------- @@ -4871,73 +4987,6 @@ package body Sem_Ch3 is end if; end Analyze_Subtype_Indication; - ------------------------------- - -- Analyze_Variable_Contract -- - ------------------------------- - - procedure Analyze_Variable_Contract (Var_Id : Entity_Id) is - Items : constant Node_Id := Contract (Var_Id); - AR_Val : Boolean := False; - AW_Val : Boolean := False; - ER_Val : Boolean := False; - EW_Val : Boolean := False; - Nam : Name_Id; - Prag : Node_Id; - Seen : Boolean := False; - - begin - -- The declaration of a volatile variable must appear at the library - -- level. The check is only relevant when SPARK_Mode is on as it is not - -- standard Ada legality rule. - - if SPARK_Mode = On - and then Is_Volatile_Object (Var_Id) - and then not Is_Library_Level_Entity (Var_Id) - then - Error_Msg_N - ("volatile variable & must be declared at library level (SPARK RM " - & "7.1.3(3))", Var_Id); - end if; - - -- Examine the contract - - if Present (Items) then - - -- Analyze classification pragmas - - Prag := Classifications (Items); - while Present (Prag) loop - Nam := Pragma_Name (Prag); - - if Nam = Name_Async_Readers then - Analyze_External_State_In_Decl_Part (Prag, AR_Val); - Seen := True; - - elsif Nam = Name_Async_Writers then - Analyze_External_State_In_Decl_Part (Prag, AW_Val); - Seen := True; - - elsif Nam = Name_Effective_Reads then - Analyze_External_State_In_Decl_Part (Prag, ER_Val); - Seen := True; - - else pragma Assert (Nam = Name_Effective_Writes); - Analyze_External_State_In_Decl_Part (Prag, EW_Val); - Seen := True; - end if; - - Prag := Next_Pragma (Prag); - end loop; - end if; - - -- Once all external properties have been processed, verify their mutual - -- interaction. - - if Seen then - Check_External_Properties (Var_Id, AR_Val, AW_Val, ER_Val, EW_Val); - end if; - end Analyze_Variable_Contract; - -------------------------- -- Analyze_Variant_Part -- -------------------------- @@ -9672,18 +9721,17 @@ package body Sem_Ch3 is elsif Is_Concurrent_Record_Type (T) and then Present (Interfaces (T)) then - -- The controlling formal of Subp must be of mode "out", - -- "in out" or an access-to-variable to be overridden. + -- If an inherited subprogram is implemented by a protected + -- procedure or an entry, then the first parameter of the + -- inherited subprogram shall be of mode OUT or IN OUT, or + -- an access-to-variable parameter (RM 9.4(11.9/3)) - if Ekind (First_Formal (Subp)) = E_In_Parameter + if Is_Protected_Type (Corresponding_Concurrent_Type (T)) + and then Ekind (First_Formal (Subp)) = E_In_Parameter and then Ekind (Subp) /= E_Function + and then not Is_Predefined_Dispatching_Operation (Subp) then - if not Is_Predefined_Dispatching_Operation (Subp) - and then Is_Protected_Type - (Corresponding_Concurrent_Type (T)) - then - Error_Msg_PT (T, Subp); - end if; + Error_Msg_PT (T, Subp); -- Some other kind of overriding failure @@ -11087,10 +11135,13 @@ package body Sem_Ch3 is -- If previous full declaration or a renaming declaration exists, or if -- a homograph is present, let Enter_Name handle it, either with an -- error or with the removal of an overridden implicit subprogram. + -- The previous one is a full declaration if it has an expression + -- (which in the case of an aggregate is indicated by the Init flag). if Ekind (Prev) /= E_Constant or else Nkind (Parent (Prev)) = N_Object_Renaming_Declaration or else Present (Expression (Parent (Prev))) + or else Has_Init_Expression (Parent (Prev)) or else Present (Full_View (Prev)) then Enter_Name (Id); @@ -18056,6 +18107,16 @@ package body Sem_Ch3 is end if; end if; + -- A discriminant cannot be volatile. This check is only relevant + -- when SPARK_Mode is on as it is not standard Ada legality rule. + + if SPARK_Mode = On + and then Is_SPARK_Volatile_Object (Defining_Identifier (Discr)) + then + Error_Msg_N + ("discriminant cannot be volatile (SPARK RM 7.1.3(6))", Discr); + end if; + Next (Discr); end loop; diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 4bff4df47df..51e7f090b19 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -3943,6 +3943,7 @@ package body Sem_Ch4 is -- searches have failed. When the match is found (it always will be), -- the Etype of both N and Sel are set from this component, and the -- entity of Sel is set to reference this component. + -- ??? no longer true that a match is found ??? function Has_Mode_Conformant_Spec (Comp : Entity_Id) return Boolean; -- It is known that the parent of N denotes a subprogram call. Comp @@ -3971,9 +3972,7 @@ package body Sem_Ch4 is Next_Component (Comp); end loop; - -- This must succeed because code was legal in the generic - - raise Program_Error; + -- Need comment on what is going on when we fall through ??? end Find_Component_In_Instance; ------------------------------ @@ -4594,41 +4593,60 @@ package body Sem_Ch4 is Check_Misspelled_Selector (Type_To_Use, Sel); + -- If this is a derived formal type, the parent may have different + -- visibility at this point. Try for an inherited component before + -- reporting an error. + elsif Is_Generic_Type (Prefix_Type) and then Ekind (Prefix_Type) = E_Record_Type_With_Private and then Prefix_Type /= Etype (Prefix_Type) and then Is_Record_Type (Etype (Prefix_Type)) then - -- If this is a derived formal type, the parent may have - -- different visibility at this point. Try for an inherited - -- component before reporting an error. - Set_Etype (Prefix (N), Etype (Prefix_Type)); Analyze_Selected_Component (N); return; - -- Similarly, if this is the actual for a formal derived type, the - -- component inherited from the generic parent may not be visible - -- in the actual, but the selected component is legal. + -- Similarly, if this is the actual for a formal derived type, or + -- a derived type thereof, the component inherited from the generic + -- parent may not be visible in the actual, but the selected + -- component is legal. Climb up the derivation chain of the generic + -- parent type until we find the proper ancestor type. - elsif Ekind (Prefix_Type) = E_Record_Subtype_With_Private - and then Is_Generic_Actual_Type (Prefix_Type) - and then Present (Full_View (Prefix_Type)) - then + elsif In_Instance and then Is_Tagged_Type (Prefix_Type) then + declare + Par : Entity_Id := Prefix_Type; + begin + -- Climb up derivation chain to generic actual subtype - Find_Component_In_Instance - (Generic_Parent_Type (Parent (Prefix_Type))); - return; + while not Is_Generic_Actual_Type (Par) loop + if Ekind (Par) = E_Record_Type then + Par := Parent_Subtype (Par); + exit when No (Par); + else + exit when Par = Etype (Par); + Par := Etype (Par); + end if; + end loop; - -- Finally, the formal and the actual may be private extensions, - -- but the generic is declared in a child unit of the parent, and - -- an additional step is needed to retrieve the proper scope. + if Present (Par) and then Is_Generic_Actual_Type (Par) then + -- Now look for component in ancestor types - elsif In_Instance - and then Present (Parent_Subtype (Etype (Base_Type (Prefix_Type)))) - then - Find_Component_In_Instance - (Parent_Subtype (Etype (Base_Type (Prefix_Type)))); + Par := Generic_Parent_Type (Declaration_Node (Par)); + loop + Find_Component_In_Instance (Par); + exit when Present (Entity (Sel)) + or else Par = Etype (Par); + Par := Etype (Par); + end loop; + end if; + end; + + -- The search above must have eventually succeeded, since the + -- selected component was legal in the generic. + + if No (Entity (Sel)) then + raise Program_Error; + end if; return; -- Component not found, specialize error message when appropriate @@ -5034,13 +5052,13 @@ package body Sem_Ch4 is then Add_One_Interp (N, Op_Id, Etype (Op_Id)); - -- If the left operand is overloaded, indicate that the - -- current type is a viable candidate. This is redundant - -- in most cases, but for equality and comparison operators - -- where the context does not impose a type on the operands, - -- setting the proper type is necessary to avoid subsequent - -- ambiguities during resolution, when both user-defined and - -- predefined operators may be candidates. + -- If the left operand is overloaded, indicate that the current + -- type is a viable candidate. This is redundant in most cases, + -- but for equality and comparison operators where the context + -- does not impose a type on the operands, setting the proper + -- type is necessary to avoid subsequent ambiguities during + -- resolution, when both user-defined and predefined operators + -- may be candidates. if Is_Overloaded (Left_Opnd (N)) then Set_Etype (Left_Opnd (N), Etype (F1)); @@ -5108,7 +5126,7 @@ package body Sem_Ch4 is -- (multiplication or division) that should hide the corresponding -- predefined operator. Used to implement Ada 2005 AI-264, to make -- such operators more visible and therefore useful. - + -- -- If the name of the operation is an expanded name with prefix -- Standard, the predefined universal fixed operator is available, -- as specified by AI-420 (RM 4.5.5 (19.1/2)). @@ -5325,11 +5343,11 @@ package body Sem_Ch4 is Comp : Entity_Id; begin - -- All the components of the prefix of selector Sel are matched - -- against Sel and a count is maintained of possible misspellings. - -- When at the end of the analysis there are one or two (not more!) - -- possible misspellings, these misspellings will be suggested as - -- possible correction. + -- All the components of the prefix of selector Sel are matched against + -- Sel and a count is maintained of possible misspellings. When at + -- the end of the analysis there are one or two (not more!) possible + -- misspellings, these misspellings will be suggested as possible + -- correction. if not (Is_Private_Type (Prefix) or else Is_Record_Type (Prefix)) then @@ -5661,21 +5679,17 @@ package body Sem_Ch4 is -- universal, the context will impose the correct type. if Present (Scop) - and then not Defined_In_Scope (T1, Scop) - and then T1 /= Universal_Integer - and then T1 /= Universal_Real - and then T1 /= Any_String - and then T1 /= Any_Composite + and then not Defined_In_Scope (T1, Scop) + and then T1 /= Universal_Integer + and then T1 /= Universal_Real + and then T1 /= Any_String + and then T1 /= Any_Composite then return; end if; - if Valid_Comparison_Arg (T1) - and then Has_Compatible_Type (R, T1) - then - if Found - and then Base_Type (T1) /= Base_Type (T_F) - then + if Valid_Comparison_Arg (T1) and then Has_Compatible_Type (R, T1) then + if Found and then Base_Type (T1) /= Base_Type (T_F) then It := Disambiguate (L, I_F, Index, Any_Type); if It = No_Interp then @@ -5705,9 +5719,7 @@ package body Sem_Ch4 is -- If left operand is aggregate, the right operand has to -- provide a usable type for it. - if Nkind (L) = N_Aggregate - and then Nkind (R) /= N_Aggregate - then + if Nkind (L) = N_Aggregate and then Nkind (R) /= N_Aggregate then Find_Comparison_Types (L => R, R => L, Op_Id => Op_Id, N => N); return; end if; @@ -5754,8 +5766,7 @@ package body Sem_Ch4 is It : Interp; begin - if T1 = Universal_Integer - or else T1 = Universal_Real + if T1 = Universal_Integer or else T1 = Universal_Real -- If the left operand of an equality operator is null, the visibility -- of the operator must be determined from the interpretation of the @@ -5765,8 +5776,7 @@ package body Sem_Ch4 is or else T1 = Any_Access then if not Is_Overloaded (R) then - Add_One_Interp - (N, Op_Id, Standard_Boolean, Base_Type (Etype (R))); + Add_One_Interp (N, Op_Id, Standard_Boolean, Base_Type (Etype (R))); else Get_First_Interp (R, Index, It); while Present (It.Typ) loop @@ -5846,6 +5856,7 @@ package body Sem_Ch4 is -- universal, the context will impose the correct type. An anonymous -- type for a 'Access reference is also universal in this sense, as -- the actual type is obtained from context. + -- In Ada 2005, the equality operator for anonymous access types -- is declared in Standard, and preference rules apply to it. @@ -5916,9 +5927,9 @@ package body Sem_Ch4 is -- If the right operand has a type compatible with T1, check for an -- acceptable interpretation, unless T1 is limited (no predefined -- equality available), or this is use of a "/=" for a tagged type. - -- In the latter case, possible interpretations of equality need to - -- be considered, we don't want the default inequality declared in - -- Standard to be chosen, and the "/=" will be rewritten as a + -- In the latter case, possible interpretations of equality need + -- to be considered, we don't want the default inequality declared + -- in Standard to be chosen, and the "/=" will be rewritten as a -- negation of "=" (see the end of Analyze_Equality_Op). This ensures -- that that rewriting happens during analysis rather than being -- delayed until expansion (this is needed for ASIS, which only sees @@ -6113,12 +6124,12 @@ package body Sem_Ch4 is (Base_Type (Etype (First_Formal (Hom))) = Cls_Type or else (Is_Access_Type (Etype (First_Formal (Hom))) - and then - Ekind (Etype (First_Formal (Hom))) = - E_Anonymous_Access_Type - and then - Base_Type - (Designated_Type (Etype (First_Formal (Hom)))) = + and then + Ekind (Etype (First_Formal (Hom))) = + E_Anonymous_Access_Type + and then + Base_Type + (Designated_Type (Etype (First_Formal (Hom)))) = Cls_Type)) then Add_One_Interp (Op, Hom, Etype (Hom)); @@ -6298,6 +6309,19 @@ package body Sem_Ch4 is or else Etype (R) = Any_Type or else (Nkind (N) in N_Binary_Op and then Etype (L) = Any_Type) then + -- For the rather unusual case where one of the operands is + -- a Raise_Expression, whose initial type is Any_Type, use + -- the type of the other operand. + + if Nkind (L) = N_Raise_Expression then + Set_Etype (L, Etype (R)); + Set_Etype (N, Etype (R)); + + elsif Nkind (R) = N_Raise_Expression then + Set_Etype (R, Etype (L)); + Set_Etype (N, Etype (L)); + end if; + return; -- We explicitly check for the case of concatenation of component @@ -6340,7 +6364,7 @@ package body Sem_Ch4 is else Error_Msg_NE -- CODEFIX ("add with_clause and use_clause for&!", - N, Defining_Entity (Unit (U))); + N, Defining_Entity (Unit (U))); end if; end; return; @@ -6563,7 +6587,7 @@ package body Sem_Ch4 is ("No legal interpretation for operator&", N); Error_Msg_NE ("\use clause on& would make operation legal", - N, Scope (Op_Id)); + N, Scope (Op_Id)); exit; end if; end if; @@ -6612,19 +6636,18 @@ package body Sem_Ch4 is if Present (E) and then (Operating_Mode = Check_Semantics or else not Expander_Active) then - -- We create a dummy reference to E to ensure that the reference - -- is not considered as part of an assignment (an implicit - -- dereference can never assign to its prefix). The Comes_From_Source - -- attribute needs to be propagated for accurate warnings. + -- We create a dummy reference to E to ensure that the reference is + -- not considered as part of an assignment (an implicit dereference + -- can never assign to its prefix). The Comes_From_Source attribute + -- needs to be propagated for accurate warnings. Ref := New_Reference_To (E, Sloc (P)); Set_Comes_From_Source (Ref, Comes_From_Source (P)); Generate_Reference (E, Ref); end if; - -- An implicit dereference is a legal occurrence of an - -- incomplete type imported through a limited_with clause, - -- if the full view is visible. + -- An implicit dereference is a legal occurrence of an incomplete type + -- imported through a limited_with clause, if the full view is visible. if From_Limited_With (Typ) and then not From_Limited_With (Scope (Typ)) @@ -6663,8 +6686,8 @@ package body Sem_Ch4 is procedure Remove_Address_Interpretations (Op : Operand_Position); -- Ambiguities may arise when the operands are literal and the address -- operations in s-auxdec are visible. In that case, remove the - -- interpretation of a literal as Address, to retain the semantics of - -- Address as a private type. + -- interpretation of a literal as Address, to retain the semantics + -- of Address as a private type. ------------------------------------ -- Remove_Address_Interpretations -- @@ -6766,9 +6789,9 @@ package body Sem_Ch4 is if Nkind (N) in N_Binary_Op then declare U1 : constant Boolean := - Present (Universal_Interpretation (Right_Opnd (N))); + Present (Universal_Interpretation (Right_Opnd (N))); U2 : constant Boolean := - Present (Universal_Interpretation (Left_Opnd (N))); + Present (Universal_Interpretation (Left_Opnd (N))); begin if U1 then @@ -6995,15 +7018,16 @@ package body Sem_Ch4 is end if; else - Indexing := Make_Function_Call (Loc, - Name => Make_Identifier (Loc, Chars (Func_Name)), - Parameter_Associations => Assoc); + Indexing := + Make_Function_Call (Loc, + Name => Make_Identifier (Loc, Chars (Func_Name)), + Parameter_Associations => Assoc); Rewrite (N, Indexing); declare - I : Interp_Index; - It : Interp; + I : Interp_Index; + It : Interp; Success : Boolean; begin @@ -7090,6 +7114,7 @@ package body Sem_Ch4 is end if; return True; + else return False; end if; @@ -7199,8 +7224,8 @@ package body Sem_Ch4 is -- Identifier on which possible interpretations will be collected Report_Error : Boolean := False; - -- If no candidate interpretation matches the context, redo the - -- analysis with error enabled to provide additional information. + -- If no candidate interpretation matches the context, redo analysis + -- with Report_Error True to provide additional information. Actual : Node_Id; Candidate : Entity_Id := Empty; @@ -7359,9 +7384,9 @@ package body Sem_Ch4 is First_Actual := First (Parameter_Associations (Call_Node)); - -- For cross-reference purposes, treat the new node as being in - -- the source if the original one is. Set entity and type, even - -- though they may be overwritten during resolution if overloaded. + -- For cross-reference purposes, treat the new node as being in the + -- source if the original one is. Set entity and type, even though + -- they may be overwritten during resolution if overloaded. Set_Comes_From_Source (Subprog, Comes_From_Source (N)); Set_Comes_From_Source (Call_Node, Comes_From_Source (N)); @@ -7373,9 +7398,9 @@ package body Sem_Ch4 is Set_Etype (Selector_Name (N), Etype (Entity (Subprog))); end if; - -- If need be, rewrite first actual as an explicit dereference - -- If the call is overloaded, the rewriting can only be done - -- once the primitive operation is identified. + -- If need be, rewrite first actual as an explicit dereference. If + -- the call is overloaded, the rewriting can only be done once the + -- primitive operation is identified. if Is_Overloaded (Subprog) then @@ -7490,8 +7515,8 @@ package body Sem_Ch4 is if Access_Formal and then not Access_Actual then if Nkind (Parent (Op)) = N_Full_Type_Declaration then Error_Msg_N - ("\possible interpretation" - & " (inherited, with implicit 'Access) #", N); + ("\possible interpretation " + & "(inherited, with implicit 'Access) #", N); else Error_Msg_N ("\possible interpretation (with implicit 'Access) #", N); @@ -7500,8 +7525,8 @@ package body Sem_Ch4 is elsif not Access_Formal and then Access_Actual then if Nkind (Parent (Op)) = N_Full_Type_Declaration then Error_Msg_N - ("\possible interpretation" - & " ( inherited, with implicit dereference) #", N); + ("\possible interpretation " + & "( inherited, with implicit dereference) #", N); else Error_Msg_N ("\possible interpretation (with implicit dereference) #", N); @@ -7569,9 +7594,8 @@ package body Sem_Ch4 is else Call_Node := Make_Function_Call (Loc, - Name => New_Copy (Subprog), + Name => New_Copy (Subprog), Parameter_Associations => Actuals); - end if; -- Before analysis, a function call appears as an indexed component @@ -7593,7 +7617,7 @@ package body Sem_Ch4 is Call_Node := Make_Function_Call (Loc, - Name => New_Copy (Subprog), + Name => New_Copy (Subprog), Parameter_Associations => Actuals); -- Parameterless call: Obj.F is rewritten as F (Obj) @@ -7603,7 +7627,7 @@ package body Sem_Ch4 is Call_Node := Make_Function_Call (Loc, - Name => New_Copy (Subprog), + Name => New_Copy (Subprog), Parameter_Associations => New_List (Dummy)); end if; end Transform_Object_Operation; @@ -7658,8 +7682,8 @@ package body Sem_Ch4 is -- Find a non-hidden operation whose first parameter is of the -- class-wide type, a subtype thereof, or an anonymous access -- to same. If in an instance, the operation can be considered - -- even if hidden (it may be hidden because the instantiation is - -- expanded after the containing package has been analyzed). + -- even if hidden (it may be hidden because the instantiation + -- is expanded after the containing package has been analyzed). while Present (Hom) loop if Ekind_In (Hom, E_Procedure, E_Function) @@ -7670,12 +7694,12 @@ package body Sem_Ch4 is (Base_Type (Etype (First_Formal (Hom))) = Cls_Type or else (Is_Access_Type (Etype (First_Formal (Hom))) - and then - Ekind (Etype (First_Formal (Hom))) = - E_Anonymous_Access_Type - and then - Base_Type - (Designated_Type (Etype (First_Formal (Hom)))) = + and then + Ekind (Etype (First_Formal (Hom))) = + E_Anonymous_Access_Type + and then + Base_Type + (Designated_Type (Etype (First_Formal (Hom)))) = Cls_Type)) then -- If the context is a procedure call, ignore functions @@ -7918,12 +7942,12 @@ package body Sem_Ch4 is Matching_Op : Entity_Id := Empty; Prim_Op_Ref : Node_Id := Empty; - Corr_Type : Entity_Id := Empty; + Corr_Type : Entity_Id := Empty; -- If the prefix is a synchronized type, the controlling type of -- the primitive operation is the corresponding record type, else -- this is the object type itself. - Success : Boolean := False; + Success : Boolean := False; function Collect_Generic_Type_Ops (T : Entity_Id) return Elist_Id; -- For tagged types the candidate interpretations are found in @@ -7933,6 +7957,7 @@ package body Sem_Ch4 is -- part) because the type itself carries no primitive operations, -- except for formal derived types that inherit the operations of -- the parent and progenitors. + -- -- If the context is a generic subprogram body, the generic formals -- are visible by name, but are not in the entity list of the -- subprogram because that list starts with the subprogram formals. @@ -7994,8 +8019,8 @@ package body Sem_Ch4 is -- Scan the list of generic formals to find subprograms -- that may have a first controlling formal of the type. - if Nkind (Unit_Declaration_Node (Scope (T))) - = N_Generic_Subprogram_Declaration + if Nkind (Unit_Declaration_Node (Scope (T))) = + N_Generic_Subprogram_Declaration then declare Decl : Node_Id; @@ -8130,10 +8155,11 @@ package body Sem_Ch4 is and then Valid_First_Argument_Of (Prim_Op) and then (Nkind (Call_Node) = N_Function_Call) - = (Ekind (Prim_Op) = E_Function) + = + (Ekind (Prim_Op) = E_Function) then -- Ada 2005 (AI-251): If this primitive operation corresponds - -- with an immediate ancestor interface there is no need to add + -- to an immediate ancestor interface there is no need to add -- it to the list of interpretations; the corresponding aliased -- primitive is also in this list of primitive operations and -- will be used instead. @@ -8276,8 +8302,8 @@ package body Sem_Ch4 is if All_Errors_Mode then Report_Error := True; if Try_Primitive_Operation - (Call_Node => New_Call_Node, - Node_To_Replace => Node_To_Replace) + (Call_Node => New_Call_Node, + Node_To_Replace => Node_To_Replace) or else Try_Class_Wide_Operation diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 788ff89b782..590d8ab1788 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1680,12 +1680,21 @@ package body Sem_Ch5 is Ent : Entity_Id; Typ : Entity_Id; + Bas : Entity_Id; begin Enter_Name (Def_Id); if Present (Subt) then Analyze (Subt); + + -- Save type of subtype indication for subsequent check. + + if Nkind (Subt) = N_Subtype_Indication then + Bas := Entity (Subtype_Mark (Subt)); + else + Bas := Entity (Subt); + end if; end if; Preanalyze_Range (Iter_Name); @@ -1804,6 +1813,13 @@ package body Sem_Ch5 is if Of_Present (N) then Set_Etype (Def_Id, Component_Type (Typ)); + if Present (Subt) + and then Base_Type (Bas) /= Base_Type (Component_Type (Typ)) + then + Error_Msg_N + ("subtype indication does not match component type", Subt); + end if; + -- Here we have a missing Range attribute else @@ -1849,6 +1865,17 @@ package body Sem_Ch5 is else Set_Etype (Def_Id, Entity (Element)); + -- If subtype indication was given, verify that it matches + -- element type of container. + + if Present (Subt) + and then Bas /= Base_Type (Etype (Def_Id)) + then + Error_Msg_N + ("subtype indication does not match element type", + Subt); + end if; + -- If the container has a variable indexing aspect, the -- element is a variable and is modifiable in the loop. @@ -1894,6 +1921,14 @@ package body Sem_Ch5 is end loop; end if; end if; + + -- A loop parameter cannot be volatile. This check is peformed only when + -- SPARK_Mode is on as it is not a standard Ada legality check. + + if SPARK_Mode = On and then Is_SPARK_Volatile_Object (Ent) then + Error_Msg_N + ("loop parameter cannot be volatile (SPARK RM 7.1.3(6))", Ent); + end if; end Analyze_Iterator_Specification; ------------------- @@ -2430,9 +2465,11 @@ package body Sem_Ch5 is -- Check for null or possibly null range and issue warning. We suppress -- such messages in generic templates and instances, because in practice - -- they tend to be dubious in these cases. + -- they tend to be dubious in these cases. The check applies as well to + -- rewritten array element loops where a null range may be detected + -- statically. - if Nkind (DS) = N_Range and then Comes_From_Source (N) then + if Nkind (DS) = N_Range then declare L : constant Node_Id := Low_Bound (DS); H : constant Node_Id := High_Bound (DS); @@ -2454,21 +2491,23 @@ package body Sem_Ch5 is if Compile_Time_Compare (L, H, Assume_Valid => False) = GT then - Error_Msg_N - ("??loop range is null, loop will not execute", DS); - -- Since we know the range of the loop is null, set the -- appropriate flag to remove the loop entirely during -- expansion. Set_Is_Null_Loop (Loop_Nod); - -- Here is where the loop could execute because of invalid - -- values, so issue appropriate message and in this case we - -- do not set the Is_Null_Loop flag since the loop may - -- execute. + if Comes_From_Source (N) then + Error_Msg_N + ("??loop range is null, loop will not execute", DS); + end if; + + -- Here is where the loop could execute because of + -- invalid values, so issue appropriate message and in + -- this case we do not set the Is_Null_Loop flag since + -- the loop may execute. - else + elsif Comes_From_Source (N) then Error_Msg_N ("??loop range may be null, loop may not execute", DS); @@ -2519,6 +2558,14 @@ package body Sem_Ch5 is end if; end; end if; + + -- A loop parameter cannot be volatile. This check is peformed only when + -- SPARK_Mode is on as it is not a standard Ada legality check. + + if SPARK_Mode = On and then Is_SPARK_Volatile_Object (Id) then + Error_Msg_N + ("loop parameter cannot be volatile (SPARK RM 7.1.3(6))", Id); + end if; end Analyze_Loop_Parameter_Specification; ---------------------------- diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 62dd8898760..715ca24f58b 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -435,7 +435,11 @@ package body Sem_Ch6 is -- To prevent premature freeze action, insert the new body at the end -- of the current declarations, or at the end of the package spec. -- However, resolve usage names now, to prevent spurious visibility - -- on later entities. + -- on later entities. Note that the function can now be called in + -- the current declarative part, which will appear to be prior to + -- the presence of the body in the code. There are nevertheless no + -- order of elaboration issues because all name resolution has taken + -- place at the point of declaration. declare Decls : List_Id := List_Containing (N); @@ -2995,9 +2999,23 @@ package body Sem_Ch6 is Push_Scope (Spec_Id); - -- Set SPARK_Mode from spec if spec had a SPARK_Mode pragma + -- Set SPARK_Mode - if Present (SPARK_Pragma (Spec_Id)) then + -- For internally generated subprogram, always off. But generic + -- instances are not generated implicitly, so are never considered + -- as internal, even though Comes_From_Source is false. + + if not Comes_From_Source (Spec_Id) + and then not Is_Generic_Instance (Spec_Id) + then + SPARK_Mode := Off; + SPARK_Mode_Pragma := Empty; + + -- Inherited from spec + + elsif Present (SPARK_Pragma (Spec_Id)) + and then not SPARK_Pragma_Inherited (Spec_Id) + then SPARK_Mode_Pragma := SPARK_Pragma (Spec_Id); SPARK_Mode := Get_SPARK_Mode_From_Pragma (SPARK_Mode_Pragma); Set_SPARK_Pragma (Body_Id, SPARK_Pragma (Spec_Id)); @@ -3055,7 +3073,20 @@ package body Sem_Ch6 is Generate_Reference (Body_Id, Body_Id, 'b', Set_Ref => False, Force => True); Install_Formals (Body_Id); + Push_Scope (Body_Id); + + -- Set SPARK_Mode from context or OFF for internal routine + + if Comes_From_Source (Body_Id) then + Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma); + Set_SPARK_Pragma_Inherited (Body_Id, True); + else + Set_SPARK_Pragma (Body_Id, Empty); + Set_SPARK_Pragma_Inherited (Body_Id, False); + SPARK_Mode := Off; + SPARK_Mode_Pragma := Empty; + end if; end if; -- For stubs and bodies with no previous spec, generate references to @@ -3601,8 +3632,16 @@ package body Sem_Ch6 is Generate_Definition (Designator); - Set_SPARK_Pragma (Designator, SPARK_Mode_Pragma); - Set_SPARK_Pragma_Inherited (Designator, True); + -- Set SPARK mode, always off for internal routines, otherwise set + -- from current context (may be overwritten later with explicit pragma) + + if Comes_From_Source (Designator) then + Set_SPARK_Pragma (Designator, SPARK_Mode_Pragma); + Set_SPARK_Pragma_Inherited (Designator, True); + else + Set_SPARK_Pragma (Designator, Empty); + Set_SPARK_Pragma_Inherited (Designator, False); + end if; if Debug_Flag_C then Write_Str ("==> subprogram spec "); @@ -11194,17 +11233,26 @@ package body Sem_Ch6 is Null_Exclusion_Static_Checks (Param_Spec); end if; - -- A function cannot have a volatile formal parameter. The following - -- check is relevant when SPARK_Mode is on as it is not a standard - -- Ada legality rule. + -- The following checks are relevant when SPARK_Mode is on as these + -- are not standard Ada legality rules. if SPARK_Mode = On - and then Is_Volatile_Object (Formal) and then Ekind_In (Scope (Formal), E_Function, E_Generic_Function) then - Error_Msg_N - ("function cannot have a volatile formal parameter (SPARK RM " - & "7.1.3(6))", Formal); + -- A function cannot have a parameter of mode IN OUT or OUT + + if Ekind_In (Formal, E_In_Out_Parameter, E_Out_Parameter) then + Error_Msg_N + ("function cannot have parameter of mode `OUT` or `IN OUT` " + & "(SPARK RM 6.1)", Formal); + + -- A function cannot have a volatile formal parameter + + elsif Is_SPARK_Volatile_Object (Formal) then + Error_Msg_N + ("function cannot have a volatile formal parameter (SPARK RM " + & "7.1.3(10))", Formal); + end if; end if; <<Continue>> @@ -11443,6 +11491,13 @@ package body Sem_Ch6 is if Present (First_Stmt) then Insert_List_Before_And_Analyze (First_Stmt, Freeze_Entity (Defining_Identifier (Decl), N)); + + -- Ditto if the type has a dynamic predicate, because the + -- generated function will mention the actual subtype. + + elsif Has_Dynamic_Predicate_Aspect (T) then + Insert_List_Before_And_Analyze (Decl, + Freeze_Entity (Defining_Identifier (Decl), N)); end if; if Nkind (N) = N_Accept_Statement diff --git a/gcc/ada/sem_ch6.ads b/gcc/ada/sem_ch6.ads index fc0c365e06b..e03341c199b 100644 --- a/gcc/ada/sem_ch6.ads +++ b/gcc/ada/sem_ch6.ads @@ -28,8 +28,7 @@ package Sem_Ch6 is type Conformance_Type is (Type_Conformant, Mode_Conformant, Subtype_Conformant, Fully_Conformant); - -- pragma Ordered (Conformance_Type); - -- Why is above line commented out ??? + pragma Ordered (Conformance_Type); -- Conformance type used in conformance checks between specs and bodies, -- and for overriding. The literals match the RM definitions of the -- corresponding terms. This is an ordered type, since each conformance diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index c6e23b586d5..aea2a4d2d05 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -6296,8 +6296,9 @@ package body Sem_Ch8 is -- If no interpretation as an expanded name is possible, it -- must be a selected component of a record returned by a -- function call. Reformat prefix as a function call, the rest - -- is done by type resolution. If the prefix is procedure or - -- entry, as is P.X; this is an error. + -- is done by type resolution. + + -- Error if the prefix is procedure or entry, as is P.X if Ekind (P_Name) /= E_Function and then @@ -6309,7 +6310,6 @@ package body Sem_Ch8 is -- chain, the candidate package may be anywhere on it. if Present (Homonym (Current_Entity (P_Name))) then - P_Name := Current_Entity (P_Name); while Present (P_Name) loop @@ -6327,6 +6327,7 @@ package body Sem_Ch8 is Set_Entity (Prefix (N), P_Name); Find_Expanded_Name (N); return; + else P_Name := Entity (Prefix (N)); end if; @@ -6338,11 +6339,27 @@ package body Sem_Ch8 is Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); + -- Here we have a function call, so do the reformatting + else Nam := New_Copy (P); Save_Interps (P, Nam); - Rewrite (P, + + -- We use Replace here because this is one of those cases + -- where the parser has missclassified the node, and we + -- fix things up and then do the semantic analysis on the + -- fixed up node. Normally we do this using one of the + -- Sinfo.CN routines, but this is too tricky for that. + + -- Note that using Rewrite would be wrong, because we + -- would have a tree where the original node is unanalyzed, + -- and this violates the required interface for ASIS. + + Replace (P, Make_Function_Call (Sloc (P), Name => Nam)); + + -- Now analyze the reformatted node + Analyze_Call (P); Analyze_Selected_Component (N); end if; diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index b0b45347fa0..8447be198ff 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -2155,18 +2155,52 @@ package body Sem_Elab is declare P : Node_Id; + O : Node_Id; + begin P := Parent (N); loop + -- Keep looking at parents if we are still in the subexpression + if Nkind (P) in N_Subexpr then P := Parent (P); - elsif Nkind (P) = N_If_Statement - and then Nkind (Original_Node (P)) = N_Pragma - and then Present (Corresponding_Aspect (Original_Node (P))) - then - return; + + -- Here P is the parent of the expression, check for special case + else - exit; + O := Original_Node (P); + + -- Definitely not the special case if orig node is not a pragma + + exit when Nkind (O) /= N_Pragma; + + -- Check we have an If statement or a null statement (happens + -- when the If has been expanded to be True). + + exit when not Nkind_In (P, N_If_Statement, N_Null_Statement); + + -- Our special case will be indicated either by the pragma + -- coming from an aspect ... + + if Present (Corresponding_Aspect (O)) then + return; + + -- Or, in the case of an initial condition, specifically by a + -- Check pragma specifying an Initial_Condition check. + + elsif Pragma_Name (O) = Name_Check + and then + Chars + (Expression (First (Pragma_Argument_Associations (O)))) = + Name_Initial_Condition + then + return; + + -- For anything else, we have an error + + else + exit; + end if; end if; end loop; end; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 555a7887ff6..3ddaed2773c 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -204,21 +204,23 @@ package body Sem_Prag is -- in identifiers to represent these attribute references. procedure Collect_Global_Items - (Prag : Node_Id; - In_Items : in out Elist_Id; - In_Out_Items : in out Elist_Id; - Out_Items : in out Elist_Id; - Has_In_State : out Boolean; - Has_In_Out_State : out Boolean; - Has_Out_State : out Boolean; - Has_Null_State : out Boolean); + (Prag : Node_Id; + In_Items : in out Elist_Id; + In_Out_Items : in out Elist_Id; + Out_Items : in out Elist_Id; + Proof_In_Items : in out Elist_Id; + Has_In_State : out Boolean; + Has_In_Out_State : out Boolean; + Has_Out_State : out Boolean; + Has_Proof_In_State : out Boolean; + Has_Null_State : out Boolean); -- Subsidiary to the analysis of pragma Refined_Depends/Refined_Global. - -- Prag denotes pragma [Refined_]Global. Gather all input, in out and - -- output items of Prag in lists In_Items, In_Out_Items and Out_Items. - -- Flags Has_In_State, Has_In_Out_State and Has_Out_State are set when - -- there is at least one abstract state with visible refinement available - -- in the corresponding mode. Flag Has_Null_State is set when at least - -- state has a null refinement. + -- Prag denotes pragma [Refined_]Global. Gather all input, in out, output + -- and Proof_In items of Prag in lists In_Items, In_Out_Items, Out_Items + -- and Proof_In_Items. Flags Has_In_State, Has_In_Out_State, Has_Out_State + -- and Has_Proof_In_State are set when there is at least one abstract state + -- with visible refinement available in the corresponding mode. Flag + -- Has_Null_State is set when at least state has a null refinement. procedure Collect_Subprogram_Inputs_Outputs (Subp_Id : Entity_Id; @@ -402,16 +404,16 @@ package body Sem_Prag is if Nkind (Case_Guard) = N_Others_Choice then if Others_Seen then Error_Msg_N - ("only one others choice allowed in aspect Contract_Cases", - Case_Guard); + ("only one others choice allowed in aspect Contract_Cases " + & "(SPARK RM 6.1.3(1))", Case_Guard); else Others_Seen := True; end if; elsif Others_Seen then Error_Msg_N - ("others must be the last choice in aspect Contract_Cases", - N); + ("others must be the last choice in aspect Contract_Cases " + & "(SPARK RM 6.1.3(1))", N); end if; -- Preanalyze the case guard and consequence @@ -717,13 +719,15 @@ package body Sem_Prag is Error_Msg_Name_1 := Name_Result; Error_Msg_N ("prefix of attribute % must denote the enclosing " - & "function", Item); + & "function (SPARK RM 6.1.5(11))", Item); -- Function'Result is allowed to appear on the output side of a -- dependency clause. elsif Is_Input then - Error_Msg_N ("function result cannot act as input", Item); + Error_Msg_N + ("function result cannot act as input (SPARK RM 6.1.5(6))", + Item); elsif Null_Seen then Error_Msg_N @@ -753,7 +757,7 @@ package body Sem_Prag is if not Is_Last then Error_Msg_N ("null output list must be the last clause in a " - & "dependency relation", Item); + & "dependency relation (SPARK RM 6.1.5(12))", Item); -- Catch a useless dependence of the form: -- null =>+ ... @@ -783,9 +787,9 @@ package body Sem_Prag is Item_Id := Entity_Of (Item); - Record_Possible_Body_Reference (Item, Item_Id); - if Present (Item_Id) then + Record_Possible_Body_Reference (Item, Item_Id); + if Ekind_In (Item_Id, E_Abstract_State, E_In_Parameter, E_In_Out_Parameter, @@ -817,7 +821,7 @@ package body Sem_Prag is then Error_Msg_N ("input of a null output list appears in multiple " - & "input lists", Item); + & "input lists (SPARK RM 6.1.5(13))", Item); end if; -- Add an input or a self-referential output to the list @@ -852,7 +856,8 @@ package body Sem_Prag is elsif Has_Visible_Refinement (Item_Id) then Error_Msg_NE ("cannot mention state & in global refinement, " - & "use its constituents instead", Item, Item_Id); + & "use its constituents instead (SPARK RM " + & "6.1.5(3))", Item, Item_Id); return; end if; end if; @@ -871,15 +876,15 @@ package body Sem_Prag is else Error_Msg_N ("item must denote variable, state or formal " - & "parameter", Item); + & "parameter (SPARK RM 6.1.5(1))", Item); end if; -- All other input/output items are illegal else Error_Msg_N - ("item must denote variable, state or formal parameter", - Item); + ("item must denote variable, state or formal parameter " + & "(SPARK RM 6.1.5(1))", Item); end if; end if; end Analyze_Input_Output; @@ -936,8 +941,8 @@ package body Sem_Prag is begin if Ekind (Spec_Id) = E_Function and then not Result_Seen then Error_Msg_NE - ("result of & must appear in exactly one output list", - N, Spec_Id); + ("result of & must appear in exactly one output list (SPARK RM " + & "6.1.5(10))", N, Spec_Id); end if; end Check_Function_Return; @@ -952,22 +957,26 @@ package body Sem_Prag is Self_Ref : Boolean) is procedure Find_Mode - (Is_Input : out Boolean; - Is_Output : out Boolean); + (Is_Input : out Boolean; + Is_Output : out Boolean; + From_Global : out Boolean); -- Find the mode of Item_Id. Flags Is_Input and Is_Output are set - -- depending on the mode. + -- depending on the mode. Flag From_Global is set when the mode is + -- determined by pragma [Refined_]Global. --------------- -- Find_Mode -- --------------- procedure Find_Mode - (Is_Input : out Boolean; - Is_Output : out Boolean) + (Is_Input : out Boolean; + Is_Output : out Boolean; + From_Global : out Boolean) is begin - Is_Input := False; - Is_Output := False; + Is_Input := False; + Is_Output := False; + From_Global := False; -- Abstract state cases @@ -978,28 +987,20 @@ package body Sem_Prag is if Global_Seen then if Appears_In (Subp_Inputs, Item_Id) then - Is_Input := True; + Is_Input := True; + From_Global := True; end if; if Appears_In (Subp_Outputs, Item_Id) then - Is_Output := True; + Is_Output := True; + From_Global := True; end if; - -- Otherwise the mode of the state is the one defined in pragma - -- Abstract_State. An In_Out state lacks both Input_Only and - -- Output_Only modes. + -- Otherwise the state has a default IN OUT mode - elsif not Is_Input_Only_State (Item_Id) - and then not Is_Output_Only_State (Item_Id) - then + else Is_Input := True; Is_Output := True; - - elsif Is_Input_Only_State (Item_Id) then - Is_Input := True; - - elsif Is_Output_Only_State (Item_Id) then - Is_Output := True; end if; -- Parameter cases @@ -1048,11 +1049,13 @@ package body Sem_Prag is if Appears_In (Subp_Inputs, Item_Id) or else Is_Unconstrained_Or_Tagged_Item (Item_Id) then - Is_Input := True; + Is_Input := True; + From_Global := True; end if; if Appears_In (Subp_Outputs, Item_Id) then - Is_Output := True; + Is_Output := True; + From_Global := True; end if; -- Otherwise the variable has a default IN OUT mode @@ -1068,32 +1071,49 @@ package body Sem_Prag is Item_Is_Input : Boolean; Item_Is_Output : Boolean; + From_Global : Boolean; -- Start of processing for Check_Mode begin - Find_Mode (Item_Is_Input, Item_Is_Output); + Find_Mode (Item_Is_Input, Item_Is_Output, From_Global); -- Input item if Is_Input then if not Item_Is_Input then - Error_Msg_NE - ("item & must have mode `IN` or `IN OUT`", Item, Item_Id); + if From_Global then + Error_Msg_NE + ("item & must have mode `IN` or `IN OUT`", Item, Item_Id); + else + Error_Msg_NE + ("item & appears as extra in input list", Item, Item_Id); + end if; end if; -- Self-referential item elsif Self_Ref then if not Item_Is_Input or else not Item_Is_Output then - Error_Msg_NE ("item & must have mode `IN OUT`", Item, Item_Id); + if From_Global then + Error_Msg_NE + ("item & must have mode `IN OUT`", Item, Item_Id); + else + Error_Msg_NE + ("item & appears as extra in In_Out list", Item, Item_Id); + end if; end if; -- Output item elsif not Item_Is_Output then - Error_Msg_NE - ("item & must have mode `OUT` or `IN OUT`", Item, Item_Id); + if From_Global then + Error_Msg_NE + ("item & must have mode `OUT` or `IN OUT`", Item, Item_Id); + else + Error_Msg_NE + ("item & appears as extra in output list", Item, Item_Id); + end if; end if; end Check_Mode; @@ -1121,14 +1141,14 @@ package body Sem_Prag is if Is_Input then Error_Msg_NE - ("item & must appear in at least one input list of aspect " - & "Depends", Item, Item_Id); + ("item & must appear in at least one input dependence list " + & "(SPARK RM 6.1.5(8))", Item, Item_Id); - -- Case of OUT parameter for which Is_Input is set + -- Refine the error message for unconstrained OUT parameters + -- by giving the reason for the illegality. + + if Ekind (Item_Id) = E_Out_Parameter then - if Nkind (Item) = N_Defining_Identifier - and then Ekind (Item) = E_Out_Parameter - then -- One case is an unconstrained array where the bounds -- must be read, if we have this case, output a message -- indicating why the OUT parameter is read. @@ -1167,8 +1187,8 @@ package body Sem_Prag is else Error_Msg_NE - ("item & must appear in exactly one output list of aspect " - & "Depends", Item, Item_Id); + ("item & must appear in exactly one output dependence list " + & "(SPARK RM 6.1.5(10))", Item, Item_Id); end if; end Usage_Error; @@ -1375,7 +1395,9 @@ package body Sem_Prag is -- appear in the input list of a relation. elsif Is_Attribute_Result (Output) then - Error_Msg_N ("function result cannot depend on itself", Output); + Error_Msg_N + ("function result cannot depend on itself (SPARK RM " + & "6.1.5(10))", Output); return; end if; @@ -1683,11 +1705,11 @@ package body Sem_Prag is end if; end Analyze_Depends_In_Decl_Part; - ----------------------------------------- - -- Analyze_External_State_In_Decl_Part -- - ----------------------------------------- + -------------------------------------------- + -- Analyze_External_Property_In_Decl_Part -- + -------------------------------------------- - procedure Analyze_External_State_In_Decl_Part + procedure Analyze_External_Property_In_Decl_Part (N : Node_Id; Expr_Val : out Boolean) is @@ -1701,16 +1723,19 @@ package body Sem_Prag is -- The Async / Effective pragmas must apply to a volatile object other -- than a formal subprogram parameter. - if Is_Volatile_Object (Obj) then + if Is_SPARK_Volatile_Object (Obj) then if Is_Entity_Name (Obj) and then Present (Entity (Obj)) and then Is_Formal (Entity (Obj)) then Error_Msg_N - ("external state % cannot apply to a formal parameter", N); + ("external property % cannot apply to a formal parameter " + & "(SPARK RM 7.1.3(2))", N); end if; else - Error_Msg_N ("external state % must apply to a volatile object", N); + Error_Msg_N + ("external property % must apply to a volatile object (SPARK RM " + & "7.1.3(2))", N); end if; -- Ensure that the expression (if present) is static Boolean. A missing @@ -1725,10 +1750,11 @@ package body Sem_Prag is Expr_Val := Is_True (Expr_Value (Expr)); else Error_Msg_Name_1 := Pragma_Name (N); - Error_Msg_N ("expression of % must be static", Expr); + Error_Msg_N + ("expression of % must be static (SPARK RM 7.1.2(5))", Expr); end if; end if; - end Analyze_External_State_In_Decl_Part; + end Analyze_External_Property_In_Decl_Part; --------------------------------- -- Analyze_Global_In_Decl_Part -- @@ -1833,19 +1859,31 @@ package body Sem_Prag is if Is_Formal (Item_Id) then if Scope (Item_Id) = Spec_Id then Error_Msg_N - ("global item cannot reference formal parameter", Item); + ("global item cannot reference formal parameter " + & "(SPARK RM 6.1.4(6))", Item); return; end if; + -- A constant cannot act as a global item. Do this check first + -- to provide a better error diagnostic. + + elsif Ekind (Item_Id) = E_Constant then + Error_Msg_N + ("global item cannot denote a constant (SPARK RM " + & "6.1.4(7))", Item); + -- The only legal references are those to abstract states and -- variables. elsif not Ekind_In (Item_Id, E_Abstract_State, E_Variable) then Error_Msg_N - ("global item must denote variable or state", Item); + ("global item must denote variable or state (SPARK RM " + & "6.1.4(4))", Item); return; end if; + -- State related checks + if Ekind (Item_Id) = E_Abstract_State then -- The state acts as a constituent of some other state. @@ -1868,7 +1906,25 @@ package body Sem_Prag is elsif Has_Visible_Refinement (Item_Id) then Error_Msg_NE ("cannot mention state & in global refinement, use its " - & "constituents instead", Item, Item_Id); + & "constituents instead (SPARK RM 6.1.4(8))", + Item, Item_Id); + return; + end if; + + -- Variable related checks + + else + -- A volatile object with property Effective_Reads set to + -- True must have mode Output or In_Out. + + if Is_SPARK_Volatile_Object (Item_Id) + and then Effective_Reads_Enabled (Item_Id) + and then Global_Mode = Name_Input + then + Error_Msg_NE + ("volatile global item & with property Effective_Reads " + & "must have mode In_Out or Output (SPARK RM " + & "7.1.3(11))", Item, Item_Id); return; end if; end if; @@ -1884,38 +1940,12 @@ package body Sem_Prag is -- Some form of illegal construct masquerading as a name else - Error_Msg_N ("global item must denote variable or state", Item); + Error_Msg_N + ("global item must denote variable or state (SPARK RM " + & "6.1.4(4))", Item); return; end if; - -- At this point we know that the global item is one of the two - -- valid choices. Perform mode- and usage-specific checks. - - if Ekind (Item_Id) = E_Abstract_State - and then Is_External_State (Item_Id) - then - -- A global item of mode In_Out or Output cannot denote an - -- external Input_Only state. - - if Is_Input_Only_State (Item_Id) - and then Nam_In (Global_Mode, Name_In_Out, Name_Output) - then - Error_Msg_N - ("global item of mode In_Out or Output cannot reference " - & "External Input_Only state", Item); - - -- A global item of mode In_Out or Input cannot reference an - -- external Output_Only state. - - elsif Is_Output_Only_State (Item_Id) - and then Nam_In (Global_Mode, Name_In_Out, Name_Input) - then - Error_Msg_N - ("global item of mode In_Out or Input cannot reference " - & "External Output_Only state", Item); - end if; - end if; - -- Verify that an output does not appear as an input in an -- enclosing subprogram. @@ -1928,19 +1958,20 @@ package body Sem_Prag is -- a standard Ada legality rule. if SPARK_Mode = On - and then Is_Volatile_Object (Item) + and then Is_SPARK_Volatile_Object (Item) and then Ekind_In (Spec_Id, E_Function, E_Generic_Function) then - Error_Msg_N - ("volatile object cannot act as global item of a function " - & "(SPARK RM 7.1.3(5))", Item); + Error_Msg_NE + ("volatile object & cannot act as global item of a function " + & "(SPARK RM 7.1.3(9))", Item, Item_Id); end if; -- The same entity might be referenced through various way. Check -- the entity of the item rather than the item itself. if Contains (Seen, Item_Id) then - Error_Msg_N ("duplicate global item", Item); + Error_Msg_N + ("duplicate global item (SPARK RM 6.1.4(11))", Item); -- Add the entity of the current item to the list of processed -- items. @@ -1960,7 +1991,7 @@ package body Sem_Prag is is begin if Status then - Error_Msg_N ("duplicate global mode", Mode); + Error_Msg_N ("duplicate global mode (SPARK RM 6.1.4(9))", Mode); end if; Status := True; @@ -1986,7 +2017,10 @@ package body Sem_Prag is Context := Scope (Subp_Id); while Present (Context) and then Context /= Standard_Standard loop if Is_Subprogram (Context) - and then Present (Get_Pragma (Context, Pragma_Global)) + and then + (Present (Get_Pragma (Context, Pragma_Global)) + or else + Present (Get_Pragma (Context, Pragma_Refined_Global))) then Collect_Subprogram_Inputs_Outputs (Subp_Id => Context, @@ -2001,8 +2035,8 @@ package body Sem_Prag is and then not Appears_In (Outputs, Item_Id) then Error_Msg_NE - ("global item & cannot have mode In_Out or Output", - Item, Item_Id); + ("global item & cannot have mode In_Out or Output " + & "(SPARK RM 6.1.4(12))", Item, Item_Id); Error_Msg_NE ("\item already appears as input of subprogram &", Item, Context); @@ -2025,7 +2059,8 @@ package body Sem_Prag is begin if Ekind (Spec_Id) = E_Function then Error_Msg_N - ("global mode & not applicable to functions", Mode); + ("global mode & is not applicable to functions (SPARK RM " + & "6.1.4(10))", Mode); end if; end Check_Mode_Restriction_In_Function; @@ -2358,7 +2393,7 @@ package body Sem_Prag is end if; -- The expression is preanalyzed because it has not been moved to its - -- final place yet. A direct analysis may generate sife effects and this + -- final place yet. A direct analysis may generate side effects and this -- is not desired at this point. Preanalyze_And_Resolve (Expr, Standard_Boolean); @@ -2460,12 +2495,15 @@ package body Sem_Prag is Error_Msg_Name_1 := Chars (Pack_Id); Error_Msg_NE ("initialization item & must appear in the visible " - & "declarations of package %", Item, Item_Id); + & "declarations of package % (SPARK RM 7.1.5(7))", + Item, Item_Id); -- Detect a duplicate use of the same initialization item elsif Contains (Items_Seen, Item_Id) then - Error_Msg_N ("duplicate initialization item", Item); + Error_Msg_N + ("duplicate initialization item (SPARK RM 7.1.5(5))", + Item); -- The item is legal, add it to the list of processed states -- and variables. @@ -2479,15 +2517,16 @@ package body Sem_Prag is else Error_Msg_N - ("initialization item must denote variable or state", - Item); + ("initialization item must denote variable or state " + & "(SPARK RM 7.1.5(3))", Item); end if; -- Some form of illegal construct masquerading as a name else Error_Msg_N - ("initialization item must denote variable or state", Item); + ("initialization item must denote variable or state (SPARK " + & "RM 7.1.5(3))", Item); end if; end if; end Analyze_Initialization_Item; @@ -2551,16 +2590,18 @@ package body Sem_Prag is -- The input cannot denote states or variables declared -- within the related package. - if In_Same_Code_Unit (Item, Input_Id) then + if Within_Scope (Input_Id, Current_Scope) then Error_Msg_Name_1 := Chars (Pack_Id); Error_Msg_NE ("input item & cannot denote a visible variable or " - & "state of package %", Input, Input_Id); + & "state of package % (SPARK RM 7.1.5(4))", + Input, Input_Id); -- Detect a duplicate use of the same input item elsif Contains (Inputs_Seen, Input_Id) then - Error_Msg_N ("duplicate input item", Input); + Error_Msg_N + ("duplicate input item (SPARK RM 7.1.5(5))", Input); -- Input is legal, add it to the list of processed inputs @@ -2677,22 +2718,22 @@ package body Sem_Prag is begin Set_Analyzed (N); - -- Initialize the various lists used during analysis - - Collect_States_And_Variables; - - -- All done if result is null + -- Nothing to do when the initialization list is empty if Nkind (Inits) = N_Null then return; end if; - -- Single and multiple initialization clauses must appear as an - -- aggregate. If this is not the case, then either the parser or - -- the analysis of the pragma failed to produce an aggregate. + -- Single and multiple initialization clauses appear as an aggregate. If + -- this is not the case, then either the parser or the analysis of the + -- pragma failed to produce an aggregate. pragma Assert (Nkind (Inits) = N_Aggregate); + -- Initialize the various lists used during analysis + + Collect_States_And_Variables; + if Present (Expressions (Inits)) then Init := First (Expressions (Inits)); while Present (Init) loop @@ -6029,7 +6070,8 @@ package body Sem_Prag is -- Set convention in entity E, and also flag that the entity has a -- convention pragma. If entity is for a private or incomplete type, -- also set convention and flag on underlying type. This procedure - -- also deals with the special case of C_Pass_By_Copy convention. + -- also deals with the special case of C_Pass_By_Copy convention, + -- and error checks for inappropriate convention specification. ------------------------------- -- Diagnose_Multiple_Pragmas -- @@ -6191,6 +6233,16 @@ package body Sem_Prag is procedure Set_Convention_From_Pragma (E : Entity_Id) is begin + -- Ghost convention is allowed only for functions + + if Ekind (E) /= E_Function and then C = Convention_Ghost then + Error_Msg_N + ("& may not have Ghost convention", E); + Error_Msg_N + ("\only functions are permitted to have Ghost convention", E); + return; + end if; + -- Ada 2005 (AI-430): Check invalid attempt to change convention -- for an overridden dispatching operation. Technically this is -- an amendment and should only be done in Ada 2005 mode. However, @@ -6201,11 +6253,11 @@ package body Sem_Prag is and then Present (Overridden_Operation (E)) and then C /= Convention (Overridden_Operation (E)) then - -- An attempt to override a subprogram with a ghost subprogram + -- An attempt to override a function with a ghost function -- appears as a mismatch in conventions. if C = Convention_Ghost then - Error_Msg_N ("ghost subprogram & cannot be overriding", E); + Error_Msg_N ("ghost function & cannot be overriding", E); else Error_Pragma_Arg ("cannot change convention for overridden dispatching " @@ -6401,7 +6453,7 @@ package body Sem_Prag is if Is_Ghost_Subprogram (E) and then Present (Overridden_Operation (E)) then - Error_Msg_N ("ghost subprogram & cannot be overriding", E); + Error_Msg_N ("ghost function & cannot be overriding", E); end if; -- Go to renamed subprogram if present, since convention applies to @@ -9663,6 +9715,14 @@ package body Sem_Prag is Status : in out Boolean); -- Flag Status denotes whether a particular option has been -- seen while processing a state. This routine verifies that + -- Opt is not a duplicate option and sets the flag Status. + + procedure Check_Duplicate_Property + (Prop : Node_Id; + Status : in out Boolean); + -- Flag Status denotes whether a particular property has been + -- seen while processing option External. This routine verifies + -- that Prop is not a duplicate property and sets flag Status. -- Opt is not a duplicate property and sets the flag Status. ----------------------------- @@ -9791,7 +9851,7 @@ package body Sem_Prag is else Error_Msg_N ("expression of external state property must be " - & "static", Expr); + & "static (SPARK RM 7.1.2(5))", Expr); end if; -- The lack of expression defaults the property to True @@ -9804,19 +9864,19 @@ package body Sem_Prag is if Nkind (Prop) = N_Identifier then if Chars (Prop) = Name_Async_Readers then - Check_Duplicate_Option (Prop, AR_Seen); + Check_Duplicate_Property (Prop, AR_Seen); AR_Val := Expr_Val; elsif Chars (Prop) = Name_Async_Writers then - Check_Duplicate_Option (Prop, AW_Seen); + Check_Duplicate_Property (Prop, AW_Seen); AW_Val := Expr_Val; elsif Chars (Prop) = Name_Effective_Reads then - Check_Duplicate_Option (Prop, ER_Seen); + Check_Duplicate_Property (Prop, ER_Seen); ER_Val := Expr_Val; else - Check_Duplicate_Option (Prop, EW_Seen); + Check_Duplicate_Property (Prop, EW_Seen); EW_Val := Expr_Val; end if; @@ -9878,12 +9938,31 @@ package body Sem_Prag is is begin if Status then - Error_Msg_N ("duplicate state option", Opt); + Error_Msg_N + ("duplicate state option (SPARK RM 7.1.4(1))", Opt); end if; Status := True; end Check_Duplicate_Option; + ------------------------------ + -- Check_Duplicate_Property -- + ------------------------------ + + procedure Check_Duplicate_Property + (Prop : Node_Id; + Status : in out Boolean) + is + begin + if Status then + Error_Msg_N + ("duplicate external property (SPARK RM 7.1.4(2))", + Prop); + end if; + + Status := True; + end Check_Duplicate_Property; + -- Local variables Errors : constant Nat := Serious_Errors_Detected; @@ -9949,10 +10028,20 @@ package body Sem_Prag is and then Chars (Opt) = Name_External then Analyze_External_Option (Opt); + + -- When an erroneous option Part_Of is without a parent + -- state, it appears in the list of expression of the + -- aggregate rather than the component associations. + + elsif Chars (Opt) = Name_Part_Of then + Error_Msg_N + ("option Part_Of must denote an abstract state " + & "(SPARK RM 7.1.4(9))", Opt); + else Error_Msg_N - ("simple option not allowed in state declaration", - Opt); + ("simple option not allowed in state declaration " + & "(SPARK RM 7.1.4(3))", Opt); end if; Next (Opt); @@ -10865,7 +10954,8 @@ package body Sem_Prag is -- If we get here, then the pragma applies to a non-object -- construct, issue a generic error. - Error_Pragma ("pragma % must apply to a volatile object"); + Error_Pragma + ("pragma % must apply to a volatile object (SPARK RM 7.1.3(2))"); end Async_Effective; ------------------ @@ -15545,7 +15635,11 @@ package body Sem_Prag is -- [Entity =>] LOCAL_NAME -- [Section =>] static_string_EXPRESSION); - when Pragma_Linker_Section => + when Pragma_Linker_Section => Linker_Section : declare + Arg : Node_Id; + Ent : Entity_Id; + + begin GNAT_Pragma; Check_Arg_Order ((Name_Entity, Name_Section)); Check_Arg_Count (2); @@ -15554,25 +15648,52 @@ package body Sem_Prag is Check_Arg_Is_Library_Level_Local_Name (Arg1); Check_Arg_Is_Static_Expression (Arg2, Standard_String); - -- This pragma applies to objects and types + -- Check kind of entity - if not Is_Object (Entity (Get_Pragma_Arg (Arg1))) - and then not Is_Type (Entity (Get_Pragma_Arg (Arg1))) - then - Error_Pragma_Arg - ("pragma% applies only to objects and types", Arg1); - end if; + Arg := Get_Pragma_Arg (Arg1); + Ent := Entity (Arg); - -- The only processing required is to link this item on to the - -- list of rep items for the given entity. This is accomplished - -- by the call to Rep_Item_Too_Late (when no error is detected - -- and False is returned). + case Ekind (Ent) is - if Rep_Item_Too_Late (Entity (Get_Pragma_Arg (Arg1)), N) then - return; - else - Set_Has_Gigi_Rep_Item (Entity (Get_Pragma_Arg (Arg1))); - end if; + -- Objects (constants and variables) and types. For these cases + -- all we need to do is to set the Linker_Section_pragma field. + + when E_Constant | E_Variable | Type_Kind => + Set_Linker_Section_Pragma (Ent, N); + + -- Subprograms + + when Subprogram_Kind => + + -- Aspect case, entity already set + + if From_Aspect_Specification (N) then + Set_Linker_Section_Pragma + (Entity (Corresponding_Aspect (N)), N); + + -- Pragma case, we must climb the homonym chain, but skip + -- any for which the linker section is already set. + + else + loop + if No (Linker_Section_Pragma (Ent)) then + Set_Linker_Section_Pragma (Ent, N); + end if; + + Ent := Homonym (Ent); + exit when No (Ent) + or else Scope (Ent) /= Current_Scope; + end loop; + end if; + + -- All other cases are illegal + + when others => + Error_Pragma_Arg + ("pragma% applies only to objects, subprograms, and types", + Arg1); + end case; + end Linker_Section; ---------- -- List -- @@ -17981,7 +18102,7 @@ package body Sem_Prag is then Error_Msg_NE ("useless refinement, package & does not define abstract " - & "states", N, Spec_Id); + & "states (SPARK RM 7.2.2(3))", N, Spec_Id); return; end if; @@ -18466,7 +18587,7 @@ package body Sem_Prag is -- SPARK_Mode -- ---------------- - -- pragma SPARK_Mode [(On | Off | Auto)]; + -- pragma SPARK_Mode [(On | Off)]; when Pragma_SPARK_Mode => Do_SPARK_Mode : declare Body_Id : Entity_Id; @@ -18485,8 +18606,8 @@ package body Sem_Prag is -- anything. But if the old mode is OFF, then the only allowed -- new mode is also OFF. - function Get_SPARK_Mode_Name (Id : SPARK_Mode_Type) return Name_Id; - -- Convert a value of type SPARK_Mode_Type to corresponding name + procedure Check_Library_Level_Entity (E : Entity_Id); + -- Verify that pragma is applied to library-level entity E ------------------------------ -- Check_Pragma_Conformance -- @@ -18499,41 +18620,45 @@ package body Sem_Prag is -- New mode less restrictive than the established mode - if Get_SPARK_Mode_From_Pragma (Old_Pragma) < Mode_Id then - Error_Msg_Name_1 := Mode; - Error_Msg_N ("cannot define 'S'P'A'R'K mode %", Arg1); - - Error_Msg_Name_1 := Get_SPARK_Mode_Name (SPARK_Mode); - Error_Msg_Sloc := Sloc (SPARK_Mode_Pragma); + if Get_SPARK_Mode_From_Pragma (Old_Pragma) = Off + and then Mode_Id = On + then Error_Msg_N - ("\mode is less restrictive than mode " - & "% defined #", Arg1); + ("cannot change 'S'P'A'R'K_Mode from Off to On", Arg1); + Error_Msg_Sloc := Sloc (SPARK_Mode_Pragma); + Error_Msg_N ("\'S'P'A'R'K_Mode was set to Off#", Arg1); raise Pragma_Exit; end if; end if; end Check_Pragma_Conformance; - ------------------------- - -- Get_SPARK_Mode_Name -- - ------------------------- + -------------------------------- + -- Check_Library_Level_Entity -- + -------------------------------- + + procedure Check_Library_Level_Entity (E : Entity_Id) is + MsgF : String := "incorrect placement of pragma%"; - function Get_SPARK_Mode_Name - (Id : SPARK_Mode_Type) return Name_Id - is begin - if Id = On then - return Name_On; - elsif Id = Off then - return Name_Off; - elsif Id = Auto then - return Name_Auto; + if not Is_Library_Level_Entity (E) then + Error_Msg_Name_1 := Pname; + Fix_Error (MsgF); + Error_Msg_N (MsgF, N); - -- Mode "None" should never be used in error message generation + if Ekind_In (E, E_Generic_Package, + E_Package, + E_Package_Body) + then + Error_Msg_NE + ("\& is not a library-level package", N, E); + else + Error_Msg_NE + ("\& is not a library-level subprogram", N, E); + end if; - else - raise Program_Error; + raise Pragma_Exit; end if; - end Get_SPARK_Mode_Name; + end Check_Library_Level_Entity; -- Start of processing for Do_SPARK_Mode @@ -18545,7 +18670,7 @@ package body Sem_Prag is -- Check the legality of the mode (no argument = ON) if Arg_Count = 1 then - Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off, Name_Auto); + Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); Mode := Chars (Get_Pragma_Arg (Arg1)); else Mode := Name_On; @@ -18580,14 +18705,6 @@ package body Sem_Prag is -- The pragma applies to a [library unit] subprogram or package else - -- Mode "Auto" can only be used in a configuration pragma - - if Mode_Id = Auto then - Error_Pragma_Arg - ("mode `Auto` is only allowed when pragma % appears as " - & "a configuration pragma", Arg1); - end if; - -- Verify the placement of the pragma with respect to package -- or subprogram declarations and detect duplicates. @@ -18614,7 +18731,8 @@ package body Sem_Prag is elsif Nkind_In (Stmt, N_Generic_Package_Declaration, N_Package_Declaration) then - Spec_Id := Defining_Unit_Name (Specification (Stmt)); + Spec_Id := Defining_Entity (Stmt); + Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance (SPARK_Pragma (Spec_Id)); Set_SPARK_Pragma (Spec_Id, N); @@ -18628,7 +18746,8 @@ package body Sem_Prag is elsif Nkind_In (Stmt, N_Generic_Subprogram_Declaration, N_Subprogram_Declaration) then - Spec_Id := Defining_Unit_Name (Specification (Stmt)); + Spec_Id := Defining_Entity (Stmt); + Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance (SPARK_Pragma (Spec_Id)); Set_SPARK_Pragma (Spec_Id, N); @@ -18679,11 +18798,12 @@ package body Sem_Prag is -- pragma SPARK_Mode; if Nkind (Context) = N_Package_Specification then - Spec_Id := Defining_Unit_Name (Context); + Spec_Id := Defining_Entity (Context); -- Pragma applies to private part if List_Containing (N) = Private_Declarations (Context) then + Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance (SPARK_Aux_Pragma (Spec_Id)); SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -18694,6 +18814,7 @@ package body Sem_Prag is -- Pragma applies to public part else + Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance (SPARK_Pragma (Spec_Id)); SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -18711,7 +18832,8 @@ package body Sem_Prag is elsif Nkind_In (Context, N_Function_Specification, N_Procedure_Specification) then - Spec_Id := Defining_Unit_Name (Context); + Spec_Id := Defining_Entity (Context); + Check_Library_Level_Entity (Spec_Id); Check_Pragma_Conformance (SPARK_Pragma (Spec_Id)); Set_SPARK_Pragma (Spec_Id, N); @@ -18725,6 +18847,7 @@ package body Sem_Prag is elsif Nkind (Context) = N_Package_Body then Spec_Id := Corresponding_Spec (Context); Body_Id := Defining_Entity (Context); + Check_Library_Level_Entity (Body_Id); Check_Pragma_Conformance (SPARK_Pragma (Body_Id)); SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -18743,6 +18866,7 @@ package body Sem_Prag is Spec_Id := Corresponding_Spec (Context); Context := Specification (Context); Body_Id := Defining_Entity (Context); + Check_Library_Level_Entity (Body_Id); Check_Pragma_Conformance (SPARK_Pragma (Body_Id)); SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -18761,7 +18885,8 @@ package body Sem_Prag is then Context := Parent (Context); Spec_Id := Corresponding_Spec (Context); - Body_Id := Defining_Unit_Name (Context); + Body_Id := Defining_Entity (Context); + Check_Library_Level_Entity (Body_Id); Check_Pragma_Conformance (SPARK_Aux_Pragma (Body_Id)); SPARK_Mode_Pragma := N; SPARK_Mode := Mode_Id; @@ -20538,12 +20663,12 @@ package body Sem_Prag is Depends : Node_Id; -- The corresponding Depends pragma along with its clauses - Global : Node_Id := Empty; - -- The corresponding Refined_Global pragma (if any) - Out_Items : Elist_Id := No_Elist; -- All output items as defined in pragma Refined_Global (if any) + Ref_Global : Node_Id := Empty; + -- The corresponding Refined_Global pragma (if any) + Refinements : List_Id := No_List; -- The clauses of pragma Refined_Depends @@ -20568,14 +20693,6 @@ package body Sem_Prag is -- clause Ref_Clause. If flag Do_Checks is set, the routine reports -- missed or extra input items. - function Output_Constituents (State_Id : Entity_Id) return Elist_Id; - -- Given a state denoted by State_Id, return a list of all output - -- constituents that may be referenced within Refined_Depends. The - -- contents of the list depend on whether Refined_Global is present. - - procedure Report_Unused_Constituents (Constits : Elist_Id); - -- Emit errors for all constituents found in list Constits - ------------------ -- Inputs_Match -- ------------------ @@ -20888,86 +21005,6 @@ package body Sem_Prag is return Result; end Inputs_Match; - ------------------------- - -- Output_Constituents -- - ------------------------- - - function Output_Constituents (State_Id : Entity_Id) return Elist_Id is - Item_Elmt : Elmt_Id; - Item_Id : Entity_Id; - Result : Elist_Id := No_Elist; - - begin - -- The related subprogram is subject to pragma Refined_Global. All - -- usable output constituents are defined in its output item list. - - if Present (Global) then - Item_Elmt := First_Elmt (Out_Items); - while Present (Item_Elmt) loop - Item_Id := Node (Item_Elmt); - - -- The constituent is part of the refinement of the input - -- state, add it to the result list. - - if Refined_State (Item_Id) = State_Id then - Add_Item (Item_Id, Result); - end if; - - Next_Elmt (Item_Elmt); - end loop; - - -- When pragma Refined_Global is not present, the usable output - -- constituents are all the constituents as defined in pragma - -- Refined_State. Note that the elements are copied because the - -- algorithm trims the list and this should not be reflected in - -- the state itself. - - else - Result := New_Copy_Elist (Refinement_Constituents (State_Id)); - end if; - - return Result; - end Output_Constituents; - - -------------------------------- - -- Report_Unused_Constituents -- - -------------------------------- - - procedure Report_Unused_Constituents (Constits : Elist_Id) is - Constit : Entity_Id; - Elmt : Elmt_Id; - Posted : Boolean := False; - - begin - if Present (Constits) then - Elmt := First_Elmt (Constits); - while Present (Elmt) loop - Constit := Node (Elmt); - - -- A constituent must always refine a state - - pragma Assert (Present (Refined_State (Constit))); - - -- When a state has a visible refinement and its mode is - -- Output_Only, all its constituents must be used as - -- outputs. - - if not Posted then - Posted := True; - Error_Msg_NE - ("output only state & must be replaced by all its " - & "constituents in dependence refinement", - N, Refined_State (Constit)); - end if; - - Error_Msg_NE - ("\ constituent & is missing in output list", N, Constit); - - Next_Elmt (Elmt); - end loop; - end if; - end Report_Unused_Constituents; - -- Local variables Dep_Output : constant Node_Id := First (Choices (Dep_Clause)); @@ -20990,10 +21027,6 @@ package body Sem_Prag is -- Flag set when the output of clause Dep_Clause is a state with -- visible refinement. - Out_Constits : Elist_Id := No_Elist; - -- This list contains the entities all output constituents of state - -- Dep_Id as defined in pragma Refined_State. - -- Start of processing for Check_Dependency_Clause begin @@ -21096,15 +21129,6 @@ package body Sem_Prag is elsif Has_Non_Null_Refinement (Dep_Id) then Has_Refined_State := True; - -- Store the entities of all output constituents of an - -- Output_Only state with visible refinement. - - if No (Out_Constits) - and then Is_Output_Only_State (Dep_Id) - then - Out_Constits := Output_Constituents (Dep_Id); - end if; - if Is_Entity_Name (Ref_Output) then Ref_Id := Entity_Of (Ref_Output); @@ -21123,12 +21147,6 @@ package body Sem_Prag is then Has_Constituent := True; Remove (Ref_Clause); - - -- The matching constituent may act as an output - -- for an Output_Only state. Remove the item from - -- the available output constituents. - - Remove (Out_Constits, Ref_Id); end if; end if; @@ -21215,11 +21233,6 @@ package body Sem_Prag is Ref_Clause); end if; end if; - - -- Emit errors for all unused constituents of an Output_Only state - -- with visible refinement. - - Report_Unused_Constituents (Out_Constits); end Check_Dependency_Clause; -------------------------- @@ -21262,8 +21275,8 @@ package body Sem_Prag is -- The following are dummy variables that capture unused output of -- routine Collect_Global_Items. - D1, D2 : Elist_Id := No_Elist; - D3, D4, D5, D6 : Boolean; + D1, D2, D3 : Elist_Id := No_Elist; + D4, D5, D6, D7, D8 : Boolean; -- Start of processing for Analyze_Refined_Depends_In_Decl_Part @@ -21276,8 +21289,8 @@ package body Sem_Prag is if No (Depends) then Error_Msg_NE - ("useless refinement, subprogram & lacks dependence clauses", - N, Spec_Id); + ("useless refinement, subprogram & lacks dependence clauses (SPARK " + & "RM 7.2.5(2))", N, Spec_Id); return; end if; @@ -21290,7 +21303,7 @@ package body Sem_Prag is if Nkind (Deps) = N_Null then Error_Msg_NE ("useless refinement, subprogram & does not depend on abstract " - & "state with visible refinement", N, Spec_Id); + & "state with visible refinement (SPARK RM 7.2.5(2))", N, Spec_Id); return; end if; @@ -21314,18 +21327,20 @@ package body Sem_Prag is -- verifying the use of constituents that apply to output states with -- visible refinement. - Global := Get_Pragma (Body_Id, Pragma_Refined_Global); + Ref_Global := Get_Pragma (Body_Id, Pragma_Refined_Global); - if Present (Global) then + if Present (Ref_Global) then Collect_Global_Items - (Prag => Global, - In_Items => D1, - In_Out_Items => D2, - Out_Items => Out_Items, - Has_In_State => D3, - Has_In_Out_State => D4, - Has_Out_State => D5, - Has_Null_State => D6); + (Prag => Ref_Global, + In_Items => D1, + In_Out_Items => D2, + Out_Items => Out_Items, + Proof_In_Items => D3, + Has_In_State => D4, + Has_In_Out_State => D5, + Has_Out_State => D6, + Has_Proof_In_State => D7, + Has_Null_State => D8); end if; if Nkind (Refs) = N_Null then @@ -21374,29 +21389,32 @@ package body Sem_Prag is Global : Node_Id; -- The corresponding Global pragma - Has_In_State : Boolean := False; - Has_In_Out_State : Boolean := False; - Has_Out_State : Boolean := False; + Has_In_State : Boolean := False; + Has_In_Out_State : Boolean := False; + Has_Out_State : Boolean := False; + Has_Proof_In_State : Boolean := False; -- These flags are set when the corresponding Global pragma has a state - -- of mode Input, In_Out and Output respectively with a visible + -- of mode Input, In_Out, Output or Proof_In respectively with a visible -- refinement. Has_Null_State : Boolean := False; -- This flag is set when the corresponding Global pragma has at least -- one state with a null refinement. - In_Constits : Elist_Id := No_Elist; - In_Out_Constits : Elist_Id := No_Elist; - Out_Constits : Elist_Id := No_Elist; - -- These lists contain the entities of all Input, In_Out and Output - -- constituents that appear in Refined_Global and participate in state - -- refinement. - - In_Items : Elist_Id := No_Elist; - In_Out_Items : Elist_Id := No_Elist; - Out_Items : Elist_Id := No_Elist; - -- These list contain the entities of all Input, In_Out and Output items - -- defined in the corresponding Global pragma. + In_Constits : Elist_Id := No_Elist; + In_Out_Constits : Elist_Id := No_Elist; + Out_Constits : Elist_Id := No_Elist; + Proof_In_Constits : Elist_Id := No_Elist; + -- These lists contain the entities of all Input, In_Out, Output and + -- Proof_In constituents that appear in Refined_Global and participate + -- in state refinement. + + In_Items : Elist_Id := No_Elist; + In_Out_Items : Elist_Id := No_Elist; + Out_Items : Elist_Id := No_Elist; + Proof_In_Items : Elist_Id := No_Elist; + -- These list contain the entities of all Input, In_Out, Output and + -- Proof_In items defined in the corresponding Global pragma. procedure Check_In_Out_States; -- Determine whether the corresponding Global pragma mentions In_Out @@ -21406,22 +21424,29 @@ package body Sem_Prag is -- 2) there is at least one Input and one Output constituent -- 3) not all constituents are present and one of them is of mode -- Output. - -- This routine may remove elements from In_Constits, In_Out_Constits - -- and Out_Constits. + -- This routine may remove elements from In_Constits, In_Out_Constits, + -- Out_Constits and Proof_In_Constits. procedure Check_Input_States; -- Determine whether the corresponding Global pragma mentions Input -- states with visible refinement and if so, ensure that at least one of -- its constituents appears as an Input item in Refined_Global. - -- This routine may remove elements from In_Constits, In_Out_Constits - -- and Out_Constits. + -- This routine may remove elements from In_Constits, In_Out_Constits, + -- Out_Constits and Proof_In_Constits. procedure Check_Output_States; -- Determine whether the corresponding Global pragma mentions Output -- states with visible refinement and if so, ensure that all of its - -- constituents appear as Output items in Refined_Global. This routine - -- may remove elements from In_Constits, In_Out_Constits and - -- Out_Constits. + -- constituents appear as Output items in Refined_Global. + -- This routine may remove elements from In_Constits, In_Out_Constits, + -- Out_Constits and Proof_In_Constits. + + procedure Check_Proof_In_States; + -- Determine whether the corresponding Global pragma mentions Proof_In + -- states with visible refinement and if so, ensure that at least one of + -- its constituents appears as a Proof_In item in Refined_Global. + -- This routine may remove elements from In_Constits, In_Out_Constits, + -- Out_Constits and Proof_In_Constits. procedure Check_Refined_Global_List (List : Node_Id; @@ -21483,6 +21508,16 @@ package body Sem_Prag is elsif Present_Then_Remove (Out_Constits, Constit_Id) then Out_Seen := True; + -- A Proof_In constituent cannot participate in the completion + -- of an Output state. + + elsif Present_Then_Remove (Proof_In_Constits, Constit_Id) then + Error_Msg_Name_1 := Chars (State_Id); + Error_Msg_NE + ("constituent & of state % must have mode Input, In_Out " + & "or Output in global refinement (SPARK RM 7.2.4(5))", + N, Constit_Id); + else Has_Missing := True; end if; @@ -21510,7 +21545,7 @@ package body Sem_Prag is else Error_Msg_NE ("global refinement of state & redefines the mode of its " - & "constituents", N, State_Id); + & "constituents (SPARK RM 7.2.4(5))", N, State_Id); end if; end Check_Constituent_Usage; @@ -21551,7 +21586,8 @@ package body Sem_Prag is procedure Check_Constituent_Usage (State_Id : Entity_Id); -- Determine whether at least one constituent of state State_Id with -- visible refinement is used and has mode Input. Ensure that the - -- remaining constituents do not have In_Out or Output modes. + -- remaining constituents do not have In_Out, Output or Proof_In + -- modes. ----------------------------- -- Check_Constituent_Usage -- @@ -21573,15 +21609,16 @@ package body Sem_Prag is In_Seen := True; -- The constituent appears in the global refinement, but has - -- mode In_Out or Output. + -- mode In_Out, Output or Proof_In. elsif Present_Then_Remove (In_Out_Constits, Constit_Id) or else Present_Then_Remove (Out_Constits, Constit_Id) + or else Present_Then_Remove (Proof_In_Constits, Constit_Id) then Error_Msg_Name_1 := Chars (State_Id); Error_Msg_NE ("constituent & of state % must have mode Input in global " - & "refinement", N, Constit_Id); + & "refinement (SPARK RM 7.2.4(5))", N, Constit_Id); end if; Next_Elmt (Constit_Elmt); @@ -21643,6 +21680,7 @@ package body Sem_Prag is procedure Check_Constituent_Usage (State_Id : Entity_Id) is Constit_Elmt : Elmt_Id; Constit_Id : Entity_Id; + Posted : Boolean := False; begin Constit_Elmt := First_Elmt (Refinement_Constituents (State_Id)); @@ -21652,14 +21690,32 @@ package body Sem_Prag is if Present_Then_Remove (Out_Constits, Constit_Id) then null; - else - Remove (In_Constits, Constit_Id); - Remove (In_Out_Constits, Constit_Id); + -- The constituent appears in the global refinement, but has + -- mode Input, In_Out or Proof_In. + elsif Present_Then_Remove (In_Constits, Constit_Id) + or else Present_Then_Remove (In_Out_Constits, Constit_Id) + or else Present_Then_Remove (Proof_In_Constits, Constit_Id) + then Error_Msg_Name_1 := Chars (State_Id); Error_Msg_NE ("constituent & of state % must have mode Output in " - & "global refinement", N, Constit_Id); + & "global refinement (SPARK RM 7.2.4(5))", N, Constit_Id); + + -- The constituent is altogether missing + + else + if not Posted then + Posted := True; + Error_Msg_NE + ("output state & must be replaced by all its " + & "constituents in global refinement (SPARK RM " + & "7.2.5(3))", N, State_Id); + end if; + + Error_Msg_NE + ("\ constituent & is missing in output list", + N, Constit_Id); end if; Next_Elmt (Constit_Elmt); @@ -21696,6 +21752,90 @@ package body Sem_Prag is end if; end Check_Output_States; + --------------------------- + -- Check_Proof_In_States -- + --------------------------- + + procedure Check_Proof_In_States is + procedure Check_Constituent_Usage (State_Id : Entity_Id); + -- Determine whether at least one constituent of state State_Id with + -- visible refinement is used and has mode Proof_In. Ensure that the + -- remaining constituents do not have Input, In_Out or Output modes. + + ----------------------------- + -- Check_Constituent_Usage -- + ----------------------------- + + procedure Check_Constituent_Usage (State_Id : Entity_Id) is + Constit_Elmt : Elmt_Id; + Constit_Id : Entity_Id; + Proof_In_Seen : Boolean := False; + + begin + Constit_Elmt := First_Elmt (Refinement_Constituents (State_Id)); + while Present (Constit_Elmt) loop + Constit_Id := Node (Constit_Elmt); + + -- At least one of the constituents appears as Proof_In + + if Present_Then_Remove (Proof_In_Constits, Constit_Id) then + Proof_In_Seen := True; + + -- The constituent appears in the global refinement, but has + -- mode Input, In_Out or Output. + + elsif Present_Then_Remove (In_Constits, Constit_Id) + or else Present_Then_Remove (In_Out_Constits, Constit_Id) + or else Present_Then_Remove (Out_Constits, Constit_Id) + then + Error_Msg_Name_1 := Chars (State_Id); + Error_Msg_NE + ("constituent & of state % must have mode Proof_In in " + & "global refinement (SPARK RM 7.2.4(5))", N, Constit_Id); + end if; + + Next_Elmt (Constit_Elmt); + end loop; + + -- Not one of the constituents appeared as Proof_In + + if not Proof_In_Seen then + Error_Msg_NE + ("global refinement of state & must include at least one " + & "constituent of mode Proof_In", N, State_Id); + end if; + end Check_Constituent_Usage; + + -- Local variables + + Item_Elmt : Elmt_Id; + Item_Id : Entity_Id; + + -- Start of processing for Check_Proof_In_States + + begin + -- Inspect the Proof_In items of the corresponding Global pragma + -- looking for a state with a visible refinement. + + if Has_Proof_In_State and then Present (Proof_In_Items) then + Item_Elmt := First_Elmt (Proof_In_Items); + while Present (Item_Elmt) loop + Item_Id := Node (Item_Elmt); + + -- Ensure that at least one of the constituents is utilized and + -- is of mode Proof_In + + if Ekind (Item_Id) = E_Abstract_State + and then Has_Non_Null_Refinement (Item_Id) + then + Check_Constituent_Usage (Item_Id); + end if; + + Next_Elmt (Item_Elmt); + end loop; + end if; + end Check_Proof_In_States; + ------------------------------- -- Check_Refined_Global_List -- ------------------------------- @@ -21755,6 +21895,9 @@ package body Sem_Prag is elsif Global_Mode = Name_Output then Add_Item (Item_Id, Out_Constits); + + elsif Global_Mode = Name_Proof_In then + Add_Item (Item_Id, Proof_In_Constits); end if; -- When not a constituent, ensure that both occurrences of the @@ -21775,11 +21918,15 @@ package body Sem_Prag is Inconsistent_Mode_Error (Name_Output); end if; + elsif Contains (Proof_In_Items, Item_Id) then + null; + -- The item does not appear in the corresponding Global pragma, it -- must be an extra. else - Error_Msg_NE ("extra global item &", Item, Item_Id); + Error_Msg_NE + ("extra global item & (SPARK RM 7.2.4(3))", Item, Item_Id); end if; end Check_Refined_Global_Item; @@ -21900,6 +22047,7 @@ package body Sem_Prag is Report_Extra_Constituents_In_List (In_Constits); Report_Extra_Constituents_In_List (In_Out_Constits); Report_Extra_Constituents_In_List (Out_Constits); + Report_Extra_Constituents_In_List (Proof_In_Constits); end Report_Extra_Constituents; -- Local variables @@ -21927,14 +22075,16 @@ package body Sem_Prag is -- Extract all relevant items from the corresponding Global pragma Collect_Global_Items - (Prag => Global, - In_Items => In_Items, - In_Out_Items => In_Out_Items, - Out_Items => Out_Items, - Has_In_State => Has_In_State, - Has_In_Out_State => Has_In_Out_State, - Has_Out_State => Has_Out_State, - Has_Null_State => Has_Null_State); + (Prag => Global, + In_Items => In_Items, + In_Out_Items => In_Out_Items, + Out_Items => Out_Items, + Proof_In_Items => Proof_In_Items, + Has_In_State => Has_In_State, + Has_In_Out_State => Has_In_Out_State, + Has_Out_State => Has_Out_State, + Has_Proof_In_State => Has_Proof_In_State, + Has_Null_State => Has_Null_State); -- The corresponding Global pragma must mention at least one state with -- a visible refinement at the point Refined_Global is processed. States @@ -21943,6 +22093,7 @@ package body Sem_Prag is if not Has_In_State and then not Has_In_Out_State and then not Has_Out_State + and then not Has_Proof_In_State and then not Has_Null_State then Error_Msg_NE @@ -21959,7 +22110,8 @@ package body Sem_Prag is and then (Present (In_Items) or else Present (In_Out_Items) - or else Present (Out_Items)) + or else Present (Out_Items) + or else Present (Proof_In_Items)) and then not Has_Null_State then Error_Msg_NE @@ -22002,6 +22154,13 @@ package body Sem_Prag is Check_Output_States; end if; + -- For Proof_In states with visible refinement, at least one constituent + -- must be used as Proof_In in the global refinement. + + if Serious_Errors_Detected = Errors then + Check_Proof_In_States; + end if; + -- Emit errors for all constituents that belong to other states with -- visible refinement that do not appear in Global. @@ -22055,24 +22214,44 @@ package body Sem_Prag is ------------------------------- procedure Analyze_Refinement_Clause (Clause : Node_Id) is - State_Id : Entity_Id := Empty; - -- The entity of the state being refined in the current clause + AR_Constit : Entity_Id := Empty; + AW_Constit : Entity_Id := Empty; + ER_Constit : Entity_Id := Empty; + EW_Constit : Entity_Id := Empty; + -- The entities of external constituents that contain one of the + -- following enabled properties: Async_Readers, Async_Writers, + -- Effective_Reads and Effective_Writes. + + External_Constit_Seen : Boolean := False; + -- Flag used to mark when at least one external constituent is part + -- of the state refinement. Non_Null_Seen : Boolean := False; Null_Seen : Boolean := False; -- Flags used to detect multiple uses of null in a single clause or a -- mixture of null and non-null constituents. + State : Node_Id; + State_Id : Entity_Id; + -- The state being refined in the current clause + procedure Analyze_Constituent (Constit : Node_Id); -- Perform full analysis of a single constituent - procedure Check_Matching_State - (State : Node_Id; - State_Id : Entity_Id); - -- Determine whether state State denoted by its name State_Id appears - -- in Abstr_States. Emit an error when attempting to re-refine the - -- state or when the state is not defined in the package declaration. - -- Otherwise remove the state from Abstr_States. + procedure Check_External_Property + (Prop_Nam : Name_Id; + Enabled : Boolean; + Constit : Entity_Id); + -- Determine whether a property denoted by name Prop_Nam is present + -- in both the refined state and constituent Constit. Flag Enabled + -- should be set when the property applies to the refined state. If + -- this is not the case, emit an error message. + + procedure Check_Matching_State; + -- Determine whether the state being refined appears in Abstr_States. + -- Emit an error when attempting to re-refine the state or when the + -- state is not defined in the package declaration. Otherwise remove + -- the state from Abstr_States. ------------------------- -- Analyze_Constituent -- @@ -22117,6 +22296,29 @@ package body Sem_Prag is -- body declarations end (see routine Analyze_Declarations). Set_Has_Visible_Refinement (State_Id); + + -- When the constituent is external, save its relevant + -- property for further checks. + + if Async_Readers_Enabled (Constit_Id) then + AR_Constit := Constit_Id; + External_Constit_Seen := True; + end if; + + if Async_Writers_Enabled (Constit_Id) then + AW_Constit := Constit_Id; + External_Constit_Seen := True; + end if; + + if Effective_Reads_Enabled (Constit_Id) then + ER_Constit := Constit_Id; + External_Constit_Seen := True; + end if; + + if Effective_Writes_Enabled (Constit_Id) then + EW_Constit := Constit_Id; + External_Constit_Seen := True; + end if; end Collect_Constituent; -- Local variables @@ -22194,7 +22396,8 @@ package body Sem_Prag is Error_Msg_Name_1 := Chars (Spec_Id); Error_Msg_NE ("cannot use & in refinement, constituent is not a hidden " - & "state of package %", Constit, Constit_Id); + & "state of package % (SPARK RM 7.2.2(9))", + Constit, Constit_Id); end Check_Matching_Constituent; -- Local variables @@ -22254,8 +22457,8 @@ package body Sem_Prag is else Error_Msg_NE - ("constituent & must denote a variable or state", - Constit, Constit_Id); + ("constituent & must denote a variable or state (SPARK " + & "RM 7.2.2(5))", Constit, Constit_Id); end if; -- The constituent is illegal @@ -22266,14 +22469,44 @@ package body Sem_Prag is end if; end Analyze_Constituent; + ----------------------------- + -- Check_External_Property -- + ----------------------------- + + procedure Check_External_Property + (Prop_Nam : Name_Id; + Enabled : Boolean; + Constit : Entity_Id) + is + begin + Error_Msg_Name_1 := Prop_Nam; + + -- The property is enabled in the related Abstract_State pragma + -- that defines the state. + + if Enabled then + if No (Constit) then + Error_Msg_NE + ("external state & requires at least one constituent with " + & "property % (SPARK RM 7.2.8(3))", State, State_Id); + end if; + + -- The property is missing in the declaration of the state, but a + -- constituent is introducing it in the state refinement. + + elsif Present (Constit) then + Error_Msg_Name_2 := Chars (Constit); + Error_Msg_NE + ("external state & lacks property % set by constituent % " + & "(SPARK RM 7.2.8(3))", State, State_Id); + end if; + end Check_External_Property; + -------------------------- -- Check_Matching_State -- -------------------------- - procedure Check_Matching_State - (State : Node_Id; - State_Id : Entity_Id) - is + procedure Check_Matching_State is State_Elmt : Elmt_Id; begin @@ -22281,7 +22514,8 @@ package body Sem_Prag is if Contains (Refined_States_Seen, State_Id) then Error_Msg_NE - ("duplicate refinement of state &", State, State_Id); + ("duplicate refinement of state & (SPARK RM 7.2.2(8))", + State, State_Id); return; end if; @@ -22317,8 +22551,10 @@ package body Sem_Prag is -- Local declarations - Constit : Node_Id; - State : Node_Id; + Body_Ref : Node_Id; + Body_Ref_Elmt : Elmt_Id; + Constit : Node_Id; + Extra_State : Node_Id; -- Start of processing for Analyze_Refinement_Clause @@ -22326,64 +22562,60 @@ package body Sem_Prag is -- Analyze the state name of a refinement clause State := First (Choices (Clause)); - while Present (State) loop - if Present (State_Id) then - Error_Msg_N - ("refinement clause cannot cover multiple states", State); - - else - Analyze (State); - Resolve_State (State); - -- Ensure that the state name denotes a valid abstract state - -- that is defined in the spec of the related package. + Analyze (State); + Resolve_State (State); - if Is_Entity_Name (State) then - State_Id := Entity_Of (State); + -- Ensure that the state name denotes a valid abstract state that is + -- defined in the spec of the related package. - -- Catch any attempts to re-refine a state or refine a - -- state that is not defined in the package declaration. + if Is_Entity_Name (State) then + State_Id := Entity_Of (State); - if Ekind (State_Id) = E_Abstract_State then - Check_Matching_State (State, State_Id); - else - Error_Msg_NE - ("& must denote an abstract state", State, State_Id); - end if; + -- Catch any attempts to re-refine a state or refine a state that + -- is not defined in the package declaration. - -- Enforce SPARK RM (6.1.5(4)): A global item shall not - -- denote a state abstraction whose refinement is visible - -- (a state abstraction cannot be named within its enclosing - -- package's body other than in its refinement). + if Ekind (State_Id) = E_Abstract_State then + Check_Matching_State; + else + Error_Msg_NE + ("& must denote an abstract state", State, State_Id); + end if; - if Has_Body_References (State_Id) then - declare - Ref : Elmt_Id; - Nod : Node_Id; - begin - Ref := First_Elmt (Body_References (State_Id)); - while Present (Ref) loop - Nod := Node (Ref); - Error_Msg_N - ("global reference to & not allowed " - & "(SPARK RM 6.1.5(4))", Nod); - Error_Msg_Sloc := Sloc (State); - Error_Msg_N ("\refinement of & is visible#", Nod); - Next_Elmt (Ref); - end loop; - end; - end if; + -- A global item cannot denote a state abstraction whose + -- refinement is visible, in other words a state abstraction + -- cannot be named within its enclosing package's body other than + -- in its refinement. - -- The state name is illegal + if Has_Body_References (State_Id) then + Body_Ref_Elmt := First_Elmt (Body_References (State_Id)); + while Present (Body_Ref_Elmt) loop + Body_Ref := Node (Body_Ref_Elmt); - else Error_Msg_N - ("malformed state name in refinement clause", State); - end if; + ("global reference to & not allowed (SPARK RM 6.1.4(8))", + Body_Ref); + Error_Msg_Sloc := Sloc (State); + Error_Msg_N ("\refinement of & is visible#", Body_Ref); + + Next_Elmt (Body_Ref_Elmt); + end loop; end if; - Next (State); - end loop; + -- The state name is illegal + + else + Error_Msg_N ("malformed state name in refinement clause", State); + end if; + + -- A refinement clause may only refine one state at a time + + Extra_State := Next (State); + + if Present (Extra_State) then + Error_Msg_N + ("refinement clause cannot cover multiple states", Extra_State); + end if; -- Analyze all constituents of the refinement. Multiple constituents -- appear as an aggregate. @@ -22411,6 +22643,60 @@ package body Sem_Prag is else Analyze_Constituent (Constit); end if; + + -- A refined external state is subject to special rules with respect + -- to its properties and constituents. + + if Is_External_State (State_Id) then + + -- The set of properties that all external constituents yield must + -- match that of the refined state. There are two cases to detect: + -- the refined state lacks a property or has an extra property. + + if External_Constit_Seen then + Check_External_Property + (Prop_Nam => Name_Async_Readers, + Enabled => Async_Readers_Enabled (State_Id), + Constit => AR_Constit); + + Check_External_Property + (Prop_Nam => Name_Async_Writers, + Enabled => Async_Writers_Enabled (State_Id), + Constit => AW_Constit); + + Check_External_Property + (Prop_Nam => Name_Effective_Reads, + Enabled => Effective_Reads_Enabled (State_Id), + Constit => ER_Constit); + + Check_External_Property + (Prop_Nam => Name_Effective_Writes, + Enabled => Effective_Writes_Enabled (State_Id), + Constit => EW_Constit); + + -- An external state may be refined to null (SPARK RM 7.2.8(2)) + + elsif Null_Seen then + null; + + -- The external state has constituents, but none of them are + -- external. + + else + Error_Msg_NE + ("external state & requires at least one external " + & "constituent or null refinement (SPARK RM 7.2.8(2))", + State, State_Id); + end if; + + -- When a refined state is not external, it should not have external + -- constituents. + + elsif External_Constit_Seen then + Error_Msg_NE + ("non-external state & cannot contain external constituents in " + & "refinement (SPARK RM 7.2.8(1))", State, State_Id); + end if; end Analyze_Refinement_Clause; --------------------------- @@ -22702,7 +22988,8 @@ package body Sem_Prag is else Error_Msg_N - ("illegal combination of external state properties", Item); + ("illegal combination of external properties (SPARK RM 7.1.2(6))", + Item); end if; end Check_External_Properties; @@ -22846,14 +23133,16 @@ package body Sem_Prag is -------------------------- procedure Collect_Global_Items - (Prag : Node_Id; - In_Items : in out Elist_Id; - In_Out_Items : in out Elist_Id; - Out_Items : in out Elist_Id; - Has_In_State : out Boolean; - Has_In_Out_State : out Boolean; - Has_Out_State : out Boolean; - Has_Null_State : out Boolean) + (Prag : Node_Id; + In_Items : in out Elist_Id; + In_Out_Items : in out Elist_Id; + Out_Items : in out Elist_Id; + Proof_In_Items : in out Elist_Id; + Has_In_State : out Boolean; + Has_In_Out_State : out Boolean; + Has_Out_State : out Boolean; + Has_Proof_In_State : out Boolean; + Has_Null_State : out Boolean) is procedure Process_Global_List (List : Node_Id; @@ -22898,6 +23187,8 @@ package body Sem_Prag is Has_In_Out_State := True; elsif Mode = Name_Output then Has_Out_State := True; + elsif Mode = Name_Proof_In then + Has_Proof_In_State := True; end if; end if; end if; @@ -22910,6 +23201,8 @@ package body Sem_Prag is Add_Item (Item_Id, In_Out_Items); elsif Mode = Name_Output then Add_Item (Item_Id, Out_Items); + elsif Mode = Name_Proof_In then + Add_Item (Item_Id, Proof_In_Items); end if; end Process_Global_Item; @@ -22982,10 +23275,11 @@ package body Sem_Prag is begin -- Assume that no states have been encountered - Has_In_State := False; - Has_In_Out_State := False; - Has_Out_State := False; - Has_Null_State := False; + Has_In_State := False; + Has_In_Out_State := False; + Has_Out_State := False; + Has_Proof_In_State := False; + Has_Null_State := False; Process_Global_List (Items); end Collect_Global_Items; @@ -23306,8 +23600,6 @@ package body Sem_Prag is return On; elsif N = Name_Off then return Off; - elsif N = Name_Auto then - return Auto; -- Any other argument is erroneous diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads index 6d1a01a6ecc..730643a1c51 100644 --- a/gcc/ada/sem_prag.ads +++ b/gcc/ada/sem_prag.ads @@ -60,7 +60,7 @@ package Sem_Prag is -- Perform full analysis of delayed pragma Depends. This routine is also -- capable of performing basic analysis of pragma Refined_Depends. - procedure Analyze_External_State_In_Decl_Part + procedure Analyze_External_Property_In_Decl_Part (N : Node_Id; Expr_Val : out Boolean); -- Perform full analysis of delayed pragmas Async_Readers, Async_Writers, diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 537a6e166ae..aff4b47926a 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -193,6 +193,7 @@ package body Sem_Res is procedure Resolve_Op_Expon (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id); procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id); + procedure Resolve_Raise_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Range (N : Node_Id; Typ : Entity_Id); procedure Resolve_Real_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Reference (N : Node_Id; Typ : Entity_Id); @@ -201,7 +202,6 @@ package body Sem_Res is procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id); procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id); procedure Resolve_String_Literal (N : Node_Id; Typ : Entity_Id); - procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id); procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unary_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unchecked_Expression (N : Node_Id; Typ : Entity_Id); @@ -977,8 +977,12 @@ package body Sem_Res is end if; end if; + -- Do style check (but skip if in instance, error is on template) + if Style_Check then - Check_Boolean_Operator (N); + if not In_Instance then + Check_Boolean_Operator (N); + end if; end if; end Check_No_Direct_Boolean_Operators; @@ -1581,17 +1585,20 @@ package body Sem_Res is -- If in ASIS_Mode, propagate operand types to original actuals of -- function call, which would otherwise not be fully resolved. If - -- the call has already been constant-folded, nothing to do. + -- the call has already been constant-folded, nothing to do. We + -- relocate the operand nodes rather than copy them, to preserve + -- original_node pointers, given that the operands themselves may + -- have been rewritten. if ASIS_Mode and then Nkind (N) in N_Op then if Is_Binary then Rewrite (First (Parameter_Associations (Original_Node (N))), - New_Copy_Tree (Left_Opnd (N))); + Relocate_Node (Left_Opnd (N))); Rewrite (Next (First (Parameter_Associations (Original_Node (N)))), - New_Copy_Tree (Right_Opnd (N))); + Relocate_Node (Right_Opnd (N))); else Rewrite (First (Parameter_Associations (Original_Node (N))), - New_Copy_Tree (Right_Opnd (N))); + Relocate_Node (Right_Opnd (N))); end if; Set_Parent (Original_Node (N), Parent (N)); @@ -2873,11 +2880,8 @@ package body Sem_Res is when N_Quantified_Expression => null; - -- Nothing to do for Raise_Expression, since we took care of - -- setting the Etype earlier, and no other processing is needed. - when N_Raise_Expression - => null; + => Resolve_Raise_Expression (N, Ctx_Type); when N_Raise_xxx_Error => Set_Etype (N, Ctx_Type); @@ -2897,9 +2901,6 @@ package body Sem_Res is when N_String_Literal => Resolve_String_Literal (N, Ctx_Type); - when N_Subprogram_Info - => Resolve_Subprogram_Info (N, Ctx_Type); - when N_Type_Conversion => Resolve_Type_Conversion (N, Ctx_Type); @@ -3453,13 +3454,16 @@ package body Sem_Res is -- If we have an error in any actual or formal, indicated by a type -- of Any_Type, then abandon resolution attempt, and set result type - -- to Any_Type. + -- to Any_Type. Skip this if the actual is a Raise_Expression, whose + -- type is imposed from context. elsif (Present (A) and then Etype (A) = Any_Type) or else Etype (F) = Any_Type then - Set_Etype (N, Any_Type); - return; + if Nkind (A) /= N_Raise_Expression then + Set_Etype (N, Any_Type); + return; + end if; end if; -- Case where actual is present @@ -4040,6 +4044,16 @@ package body Sem_Res is then Apply_Discriminant_Check (A, F_Typ); + -- For view conversions of a discriminated object, apply + -- check to object itself, the conversion alreay has the + -- proper type. + + if Nkind (A) = N_Type_Conversion + and then Is_Constrained (Etype (Expression (A))) + then + Apply_Discriminant_Check (Expression (A), F_Typ); + end if; + elsif Is_Access_Type (F_Typ) and then Is_Array_Type (Designated_Type (F_Typ)) and then Is_Constrained (Designated_Type (F_Typ)) @@ -4253,7 +4267,7 @@ package body Sem_Res is -- they are not standard Ada legality rule. if SPARK_Mode = On - and then Is_Volatile_Object (A) + and then Is_SPARK_Volatile_Object (A) then -- A volatile object may act as an actual parameter when the -- corresponding formal is of a non-scalar volatile type. @@ -4272,7 +4286,7 @@ package body Sem_Res is else Error_Msg_N ("volatile object cannot act as actual in a call (SPARK " - & "RM 7.1.3(8))", A); + & "RM 7.1.3(12))", A); end if; end if; @@ -6273,7 +6287,10 @@ package body Sem_Res is -- Check comparison on unordered enumeration if Bad_Unordered_Enumeration_Reference (N, Etype (L)) then - Error_Msg_N ("comparison on unordered enumeration type?U?", N); + Error_Msg_Sloc := Sloc (Etype (L)); + Error_Msg_NE + ("comparison on unordered enumeration type& declared#?U?", + N, Etype (L)); end if; -- Evaluate the relation (note we do this after the above check since @@ -6496,8 +6513,7 @@ package body Sem_Res is -- standard Ada legality rules. if SPARK_Mode = On - and then Ekind (E) = E_Variable - and then Is_Volatile_Object (E) + and then Is_SPARK_Volatile_Object (E) and then (Async_Writers_Enabled (E) or else Effective_Reads_Enabled (E)) @@ -6554,7 +6570,7 @@ package body Sem_Res is if not Usage_OK then Error_Msg_N ("volatile object cannot appear in this context (SPARK RM " - & "7.1.3(9))", N); + & "7.1.3(13))", N); end if; end if; end Resolve_Entity_Name; @@ -8751,6 +8767,15 @@ package body Sem_Res is Eval_Qualified_Expression (N); end Resolve_Qualified_Expression; + ------------------------------ + -- Resolve_Raise_Expression -- + ------------------------------ + + procedure Resolve_Raise_Expression (N : Node_Id; Typ : Entity_Id) is + begin + Set_Etype (N, Typ); + end Resolve_Raise_Expression; + ------------------- -- Resolve_Range -- ------------------- @@ -8808,7 +8833,9 @@ package body Sem_Res is and then not First_Last_Ref then - Error_Msg ("subrange of unordered enumeration type?U?", Sloc (N)); + Error_Msg_Sloc := Sloc (Typ); + Error_Msg_NE + ("subrange of unordered enumeration type& declared#?U?", N, Typ); end if; Check_Unset_Reference (L); @@ -9781,15 +9808,6 @@ package body Sem_Res is end Resolve_String_Literal; ----------------------------- - -- Resolve_Subprogram_Info -- - ----------------------------- - - procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id) is - begin - Set_Etype (N, Typ); - end Resolve_Subprogram_Info; - - ----------------------------- -- Resolve_Type_Conversion -- ----------------------------- @@ -10517,6 +10535,8 @@ package body Sem_Res is Drange : constant Node_Id := Discrete_Range (N); begin + Index_Type := Base_Type (Etype (Drange)); + if Is_Entity_Name (Drange) then Index_Subtype := Entity (Drange); @@ -10530,9 +10550,19 @@ package body Sem_Res is if Nkind (Drange) = N_Range then Force_Evaluation (Low_Bound (Drange)); Force_Evaluation (High_Bound (Drange)); - end if; - Index_Type := Base_Type (Etype (Drange)); + -- If the discrete range is given by a subtype indication, the + -- type of the slice is the base of the subtype mark. + + elsif Nkind (Drange) = N_Subtype_Indication then + declare + R : constant Node_Id := Range_Expression (Constraint (Drange)); + begin + Index_Type := Base_Type (Entity (Subtype_Mark (Drange))); + Force_Evaluation (Low_Bound (R)); + Force_Evaluation (High_Bound (R)); + end; + end if; Index_Subtype := Create_Itype (Subtype_Kind (Ekind (Index_Type)), N); diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb index b7371b7d500..f0fea637a38 100644 --- a/gcc/ada/sem_type.adb +++ b/gcc/ada/sem_type.adb @@ -2221,6 +2221,11 @@ package body Sem_Type is then return Etype (R); + -- If one operand is a raise_expression, use type of other operand + + elsif Nkind (L) = N_Raise_Expression then + return Etype (R); + else return Specific_Type (T, Etype (R)); end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 6ba2a16e8d8..8fc28ef4be8 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -114,11 +114,11 @@ package body Sem_Util is -- have a default. function Has_Enabled_Property - (Extern : Node_Id; + (State_Id : Node_Id; Prop_Nam : Name_Id) return Boolean; -- Subsidiary to routines Async_xxx_Enabled and Effective_xxx_Enabled. - -- Given pragma External, determine whether it contains a property denoted - -- by its name Prop_Nam and if it does, whether its expression is True. + -- Determine whether an abstract state denoted by its entity State_Id has + -- enabled property Prop_Name. function Has_Null_Extension (T : Entity_Id) return Boolean; -- T is a derived tagged type. Check whether the type extension is null. @@ -560,10 +560,7 @@ package body Sem_Util is function Async_Readers_Enabled (Id : Entity_Id) return Boolean is begin if Ekind (Id) = E_Abstract_State then - return - Has_Enabled_Property - (Extern => Get_Pragma (Id, Pragma_External), - Prop_Nam => Name_Async_Readers); + return Has_Enabled_Property (Id, Name_Async_Readers); else pragma Assert (Ekind (Id) = E_Variable); return Present (Get_Pragma (Id, Pragma_Async_Readers)); @@ -577,10 +574,7 @@ package body Sem_Util is function Async_Writers_Enabled (Id : Entity_Id) return Boolean is begin if Ekind (Id) = E_Abstract_State then - return - Has_Enabled_Property - (Extern => Get_Pragma (Id, Pragma_External), - Prop_Nam => Name_Async_Writers); + return Has_Enabled_Property (Id, Name_Async_Writers); else pragma Assert (Ekind (Id) = E_Variable); return Present (Get_Pragma (Id, Pragma_Async_Writers)); @@ -2240,7 +2234,19 @@ package body Sem_Util is end loop; if Scope (Nam) = Prot and then Ekind (Nam) /= E_Function then - if Nkind (N) = N_Subprogram_Renaming_Declaration then + + -- An indirect function call (e.g. a callback within a protected + -- function body) is not statically illegal. If the access type is + -- anonymous and is the type of an access parameter, the scope of Nam + -- will be the protected type, but it is not a protected operation. + + if Ekind (Nam) = E_Subprogram_Type + and then + Nkind (Associated_Node_For_Itype (Nam)) = N_Function_Specification + then + null; + + elsif Nkind (N) = N_Subprogram_Renaming_Declaration then Error_Msg_N ("within protected function cannot use protected " & "procedure in renaming or as generic actual", N); @@ -2618,7 +2624,13 @@ package body Sem_Util is elsif Nkind_In (N, N_Expanded_Name, N_Identifier) then Ent := Entity (N); - if No (Ent) or else Ekind (Ent) in Assignable_Kind then + -- The entity may be modifiable through an implicit dereference + + if No (Ent) + or else Ekind (Ent) in Assignable_Kind + or else (Is_Access_Type (Etype (Ent)) + and then Nkind (Parent (N)) = N_Selected_Component) + then Post_State_Seen := True; return Abandon; end if; @@ -3724,7 +3736,8 @@ package body Sem_Util is Item_Id := Entity_Of (Item); return - Ekind (Item_Id) = E_Abstract_State + Present (Item_Id) + and then Ekind (Item_Id) = E_Abstract_State and then Has_Visible_Refinement (Item_Id); end if; end Is_Refined_State; @@ -4799,10 +4812,7 @@ package body Sem_Util is function Effective_Reads_Enabled (Id : Entity_Id) return Boolean is begin if Ekind (Id) = E_Abstract_State then - return - Has_Enabled_Property - (Extern => Get_Pragma (Id, Pragma_External), - Prop_Nam => Name_Effective_Reads); + return Has_Enabled_Property (Id, Name_Effective_Reads); else pragma Assert (Ekind (Id) = E_Variable); return Present (Get_Pragma (Id, Pragma_Effective_Reads)); @@ -4816,10 +4826,7 @@ package body Sem_Util is function Effective_Writes_Enabled (Id : Entity_Id) return Boolean is begin if Ekind (Id) = E_Abstract_State then - return - Has_Enabled_Property - (Extern => Get_Pragma (Id, Pragma_External), - Prop_Nam => Name_Effective_Writes); + return Has_Enabled_Property (Id, Name_Effective_Writes); else pragma Assert (Ekind (Id) = E_Variable); return Present (Get_Pragma (Id, Pragma_Effective_Writes)); @@ -7163,69 +7170,86 @@ package body Sem_Util is -------------------------- function Has_Enabled_Property - (Extern : Node_Id; + (State_Id : Node_Id; Prop_Nam : Name_Id) return Boolean is - Prop : Node_Id; - Props : Node_Id := Empty; + Decl : constant Node_Id := Parent (State_Id); + Opt : Node_Id; + Opt_Nam : Node_Id; + Prop : Node_Id; + Props : Node_Id; begin - -- The related abstract state or variable do not have an Extern pragma, - -- the property in question cannot be set. + -- The declaration of an external abstract state appears as an extension + -- aggregate. If this is not the case, properties can never be set. - if No (Extern) then + if Nkind (Decl) /= N_Extension_Aggregate then return False; - - elsif Nkind (Extern) = N_Component_Association then - Props := Expression (Extern); end if; - -- External state with properties + -- When External appears as a simple option, it automatically enables + -- all properties. + + Opt := First (Expressions (Decl)); + while Present (Opt) loop + if Nkind (Opt) = N_Identifier + and then Chars (Opt) = Name_External + then + return True; + end if; + + Next (Opt); + end loop; - if Present (Props) then + -- When External specifies particular properties, inspect those and + -- find the desired one (if any). - -- Multiple properties appear as an aggregate + Opt := First (Component_Associations (Decl)); + while Present (Opt) loop + Opt_Nam := First (Choices (Opt)); - if Nkind (Props) = N_Aggregate then + if Nkind (Opt_Nam) = N_Identifier + and then Chars (Opt_Nam) = Name_External + then + Props := Expression (Opt); - -- Simple property form + -- Multiple properties appear as an aggregate - Prop := First (Expressions (Props)); - while Present (Prop) loop - if Chars (Prop) = Prop_Nam then - return True; - end if; + if Nkind (Props) = N_Aggregate then - Next (Prop); - end loop; + -- Simple property form - -- Property with expression form + Prop := First (Expressions (Props)); + while Present (Prop) loop + if Chars (Prop) = Prop_Nam then + return True; + end if; - Prop := First (Component_Associations (Props)); - while Present (Prop) loop - if Chars (Prop) = Prop_Nam then - return Is_True (Expr_Value (Expression (Prop))); - end if; + Next (Prop); + end loop; - Next (Prop); - end loop; + -- Property with expression form - -- Pragma Extern contains properties, but not the one we want + Prop := First (Component_Associations (Props)); + while Present (Prop) loop + if Chars (Prop) = Prop_Nam then + return Is_True (Expr_Value (Expression (Prop))); + end if; - return False; + Next (Prop); + end loop; - -- Single property + -- Single property - else - return Chars (Prop) = Prop_Nam; + else + return Chars (Prop) = Prop_Nam; + end if; end if; - -- An external state defined without any properties defaults all - -- properties to True; + Next (Opt); + end loop; - else - return True; - end if; + return False; end Has_Enabled_Property; -------------------- @@ -8085,6 +8109,34 @@ package body Sem_Util is end if; end Has_Tagged_Component; + ---------------------------- + -- Has_Volatile_Component -- + ---------------------------- + + function Has_Volatile_Component (Typ : Entity_Id) return Boolean is + Comp : Entity_Id; + + begin + if Has_Volatile_Components (Typ) then + return True; + + elsif Is_Array_Type (Typ) then + return Is_Volatile (Component_Type (Typ)); + + elsif Is_Record_Type (Typ) then + Comp := First_Component (Typ); + while Present (Comp) loop + if Is_Volatile_Object (Comp) then + return True; + end if; + + Comp := Next_Component (Comp); + end loop; + end if; + + return False; + end Has_Volatile_Component; + ------------------------- -- Implementation_Kind -- ------------------------- @@ -9844,20 +9896,53 @@ package body Sem_Util is ------------ -- We seem to have a lot of overlapping functions that do similar things - -- (testing for left hand sides or lvalues???). Anyway, since this one is - -- purely syntactic, it should be in Sem_Aux I would think??? + -- (testing for left hand sides or lvalues???). function Is_LHS (N : Node_Id) return Boolean is P : constant Node_Id := Parent (N); begin + -- Return True if we are the left hand side of an assignment statement + if Nkind (P) = N_Assignment_Statement then return Name (P) = N; - elsif - Nkind_In (P, N_Indexed_Component, N_Selected_Component, N_Slice) + -- Case of prefix of indexed or selected component or slice + + elsif Nkind_In (P, N_Indexed_Component, N_Selected_Component, N_Slice) + and then N = Prefix (P) then - return N = Prefix (P) and then Is_LHS (P); + -- Here we have the case where the parent P is N.Q or N(Q .. R). + -- If P is an LHS, then N is also effectively an LHS, but there + -- is an important exception. If N is of an access type, then + -- what we really have is N.all.Q (or N.all(Q .. R)). In either + -- case this makes N.all a left hand side but not N itself! + + -- Here follows a worrisome kludge. If Etype (N) is not set, which + -- for sure happens in the call from Find_Direct_Name, that means we + -- don't know if N is of an access type, so we can't give an accurate + -- answer. For now, we assume we do not have an access type, which + -- means for example that P.Q.R := X will look like a modification + -- of P, even if P.Q eventually turns out to be an access type. The + -- consequence is at least that in some cases we incorrectly identify + -- a reference as a modification. It is not clear if there are any + -- other bad consequences. ??? + + if No (Etype (N)) then + return False; + + -- We have an Etype set, so we can check it + + elsif Is_Access_Type (Etype (N)) then + return False; + + -- OK, not access type case, so just test whole expression + + else + return Is_LHS (P); + end if; + + -- All other cases are not left hand sides else return False; @@ -10313,6 +10398,55 @@ package body Sem_Util is end if; end Is_Potentially_Persistent_Type; + -------------------------------- + -- Is_Potentially_Unevaluated -- + -------------------------------- + + function Is_Potentially_Unevaluated (N : Node_Id) return Boolean is + Par : Node_Id; + Expr : Node_Id; + + begin + Expr := N; + Par := Parent (N); + while not Nkind_In (Par, N_If_Expression, + N_Case_Expression, + N_And_Then, + N_Or_Else, + N_In, + N_Not_In) + loop + Expr := Par; + Par := Parent (Par); + + -- If the context is not an expression, or if is the result of + -- expansion of an enclosing construct (such as another attribute) + -- the predicate does not apply. + + if Nkind (Par) not in N_Subexpr + or else not Comes_From_Source (Par) + then + return False; + end if; + end loop; + + if Nkind (Par) = N_If_Expression then + return Is_Elsif (Par) or else Expr /= First (Expressions (Par)); + + elsif Nkind (Par) = N_Case_Expression then + return Expr /= Expression (Par); + + elsif Nkind_In (Par, N_And_Then, N_Or_Else) then + return Expr = Right_Opnd (Par); + + elsif Nkind_In (Par, N_In, N_Not_In) then + return Expr /= Left_Opnd (Par); + + else + return False; + end if; + end Is_Potentially_Unevaluated; + --------------------------------- -- Is_Protected_Self_Reference -- --------------------------------- @@ -10733,6 +10867,37 @@ package body Sem_Util is end if; end Is_SPARK_Object_Reference; + ------------------------------ + -- Is_SPARK_Volatile_Object -- + ------------------------------ + + function Is_SPARK_Volatile_Object (N : Node_Id) return Boolean is + begin + if Nkind (N) = N_Defining_Identifier then + return Is_Volatile (N) or else Is_Volatile (Etype (N)); + + elsif Is_Entity_Name (N) then + return + Is_SPARK_Volatile_Object (Entity (N)) + or else Is_Volatile (Etype (N)); + + elsif Nkind (N) = N_Expanded_Name then + return Is_SPARK_Volatile_Object (Entity (N)); + + elsif Nkind (N) = N_Indexed_Component then + return Is_SPARK_Volatile_Object (Prefix (N)); + + elsif Nkind (N) = N_Selected_Component then + return + Is_SPARK_Volatile_Object (Prefix (N)) + or else + Is_SPARK_Volatile_Object (Selector_Name (N)); + + else + return False; + end if; + end Is_SPARK_Volatile_Object; + ------------------ -- Is_Statement -- ------------------ @@ -13344,7 +13509,6 @@ package body Sem_Util is Exp := N; loop - <<Continue>> Ent := Empty; if Is_Entity_Name (Exp) then @@ -13370,8 +13534,7 @@ package body Sem_Util is end if; if Nkind (P) = N_Selected_Component - and then - Present (Entry_Formal (Entity (Selector_Name (P)))) + and then Present (Entry_Formal (Entity (Selector_Name (P)))) then -- Case of a reference to an entry formal @@ -13380,8 +13543,8 @@ package body Sem_Util is elsif Nkind (P) = N_Identifier and then Nkind (Parent (Entity (P))) = N_Object_Declaration and then Present (Expression (Parent (Entity (P)))) - and then Nkind (Expression (Parent (Entity (P)))) - = N_Reference + and then Nkind (Expression (Parent (Entity (P)))) = + N_Reference then -- Case of a reference to a value on which side effects have -- been removed. @@ -13391,7 +13554,6 @@ package body Sem_Util is else return; - end if; end; @@ -13405,8 +13567,24 @@ package body Sem_Util is N_Indexed_Component, N_Selected_Component) then - Exp := Prefix (Exp); - goto Continue; + -- Special check, if the prefix is an access type, then return + -- since we are modifying the thing pointed to, not the prefix. + -- When we are expanding, most usually the prefix is replaced + -- by an explicit dereference, and this test is not needed, but + -- in some cases (notably -gnatc mode and generics) when we do + -- not do full expansion, we need this special test. + + if Is_Access_Type (Etype (Prefix (Exp))) then + return; + + -- Otherwise go to prefix and keep going + + else + Exp := Prefix (Exp); + goto Continue; + end if; + + -- All other cases, not a modification else return; @@ -13539,6 +13717,9 @@ package body Sem_Util is return; end if; + + <<Continue>> + null; end loop; end Note_Possible_Modification; @@ -15990,6 +16171,25 @@ package body Sem_Util is return Is_Init_Proc (S); end Within_Init_Proc; + ------------------ + -- Within_Scope -- + ------------------ + + function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean is + SE : Entity_Id; + begin + SE := Scope (E); + loop + if SE = S then + return True; + elsif SE = Standard_Standard then + return False; + else + SE := Scope (SE); + end if; + end loop; + end Within_Scope; + ---------------- -- Wrong_Type -- ---------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index a093a395ddb..3c512df64fc 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -886,6 +886,10 @@ package Sem_Util is -- component is present. This function is used to check if "=" has to be -- expanded into a bunch component comparisons. + function Has_Volatile_Component (Typ : Entity_Id) return Boolean; + -- Given an arbitrary type, determine whether it contains at least one + -- volatile component. + function Implementation_Kind (Subp : Entity_Id) return Name_Id; -- Subp is a subprogram marked with pragma Implemented. Return the specific -- implementation requirement which the pragma imposes. The return value is @@ -1015,6 +1019,11 @@ package Sem_Util is -- First determine whether type T is an interface and then check whether -- it is of protected, synchronized or task kind. + function Is_Delegate (T : Entity_Id) return Boolean; + -- Returns true if type T represents a delegate. A Delegate is the CIL + -- object used to represent access-to-subprogram types. This is only + -- relevant to CIL, will always return false for other targets. + function Is_Dependent_Component_Of_Mutable_Object (Object : Node_Id) return Boolean; -- Returns True if Object is the name of a subcomponent that depends on @@ -1116,6 +1125,9 @@ package Sem_Util is -- if Include_Implicit is False, these cases do not count as making the -- type be partially initialized. + function Is_Potentially_Unevaluated (N : Node_Id) return Boolean; + -- Predicate to implement definition given in RM 6.1.1 (20/3) + function Is_Potentially_Persistent_Type (T : Entity_Id) return Boolean; -- Determines if type T is a potentially persistent type. A potentially -- persistent type is defined (recursively) as a scalar type, a non-tagged @@ -1162,6 +1174,13 @@ package Sem_Util is function Is_SPARK_Object_Reference (N : Node_Id) return Boolean; -- Determines if the tree referenced by N represents an object in SPARK + function Is_SPARK_Volatile_Object (N : Node_Id) return Boolean; + -- Determine whether an arbitrary node denotes a volatile object reference + -- according to the semantics of SPARK. To qualify as volatile, an object + -- must be subject to aspect/pragma Volatile or Atomic or have a [sub]type + -- subject to the same attributes. Note that volatile components do not + -- render an object volatile. + function Is_Statement (N : Node_Id) return Boolean; pragma Inline (Is_Statement); -- Check if the node N is a statement node. Note that this includes @@ -1212,11 +1231,6 @@ package Sem_Util is -- Determine whether an operator is one of the intrinsics defined -- in the DEC system extension. - function Is_Delegate (T : Entity_Id) return Boolean; - -- Returns true if type T represents a delegate. A Delegate is the CIL - -- object used to represent access-to-subprogram types. This is only - -- relevant to CIL, will always return false for other targets. - function Is_Variable (N : Node_Id; Use_Original_Node : Boolean := True) return Boolean; @@ -1751,6 +1765,9 @@ package Sem_Util is function Within_Init_Proc return Boolean; -- Determines if Current_Scope is within an init proc + function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean; + -- Returns True if entity Id is declared within scope S + procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id); -- Output error message for incorrectly typed expression. Expr is the node -- for the incorrectly typed construct (Etype (Expr) is the type found), diff --git a/gcc/ada/set_targ.adb b/gcc/ada/set_targ.adb index db08f0d4e7b..83ba3313483 100755 --- a/gcc/ada/set_targ.adb +++ b/gcc/ada/set_targ.adb @@ -60,6 +60,7 @@ package body Set_Targ is S_Maximum_Alignment : constant Str := "Maximum_Alignment"; S_Max_Unaligned_Field : constant Str := "Max_Unaligned_Field"; S_Pointer_Size : constant Str := "Pointer_Size"; + S_Short_Enums : constant Str := "Short_Enums"; S_Short_Size : constant Str := "Short_Size"; S_Strict_Alignment : constant Str := "Strict_Alignment"; S_System_Allocator_Alignment : constant Str := "System_Allocator_Alignment"; @@ -88,6 +89,7 @@ package body Set_Targ is S_Maximum_Alignment 'Unrestricted_Access, S_Max_Unaligned_Field 'Unrestricted_Access, S_Pointer_Size 'Unrestricted_Access, + S_Short_Enums 'Unrestricted_Access, S_Short_Size 'Unrestricted_Access, S_Strict_Alignment 'Unrestricted_Access, S_System_Allocator_Alignment 'Unrestricted_Access, @@ -114,6 +116,7 @@ package body Set_Targ is Maximum_Alignment 'Address, Max_Unaligned_Field 'Address, Pointer_Size 'Address, + Short_Enums 'Address, Short_Size 'Address, Strict_Alignment 'Address, System_Allocator_Alignment 'Address, @@ -570,6 +573,7 @@ begin Maximum_Alignment := Get_Maximum_Alignment; Max_Unaligned_Field := Get_Max_Unaligned_Field; Pointer_Size := Get_Pointer_Size; + Short_Enums := Get_Short_Enums; Short_Size := Get_Short_Size; Strict_Alignment := Get_Strict_Alignment; System_Allocator_Alignment := Get_System_Allocator_Alignment; diff --git a/gcc/ada/set_targ.ads b/gcc/ada/set_targ.ads index a14fbcbce3e..62008cd5b4e 100755 --- a/gcc/ada/set_targ.ads +++ b/gcc/ada/set_targ.ads @@ -75,6 +75,7 @@ package Set_Targ is Maximum_Alignment : Pos; -- Maximum permitted alignment Max_Unaligned_Field : Pos; -- Maximum size for unaligned bit field Pointer_Size : Pos; -- System.Address'Size + Short_Enums : Nat; -- Foreign enums use short size? Short_Size : Pos; -- Standard.Short_Integer'Size Strict_Alignment : Nat; -- Strict alignment? System_Allocator_Alignment : Nat; -- Alignment for malloc calls diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb index 8556f3e776b..b698641ab42 100644 --- a/gcc/ada/sinfo.adb +++ b/gcc/ada/sinfo.adb @@ -1627,8 +1627,7 @@ package body Sinfo is or else NT (N).Nkind = N_Enumeration_Representation_Clause or else NT (N).Nkind = N_Label or else NT (N).Nkind = N_Loop_Statement - or else NT (N).Nkind = N_Record_Representation_Clause - or else NT (N).Nkind = N_Subprogram_Info); + or else NT (N).Nkind = N_Record_Representation_Clause); return Node1 (N); end Identifier; @@ -4768,8 +4767,7 @@ package body Sinfo is or else NT (N).Nkind = N_Enumeration_Representation_Clause or else NT (N).Nkind = N_Label or else NT (N).Nkind = N_Loop_Statement - or else NT (N).Nkind = N_Record_Representation_Clause - or else NT (N).Nkind = N_Subprogram_Info); + or else NT (N).Nkind = N_Record_Representation_Clause); Set_Node1_With_Parent (N, Val); end Set_Identifier; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 866332ed81f..61c7da4c7c4 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -516,12 +516,12 @@ package Sinfo is -- expansion is performed and the analysis must generate a tree in a -- form that meets additional requirements. - -- This light expansion does two transformations of the tree, that cannot - -- be postponed after the frontend semantic analysis: + -- This light expansion does two transformations of the tree that cannot + -- be postponed till after semantic analysis: -- 1. Replace object renamings by renamed object. This requires the - -- introdtion of temporaries at the point of the renaming, which must - -- be properly analyzed. + -- introduction of temporaries at the point of the renaming, which + -- must be properly analyzed. -- 2. Fully qualify entity names. This is needed to generate suitable -- local effects and call-graphs in ALI files, with the completely @@ -549,6 +549,39 @@ package Sinfo is -- not make sense from a user point-of-view, and that cross-references that -- do not lead to data dependences for subprograms can be safely ignored. + ----------------------- + -- Check Flag Fields -- + ----------------------- + + -- The following flag fields appear in expression nodes: + + -- Do_Division_Check + -- Do_Overflow_Check + -- Do_Range_Check + + -- These three flags are always set by the front end during semantic + -- analysis, on expression nodes that may trigger the corresponding + -- check. The front end then inserts or not the check during expansion. In + -- particular, these flags should also be correctly set in ASIS mode and + -- GNATprove mode. + + -- Note that this accounts for all nodes that trigger the corresponding + -- checks, except for range checks on subtype_indications, which may be + -- required to check that a range_constraint is compatible with the given + -- subtype (RM 3.2.2(11)). + + -- The following flag fields appear in various nodes: + + -- Do_Accessibility_Check + -- Do_Discriminant_Check + -- Do_Length_Check + -- Do_Storage_Check + -- Do_Tag_Check + + -- These flags are used in some specific cases by the front end, either + -- during semantic analysis or during expansion, and cannot be expected + -- to be set on all nodes that trigger the corresponding check. + ------------------------ -- Common Flag Fields -- ------------------------ @@ -2430,12 +2463,14 @@ package Sinfo is -- Etype (Node5-Sem) -- Must_Not_Freeze (Flag8-Sem) - -- Note: Etype is a copy of the Etype field of the Subtype_Mark. The - -- reason for this redundancy is so that in a list of array index types, - -- the Etype can be uniformly accessed to determine the subscript type. - -- This means that no Itype is constructed for the actual subtype that - -- is created by the subtype indication. If such an Itype is required, - -- it is constructed in the context in which the indication appears. + -- Note: Depending on context, the Etype is either the entity of the + -- Subtype_Mark field, or it is an itype constructed to reify the + -- subtype indication. In particular, such itypes are created for a + -- subtype indication that appears in an array type declaration. This + -- simplifies constraint checking in indexed components. + + -- For subtype indications that appear in scalar type and subtype + -- declarations, the Etype is the entity of the subtype mark. ------------------------- -- 3.2.2 Subtype Mark -- @@ -7325,7 +7360,7 @@ package Sinfo is -- N_Expression_With_Actions has type Standard_Void_Type. However some -- backends do not support such expression-with-actions occurring -- outside of a proper (non-void) expression, so this should just be - -- used as an intermediate representation within the front-end. Also + -- used as an intermediate representation within the front end. Also -- note that this is really an irregularity (expressions and statements -- are not interchangeable, and in particular an N_Null_Statement is -- not a proper expression), and in the long term all cases of this @@ -7683,23 +7718,6 @@ package Sinfo is -- with the N_In node (or a rewriting thereof) corresponding to a -- classwide membership test. - --------------------- - -- Subprogram_Info -- - --------------------- - - -- This node generates the appropriate Subprogram_Info value for a - -- given procedure. See Ada.Exceptions for further details - - -- Sprint syntax: subprog'subprogram_info - - -- N_Subprogram_Info - -- Sloc points to the entity for the procedure - -- Identifier (Node1) identifier referencing the procedure - -- Etype (Node5-Sem) type (always set to Ada.Exceptions.Code_Loc) - - -- Note: in the case where a debug source file is generated, the Sloc - -- for this node points to the quote in the Sprint file output. - -------------------------- -- Unchecked Expression -- -------------------------- @@ -7763,7 +7781,7 @@ package Sinfo is -- e.g. involving unconstrained array types. -- For the case of the standard gigi backend, this means that all - -- checks are done in the front-end. + -- checks are done in the front end. -- However, in the case of specialized back-ends, notably the JVM -- backend for JGNAT, additional requirements and restrictions apply @@ -7977,7 +7995,6 @@ package Sinfo is N_Reference, N_Selected_Component, N_Slice, - N_Subprogram_Info, N_Type_Conversion, N_Unchecked_Expression, N_Unchecked_Type_Conversion, @@ -12080,13 +12097,6 @@ package Sinfo is 4 => False, -- unused 5 => False), -- Etype (Node5-Sem) - N_Subprogram_Info => - (1 => True, -- Identifier (Node1) - 2 => False, -- unused - 3 => False, -- unused - 4 => False, -- unused - 5 => False), -- Etype (Node5-Sem) - N_Unchecked_Expression => (1 => False, -- unused 2 => False, -- unused diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl index 8259976fb19..a018dc9aaa0 100644 --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -688,7 +688,6 @@ package Snames is Name_Assertion : constant Name_Id := N + $; Name_Assertions : constant Name_Id := N + $; Name_Attribute_Name : constant Name_Id := N + $; - Name_Auto : constant Name_Id := N + $; Name_Body_File_Name : constant Name_Id := N + $; Name_Boolean_Entry_Barriers : constant Name_Id := N + $; Name_By_Any : constant Name_Id := N + $; @@ -724,7 +723,6 @@ package Snames is Name_In_Out : constant Name_Id := N + $; Name_Increases : constant Name_Id := N + $; Name_Info : constant Name_Id := N + $; - Name_Input_Only : constant Name_Id := N + $; Name_Internal : constant Name_Id := N + $; Name_Link_Name : constant Name_Id := N + $; Name_Lowercase : constant Name_Id := N + $; @@ -761,7 +759,6 @@ package Snames is Name_Non_Volatile : constant Name_Id := N + $; Name_On : constant Name_Id := N + $; Name_Optional : constant Name_Id := N + $; - Name_Output_Only : constant Name_Id := N + $; Name_Policy : constant Name_Id := N + $; Name_Parameter_Types : constant Name_Id := N + $; Name_Part_Of : constant Name_Id := N + $; @@ -1263,6 +1260,7 @@ package Snames is Name_Excluded_Source_List_File : constant Name_Id := N + $; Name_Exec_Dir : constant Name_Id := N + $; Name_Exec_Subdir : constant Name_Id := N + $; + Name_Excluded_Patterns : constant Name_Id := N + $; Name_Executable : constant Name_Id := N + $; Name_Executable_Suffix : constant Name_Id := N + $; Name_Extends : constant Name_Id := N + $; diff --git a/gcc/ada/spark_xrefs.ads b/gcc/ada/spark_xrefs.ads index e7df0331ba1..b17d7996c6c 100644 --- a/gcc/ada/spark_xrefs.ads +++ b/gcc/ada/spark_xrefs.ads @@ -177,6 +177,7 @@ package SPARK_Xrefs is -- m = modification -- r = reference + -- c = reference to constant object -- s = subprogram reference in a static call -- Special entries for reads and writes to memory reference a special @@ -229,6 +230,7 @@ package SPARK_Xrefs is Rtype : Character; -- Indicates type of reference, using code used in ALI file: -- r = reference + -- c = reference to constant object -- m = modification -- s = call diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb index 43ed21a2862..9e8362fa223 100644 --- a/gcc/ada/sprint.adb +++ b/gcc/ada/sprint.adb @@ -3091,10 +3091,6 @@ package body Sprint is Write_Char (';'); - when N_Subprogram_Info => - Sprint_Node (Identifier (Node)); - Write_Str_With_Col_Check_Sloc ("'subprogram_info"); - when N_Subprogram_Renaming_Declaration => Write_Indent; Sprint_Node (Specification (Node)); diff --git a/gcc/ada/sprint.ads b/gcc/ada/sprint.ads index 72fde2f23eb..85518bee259 100644 --- a/gcc/ada/sprint.ads +++ b/gcc/ada/sprint.ads @@ -81,7 +81,6 @@ package Sprint is -- Reference expression'reference -- Shift nodes shift_name!(expr, count) -- Static declaration name : static xxx - -- Subprogram_Info subprog'Subprogram_Info -- Unchecked conversion target_type!(source_expression) -- Unchecked expression `(expression) -- Validate_Unchecked_Conversion validate unchecked_conversion diff --git a/gcc/ada/system-lynxos-ppc.ads b/gcc/ada/system-lynxos-ppc.ads deleted file mode 100644 index 3f701b2dcf9..00000000000 --- a/gcc/ada/system-lynxos-ppc.ads +++ /dev/null @@ -1,157 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME COMPONENTS -- --- -- --- S Y S T E M -- --- -- --- S p e c -- --- (LynxOS PPC Version) -- --- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- --- -- --- This specification is derived from the Ada Reference Manual for use with -- --- GNAT. The copyright notice above, and the license provisions that follow -- --- apply solely to the contents of the part following the private keyword. -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNAT was originally developed by the GNAT team at New York University. -- --- Extensive contributions were provided by Ada Core Technologies Inc. -- --- -- ------------------------------------------------------------------------------- - -package System is - pragma Pure; - -- Note that we take advantage of the implementation permission to make - -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada - -- 2005, this is Pure in any case (AI-362). - - type Name is (SYSTEM_NAME_GNAT); - System_Name : constant Name := SYSTEM_NAME_GNAT; - - -- System-Dependent Named Numbers - - Min_Int : constant := Long_Long_Integer'First; - Max_Int : constant := Long_Long_Integer'Last; - - Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; - Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1; - - Max_Base_Digits : constant := Long_Long_Float'Digits; - Max_Digits : constant := Long_Long_Float'Digits; - - Max_Mantissa : constant := 63; - Fine_Delta : constant := 2.0 ** (-Max_Mantissa); - - Tick : constant := 0.01; - - -- Storage-related Declarations - - type Address is private; - pragma Preelaborable_Initialization (Address); - Null_Address : constant Address; - - Storage_Unit : constant := 8; - Word_Size : constant := 32; - Memory_Size : constant := 2 ** 32; - - -- Address comparison - - function "<" (Left, Right : Address) return Boolean; - function "<=" (Left, Right : Address) return Boolean; - function ">" (Left, Right : Address) return Boolean; - function ">=" (Left, Right : Address) return Boolean; - function "=" (Left, Right : Address) return Boolean; - - pragma Import (Intrinsic, "<"); - pragma Import (Intrinsic, "<="); - pragma Import (Intrinsic, ">"); - pragma Import (Intrinsic, ">="); - pragma Import (Intrinsic, "="); - - -- Other System-Dependent Declarations - - type Bit_Order is (High_Order_First, Low_Order_First); - Default_Bit_Order : constant Bit_Order := High_Order_First; - pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning - - -- Priority-related Declarations (RM D.1) - - -- 17 is the system determined default priority for user applications - -- running on LynxOS. - - -- The standard (Rm 13.7) requires that Default_Priority has the value: - - -- (Priority'First + Priority'Last) / 2 - - -- To allow an appropriate value for Default_Priority and expose a useful - -- range of priorities to the user, we use a range of 0 .. 34 for subtype - -- Priority. - - -- The rest of the range allowed by the system from 35 to 255 is made - -- available here in Interrupt_Priority. - - Max_Priority : constant Positive := 34; - Max_Interrupt_Priority : constant Positive := 255; - - subtype Any_Priority is Integer range 0 .. 255; - subtype Priority is Any_Priority range 0 .. 34; - subtype Interrupt_Priority is Any_Priority range 35 .. 255; - - Default_Priority : constant Priority := 17; - -private - - type Address is mod Memory_Size; - Null_Address : constant Address := 0; - - -------------------------------------- - -- System Implementation Parameters -- - -------------------------------------- - - -- These parameters provide information about the target that is used - -- by the compiler. They are in the private part of System, where they - -- can be accessed using the special circuitry in the Targparm unit - -- whose source should be consulted for more detailed descriptions - -- of the individual switch values. - - Backend_Divide_Checks : constant Boolean := False; - Backend_Overflow_Checks : constant Boolean := False; - Command_Line_Args : constant Boolean := True; - Configurable_Run_Time : constant Boolean := False; - Denorm : constant Boolean := True; - Duration_32_Bits : constant Boolean := False; - Exit_Status_Supported : constant Boolean := True; - Fractional_Fixed_Ops : constant Boolean := False; - Frontend_Layout : constant Boolean := False; - Machine_Overflows : constant Boolean := False; - Machine_Rounds : constant Boolean := True; - Preallocated_Stacks : constant Boolean := False; - Signed_Zeros : constant Boolean := True; - Stack_Check_Default : constant Boolean := False; - Stack_Check_Probes : constant Boolean := True; - Stack_Check_Limits : constant Boolean := False; - Support_Aggregates : constant Boolean := True; - Support_Composite_Assign : constant Boolean := True; - Support_Composite_Compare : constant Boolean := True; - Support_Long_Shifts : constant Boolean := True; - Always_Compatible_Rep : constant Boolean := False; - Suppress_Standard_Library : constant Boolean := False; - Use_Ada_Main_Program_Name : constant Boolean := False; - ZCX_By_Default : constant Boolean := False; - -end System; diff --git a/gcc/ada/system-lynxos-x86.ads b/gcc/ada/system-lynxos-x86.ads deleted file mode 100644 index 70adfa98e19..00000000000 --- a/gcc/ada/system-lynxos-x86.ads +++ /dev/null @@ -1,158 +0,0 @@ ------------------------------------------------------------------------------- --- -- --- GNAT RUN-TIME COMPONENTS -- --- -- --- S Y S T E M -- --- -- --- S p e c -- --- (LynxOS x86 Version) -- --- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- --- -- --- This specification is derived from the Ada Reference Manual for use with -- --- GNAT. The copyright notice above, and the license provisions that follow -- --- apply solely to the contents of the part following the private keyword. -- --- -- --- GNAT is free software; you can redistribute it and/or modify it under -- --- terms of the GNU General Public License as published by the Free Soft- -- --- ware Foundation; either version 3, or (at your option) any later ver- -- --- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- --- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- --- or FITNESS FOR A PARTICULAR PURPOSE. -- --- -- --- As a special exception under Section 7 of GPL version 3, you are granted -- --- additional permissions described in the GCC Runtime Library Exception, -- --- version 3.1, as published by the Free Software Foundation. -- --- -- --- You should have received a copy of the GNU General Public License and -- --- a copy of the GCC Runtime Library Exception along with this program; -- --- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- --- <http://www.gnu.org/licenses/>. -- --- -- --- GNAT was originally developed by the GNAT team at New York University. -- --- Extensive contributions were provided by Ada Core Technologies Inc. -- --- -- ------------------------------------------------------------------------------- - -package System is - pragma Pure; - -- Note that we take advantage of the implementation permission to make - -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada - -- 2005, this is Pure in any case (AI-362). - - type Name is (SYSTEM_NAME_GNAT); - System_Name : constant Name := SYSTEM_NAME_GNAT; - - -- System-Dependent Named Numbers - - Min_Int : constant := Long_Long_Integer'First; - Max_Int : constant := Long_Long_Integer'Last; - - Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; - Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1; - - Max_Base_Digits : constant := Long_Long_Float'Digits; - Max_Digits : constant := Long_Long_Float'Digits; - - Max_Mantissa : constant := 63; - Fine_Delta : constant := 2.0 ** (-Max_Mantissa); - - Tick : constant := 0.01; - - -- Storage-related Declarations - - type Address is private; - pragma Preelaborable_Initialization (Address); - Null_Address : constant Address; - - Storage_Unit : constant := 8; - Word_Size : constant := 32; - Memory_Size : constant := 2 ** 32; - - -- Address comparison - - function "<" (Left, Right : Address) return Boolean; - function "<=" (Left, Right : Address) return Boolean; - function ">" (Left, Right : Address) return Boolean; - function ">=" (Left, Right : Address) return Boolean; - function "=" (Left, Right : Address) return Boolean; - - pragma Import (Intrinsic, "<"); - pragma Import (Intrinsic, "<="); - pragma Import (Intrinsic, ">"); - pragma Import (Intrinsic, ">="); - pragma Import (Intrinsic, "="); - - -- Other System-Dependent Declarations - - type Bit_Order is (High_Order_First, Low_Order_First); - Default_Bit_Order : constant Bit_Order := Low_Order_First; - pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning - - -- Priority-related Declarations (RM D.1) - - -- 17 is the system determined default priority for user applications - -- running on LynxOS. - - -- The standard (Rm 13.7) requires that Default_Priority has the value: - - -- (Priority'First + Priority'Last) / 2 - - -- To allow an appropriate value for Default_Priority and expose a useful - -- range of priorities to the user, we use a range of 0 .. 34 for subtype - -- Priority. - - -- The rest of the range allowed by the system from 35 to 255 is made - -- available here in Interrupt_Priority. - - Max_Priority : constant Positive := 34; - Max_Interrupt_Priority : constant Positive := 255; - - subtype Any_Priority is Integer range 0 .. 255; - subtype Priority is Any_Priority range 0 .. 34; - subtype Interrupt_Priority is Any_Priority range 35 .. 255; - - Default_Priority : constant Priority := 17; - -private - - type Address is mod Memory_Size; - Null_Address : constant Address := 0; - - -------------------------------------- - -- System Implementation Parameters -- - -------------------------------------- - - -- These parameters provide information about the target that is used - -- by the compiler. They are in the private part of System, where they - -- can be accessed using the special circuitry in the Targparm unit - -- whose source should be consulted for more detailed descriptions - -- of the individual switch values. - - Backend_Divide_Checks : constant Boolean := False; - Backend_Overflow_Checks : constant Boolean := False; - Command_Line_Args : constant Boolean := True; - Configurable_Run_Time : constant Boolean := False; - Denorm : constant Boolean := True; - Duration_32_Bits : constant Boolean := False; - Exit_Status_Supported : constant Boolean := True; - Fractional_Fixed_Ops : constant Boolean := False; - Frontend_Layout : constant Boolean := False; - Machine_Overflows : constant Boolean := False; - Machine_Rounds : constant Boolean := True; - Preallocated_Stacks : constant Boolean := False; - Signed_Zeros : constant Boolean := True; - Stack_Check_Default : constant Boolean := False; - Stack_Check_Probes : constant Boolean := True; - Stack_Check_Limits : constant Boolean := False; - Support_Aggregates : constant Boolean := True; - Support_Atomic_Primitives : constant Boolean := True; - Support_Composite_Assign : constant Boolean := True; - Support_Composite_Compare : constant Boolean := True; - Support_Long_Shifts : constant Boolean := True; - Always_Compatible_Rep : constant Boolean := False; - Suppress_Standard_Library : constant Boolean := False; - Use_Ada_Main_Program_Name : constant Boolean := False; - ZCX_By_Default : constant Boolean := False; - -end System; diff --git a/gcc/ada/targparm.adb b/gcc/ada/targparm.adb index 37ac4cd25f9..3357c5dfe0e 100644 --- a/gcc/ada/targparm.adb +++ b/gcc/ada/targparm.adb @@ -587,6 +587,7 @@ package body Targparm is when EXS => Exit_Status_Supported_On_Target := Result; when FEL => Frontend_Layout_On_Target := Result; when FFO => Fractional_Fixed_Ops_On_Target := Result; + when JVM => if Result then VM_Target := JVM_Target; diff --git a/gcc/ada/targparm.ads b/gcc/ada/targparm.ads index c3cace3c559..11c7a7edfb3 100644 --- a/gcc/ada/targparm.ads +++ b/gcc/ada/targparm.ads @@ -197,7 +197,7 @@ package Targparm is ---------------------------- -- The great majority of GNAT ports are based on GCC. The switches in - -- This section indicate the use of some non-standard target back end + -- this section indicate the use of some non-standard target back end -- or other special targetting requirements. AAMP_On_Target : Boolean := False; diff --git a/gcc/ada/ttypes.ads b/gcc/ada/ttypes.ads index 5e27cbd2e58..efeea41965d 100644 --- a/gcc/ada/ttypes.ads +++ b/gcc/ada/ttypes.ads @@ -224,6 +224,13 @@ package Ttypes is -- and thus relevant only to the back end. Note that this is a variable -- rather than a constant, since it can be modified (flipped) by -gnatd8. + Target_Short_Enums : constant Boolean := Set_Targ.Short_Enums /= 0; + -- True if we are in short enums mode, where foreign convention + -- (in particular C and C++) enumeration types will be sized as in Ada, + -- using the shortest possibility from 8,16,32 bits, signed or unsigned. + -- A zero value means Short_Enums are not in use, and in this case all + -- foreign convention enumeration types are given the same size as c int. + Target_Strict_Alignment : Boolean := Set_Targ.Strict_Alignment /= 0; -- True if instructions will fail if data is misaligned. Note that this diff --git a/gcc/ada/vms_cmds.ads b/gcc/ada/vms_cmds.ads index d61e3eddf31..f8258af8e3d 100644 --- a/gcc/ada/vms_cmds.ads +++ b/gcc/ada/vms_cmds.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2010-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2010-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -50,4 +50,7 @@ package VMS_Cmds is Test, Xref, Undefined); + + subtype Real_Command_Type is Command_Type range Bind .. Xref; + -- All real command types (excludes only Undefined). end VMS_Cmds; diff --git a/gcc/ada/vms_conv.ads b/gcc/ada/vms_conv.ads index 7e2127f10a2..bba701505df 100644 --- a/gcc/ada/vms_conv.ads +++ b/gcc/ada/vms_conv.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2003-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2003-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -104,8 +104,6 @@ package VMS_Conv is Pp => Pretty); -- Mapping of alternate commands to commands - subtype Real_Command_Type is Command_Type range Bind .. Xref; - type Command_Entry is record Cname : String_Ptr; -- Command name for GNAT xxx command diff --git a/gcc/ada/xr_tabls.adb b/gcc/ada/xr_tabls.adb index 61ac67523b0..4b82b035e99 100644 --- a/gcc/ada/xr_tabls.adb +++ b/gcc/ada/xr_tabls.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -431,7 +431,7 @@ package body Xr_Tabls is Decl_Type => ' ', Is_Parameter => True); - when 'e' | 'z' | 't' | 'p' | 'P' | 'k' | 'd' => + when 'e' | 'E' | 'z' | 't' | 'p' | 'P' | 'k' | 'd' => return; when others => diff --git a/gcc/builtins.c b/gcc/builtins.c index d2ea606260b..3e34c83858b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -244,7 +244,7 @@ is_builtin_name (const char *name) return true; if (strncmp (name, "__atomic_", 9) == 0) return true; - if (flag_enable_cilkplus + if (flag_cilkplus && (!strcmp (name, "__cilkrts_detach") || !strcmp (name, "__cilkrts_pop_frame"))) return true; diff --git a/gcc/builtins.def b/gcc/builtins.def index 5a4012d3c81..524153f22a5 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -174,7 +174,7 @@ along with GCC; see the file COPYING3. If not see #undef DEF_CILKPLUS_BUILTIN #define DEF_CILKPLUS_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, BT_FN_INT_VAR, BT_LAST, \ - false, false, false, ATTRS, false, flag_enable_cilkplus) + false, false, false, ATTRS, false, flag_cilkplus) /* Define an attribute list for math functions that are normally "impure" because some of them may write into global memory for diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 31985585b59..8e3c3f89fd9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,22 @@ +2014-01-24 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * c-common.c (c_define_builtins): Replaced flag_enable_cilkplus with + flag_cilkplus. + * c-pragma.c (init_pragma): Likewise. + * c.opt: Likewise. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59846 + * c-common.c (shorten_compare): Add location_t parameter. + * c-common.h (shorten_binary_op): Adjust declaration. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/58346 + * c-common.c (pointer_to_zero_sized_aggr_p): New function. + * c-common.h: Declare it. + 2014-01-20 Eric Botcazou <ebotcazou@adacore.com> * c-ada-spec.h (dump_ada_specs): Revert prototype change. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 35958ea41f0..3ea5763e8da 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3974,13 +3974,15 @@ expr_original_type (tree expr) of build_binary_op: OP0_PTR is &OP0, OP1_PTR is &OP1, RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE. + LOC is the location of the comparison. + If this function returns nonzero, it means that the comparison has a constant value. What this function returns is an expression for that value. */ tree -shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, - enum tree_code *rescode_ptr) +shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr, + tree *restype_ptr, enum tree_code *rescode_ptr) { tree type; tree op0 = *op0_ptr; @@ -3989,7 +3991,6 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, int real1, real2; tree primop0, primop1; enum tree_code code = *rescode_ptr; - location_t loc = EXPR_LOC_OR_LOC (op0, input_location); /* Throw away any conversions to wider types already present in the operands. */ @@ -5260,7 +5261,7 @@ c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node) build_common_builtin_nodes (); - if (flag_enable_cilkplus) + if (flag_cilkplus) cilk_init_builtins (); } @@ -11823,4 +11824,15 @@ cxx_fundamental_alignment_p (unsigned align) TYPE_ALIGN (long_double_type_node))); } +/* Return true if T is a pointer to a zero-sized aggregate. */ + +bool +pointer_to_zero_sized_aggr_p (tree t) +{ + if (!POINTER_TYPE_P (t)) + return false; + t = TREE_TYPE (t); + return (TYPE_SIZE (t) && integer_zerop (TYPE_SIZE (t))); +} + #include "gt-c-family-c-common.h" diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 7e3ece6a691..d7077fd7f94 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -789,6 +789,7 @@ extern bool keyword_is_storage_class_specifier (enum rid); extern bool keyword_is_type_qualifier (enum rid); extern bool keyword_is_decl_specifier (enum rid); extern bool cxx_fundamental_alignment_p (unsigned); +extern bool pointer_to_zero_sized_aggr_p (tree); #define c_sizeof(LOC, T) c_sizeof_or_alignof_type (LOC, T, true, false, 1) #define c_alignof(LOC, T) c_sizeof_or_alignof_type (LOC, T, false, false, 1) @@ -799,7 +800,8 @@ extern tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwis /* Subroutine of build_binary_op, used for comparison operations. See if the operands have both been converted from subword integer types and, if so, perhaps change them both back to their original type. */ -extern tree shorten_compare (tree *, tree *, tree *, enum tree_code *); +extern tree shorten_compare (location_t, tree *, tree *, tree *, + enum tree_code *); extern tree pointer_int_sum (location_t, enum tree_code, tree, tree, bool = true); diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index af280856999..07d23ace945 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1384,7 +1384,7 @@ init_pragma (void) omp_pragmas_simd[i].id, true, true); } - if (flag_enable_cilkplus && !flag_preprocess_only) + if (flag_cilkplus && !flag_preprocess_only) cpp_register_deferred_pragma (parse_in, NULL, "simd", PRAGMA_CILK_SIMD, true, false); diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 38ae58efdb8..aad54e2cd34 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -863,7 +863,7 @@ C ObjC C++ ObjC++ Where shorter, use canonicalized paths to systems headers. fcilkplus -C ObjC C++ ObjC++ LTO Report Var(flag_enable_cilkplus) Init(0) +C ObjC C++ ObjC++ LTO Report Var(flag_cilkplus) Init(0) Enable Cilk Plus fcond-mismatch diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ec4fe7de16..228a93be42d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,71 @@ +2014-01-24 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * c-parser.c (c_parser_declaration_or_fndef): Replaced + flag_enable_cilkplus with flag_cilkplus. + (c_parser_direct_declarator_inner): Likewise. + (c_parser_attribute_any_word): Likewise. + (c_parser_attributes): Likewise. + (c_parser_compound_statement): Likewise. + (c_parser_statement_after_labels): Likewise. + (c_parser_if_statement): Likewise. + (c_parser_switch_statement): Likewise. + (c_parser_do_statement): Likewise. + (c_parser_for_statement): Likewise. + (c_parser_unary_expression): Likewise. + (c_parser_postfix_expression): Likewise. + (c_parser_postfix_expression_after_primary): Likewise. + (c_parser_postfix_expression_after_primary): Likewise. + (c_parser_omp_clause_name): Likewise. + (c_finish_omp_declare_simd): Likewise. + (c_parser_cilk_verify_simd): Likewise. + * c-typeck.c (build_array_ref): Likewise. + (build_function_call_vec): Likewise. + (convert_arguments): Likewise. + (build_compound_expr): Likewise. + (c_finish_return): Likewise. + (c_finish_if_stmt): Likewise. + (c_finish_loop): Likewise. + (build_binary_op): Likewise. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59846 + * c-typeck.c (parser_build_binary_op): Use location instead of + input_location. + (build_binary_op): Pass location to shorten_compare. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/58346 + * c-typeck.c (pointer_diff): Give an error on arithmetic on pointer to + an empty aggregate. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59871 + * c-typeck.c (build_compound_expr): Warn even for right-hand operand + of a comma expression. + (emit_side_effect_warnings): Likewise. + +2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com> + + PR c/59825 + * c-array-notation.c (expand_array_notation_exprs): Rewrote this + function to use walk_tree and moved a lot of its functionality to + expand_array_notations. + (expand_array_notations): New function. + +2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * c-parser.c (c_finish_omp_declare_simd): Made "cilk simd function" + attribute an attribute without value. + +2014-01-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58809 + * c-typeck.c (c_finish_omp_clause): Reject MIN_EXPR, MAX_EXPR, + BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs. + 2014-01-22 Marek Polacek <polacek@redhat.com> PR c/59891 diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 5526ee9a98c..6a5631c3b6f 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -1218,22 +1218,21 @@ fix_return_expr (tree expr) return new_mod_list; } -/* Walks through tree node T and find all the call-statements that do not return - anything and fix up any array notations they may carry. The return value - is the same type as T but with all array notations replaced with appropriate - STATEMENT_LISTS. */ +/* Callback for walk_tree. Expands all array notations in *TP. *WALK_SUBTREES + is set to 1 unless *TP contains no array notation expressions. */ -tree -expand_array_notation_exprs (tree t) +static tree +expand_array_notations (tree *tp, int *walk_subtrees, void *) { - if (!contains_array_notation_expr (t)) - return t; + if (!contains_array_notation_expr (*tp)) + { + *walk_subtrees = 0; + return NULL_TREE; + } + *walk_subtrees = 1; - switch (TREE_CODE (t)) + switch (TREE_CODE (*tp)) { - case BIND_EXPR: - t = expand_array_notation_exprs (BIND_EXPR_BODY (t)); - return t; case TRUTH_ORIF_EXPR: case TRUTH_ANDIF_EXPR: case TRUTH_OR_EXPR: @@ -1241,61 +1240,63 @@ expand_array_notation_exprs (tree t) case TRUTH_XOR_EXPR: case TRUTH_NOT_EXPR: case COND_EXPR: - t = fix_conditional_array_notations (t); - - /* After the expansion if they are still a COND_EXPR, we go into its - subtrees. */ - if (TREE_CODE (t) == COND_EXPR) - { - if (COND_EXPR_THEN (t)) - COND_EXPR_THEN (t) = - expand_array_notation_exprs (COND_EXPR_THEN (t)); - if (COND_EXPR_ELSE (t)) - COND_EXPR_ELSE (t) = - expand_array_notation_exprs (COND_EXPR_ELSE (t)); - } - return t; - case STATEMENT_LIST: - { - tree_stmt_iterator ii_tsi; - for (ii_tsi = tsi_start (t); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi)) - *tsi_stmt_ptr (ii_tsi) = - expand_array_notation_exprs (*tsi_stmt_ptr (ii_tsi)); - } - return t; + *tp = fix_conditional_array_notations (*tp); + break; case MODIFY_EXPR: { - location_t loc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : + location_t loc = EXPR_HAS_LOCATION (*tp) ? EXPR_LOCATION (*tp) : UNKNOWN_LOCATION; - tree lhs = TREE_OPERAND (t, 0); - tree rhs = TREE_OPERAND (t, 1); + tree lhs = TREE_OPERAND (*tp, 0); + tree rhs = TREE_OPERAND (*tp, 1); location_t rhs_loc = EXPR_HAS_LOCATION (rhs) ? EXPR_LOCATION (rhs) : UNKNOWN_LOCATION; - t = build_array_notation_expr (loc, lhs, TREE_TYPE (lhs), NOP_EXPR, - rhs_loc, rhs, TREE_TYPE (rhs)); - return t; + *tp = build_array_notation_expr (loc, lhs, TREE_TYPE (lhs), NOP_EXPR, + rhs_loc, rhs, TREE_TYPE (rhs)); } + break; case CALL_EXPR: - t = fix_array_notation_call_expr (t); - return t; + *tp = fix_array_notation_call_expr (*tp); + break; case RETURN_EXPR: - if (contains_array_notation_expr (t)) - t = fix_return_expr (t); - return t; + *tp = fix_return_expr (*tp); + break; + case COMPOUND_EXPR: + if (TREE_CODE (TREE_OPERAND (*tp, 0)) == SAVE_EXPR) + { + /* In here we are calling expand_array_notations because + we need to be able to catch the return value and check if + it is an error_mark_node. */ + expand_array_notations (&TREE_OPERAND (*tp, 1), walk_subtrees, NULL); + + /* SAVE_EXPR cannot have an error_mark_node inside it. This check + will make sure that if there is an error in expanding of + array notations (e.g. rank mismatch) then replace the entire + SAVE_EXPR with an error_mark_node. */ + if (TREE_OPERAND (*tp, 1) == error_mark_node) + *tp = error_mark_node; + } + break; case ARRAY_NOTATION_REF: - /* IF we are here, then we are dealing with cases like this: + /* If we are here, then we are dealing with cases like this: A[:]; A[x:y:z]; A[x:y]; Replace those with just void zero node. */ - t = void_zero_node; + *tp = void_zero_node; default: - for (int ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (t)); ii++) - if (contains_array_notation_expr (TREE_OPERAND (t, ii))) - TREE_OPERAND (t, ii) = - expand_array_notation_exprs (TREE_OPERAND (t, ii)); - return t; + break; } + return NULL_TREE; +} + +/* Walks through tree node T and expands all array notations in its subtrees. + The return value is the same type as T but with all array notations + replaced with appropriate ARRAY_REFS with a loop around it. */ + +tree +expand_array_notation_exprs (tree t) +{ + walk_tree (&t, expand_array_notations, NULL, NULL); return t; } diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 44902100bc6..e6b7b301258 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1919,7 +1919,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus = c_parser_peek_token (parser)->location; fnbody = c_parser_compound_statement (parser); - if (flag_enable_cilkplus && contains_array_notation_expr (fnbody)) + if (flag_cilkplus && contains_array_notation_expr (fnbody)) fnbody = expand_array_notation_exprs (fnbody); if (nested) { @@ -3340,7 +3340,7 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present, dimen.value = NULL_TREE; star_seen = false; } - else if (flag_enable_cilkplus + else if (flag_cilkplus && c_parser_next_token_is (parser, CPP_COLON)) { dimen.value = error_mark_node; @@ -3371,7 +3371,7 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present, } if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) c_parser_consume_token (parser); - else if (flag_enable_cilkplus + else if (flag_cilkplus && c_parser_next_token_is (parser, CPP_COLON)) { error_at (c_parser_peek_token (parser)->location, @@ -3783,7 +3783,7 @@ c_parser_attribute_any_word (c_parser *parser) static inline bool is_cilkplus_vector_p (tree name) { - if (flag_enable_cilkplus && is_attribute_p ("vector", name)) + if (flag_cilkplus && is_attribute_p ("vector", name)) return true; return false; } @@ -4009,7 +4009,7 @@ c_parser_attributes (c_parser *parser) parser->lex_untranslated_string = false; } - if (flag_enable_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) + if (flag_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) c_finish_cilk_simd_fn_tokens (parser); return attrs; } @@ -4461,7 +4461,7 @@ c_parser_compound_statement (c_parser *parser) c_parser_compound_statement_nostart (parser); /* If the compound stmt contains array notations, then we expand them. */ - if (flag_enable_cilkplus && contains_array_notation_expr (stmt)) + if (flag_cilkplus && contains_array_notation_expr (stmt)) stmt = expand_array_notation_exprs (stmt); return c_end_compound_stmt (brace_loc, stmt, true); } @@ -4881,7 +4881,7 @@ c_parser_statement_after_labels (c_parser *parser) case RID_CILK_SYNC: c_parser_consume_token (parser); c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); - if (!flag_enable_cilkplus) + if (!flag_cilkplus) error_at (loc, "-fcilkplus must be enabled to use %<_Cilk_sync%>"); else add_stmt (build_cilk_sync ()); @@ -5151,7 +5151,7 @@ c_parser_if_statement (c_parser *parser) if_stmt = c_end_compound_stmt (loc, block, flag_isoc99); /* If the if statement contains array notations, then we expand them. */ - if (flag_enable_cilkplus && contains_array_notation_expr (if_stmt)) + if (flag_cilkplus && contains_array_notation_expr (if_stmt)) if_stmt = fix_conditional_array_notations (if_stmt); add_stmt (if_stmt); } @@ -5178,7 +5178,7 @@ c_parser_switch_statement (c_parser *parser) ce = c_parser_expression (parser); ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false); expr = ce.value; - if (flag_enable_cilkplus && contains_array_notation_expr (expr)) + if (flag_cilkplus && contains_array_notation_expr (expr)) { error_at (switch_cond_loc, "array notations cannot be used as a condition for switch " @@ -5224,7 +5224,7 @@ c_parser_while_statement (c_parser *parser, bool ivdep) block = c_begin_compound_stmt (flag_isoc99); loc = c_parser_peek_token (parser)->location; cond = c_parser_paren_condition (parser); - if (flag_enable_cilkplus && contains_array_notation_expr (cond)) + if (flag_cilkplus && contains_array_notation_expr (cond)) { error_at (loc, "array notations cannot be used as a condition for while " "statement"); @@ -5276,7 +5276,7 @@ c_parser_do_statement (c_parser *parser, bool ivdep) new_cont = c_cont_label; c_cont_label = save_cont; cond = c_parser_paren_condition (parser); - if (flag_enable_cilkplus && contains_array_notation_expr (cond)) + if (flag_cilkplus && contains_array_notation_expr (cond)) { error_at (loc, "array notations cannot be used as a condition for a " "do-while statement"); @@ -5474,7 +5474,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep) else { cond = c_parser_condition (parser); - if (flag_enable_cilkplus && contains_array_notation_expr (cond)) + if (flag_cilkplus && contains_array_notation_expr (cond)) { error_at (loc, "array notations cannot be used in a " "condition for a for-loop"); @@ -6370,7 +6370,7 @@ c_parser_unary_expression (c_parser *parser) op = c_parser_cast_expression (parser, NULL); /* If there is array notations in op, we expand them. */ - if (flag_enable_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) + if (flag_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) return fix_array_notation_expr (exp_loc, PREINCREMENT_EXPR, op); else { @@ -6383,7 +6383,7 @@ c_parser_unary_expression (c_parser *parser) op = c_parser_cast_expression (parser, NULL); /* If there is array notations in op, we expand them. */ - if (flag_enable_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) + if (flag_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) return fix_array_notation_expr (exp_loc, PREDECREMENT_EXPR, op); else { @@ -7493,7 +7493,7 @@ c_parser_postfix_expression (c_parser *parser) break; case RID_CILK_SPAWN: c_parser_consume_token (parser); - if (!flag_enable_cilkplus) + if (!flag_cilkplus) { error_at (loc, "-fcilkplus must be enabled to use " "%<_Cilk_spawn%>"); @@ -7645,7 +7645,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, case CPP_OPEN_SQUARE: /* Array reference. */ c_parser_consume_token (parser); - if (flag_enable_cilkplus + if (flag_cilkplus && c_parser_peek_token (parser)->type == CPP_COLON) /* If we are here, then we have something like this: Array [ : ] @@ -7664,7 +7664,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, For 2 and 3 we handle it like we handle array notations. The idx value we have above becomes the initial/start index. */ - if (flag_enable_cilkplus + if (flag_cilkplus && c_parser_peek_token (parser)->type == CPP_COLON) expr.value = c_parser_array_notation (expr_loc, parser, idx, expr.value); @@ -7783,7 +7783,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, /* Postincrement. */ c_parser_consume_token (parser); /* If the expressions have array notations, we expand them. */ - if (flag_enable_cilkplus + if (flag_cilkplus && TREE_CODE (expr.value) == ARRAY_NOTATION_REF) expr = fix_array_notation_expr (expr_loc, POSTINCREMENT_EXPR, expr); else @@ -7799,7 +7799,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, /* Postdecrement. */ c_parser_consume_token (parser); /* If the expressions have array notations, we expand them. */ - if (flag_enable_cilkplus + if (flag_cilkplus && TREE_CODE (expr.value) == ARRAY_NOTATION_REF) expr = fix_array_notation_expr (expr_loc, POSTDECREMENT_EXPR, expr); else @@ -9626,7 +9626,7 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_MAP; else if (!strcmp ("mergeable", p)) result = PRAGMA_OMP_CLAUSE_MERGEABLE; - else if (flag_enable_cilkplus && !strcmp ("mask", p)) + else if (flag_cilkplus && !strcmp ("mask", p)) result = PRAGMA_CILK_CLAUSE_MASK; break; case 'n': @@ -9638,7 +9638,7 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_NUM_TEAMS; else if (!strcmp ("num_threads", p)) result = PRAGMA_OMP_CLAUSE_NUM_THREADS; - else if (flag_enable_cilkplus && !strcmp ("nomask", p)) + else if (flag_cilkplus && !strcmp ("nomask", p)) result = PRAGMA_CILK_CLAUSE_NOMASK; break; case 'o': @@ -9684,7 +9684,7 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_UNTIED; break; case 'v': - if (flag_enable_cilkplus && !strcmp ("vectorlength", p)) + if (flag_cilkplus && !strcmp ("vectorlength", p)) result = PRAGMA_CILK_CLAUSE_VECTORLENGTH; break; } @@ -12850,7 +12850,7 @@ static void c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, vec<c_token> clauses) { - if (flag_enable_cilkplus + if (flag_cilkplus && clauses.exists () && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) { error ("%<#pragma omp declare simd%> cannot be used in the same " @@ -12887,7 +12887,7 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, gcc_assert (parser->tokens == &parser->tokens_buf[0]); bool is_cilkplus_cilk_simd_fn = false; - if (flag_enable_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) + if (flag_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) { parser->tokens = parser->cilk_simd_fn_tokens->address (); parser->tokens_avail = vec_safe_length (parser->cilk_simd_fn_tokens); @@ -12924,7 +12924,8 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, c = tree_cons (NULL_TREE, c, NULL_TREE); if (is_cilkplus_cilk_simd_fn) { - tree k = build_tree_list (get_identifier ("cilk simd function"), c); + tree k = build_tree_list (get_identifier ("cilk simd function"), + NULL_TREE); TREE_CHAIN (k) = DECL_ATTRIBUTES (fndecl); DECL_ATTRIBUTES (fndecl) = k; } @@ -13516,7 +13517,7 @@ static bool c_parser_cilk_verify_simd (c_parser *parser, enum pragma_context context) { - if (!flag_enable_cilkplus) + if (!flag_cilkplus) { warning (0, "pragma simd ignored because -fcilkplus is not enabled"); c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 7cb717a9749..8477dd43fbf 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2423,7 +2423,7 @@ build_array_ref (location_t loc, tree array, tree index) || TREE_TYPE (index) == error_mark_node) return error_mark_node; - if (flag_enable_cilkplus && contains_array_notation_expr (index)) + if (flag_cilkplus && contains_array_notation_expr (index)) { size_t rank = 0; if (!find_rank (loc, index, index, true, &rank)) @@ -2853,7 +2853,7 @@ build_function_call_vec (location_t loc, tree function, if (name && !strncmp (IDENTIFIER_POINTER (name), "__atomic_", 9)) origtypes = NULL; - if (flag_enable_cilkplus + if (flag_cilkplus && is_cilkplus_reduce_builtin (function)) origtypes = NULL; } @@ -3061,7 +3061,7 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values, break; } } - if (flag_enable_cilkplus && fundecl && is_cilkplus_reduce_builtin (fundecl)) + if (flag_cilkplus && fundecl && is_cilkplus_reduce_builtin (fundecl)) return vec_safe_length (values); /* Scan the given expressions and types, producing individual @@ -3388,11 +3388,11 @@ parser_build_binary_op (location_t location, enum tree_code code, /* Check for cases such as x+y<<z which users are likely to misinterpret. */ if (warn_parentheses) - warn_about_parentheses (input_location, code, - code1, arg1.value, code2, arg2.value); + warn_about_parentheses (location, code, code1, arg1.value, code2, + arg2.value); if (warn_logical_op) - warn_logical_operator (input_location, code, TREE_TYPE (result.value), + warn_logical_operator (location, code, TREE_TYPE (result.value), code1, arg1.value, code2, arg2.value); /* Warn about comparisons against string literals, with the exception @@ -3536,6 +3536,9 @@ pointer_diff (location_t loc, tree op0, tree op1) /* This generates an error if op0 is pointer to incomplete type. */ op1 = c_size_in_bytes (target_type); + if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1))) + error_at (loc, "arithmetic on pointer to an empty aggregate"); + /* Divide by the size, in easiest possible way. */ result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype, op0, convert (inttype, op1)); @@ -4736,7 +4739,7 @@ build_compound_expr (location_t loc, tree expr1, tree expr2) tree eptype = NULL_TREE; tree ret; - if (flag_enable_cilkplus + if (flag_cilkplus && (TREE_CODE (expr1) == CILK_SPAWN_STMT || TREE_CODE (expr2) == CILK_SPAWN_STMT)) { @@ -4778,6 +4781,23 @@ build_compound_expr (location_t loc, tree expr1, tree expr2) "left-hand operand of comma expression has no effect"); } } + else if (TREE_CODE (expr1) == COMPOUND_EXPR + && warn_unused_value) + { + tree r = expr1; + location_t cloc = loc; + while (TREE_CODE (r) == COMPOUND_EXPR) + { + if (EXPR_HAS_LOCATION (r)) + cloc = EXPR_LOCATION (r); + r = TREE_OPERAND (r, 1); + } + if (!TREE_SIDE_EFFECTS (r) + && !VOID_TYPE_P (TREE_TYPE (r)) + && !CONVERT_EXPR_P (r)) + warning_at (cloc, OPT_Wunused_value, + "right-hand operand of comma expression has no effect"); + } /* With -Wunused, we should also warn if the left-hand operand does have side-effects, but computes a value which is not used. For example, in @@ -9116,7 +9136,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) warning_at (loc, 0, "function declared %<noreturn%> has a %<return%> statement"); - if (flag_enable_cilkplus && contains_array_notation_expr (retval)) + if (flag_cilkplus && contains_array_notation_expr (retval)) { /* Array notations are allowed in a return statement if it is inside a built-in array notation reduction function. */ @@ -9129,7 +9149,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) return error_mark_node; } } - if (flag_enable_cilkplus && retval && TREE_CODE (retval) == CILK_SPAWN_STMT) + if (flag_cilkplus && retval && TREE_CODE (retval) == CILK_SPAWN_STMT) { error_at (loc, "use of %<_Cilk_spawn%> in a return statement is not " "allowed"); @@ -9430,7 +9450,7 @@ c_finish_if_stmt (location_t if_locus, tree cond, tree then_block, else_block must be either 0 or be equal to the rank of the condition. If the condition does not have array notations then break them up as it is broken up in a normal expression. */ - if (flag_enable_cilkplus && contains_array_notation_expr (cond)) + if (flag_cilkplus && contains_array_notation_expr (cond)) { size_t then_rank = 0, cond_rank = 0, else_rank = 0; if (!find_rank (if_locus, cond, cond, true, &cond_rank)) @@ -9505,7 +9525,7 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, { tree entry = NULL, exit = NULL, t; - if (flag_enable_cilkplus && contains_array_notation_expr (cond)) + if (flag_cilkplus && contains_array_notation_expr (cond)) { error_at (start_locus, "array notation expression cannot be used in a " "loop%'s condition"); @@ -9643,6 +9663,23 @@ emit_side_effect_warnings (location_t loc, tree expr) if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr)) warning_at (loc, OPT_Wunused_value, "statement with no effect"); } + else if (TREE_CODE (expr) == COMPOUND_EXPR) + { + tree r = expr; + location_t cloc = loc; + while (TREE_CODE (r) == COMPOUND_EXPR) + { + if (EXPR_HAS_LOCATION (r)) + cloc = EXPR_LOCATION (r); + r = TREE_OPERAND (r, 1); + } + if (!TREE_SIDE_EFFECTS (r) + && !VOID_TYPE_P (TREE_TYPE (r)) + && !CONVERT_EXPR_P (r) + && !TREE_NO_WARNING (expr)) + warning_at (cloc, OPT_Wunused_value, + "right-hand operand of comma expression has no effect"); + } else warn_if_unused_value (expr, loc); } @@ -10037,12 +10074,12 @@ build_binary_op (location_t location, enum tree_code code, /* When Cilk Plus is enabled and there are array notations inside op0, then we check to see if there are builtin array notation functions. If so, then we take on the type of the array notation inside it. */ - if (flag_enable_cilkplus && contains_array_notation_expr (op0)) + if (flag_cilkplus && contains_array_notation_expr (op0)) orig_type0 = type0 = find_correct_array_notation_type (op0); else orig_type0 = type0 = TREE_TYPE (op0); - if (flag_enable_cilkplus && contains_array_notation_expr (op1)) + if (flag_cilkplus && contains_array_notation_expr (op1)) orig_type1 = type1 = find_correct_array_notation_type (op1); else orig_type1 = type1 = TREE_TYPE (op1); @@ -10854,7 +10891,8 @@ build_binary_op (location_t location, enum tree_code code, tree xop0 = op0, xop1 = op1, xresult_type = result_type; enum tree_code xresultcode = resultcode; tree val - = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode); + = shorten_compare (location, &xop0, &xop1, &xresult_type, + &xresultcode); if (val != 0) { @@ -11713,7 +11751,8 @@ c_finish_omp_clauses (tree clauses) need_implicitly_determined = true; t = OMP_CLAUSE_DECL (c); if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE - && FLOAT_TYPE_P (TREE_TYPE (t))) + && (FLOAT_TYPE_P (TREE_TYPE (t)) + || TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)) { enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c); const char *r_name = NULL; @@ -11723,8 +11762,14 @@ c_finish_omp_clauses (tree clauses) case PLUS_EXPR: case MULT_EXPR: case MINUS_EXPR: + break; case MIN_EXPR: + if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE) + r_name = "min"; + break; case MAX_EXPR: + if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE) + r_name = "max"; break; case BIT_AND_EXPR: r_name = "&"; @@ -11736,10 +11781,12 @@ c_finish_omp_clauses (tree clauses) r_name = "|"; break; case TRUTH_ANDIF_EXPR: - r_name = "&&"; + if (FLOAT_TYPE_P (TREE_TYPE (t))) + r_name = "&&"; break; case TRUTH_ORIF_EXPR: - r_name = "||"; + if (FLOAT_TYPE_P (TREE_TYPE (t))) + r_name = "||"; break; default: gcc_unreachable (); diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index afbe85d4add..83a0d517f00 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -1022,6 +1022,8 @@ copy_loop_info (struct loop *loop, struct loop *target) target->any_estimate = loop->any_estimate; target->nb_iterations_estimate = loop->nb_iterations_estimate; target->estimate_state = loop->estimate_state; + target->warned_aggressive_loop_optimizations + |= loop->warned_aggressive_loop_optimizations; } /* Copies copy of LOOP as subloop of TARGET loop, placing newly diff --git a/gcc/cgraph.h b/gcc/cgraph.h index c763516641f..e9e93cd3481 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -82,7 +82,7 @@ public: /* Set when function is visible by other units. */ unsigned externally_visible : 1; - /* The symbol will be assumed to be used in an invisiable way (like + /* The symbol will be assumed to be used in an invisible way (like by an toplevel asm statement). */ unsigned force_output : 1; /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be diff --git a/gcc/cilk.h b/gcc/cilk.h index d2ae9314994..ae96f53c37c 100644 --- a/gcc/cilk.h +++ b/gcc/cilk.h @@ -97,7 +97,7 @@ extern tree cilk_call_setjmp (tree); inline bool fn_contains_cilk_spawn_p (function *f) { - return (flag_enable_cilkplus + return (flag_cilkplus && (f->calls_cilk_spawn || f->cilk_frame_decl != NULL_TREE)); } diff --git a/gcc/common/config/aarch64/aarch64-common.c b/gcc/common/config/aarch64/aarch64-common.c index 6107007ed41..e44b40a1754 100644 --- a/gcc/common/config/aarch64/aarch64-common.c +++ b/gcc/common/config/aarch64/aarch64-common.c @@ -110,13 +110,15 @@ aarch64_rewrite_selected_cpu (const char *name) /* Called by the driver to rewrite a name passed to the -mcpu argument in preparation to be passed to the assembler. The - name will be in ARGV[0], ARGC should always be 1. */ + names passed from the commend line will be in ARGV, we want + to use the right-most argument, which should be in + ARGV[ARGC - 1]. ARGC should always be greater than 0. */ const char * aarch64_rewrite_mcpu (int argc, const char **argv) { - gcc_assert (argc == 1); - return aarch64_rewrite_selected_cpu (argv[0]); + gcc_assert (argc); + return aarch64_rewrite_selected_cpu (argv[argc - 1]); } #undef AARCH64_CPU_NAME_LENGTH diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 065de7d8d0a..205d82ab0bc 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -86,13 +86,15 @@ arm_rewrite_selected_cpu (const char *name) /* Called by the driver to rewrite a name passed to the -mcpu argument in preparation to be passed to the assembler. The - name will be in ARGV[0], ARGC should always be 1. */ + names passed from the command line will be in ARGV, we want + to use the right-most argument, which should be in + ARGV[ARGC - 1]. ARGC should always be greater than 0. */ const char * arm_rewrite_mcpu (int argc, const char **argv) { - gcc_assert (argc == 1); - return arm_rewrite_selected_cpu (argv[0]); + gcc_assert (argc); + return arm_rewrite_selected_cpu (argv[argc - 1]); } #undef ARM_CPU_NAME_LENGTH diff --git a/gcc/common/config/mips/mips-common.c b/gcc/common/config/mips/mips-common.c index cece4ae3b65..7dd8d2d56a8 100644 --- a/gcc/common/config/mips/mips-common.c +++ b/gcc/common/config/mips/mips-common.c @@ -62,9 +62,7 @@ static const struct default_options mips_option_optimization_table[] = (TARGET_DEFAULT \ | TARGET_CPU_DEFAULT \ | TARGET_ENDIAN_DEFAULT \ - | TARGET_FP_EXCEPTIONS_DEFAULT \ - | MASK_CHECK_ZERO_DIV \ - | MASK_FUSED_MADD) + | MASK_CHECK_ZERO_DIV) #undef TARGET_HANDLE_OPTION #define TARGET_HANDLE_OPTION mips_handle_option diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def index 034afbf515e..e5f71b479cc 100644 --- a/gcc/config/aarch64/aarch64-simd-builtins.def +++ b/gcc/config/aarch64/aarch64-simd-builtins.def @@ -49,6 +49,7 @@ BUILTIN_VALL (GETLANE, get_lane, 0) VAR1 (GETLANE, get_lane, 0, di) + BUILTIN_VALL (GETLANE, be_checked_get_lane, 0) BUILTIN_VD_RE (REINTERP, reinterpretdi, 0) BUILTIN_VDC (REINTERP, reinterpretv8qi, 0) @@ -189,7 +190,8 @@ BUILTIN_VSDQ_I_DI (BINOP, srshl, 0) BUILTIN_VSDQ_I_DI (BINOP, urshl, 0) - BUILTIN_VSDQ_I_DI (SHIFTIMM, ashr, 3) + BUILTIN_VDQ_I (SHIFTIMM, ashr, 3) + VAR1 (SHIFTIMM, ashr_simd, 0, di) BUILTIN_VSDQ_I_DI (SHIFTIMM, lshr, 3) /* Implemented by aarch64_<sur>shr_n<mode>. */ BUILTIN_VSDQ_I_DI (SHIFTIMM, srshr_n, 0) diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 43a9c5b27d7..7378da9122d 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -67,7 +67,10 @@ (parallel [(match_operand:SI 2 "immediate_operand" "i")]) )))] "TARGET_SIMD" - "dup\\t%0.<Vtype>, %1.<Vetype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "dup\\t%0.<Vtype>, %1.<Vetype>[%2]"; + } [(set_attr "type" "neon_dup<q>")] ) @@ -79,7 +82,11 @@ (parallel [(match_operand:SI 2 "immediate_operand" "i")]) )))] "TARGET_SIMD" - "dup\\t%0.<Vtype>, %1.<Vetype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "dup\\t%0.<Vtype>, %1.<Vetype>[%2]"; + } [(set_attr "type" "neon_dup<q>")] ) @@ -288,7 +295,10 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VMUL 3 "register_operand" "w")))] "TARGET_SIMD" - "<f>mul\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "<f>mul\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]"; + } [(set_attr "type" "neon<fp>_mul_<Vetype>_scalar<q>")] ) @@ -301,7 +311,11 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VMUL_CHANGE_NLANES 3 "register_operand" "w")))] "TARGET_SIMD" - "<f>mul\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "<f>mul\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]"; + } [(set_attr "type" "neon<fp>_mul_<Vetype>_scalar<q>")] ) @@ -324,7 +338,10 @@ (parallel [(match_operand:SI 2 "immediate_operand")])) (match_operand:DF 3 "register_operand" "w")))] "TARGET_SIMD" - "fmul\\t%0.2d, %3.2d, %1.d[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (V2DFmode, INTVAL (operands[2]))); + return "fmul\\t%0.2d, %3.2d, %1.d[%2]"; + } [(set_attr "type" "neon_fp_mul_d_scalar_q")] ) @@ -668,6 +685,32 @@ DONE; }) +;; DI vector shift +(define_expand "aarch64_ashr_simddi" + [(match_operand:DI 0 "register_operand" "=w") + (match_operand:DI 1 "register_operand" "w") + (match_operand:QI 2 "aarch64_shift_imm64_di" "")] + "TARGET_SIMD" + { + if (INTVAL (operands[2]) == 64) + emit_insn (gen_aarch64_sshr_simddi (operands[0], operands[1])); + else + emit_insn (gen_ashrdi3 (operands[0], operands[1], operands[2])); + DONE; + } +) + +;; SIMD shift by 64. This pattern is a special case as standard pattern does +;; not handle NEON shifts by 64. +(define_insn "aarch64_sshr_simddi" + [(set (match_operand:DI 0 "register_operand" "=w") + (unspec:DI + [(match_operand:DI 1 "register_operand" "w")] UNSPEC_SSHR64))] + "TARGET_SIMD" + "sshr\t%d0, %d1, 64" + [(set_attr "type" "neon_shift_imm")] +) + (define_expand "vlshr<mode>3" [(match_operand:VQ_S 0 "register_operand" "") (match_operand:VQ_S 1 "register_operand" "") @@ -783,7 +826,10 @@ (match_operand:VDQHS 3 "register_operand" "w")) (match_operand:VDQHS 4 "register_operand" "0")))] "TARGET_SIMD" - "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")] ) @@ -798,7 +844,11 @@ (match_operand:VDQHS 3 "register_operand" "w")) (match_operand:VDQHS 4 "register_operand" "0")))] "TARGET_SIMD" - "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")] ) @@ -823,7 +873,10 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VDQHS 3 "register_operand" "w"))))] "TARGET_SIMD" - "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")] ) @@ -838,7 +891,11 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VDQHS 3 "register_operand" "w"))))] "TARGET_SIMD" - "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")] ) @@ -1237,7 +1294,10 @@ (match_operand:VDQF 3 "register_operand" "w") (match_operand:VDQF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")] ) @@ -1251,7 +1311,11 @@ (match_operand:VDQSF 3 "register_operand" "w") (match_operand:VDQSF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")] ) @@ -1276,7 +1340,10 @@ (match_operand:DF 3 "register_operand" "w") (match_operand:DF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmla\\t%0.2d, %3.2d, %1.2d[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (V2DFmode, INTVAL (operands[2]))); + return "fmla\\t%0.2d, %3.2d, %1.2d[%2]"; + } [(set_attr "type" "neon_fp_mla_d_scalar_q")] ) @@ -1303,7 +1370,10 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VDQF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + return "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")] ) @@ -1318,7 +1388,11 @@ (parallel [(match_operand:SI 2 "immediate_operand")]))) (match_operand:VDQSF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<VSWAP_WIDTH>mode, + INTVAL (operands[2]))); + return "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vtype>[%2]"; + } [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")] ) @@ -1345,7 +1419,10 @@ (match_operand:DF 3 "register_operand" "w")) (match_operand:DF 4 "register_operand" "0")))] "TARGET_SIMD" - "fmls\\t%0.2d, %3.2d, %1.2d[%2]" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (V2DFmode, INTVAL (operands[2]))); + return "fmls\\t%0.2d, %3.2d, %1.2d[%2]"; + } [(set_attr "type" "neon_fp_mla_d_scalar_q")] ) @@ -2062,6 +2139,20 @@ [(set_attr "type" "neon_to_gp<q>")] ) +(define_expand "aarch64_be_checked_get_lane<mode>" + [(match_operand:<VEL> 0 "aarch64_simd_nonimmediate_operand") + (match_operand:VALL 1 "register_operand") + (match_operand:SI 2 "immediate_operand")] + "TARGET_SIMD" + { + operands[2] = GEN_INT (ENDIAN_LANE_N (<MODE>mode, INTVAL (operands[2]))); + emit_insn (gen_aarch64_get_lane<mode> (operands[0], + operands[1], + operands[2])); + DONE; + } +) + ;; Lane extraction of a value, neither sign nor zero extension ;; is guaranteed so upper bits should be considered undefined. (define_insn "aarch64_get_lane<mode>" @@ -2528,6 +2619,7 @@ "TARGET_SIMD" "* aarch64_simd_lane_bounds (operands[3], 0, GET_MODE_NUNITS (<VCOND>mode)); + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCOND>mode, INTVAL (operands[3]))); return \"sq<r>dmulh\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]\";" [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")] ) @@ -2543,6 +2635,7 @@ "TARGET_SIMD" "* aarch64_simd_lane_bounds (operands[3], 0, GET_MODE_NUNITS (<VCONQ>mode)); + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[3]))); return \"sq<r>dmulh\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]\";" [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")] ) @@ -2558,6 +2651,7 @@ "TARGET_SIMD" "* aarch64_simd_lane_bounds (operands[3], 0, GET_MODE_NUNITS (<VCONQ>mode)); + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[3]))); return \"sq<r>dmulh\\t%<v>0, %<v>1, %2.<v>[%3]\";" [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")] ) @@ -2598,7 +2692,11 @@ )) (const_int 1))))] "TARGET_SIMD" - "sqdml<SBINQOPS:as>l\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]" + { + operands[4] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[4]))); + return + "sqdml<SBINQOPS:as>l\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]"; + } [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")] ) @@ -2617,7 +2715,11 @@ ) (const_int 1))))] "TARGET_SIMD" - "sqdml<SBINQOPS:as>l\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]" + { + operands[4] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[4]))); + return + "sqdml<SBINQOPS:as>l\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]"; + } [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")] ) @@ -2768,7 +2870,11 @@ )))) (const_int 1))))] "TARGET_SIMD" - "sqdml<SBINQOPS:as>l2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]" + { + operands[4] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[4]))); + return + "sqdml<SBINQOPS:as>l2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]"; + } [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")] ) @@ -2915,7 +3021,10 @@ )) (const_int 1)))] "TARGET_SIMD" - "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]" + { + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[3]))); + return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]"; + } [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")] ) @@ -2932,7 +3041,10 @@ )) (const_int 1)))] "TARGET_SIMD" - "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]" + { + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[3]))); + return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]"; + } [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")] ) @@ -3033,7 +3145,10 @@ )) (const_int 1)))] "TARGET_SIMD" - "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]" + { + operands[3] = GEN_INT (ENDIAN_LANE_N (<VCONQ>mode, INTVAL (operands[3]))); + return "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]"; + } [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")] ) @@ -3544,6 +3659,24 @@ (set (attr "length") (symbol_ref "aarch64_simd_attr_length_move (insn)"))] ) +(define_insn "aarch64_be_ld1<mode>" + [(set (match_operand:VALLDI 0 "register_operand" "=w") + (unspec:VALLDI [(match_operand:VALLDI 1 "aarch64_simd_struct_operand" "Utv")] + UNSPEC_LD1))] + "TARGET_SIMD" + "ld1\\t{%0<Vmtype>}, %1" + [(set_attr "type" "neon_load1_1reg<q>")] +) + +(define_insn "aarch64_be_st1<mode>" + [(set (match_operand:VALLDI 0 "aarch64_simd_struct_operand" "=Utv") + (unspec:VALLDI [(match_operand:VALLDI 1 "register_operand" "w")] + UNSPEC_ST1))] + "TARGET_SIMD" + "st1\\t{%1<Vmtype>}, %0" + [(set_attr "type" "neon_store1_1reg<q>")] +) + (define_split [(set (match_operand:OI 0 "register_operand" "") (match_operand:OI 1 "register_operand" ""))] @@ -3762,7 +3895,11 @@ { enum machine_mode mode = <VALL:MODE>mode; rtx mem = gen_rtx_MEM (mode, operands[1]); - emit_move_insn (operands[0], mem); + + if (BYTES_BIG_ENDIAN) + emit_insn (gen_aarch64_be_ld1<VALL:mode> (operands[0], mem)); + else + emit_move_insn (operands[0], mem); DONE; }) @@ -3988,7 +4125,11 @@ { enum machine_mode mode = <VALL:MODE>mode; rtx mem = gen_rtx_MEM (mode, operands[0]); - emit_move_insn (mem, operands[1]); + + if (BYTES_BIG_ENDIAN) + emit_insn (gen_aarch64_be_st1<VALL:mode> (mem, operands[1])); + else + emit_move_insn (mem, operands[1]); DONE; }) diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index a08dee0532f..13c424c298d 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -857,7 +857,7 @@ extern enum aarch64_code_model aarch64_cmodel; (BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 - n : n) #define BIG_LITTLE_SPEC \ - " %{mcpu=*:%<mcpu=* -mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}" + " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}" extern const char *aarch64_rewrite_mcpu (int argc, const char **argv); #define BIG_LITTLE_CPU_SPEC_FUNCTIONS \ diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 3b5e92e4162..99a6ac8fcbd 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -81,6 +81,7 @@ UNSPEC_GOTSMALLPIC UNSPEC_GOTSMALLTLS UNSPEC_GOTTINYPIC + UNSPEC_LD1 UNSPEC_LD2 UNSPEC_LD3 UNSPEC_LD4 @@ -92,6 +93,8 @@ UNSPEC_SISD_SSHL UNSPEC_SISD_USHL UNSPEC_SSHL_2S + UNSPEC_SSHR64 + UNSPEC_ST1 UNSPEC_ST2 UNSPEC_ST3 UNSPEC_ST4 diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h index ac87d7065d1..6af99361b8e 100644 --- a/gcc/config/aarch64/arm_neon.h +++ b/gcc/config/aarch64/arm_neon.h @@ -457,7 +457,7 @@ typedef struct poly16x8x4_t #define __aarch64_vget_lane_any(__size, __cast_ret, __cast_a, __a, __b) \ (__cast_ret \ - __builtin_aarch64_get_lane##__size (__cast_a __a, __b)) + __builtin_aarch64_be_checked_get_lane##__size (__cast_a __a, __b)) #define __aarch64_vget_lane_f32(__a, __b) \ __aarch64_vget_lane_any (v2sf, , , __a, __b) @@ -15311,30 +15311,24 @@ vaddd_u64 (uint64x1_t __a, uint64x1_t __b) return __a + __b; } -#if __AARCH64EB__ -#define __LANE0(__t) ((__t) - 1) -#else -#define __LANE0(__t) 0 -#endif - /* vaddv */ __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vaddv_s8 (int8x8_t __a) { - return vget_lane_s8 (__builtin_aarch64_reduc_splus_v8qi (__a), __LANE0 (8)); + return vget_lane_s8 (__builtin_aarch64_reduc_splus_v8qi (__a), 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vaddv_s16 (int16x4_t __a) { - return vget_lane_s16 (__builtin_aarch64_reduc_splus_v4hi (__a), __LANE0 (4)); + return vget_lane_s16 (__builtin_aarch64_reduc_splus_v4hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vaddv_s32 (int32x2_t __a) { - return vget_lane_s32 (__builtin_aarch64_reduc_splus_v2si (__a), __LANE0 (2)); + return vget_lane_s32 (__builtin_aarch64_reduc_splus_v2si (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -15342,7 +15336,7 @@ vaddv_u8 (uint8x8_t __a) { return vget_lane_u8 ((uint8x8_t) __builtin_aarch64_reduc_uplus_v8qi ((int8x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -15350,7 +15344,7 @@ vaddv_u16 (uint16x4_t __a) { return vget_lane_u16 ((uint16x4_t) __builtin_aarch64_reduc_uplus_v4hi ((int16x4_t) __a), - __LANE0 (4)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -15358,32 +15352,32 @@ vaddv_u32 (uint32x2_t __a) { return vget_lane_u32 ((uint32x2_t) __builtin_aarch64_reduc_uplus_v2si ((int32x2_t) __a), - __LANE0 (2)); + 0); } __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vaddvq_s8 (int8x16_t __a) { return vgetq_lane_s8 (__builtin_aarch64_reduc_splus_v16qi (__a), - __LANE0 (16)); + 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vaddvq_s16 (int16x8_t __a) { - return vgetq_lane_s16 (__builtin_aarch64_reduc_splus_v8hi (__a), __LANE0 (8)); + return vgetq_lane_s16 (__builtin_aarch64_reduc_splus_v8hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vaddvq_s32 (int32x4_t __a) { - return vgetq_lane_s32 (__builtin_aarch64_reduc_splus_v4si (__a), __LANE0 (4)); + return vgetq_lane_s32 (__builtin_aarch64_reduc_splus_v4si (__a), 0); } __extension__ static __inline int64_t __attribute__ ((__always_inline__)) vaddvq_s64 (int64x2_t __a) { - return vgetq_lane_s64 (__builtin_aarch64_reduc_splus_v2di (__a), __LANE0 (2)); + return vgetq_lane_s64 (__builtin_aarch64_reduc_splus_v2di (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -15391,7 +15385,7 @@ vaddvq_u8 (uint8x16_t __a) { return vgetq_lane_u8 ((uint8x16_t) __builtin_aarch64_reduc_uplus_v16qi ((int8x16_t) __a), - __LANE0 (16)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -15399,7 +15393,7 @@ vaddvq_u16 (uint16x8_t __a) { return vgetq_lane_u16 ((uint16x8_t) __builtin_aarch64_reduc_uplus_v8hi ((int16x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -15407,7 +15401,7 @@ vaddvq_u32 (uint32x4_t __a) { return vgetq_lane_u32 ((uint32x4_t) __builtin_aarch64_reduc_uplus_v4si ((int32x4_t) __a), - __LANE0 (4)); + 0); } __extension__ static __inline uint64_t __attribute__ ((__always_inline__)) @@ -15415,28 +15409,28 @@ vaddvq_u64 (uint64x2_t __a) { return vgetq_lane_u64 ((uint64x2_t) __builtin_aarch64_reduc_uplus_v2di ((int64x2_t) __a), - __LANE0 (2)); + 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vaddv_f32 (float32x2_t __a) { float32x2_t __t = __builtin_aarch64_reduc_splus_v2sf (__a); - return vget_lane_f32 (__t, __LANE0 (2)); + return vget_lane_f32 (__t, 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vaddvq_f32 (float32x4_t __a) { float32x4_t __t = __builtin_aarch64_reduc_splus_v4sf (__a); - return vgetq_lane_f32 (__t, __LANE0 (4)); + return vgetq_lane_f32 (__t, 0); } __extension__ static __inline float64_t __attribute__ ((__always_inline__)) vaddvq_f64 (float64x2_t __a) { float64x2_t __t = __builtin_aarch64_reduc_splus_v2df (__a); - return vgetq_lane_f64 (__t, __LANE0 (2)); + return vgetq_lane_f64 (__t, 0); } /* vbsl */ @@ -19848,25 +19842,25 @@ __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vmaxv_f32 (float32x2_t __a) { return vget_lane_f32 (__builtin_aarch64_reduc_smax_nan_v2sf (__a), - __LANE0 (2)); + 0); } __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vmaxv_s8 (int8x8_t __a) { - return vget_lane_s8 (__builtin_aarch64_reduc_smax_v8qi (__a), __LANE0 (8)); + return vget_lane_s8 (__builtin_aarch64_reduc_smax_v8qi (__a), 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vmaxv_s16 (int16x4_t __a) { - return vget_lane_s16 (__builtin_aarch64_reduc_smax_v4hi (__a), __LANE0 (4)); + return vget_lane_s16 (__builtin_aarch64_reduc_smax_v4hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vmaxv_s32 (int32x2_t __a) { - return vget_lane_s32 (__builtin_aarch64_reduc_smax_v2si (__a), __LANE0 (2)); + return vget_lane_s32 (__builtin_aarch64_reduc_smax_v2si (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -19874,7 +19868,7 @@ vmaxv_u8 (uint8x8_t __a) { return vget_lane_u8 ((uint8x8_t) __builtin_aarch64_reduc_umax_v8qi ((int8x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -19882,7 +19876,7 @@ vmaxv_u16 (uint16x4_t __a) { return vget_lane_u16 ((uint16x4_t) __builtin_aarch64_reduc_umax_v4hi ((int16x4_t) __a), - __LANE0 (4)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -19890,39 +19884,39 @@ vmaxv_u32 (uint32x2_t __a) { return vget_lane_u32 ((uint32x2_t) __builtin_aarch64_reduc_umax_v2si ((int32x2_t) __a), - __LANE0 (2)); + 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vmaxvq_f32 (float32x4_t __a) { return vgetq_lane_f32 (__builtin_aarch64_reduc_smax_nan_v4sf (__a), - __LANE0 (4)); + 0); } __extension__ static __inline float64_t __attribute__ ((__always_inline__)) vmaxvq_f64 (float64x2_t __a) { return vgetq_lane_f64 (__builtin_aarch64_reduc_smax_nan_v2df (__a), - __LANE0 (2)); + 0); } __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vmaxvq_s8 (int8x16_t __a) { - return vgetq_lane_s8 (__builtin_aarch64_reduc_smax_v16qi (__a), __LANE0 (16)); + return vgetq_lane_s8 (__builtin_aarch64_reduc_smax_v16qi (__a), 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vmaxvq_s16 (int16x8_t __a) { - return vgetq_lane_s16 (__builtin_aarch64_reduc_smax_v8hi (__a), __LANE0 (8)); + return vgetq_lane_s16 (__builtin_aarch64_reduc_smax_v8hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vmaxvq_s32 (int32x4_t __a) { - return vgetq_lane_s32 (__builtin_aarch64_reduc_smax_v4si (__a), __LANE0 (4)); + return vgetq_lane_s32 (__builtin_aarch64_reduc_smax_v4si (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -19930,7 +19924,7 @@ vmaxvq_u8 (uint8x16_t __a) { return vgetq_lane_u8 ((uint8x16_t) __builtin_aarch64_reduc_umax_v16qi ((int8x16_t) __a), - __LANE0 (16)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -19938,7 +19932,7 @@ vmaxvq_u16 (uint16x8_t __a) { return vgetq_lane_u16 ((uint16x8_t) __builtin_aarch64_reduc_umax_v8hi ((int16x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -19946,7 +19940,7 @@ vmaxvq_u32 (uint32x4_t __a) { return vgetq_lane_u32 ((uint32x4_t) __builtin_aarch64_reduc_umax_v4si ((int32x4_t) __a), - __LANE0 (4)); + 0); } /* vmaxnmv */ @@ -19955,19 +19949,19 @@ __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vmaxnmv_f32 (float32x2_t __a) { return vget_lane_f32 (__builtin_aarch64_reduc_smax_v2sf (__a), - __LANE0 (2)); + 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vmaxnmvq_f32 (float32x4_t __a) { - return vgetq_lane_f32 (__builtin_aarch64_reduc_smax_v4sf (__a), __LANE0 (4)); + return vgetq_lane_f32 (__builtin_aarch64_reduc_smax_v4sf (__a), 0); } __extension__ static __inline float64_t __attribute__ ((__always_inline__)) vmaxnmvq_f64 (float64x2_t __a) { - return vgetq_lane_f64 (__builtin_aarch64_reduc_smax_v2df (__a), __LANE0 (2)); + return vgetq_lane_f64 (__builtin_aarch64_reduc_smax_v2df (__a), 0); } /* vmin */ @@ -20094,26 +20088,26 @@ __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vminv_f32 (float32x2_t __a) { return vget_lane_f32 (__builtin_aarch64_reduc_smin_nan_v2sf (__a), - __LANE0 (2)); + 0); } __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vminv_s8 (int8x8_t __a) { return vget_lane_s8 (__builtin_aarch64_reduc_smin_v8qi (__a), - __LANE0 (8)); + 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vminv_s16 (int16x4_t __a) { - return vget_lane_s16 (__builtin_aarch64_reduc_smin_v4hi (__a), __LANE0 (4)); + return vget_lane_s16 (__builtin_aarch64_reduc_smin_v4hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vminv_s32 (int32x2_t __a) { - return vget_lane_s32 (__builtin_aarch64_reduc_smin_v2si (__a), __LANE0 (2)); + return vget_lane_s32 (__builtin_aarch64_reduc_smin_v2si (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -20121,7 +20115,7 @@ vminv_u8 (uint8x8_t __a) { return vget_lane_u8 ((uint8x8_t) __builtin_aarch64_reduc_umin_v8qi ((int8x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -20129,7 +20123,7 @@ vminv_u16 (uint16x4_t __a) { return vget_lane_u16 ((uint16x4_t) __builtin_aarch64_reduc_umin_v4hi ((int16x4_t) __a), - __LANE0 (4)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -20137,39 +20131,39 @@ vminv_u32 (uint32x2_t __a) { return vget_lane_u32 ((uint32x2_t) __builtin_aarch64_reduc_umin_v2si ((int32x2_t) __a), - __LANE0 (2)); + 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vminvq_f32 (float32x4_t __a) { return vgetq_lane_f32 (__builtin_aarch64_reduc_smin_nan_v4sf (__a), - __LANE0 (4)); + 0); } __extension__ static __inline float64_t __attribute__ ((__always_inline__)) vminvq_f64 (float64x2_t __a) { return vgetq_lane_f64 (__builtin_aarch64_reduc_smin_nan_v2df (__a), - __LANE0 (2)); + 0); } __extension__ static __inline int8_t __attribute__ ((__always_inline__)) vminvq_s8 (int8x16_t __a) { - return vgetq_lane_s8 (__builtin_aarch64_reduc_smin_v16qi (__a), __LANE0 (16)); + return vgetq_lane_s8 (__builtin_aarch64_reduc_smin_v16qi (__a), 0); } __extension__ static __inline int16_t __attribute__ ((__always_inline__)) vminvq_s16 (int16x8_t __a) { - return vgetq_lane_s16 (__builtin_aarch64_reduc_smin_v8hi (__a), __LANE0 (8)); + return vgetq_lane_s16 (__builtin_aarch64_reduc_smin_v8hi (__a), 0); } __extension__ static __inline int32_t __attribute__ ((__always_inline__)) vminvq_s32 (int32x4_t __a) { - return vgetq_lane_s32 (__builtin_aarch64_reduc_smin_v4si (__a), __LANE0 (4)); + return vgetq_lane_s32 (__builtin_aarch64_reduc_smin_v4si (__a), 0); } __extension__ static __inline uint8_t __attribute__ ((__always_inline__)) @@ -20177,7 +20171,7 @@ vminvq_u8 (uint8x16_t __a) { return vgetq_lane_u8 ((uint8x16_t) __builtin_aarch64_reduc_umin_v16qi ((int8x16_t) __a), - __LANE0 (16)); + 0); } __extension__ static __inline uint16_t __attribute__ ((__always_inline__)) @@ -20185,7 +20179,7 @@ vminvq_u16 (uint16x8_t __a) { return vgetq_lane_u16 ((uint16x8_t) __builtin_aarch64_reduc_umin_v8hi ((int16x8_t) __a), - __LANE0 (8)); + 0); } __extension__ static __inline uint32_t __attribute__ ((__always_inline__)) @@ -20193,7 +20187,7 @@ vminvq_u32 (uint32x4_t __a) { return vgetq_lane_u32 ((uint32x4_t) __builtin_aarch64_reduc_umin_v4si ((int32x4_t) __a), - __LANE0 (4)); + 0); } /* vminnmv */ @@ -20201,19 +20195,19 @@ vminvq_u32 (uint32x4_t __a) __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vminnmv_f32 (float32x2_t __a) { - return vget_lane_f32 (__builtin_aarch64_reduc_smin_v2sf (__a), __LANE0 (2)); + return vget_lane_f32 (__builtin_aarch64_reduc_smin_v2sf (__a), 0); } __extension__ static __inline float32_t __attribute__ ((__always_inline__)) vminnmvq_f32 (float32x4_t __a) { - return vgetq_lane_f32 (__builtin_aarch64_reduc_smin_v4sf (__a), __LANE0 (4)); + return vgetq_lane_f32 (__builtin_aarch64_reduc_smin_v4sf (__a), 0); } __extension__ static __inline float64_t __attribute__ ((__always_inline__)) vminnmvq_f64 (float64x2_t __a) { - return vgetq_lane_f64 (__builtin_aarch64_reduc_smin_v2df (__a), __LANE0 (2)); + return vgetq_lane_f64 (__builtin_aarch64_reduc_smin_v2df (__a), 0); } /* vmla */ @@ -23346,7 +23340,7 @@ vshr_n_s32 (int32x2_t __a, const int __b) __extension__ static __inline int64x1_t __attribute__ ((__always_inline__)) vshr_n_s64 (int64x1_t __a, const int __b) { - return (int64x1_t) __builtin_aarch64_ashrdi (__a, __b); + return (int64x1_t) __builtin_aarch64_ashr_simddi (__a, __b); } __extension__ static __inline uint8x8_t __attribute__ ((__always_inline__)) @@ -23424,7 +23418,7 @@ vshrq_n_u64 (uint64x2_t __a, const int __b) __extension__ static __inline int64x1_t __attribute__ ((__always_inline__)) vshrd_n_s64 (int64x1_t __a, const int __b) { - return (int64x1_t) __builtin_aarch64_ashrdi (__a, __b); + return (int64x1_t) __builtin_aarch64_ashr_simddi (__a, __b); } __extension__ static __inline uint64x1_t __attribute__ ((__always_inline__)) @@ -25329,8 +25323,6 @@ __INTERLEAVE_LIST (zip) /* End of optimal implementations in approved order. */ -#undef __LANE0 - #undef __aarch64_vget_lane_any #undef __aarch64_vget_lane_f32 #undef __aarch64_vget_lane_f64 diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md index 45fcdc97176..c8e27d8715d 100644 --- a/gcc/config/aarch64/predicates.md +++ b/gcc/config/aarch64/predicates.md @@ -86,6 +86,10 @@ (and (match_code "const_int") (match_test "(unsigned HOST_WIDE_INT) INTVAL (op) < 64"))) +(define_predicate "aarch64_shift_imm64_di" + (and (match_code "const_int") + (match_test "(unsigned HOST_WIDE_INT) INTVAL (op) <= 64"))) + (define_predicate "aarch64_reg_or_shift_imm_si" (ior (match_operand 0 "register_operand") (match_operand 0 "aarch64_shift_imm_si"))) diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index b815488db53..bed056e5c2b 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2356,7 +2356,7 @@ extern int making_const_table; #define MAX_LDM_STM_OPS 4 #define BIG_LITTLE_SPEC \ - " %{mcpu=*:%<mcpu=* -mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}" \ + " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}" extern const char *arm_rewrite_mcpu (int argc, const char **argv); #define BIG_LITTLE_CPU_SPEC_FUNCTIONS \ diff --git a/gcc/config/i386/avx512fintrin.h b/gcc/config/i386/avx512fintrin.h index 46799470f4f..5b2e196b7af 100644 --- a/gcc/config/i386/avx512fintrin.h +++ b/gcc/config/i386/avx512fintrin.h @@ -4566,6 +4566,13 @@ _mm512_cvtepi32_epi8 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) @@ -4593,6 +4600,13 @@ _mm512_cvtsepi32_epi8 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtsepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovsdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtsepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) @@ -4620,6 +4634,13 @@ _mm512_cvtusepi32_epi8 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtusepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovusdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtusepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) @@ -4648,6 +4669,13 @@ _mm512_cvtepi32_epi16 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtepi32_storeu_epi16 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovdw512mem_mask ((__v16hi *) __P, (__v16si) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) @@ -4675,6 +4703,13 @@ _mm512_cvtsepi32_epi16 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtsepi32_storeu_epi16 (void *__P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovsdw512mem_mask ((__v16hi*) __P, (__v16si) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtsepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) @@ -4702,6 +4737,13 @@ _mm512_cvtusepi32_epi16 (__m512i __A) (__mmask16) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtusepi32_storeu_epi16 (void *__P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovusdw512mem_mask ((__v16hi*) __P, (__v16si) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtusepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) @@ -4730,6 +4772,13 @@ _mm512_cvtepi64_epi32 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtepi64_storeu_epi32 (void* __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqd512mem_mask ((__v8si *) __P, (__v8di) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) @@ -4757,6 +4806,13 @@ _mm512_cvtsepi64_epi32 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtsepi64_storeu_epi32 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqd512mem_mask ((__v8si *) __P, (__v8di) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtsepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) @@ -4784,6 +4840,13 @@ _mm512_cvtusepi64_epi32 (__m512i __A) (__mmask8) -1); } +extern __inline +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtusepi64_storeu_epi32 (void* __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqd512mem_mask ((__v8si*) __P, (__v8di) __A, __M); +} + extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtusepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) @@ -4811,6 +4874,13 @@ _mm512_cvtepi64_epi16 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqw512mem_mask ((__v8hi *) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) @@ -4838,6 +4908,13 @@ _mm512_cvtsepi64_epi16 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtsepi64_storeu_epi16 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqw512mem_mask ((__v8hi *) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtsepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) @@ -4865,6 +4942,13 @@ _mm512_cvtusepi64_epi16 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtusepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqw512mem_mask ((__v8hi*) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtusepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) @@ -4892,6 +4976,13 @@ _mm512_cvtepi64_epi8 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) @@ -4919,6 +5010,13 @@ _mm512_cvtsepi64_epi8 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtsepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtsepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) @@ -4946,6 +5044,13 @@ _mm512_cvtusepi64_epi8 (__m512i __A) (__mmask8) -1); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_cvtusepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + extern __inline __m128i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_cvtusepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) @@ -5568,6 +5673,14 @@ _mm512_mask_storeu_epi64 (void *__P, __mmask8 __U, __m512i __A) (__mmask8) __U); } +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_storeu_epi64 (void *__P, __m512i __A) +{ + __builtin_ia32_storedqudi512_mask ((__v8di *) __P, (__v8di) __A, + (__mmask8) -1); +} + extern __inline __m512i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_loadu_epi32 (void const *__P) @@ -8678,6 +8791,150 @@ _mm512_cmpgt_epi64_mask (__m512i __A, __m512i __B) (__mmask8) -1); } +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpge_epi32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_cmpd512_mask ((__v16si) __X, + (__v16si) __Y, 5, + (__mmask16) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpge_epu32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_ucmpd512_mask ((__v16si) __X, + (__v16si) __Y, 5, + (__mmask16) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpge_epi64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_cmpq512_mask ((__v8di) __X, + (__v8di) __Y, 5, + (__mmask8) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpge_epu64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_ucmpq512_mask ((__v8di) __X, + (__v8di) __Y, 5, + (__mmask8) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmple_epi32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_cmpd512_mask ((__v16si) __X, + (__v16si) __Y, 2, + (__mmask16) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmple_epu32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_ucmpd512_mask ((__v16si) __X, + (__v16si) __Y, 2, + (__mmask16) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmple_epi64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_cmpq512_mask ((__v8di) __X, + (__v8di) __Y, 2, + (__mmask8) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmple_epu64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_ucmpq512_mask ((__v8di) __X, + (__v8di) __Y, 2, + (__mmask8) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmplt_epi32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_cmpd512_mask ((__v16si) __X, + (__v16si) __Y, 1, + (__mmask16) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmplt_epu32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_ucmpd512_mask ((__v16si) __X, + (__v16si) __Y, 1, + (__mmask16) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmplt_epi64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_cmpq512_mask ((__v8di) __X, + (__v8di) __Y, 1, + (__mmask8) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmplt_epu64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_ucmpq512_mask ((__v8di) __X, + (__v8di) __Y, 1, + (__mmask8) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpneq_epi32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_cmpd512_mask ((__v16si) __X, + (__v16si) __Y, 4, + (__mmask16) -1); +} + +extern __inline __mmask16 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpneq_epu32_mask (__m512i __X, __m512i __Y) +{ + return (__mmask16) __builtin_ia32_ucmpd512_mask ((__v16si) __X, + (__v16si) __Y, 4, + (__mmask16) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpneq_epi64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_cmpq512_mask ((__v8di) __X, + (__v8di) __Y, 4, + (__mmask8) -1); +} + +extern __inline __mmask8 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_cmpneq_epu64_mask (__m512i __X, __m512i __Y) +{ + return (__mmask8) __builtin_ia32_ucmpq512_mask ((__v8di) __X, + (__v8di) __Y, 4, + (__mmask8) -1); +} + #define _MM_CMPINT_EQ 0x0 #define _MM_CMPINT_LT 0x1 #define _MM_CMPINT_LE 0x2 @@ -9548,6 +9805,13 @@ _mm512_mask_compressstoreu_epi32 (void *__P, __mmask16 __U, __m512i __A) extern __inline __m512d __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_expand_pd (__m512d __A) +{ + return (__m512d) __builtin_ia32_expanddf512 ((__v8df) __A); +} + +extern __inline __m512d +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_expand_pd (__m512d __W, __mmask8 __U, __m512d __A) { return (__m512d) __builtin_ia32_expanddf512_mask ((__v8df) __A, @@ -9586,6 +9850,13 @@ _mm512_maskz_expandloadu_pd (__mmask8 __U, void const *__P) extern __inline __m512 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_expand_ps (__m512 __A) +{ + return (__m512) __builtin_ia32_expandsf512 ((__v16sf) __A); +} + +extern __inline __m512 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_expand_ps (__m512 __W, __mmask16 __U, __m512 __A) { return (__m512) __builtin_ia32_expandsf512_mask ((__v16sf) __A, diff --git a/gcc/config/i386/avx512pfintrin.h b/gcc/config/i386/avx512pfintrin.h index b8c011032c6..bc7598e7ae1 100644 --- a/gcc/config/i386/avx512pfintrin.h +++ b/gcc/config/i386/avx512pfintrin.h @@ -48,74 +48,157 @@ typedef unsigned short __mmask16; #ifdef __OPTIMIZE__ extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_prefetch_i32gather_pd (__m256i index, __mmask8 mask, + void *addr, int scale, int hint) +{ + __builtin_ia32_gatherpfdpd (mask, (__v8si) index, (long long const *) addr, + scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_prefetch_i32gather_ps (__m512i index, __mmask16 mask, - int const *addr, int scale, int hint) + void *addr, int scale, int hint) +{ + __builtin_ia32_gatherpfdps (mask, (__v16si) index, (int const *) addr, + scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_prefetch_i64gather_pd (__m512i index, __mmask8 mask, + void *addr, int scale, int hint) { - __builtin_ia32_gatherpfdps (mask, (__v16si) index, addr, scale, hint); + __builtin_ia32_gatherpfqpd (mask, (__v8di) index, (long long const *) addr, + scale, hint); } extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_mask_prefetch_i64gather_ps (__m512i index, __mmask8 mask, - int const *addr, int scale, int hint) + void *addr, int scale, int hint) { - __builtin_ia32_gatherpfqps (mask, (__v8di) index, addr, scale, hint); + __builtin_ia32_gatherpfqps (mask, (__v8di) index, (int const *) addr, + scale, hint); } extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) -_mm512_prefetch_i32scatter_ps (int const *addr, __m512i index, int scale, +_mm512_prefetch_i32scatter_pd (void *addr, __m256i index, int scale, int hint) { - __builtin_ia32_scatterpfdps ((__mmask16) 0xFFFF, (__v16si) index, addr, scale, - hint); + __builtin_ia32_scatterpfdpd ((__mmask8) 0xFF, (__v8si) index, + (long long const *)addr, scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_prefetch_i32scatter_ps (void *addr, __m512i index, int scale, + int hint) +{ + __builtin_ia32_scatterpfdps ((__mmask16) 0xFFFF, (__v16si) index, (int const *) addr, + scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_prefetch_i32scatter_pd (void *addr, __mmask8 mask, + __m256i index, int scale, int hint) +{ + __builtin_ia32_scatterpfdpd (mask, (__v8si) index, (long long const *) addr, + scale, hint); } extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) -_mm512_mask_prefetch_i32scatter_ps (int const *addr, __mmask16 mask, +_mm512_mask_prefetch_i32scatter_ps (void *addr, __mmask16 mask, __m512i index, int scale, int hint) { - __builtin_ia32_scatterpfdps (mask, (__v16si) index, addr, scale, hint); + __builtin_ia32_scatterpfdps (mask, (__v16si) index, (int const *) addr, + scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_prefetch_i64scatter_pd (void *addr, __m512i index, int scale, + int hint) +{ + __builtin_ia32_scatterpfqpd ((__mmask8) 0xFF, (__v8di) index, (long long const *) addr, + scale, hint); } extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) -_mm512_prefetch_i64scatter_ps (int const *addr, __m512i index, int scale, +_mm512_prefetch_i64scatter_ps (void *addr, __m512i index, int scale, int hint) { - __builtin_ia32_scatterpfqps ((__mmask8) 0xFF, (__v8di) index, addr, scale, - hint); + __builtin_ia32_scatterpfqps ((__mmask8) 0xFF, (__v8di) index, (int const *) addr, + scale, hint); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_prefetch_i64scatter_pd (void *addr, __mmask16 mask, + __m512i index, int scale, int hint) +{ + __builtin_ia32_scatterpfqpd (mask, (__v8di) index, (long long const *) addr, + scale, hint); } extern __inline void __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) -_mm512_mask_prefetch_i64scatter_ps (int const *addr, __mmask16 mask, +_mm512_mask_prefetch_i64scatter_ps (void *addr, __mmask16 mask, __m512i index, int scale, int hint) { - __builtin_ia32_scatterpfqps (mask, (__v8di) index, addr, scale, hint); + __builtin_ia32_scatterpfqps (mask, (__v8di) index, (int const *) addr, + scale, hint); } + #else +#define _mm512_mask_prefetch_i32gather_pd(INDEX, MASK, ADDR, SCALE, HINT) \ + __builtin_ia32_gatherpfdpd ((__mmask8)MASK, (__v8si)(__m256i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_mask_prefetch_i32gather_ps(INDEX, MASK, ADDR, SCALE, HINT) \ - __builtin_ia32_gatherpfdps ((__mmask16)MASK, (__v16si)(__m512i)INDEX, \ + __builtin_ia32_gatherpfdps ((__mmask16)MASK, (__v16si)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) +#define _mm512_mask_prefetch_i64gather_pd(INDEX, MASK, ADDR, SCALE, HINT) \ + __builtin_ia32_gatherpfqpd ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_mask_prefetch_i64gather_ps(INDEX, MASK, ADDR, SCALE, HINT) \ __builtin_ia32_gatherpfqps ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) +#define _mm512_prefetch_i32scatter_pd(ADDR, INDEX, SCALE, HINT) \ + __builtin_ia32_scatterpfdpd ((__mmask8)0xFF, (__v8si)(__m256i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_prefetch_i32scatter_ps(ADDR, INDEX, SCALE, HINT) \ __builtin_ia32_scatterpfdps ((__mmask16)0xFFFF, (__v16si)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) +#define _mm512_mask_prefetch_i32scatter_pd(ADDR, MASK, INDEX, SCALE, HINT) \ + __builtin_ia32_scatterpfdpd ((__mmask8)MASK, (__v8si)(__m256i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_mask_prefetch_i32scatter_ps(ADDR, MASK, INDEX, SCALE, HINT) \ __builtin_ia32_scatterpfdps ((__mmask16)MASK, (__v16si)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) +#define _mm512_prefetch_i64scatter_pd(ADDR, INDEX, SCALE, HINT) \ + __builtin_ia32_scatterpfqpd ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_prefetch_i64scatter_ps(ADDR, INDEX, SCALE, HINT) \ __builtin_ia32_scatterpfqps ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) +#define _mm512_mask_prefetch_i64scatter_pd(ADDR, MASK, INDEX, SCALE, HINT) \ + __builtin_ia32_scatterpfqpd ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \ + (long long const *)ADDR, (int)SCALE, (int)HINT) + #define _mm512_mask_prefetch_i64scatter_ps(ADDR, MASK, INDEX, SCALE, HINT) \ __builtin_ia32_scatterpfqps ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \ (int const *)ADDR, (int)SCALE, (int)HINT) diff --git a/gcc/config/i386/i386-builtin-types.def b/gcc/config/i386/i386-builtin-types.def index acf2f32d9e0..822c5e5043f 100644 --- a/gcc/config/i386/i386-builtin-types.def +++ b/gcc/config/i386/i386-builtin-types.def @@ -135,8 +135,11 @@ DEF_POINTER_TYPE (PV4SF, V4SF) DEF_POINTER_TYPE (PV8DF, V8DF) DEF_POINTER_TYPE (PV8SF, V8SF) DEF_POINTER_TYPE (PV4SI, V4SI) +DEF_POINTER_TYPE (PV8HI, V8HI) DEF_POINTER_TYPE (PV8SI, V8SI) DEF_POINTER_TYPE (PV8DI, V8DI) +DEF_POINTER_TYPE (PV16QI, V16QI) +DEF_POINTER_TYPE (PV16HI, V16HI) DEF_POINTER_TYPE (PV16SI, V16SI) DEF_POINTER_TYPE (PV16SF, V16SF) @@ -604,9 +607,14 @@ DEF_FUNCTION_TYPE (V8SI, V8DI, V8SI, QI) DEF_FUNCTION_TYPE (V8HI, V8DI, V8HI, QI) DEF_FUNCTION_TYPE (V16QI, V8DI, V16QI, QI) DEF_FUNCTION_TYPE (VOID, PV8DF, V8DF, QI) +DEF_FUNCTION_TYPE (VOID, PV8SI, V8DI, QI) +DEF_FUNCTION_TYPE (VOID, PV8HI, V8DI, QI) DEF_FUNCTION_TYPE (VOID, PV16SF, V16SF, HI) DEF_FUNCTION_TYPE (VOID, PV8DI, V8DI, QI) DEF_FUNCTION_TYPE (VOID, PV16SI, V16SI, HI) +DEF_FUNCTION_TYPE (VOID, PV16HI, V16SI, HI) +DEF_FUNCTION_TYPE (VOID, PV16QI, V16SI, HI) +DEF_FUNCTION_TYPE (VOID, PV16QI, V8DI, QI) DEF_FUNCTION_TYPE (VOID, PDOUBLE, V2DF, QI) DEF_FUNCTION_TYPE (VOID, PFLOAT, V4SF, QI) DEF_FUNCTION_TYPE (V16SI, V16SF, V16SI, HI) @@ -733,7 +741,9 @@ DEF_FUNCTION_TYPE (VOID, PLONGLONG, QI, V8SI, V8DI, INT) DEF_FUNCTION_TYPE (VOID, PINT, QI, V8DI, V8SI, INT) DEF_FUNCTION_TYPE (VOID, PLONGLONG, QI, V8DI, V8DI, INT) +DEF_FUNCTION_TYPE (VOID, QI, V8SI, PCINT64, INT, INT) DEF_FUNCTION_TYPE (VOID, HI, V16SI, PCINT, INT, INT) +DEF_FUNCTION_TYPE (VOID, QI, V8DI, PCINT64, INT, INT) DEF_FUNCTION_TYPE (VOID, QI, V8DI, PCINT, INT, INT) DEF_FUNCTION_TYPE_ALIAS (V2DF_FTYPE_V2DF, ROUND) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index cf7948616f7..38fb9fd148a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -28076,10 +28076,12 @@ enum ix86_builtins IX86_BUILTIN_DIVPS512, IX86_BUILTIN_DIVSD_ROUND, IX86_BUILTIN_DIVSS_ROUND, + IX86_BUILTIN_EXPANDPD512_NOMASK, IX86_BUILTIN_EXPANDPD512, IX86_BUILTIN_EXPANDPD512Z, IX86_BUILTIN_EXPANDPDLOAD512, IX86_BUILTIN_EXPANDPDLOAD512Z, + IX86_BUILTIN_EXPANDPS512_NOMASK, IX86_BUILTIN_EXPANDPS512, IX86_BUILTIN_EXPANDPS512Z, IX86_BUILTIN_EXPANDPSLOAD512, @@ -28181,25 +28183,40 @@ enum ix86_builtins IX86_BUILTIN_PMINUD512, IX86_BUILTIN_PMINUQ512, IX86_BUILTIN_PMOVDB512, + IX86_BUILTIN_PMOVDB512_MEM, IX86_BUILTIN_PMOVDW512, + IX86_BUILTIN_PMOVDW512_MEM, IX86_BUILTIN_PMOVQB512, + IX86_BUILTIN_PMOVQB512_MEM, IX86_BUILTIN_PMOVQD512, + IX86_BUILTIN_PMOVQD512_MEM, IX86_BUILTIN_PMOVQW512, + IX86_BUILTIN_PMOVQW512_MEM, IX86_BUILTIN_PMOVSDB512, + IX86_BUILTIN_PMOVSDB512_MEM, IX86_BUILTIN_PMOVSDW512, + IX86_BUILTIN_PMOVSDW512_MEM, IX86_BUILTIN_PMOVSQB512, + IX86_BUILTIN_PMOVSQB512_MEM, IX86_BUILTIN_PMOVSQD512, + IX86_BUILTIN_PMOVSQD512_MEM, IX86_BUILTIN_PMOVSQW512, + IX86_BUILTIN_PMOVSQW512_MEM, IX86_BUILTIN_PMOVSXBD512, IX86_BUILTIN_PMOVSXBQ512, IX86_BUILTIN_PMOVSXDQ512, IX86_BUILTIN_PMOVSXWD512, IX86_BUILTIN_PMOVSXWQ512, IX86_BUILTIN_PMOVUSDB512, + IX86_BUILTIN_PMOVUSDB512_MEM, IX86_BUILTIN_PMOVUSDW512, + IX86_BUILTIN_PMOVUSDW512_MEM, IX86_BUILTIN_PMOVUSQB512, + IX86_BUILTIN_PMOVUSQB512_MEM, IX86_BUILTIN_PMOVUSQD512, + IX86_BUILTIN_PMOVUSQD512_MEM, IX86_BUILTIN_PMOVUSQW512, + IX86_BUILTIN_PMOVUSQW512_MEM, IX86_BUILTIN_PMOVZXBD512, IX86_BUILTIN_PMOVZXBQ512, IX86_BUILTIN_PMOVZXDQ512, @@ -28406,9 +28423,13 @@ enum ix86_builtins IX86_BUILTIN_SCATTERSIV8DI, /* AVX512PF */ + IX86_BUILTIN_GATHERPFQPD, IX86_BUILTIN_GATHERPFDPS, + IX86_BUILTIN_GATHERPFDPD, IX86_BUILTIN_GATHERPFQPS, + IX86_BUILTIN_SCATTERPFDPD, IX86_BUILTIN_SCATTERPFDPS, + IX86_BUILTIN_SCATTERPFQPD, IX86_BUILTIN_SCATTERPFQPS, /* AVX-512ER */ @@ -29014,6 +29035,21 @@ static const struct builtin_description bdesc_special_args[] = { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storedquv16si_mask, "__builtin_ia32_storedqusi512_mask", IX86_BUILTIN_STOREDQUSI512, UNKNOWN, (int) VOID_FTYPE_PV16SI_V16SI_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storedquv8di_mask, "__builtin_ia32_storedqudi512_mask", IX86_BUILTIN_STOREDQUDI512, UNKNOWN, (int) VOID_FTYPE_PV8DI_V8DI_QI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storeupd512_mask, "__builtin_ia32_storeupd512_mask", IX86_BUILTIN_STOREUPD512, UNKNOWN, (int) VOID_FTYPE_PV8DF_V8DF_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_us_truncatev8div8si2_mask_store, "__builtin_ia32_pmovusqd512mem_mask", IX86_BUILTIN_PMOVUSQD512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8SI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_ss_truncatev8div8si2_mask_store, "__builtin_ia32_pmovsqd512mem_mask", IX86_BUILTIN_PMOVSQD512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8SI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_truncatev8div8si2_mask_store, "__builtin_ia32_pmovqd512mem_mask", IX86_BUILTIN_PMOVQD512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8SI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_us_truncatev8div8hi2_mask_store, "__builtin_ia32_pmovusqw512mem_mask", IX86_BUILTIN_PMOVUSQW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8HI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_ss_truncatev8div8hi2_mask_store, "__builtin_ia32_pmovsqw512mem_mask", IX86_BUILTIN_PMOVSQW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8HI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_truncatev8div8hi2_mask_store, "__builtin_ia32_pmovqw512mem_mask", IX86_BUILTIN_PMOVQW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV8HI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_us_truncatev16siv16hi2_mask_store, "__builtin_ia32_pmovusdw512mem_mask", IX86_BUILTIN_PMOVUSDW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16HI_V16SI_HI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_ss_truncatev16siv16hi2_mask_store, "__builtin_ia32_pmovsdw512mem_mask", IX86_BUILTIN_PMOVSDW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16HI_V16SI_HI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_truncatev16siv16hi2_mask_store, "__builtin_ia32_pmovdw512mem_mask", IX86_BUILTIN_PMOVDW512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16HI_V16SI_HI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_truncatev8div16qi2_mask_store, "__builtin_ia32_pmovqb512mem_mask", IX86_BUILTIN_PMOVQB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_us_truncatev8div16qi2_mask_store, "__builtin_ia32_pmovusqb512mem_mask", IX86_BUILTIN_PMOVUSQB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_ss_truncatev8div16qi2_mask_store, "__builtin_ia32_pmovsqb512mem_mask", IX86_BUILTIN_PMOVSQB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V8DI_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_us_truncatev16siv16qi2_mask_store, "__builtin_ia32_pmovusdb512mem_mask", IX86_BUILTIN_PMOVUSDB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V16SI_HI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_ss_truncatev16siv16qi2_mask_store, "__builtin_ia32_pmovsdb512mem_mask", IX86_BUILTIN_PMOVSDB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V16SI_HI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_truncatev16siv16qi2_mask_store, "__builtin_ia32_pmovdb512mem_mask", IX86_BUILTIN_PMOVDB512_MEM, UNKNOWN, (int) VOID_FTYPE_PV16QI_V16SI_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storeups512_mask, "__builtin_ia32_storeups512_mask", IX86_BUILTIN_STOREUPS512, UNKNOWN, (int) VOID_FTYPE_PV16SF_V16SF_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storev16sf_mask, "__builtin_ia32_storeaps512_mask", IX86_BUILTIN_STOREAPS512, UNKNOWN, (int) VOID_FTYPE_PV16SF_V16SF_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_storev16si_mask, "__builtin_ia32_movdqa32store512_mask", IX86_BUILTIN_MOVDQA32STORE512, UNKNOWN, (int) VOID_FTYPE_PV16SI_V16SI_HI }, @@ -29893,8 +29929,10 @@ static const struct builtin_description bdesc_args[] = { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_vcvtps2ph512_mask, "__builtin_ia32_vcvtps2ph512_mask", IX86_BUILTIN_CVTPS2PH512, UNKNOWN, (int) V16HI_FTYPE_V16SF_INT_V16HI_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_ufloatv8siv8df_mask, "__builtin_ia32_cvtudq2pd512_mask", IX86_BUILTIN_CVTUDQ2PD512, UNKNOWN, (int) V8DF_FTYPE_V8SI_V8DF_QI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_cvtusi2sd32, "__builtin_ia32_cvtusi2sd32", IX86_BUILTIN_CVTUSI2SD32, UNKNOWN, (int) V2DF_FTYPE_V2DF_UINT }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv8df, "__builtin_ia32_expanddf512", IX86_BUILTIN_EXPANDPD512_NOMASK, UNKNOWN, (int) V8DF_FTYPE_V8DF }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv8df_mask, "__builtin_ia32_expanddf512_mask", IX86_BUILTIN_EXPANDPD512, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_QI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv8df_maskz, "__builtin_ia32_expanddf512_maskz", IX86_BUILTIN_EXPANDPD512Z, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_QI }, + { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv16sf, "__builtin_ia32_expandsf512", IX86_BUILTIN_EXPANDPS512_NOMASK, UNKNOWN, (int) V16SF_FTYPE_V16SF }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv16sf_mask, "__builtin_ia32_expandsf512_mask", IX86_BUILTIN_EXPANDPS512, UNKNOWN, (int) V16SF_FTYPE_V16SF_V16SF_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_expandv16sf_maskz, "__builtin_ia32_expandsf512_maskz", IX86_BUILTIN_EXPANDPS512Z, UNKNOWN, (int) V16SF_FTYPE_V16SF_V16SF_HI }, { OPTION_MASK_ISA_AVX512F, CODE_FOR_avx512f_vextractf32x4_mask, "__builtin_ia32_extractf32x4_mask", IX86_BUILTIN_EXTRACTF32X4, UNKNOWN, (int) V4SF_FTYPE_V16SF_INT_V4SF_QI }, @@ -30939,15 +30977,27 @@ ix86_init_mmx_sse_builtins (void) IX86_BUILTIN_SCATTERDIV8DI); /* AVX512PF */ + def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_gatherpfdpd", + VOID_FTYPE_QI_V8SI_PCINT64_INT_INT, + IX86_BUILTIN_GATHERPFDPD); def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_gatherpfdps", VOID_FTYPE_HI_V16SI_PCINT_INT_INT, IX86_BUILTIN_GATHERPFDPS); + def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_gatherpfqpd", + VOID_FTYPE_QI_V8DI_PCINT64_INT_INT, + IX86_BUILTIN_GATHERPFQPD); def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_gatherpfqps", VOID_FTYPE_QI_V8DI_PCINT_INT_INT, IX86_BUILTIN_GATHERPFQPS); + def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_scatterpfdpd", + VOID_FTYPE_QI_V8SI_PCINT64_INT_INT, + IX86_BUILTIN_SCATTERPFDPD); def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_scatterpfdps", VOID_FTYPE_HI_V16SI_PCINT_INT_INT, IX86_BUILTIN_SCATTERPFDPS); + def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_scatterpfqpd", + VOID_FTYPE_QI_V8DI_PCINT64_INT_INT, + IX86_BUILTIN_SCATTERPFQPD); def_builtin (OPTION_MASK_ISA_AVX512PF, "__builtin_ia32_scatterpfqps", VOID_FTYPE_QI_V8DI_PCINT_INT_INT, IX86_BUILTIN_SCATTERPFQPS); @@ -31298,18 +31348,27 @@ get_builtin_code_for_version (tree decl, tree *predicate_list) priority = P_PROC_SSSE3; break; case PROCESSOR_NEHALEM: - /* We translate "arch=corei7" and "arch=nehelam" to - "corei7" so that it will be mapped to M_INTEL_COREI7 - as cpu type to cover all M_INTEL_COREI7_XXXs. */ - arg_str = "corei7"; + if (new_target->x_ix86_isa_flags & OPTION_MASK_ISA_AES) + arg_str = "westmere"; + else + /* We translate "arch=corei7" and "arch=nehalem" to + "corei7" so that it will be mapped to M_INTEL_COREI7 + as cpu type to cover all M_INTEL_COREI7_XXXs. */ + arg_str = "corei7"; priority = P_PROC_SSE4_2; break; case PROCESSOR_SANDYBRIDGE: - arg_str = "sandybridge"; + if (new_target->x_ix86_isa_flags & OPTION_MASK_ISA_F16C) + arg_str = "ivybridge"; + else + arg_str = "sandybridge"; priority = P_PROC_AVX; break; case PROCESSOR_HASWELL: - arg_str = "haswell"; + if (new_target->x_ix86_isa_flags & OPTION_MASK_ISA_ADX) + arg_str = "broadwell"; + else + arg_str = "haswell"; priority = P_PROC_AVX2; break; case PROCESSOR_BONNELL: @@ -34568,6 +34627,11 @@ ix86_expand_special_args_builtin (const struct builtin_description *d, case VOID_FTYPE_PV2DI_V2DI_V2DI: case VOID_FTYPE_PDOUBLE_V2DF_QI: case VOID_FTYPE_PFLOAT_V4SF_QI: + case VOID_FTYPE_PV8SI_V8DI_QI: + case VOID_FTYPE_PV8HI_V8DI_QI: + case VOID_FTYPE_PV16HI_V16SI_HI: + case VOID_FTYPE_PV16QI_V8DI_QI: + case VOID_FTYPE_PV16QI_V16SI_HI: nargs = 2; klass = store; /* Reserve memory operand for target. */ @@ -35593,17 +35657,30 @@ addcarryx: case IX86_BUILTIN_SCATTERDIV8DI: icode = CODE_FOR_avx512f_scatterdiv8di; goto scatter_gen; + + case IX86_BUILTIN_GATHERPFDPD: + icode = CODE_FOR_avx512pf_gatherpfv8sidf; + goto vec_prefetch_gen; case IX86_BUILTIN_GATHERPFDPS: - icode = CODE_FOR_avx512pf_gatherpfv16si; + icode = CODE_FOR_avx512pf_gatherpfv16sisf; + goto vec_prefetch_gen; + case IX86_BUILTIN_GATHERPFQPD: + icode = CODE_FOR_avx512pf_gatherpfv8didf; goto vec_prefetch_gen; case IX86_BUILTIN_GATHERPFQPS: - icode = CODE_FOR_avx512pf_gatherpfv8di; + icode = CODE_FOR_avx512pf_gatherpfv8disf; + goto vec_prefetch_gen; + case IX86_BUILTIN_SCATTERPFDPD: + icode = CODE_FOR_avx512pf_scatterpfv8sidf; goto vec_prefetch_gen; case IX86_BUILTIN_SCATTERPFDPS: - icode = CODE_FOR_avx512pf_scatterpfv16si; + icode = CODE_FOR_avx512pf_scatterpfv16sisf; + goto vec_prefetch_gen; + case IX86_BUILTIN_SCATTERPFQPD: + icode = CODE_FOR_avx512pf_scatterpfv8didf; goto vec_prefetch_gen; case IX86_BUILTIN_SCATTERPFQPS: - icode = CODE_FOR_avx512pf_scatterpfv8di; + icode = CODE_FOR_avx512pf_scatterpfv8disf; goto vec_prefetch_gen; gather_gen: diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index ddc3be67c65..92e8fd0144c 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -2765,7 +2765,20 @@ "reload_completed" [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2))) (set (mem:SF (reg:P SP_REG)) (match_dup 1))] - "operands[2] = GEN_INT (-<P:MODE_SIZE>);") +{ + rtx op = XEXP (operands[0], 0); + if (GET_CODE (op) == PRE_DEC) + { + gcc_assert (!TARGET_64BIT); + op = GEN_INT (-4); + } + else + { + op = XEXP (XEXP (op, 1), 1); + gcc_assert (CONST_INT_P (op)); + } + operands[2] = op; +}) (define_split [(set (match_operand:SF 0 "push_operand") diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 2e68fb6241b..ac0582fc631 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -105,6 +105,7 @@ UNSPEC_COMPRESS UNSPEC_COMPRESS_STORE UNSPEC_EXPAND + UNSPEC_EXPAND_NOMASK UNSPEC_MASKED_EQ UNSPEC_MASKED_GT @@ -417,6 +418,7 @@ [V32QI V16HI V8SI (V8DI "TARGET_AVX512F") (V16SI "TARGET_AVX512F")]) (define_mode_iterator VI48_256 [V8SI V4DI]) (define_mode_iterator VI48_512 [V16SI V8DI]) +(define_mode_iterator VI4_256_8_512 [V8SI V8DI]) ;; Int-float size matches (define_mode_iterator VI4F_128 [V4SI V4SF]) @@ -7456,6 +7458,15 @@ (set_attr "prefix" "evex") (set_attr "mode" "<sseinsnmode>")]) +(define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store" + [(set (match_operand:PMOV_DST_MODE 0 "memory_operand") + (vec_merge:PMOV_DST_MODE + (any_truncate:PMOV_DST_MODE + (match_operand:<pmov_src_mode> 1 "register_operand")) + (match_dup 0) + (match_operand:<avx512fmaskmode> 2 "register_operand")))] + "TARGET_AVX512F") + (define_insn "*avx512f_<code>v8div16qi2" [(set (match_operand:V16QI 0 "register_operand" "=v") (vec_concat:V16QI @@ -7512,7 +7523,7 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) -(define_insn "*avx512f_<code>v8div16qi2_store_mask" +(define_insn "avx512f_<code>v8div16qi2_mask_store" [(set (match_operand:V16QI 0 "memory_operand" "=m") (vec_concat:V16QI (vec_merge:V8QI @@ -12495,10 +12506,14 @@ (set_attr "btver2_decode" "vector,vector,vector,vector") (set_attr "mode" "TI")]) -(define_expand "avx512pf_gatherpf<mode>" +;; Packed float variants +(define_mode_attr GATHER_SCATTER_SF_MEM_MODE + [(V8DI "V8SF") (V16SI "V16SF")]) + +(define_expand "avx512pf_gatherpf<mode>sf" [(unspec [(match_operand:<avx512fmaskmode> 0 "register_or_constm1_operand") - (mem:<ssescalarmode> + (mem:<GATHER_SCATTER_SF_MEM_MODE> (match_par_dup 5 [(match_operand 2 "vsib_address_operand") (match_operand:VI48_512 1 "register_operand") @@ -12512,10 +12527,10 @@ operands[3]), UNSPEC_VSIBADDR); }) -(define_insn "*avx512pf_gatherpf<mode>_mask" +(define_insn "*avx512pf_gatherpf<mode>sf_mask" [(unspec [(match_operand:<avx512fmaskmode> 0 "register_operand" "k") - (match_operator:<ssescalarmode> 5 "vsib_mem_operator" + (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator" [(unspec:P [(match_operand:P 2 "vsib_address_operand" "Tv") (match_operand:VI48_512 1 "register_operand" "v") @@ -12539,10 +12554,10 @@ (set_attr "prefix" "evex") (set_attr "mode" "XI")]) -(define_insn "*avx512pf_gatherpf<mode>" +(define_insn "*avx512pf_gatherpf<mode>sf" [(unspec [(const_int -1) - (match_operator:<ssescalarmode> 4 "vsib_mem_operator" + (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 4 "vsib_mem_operator" [(unspec:P [(match_operand:P 1 "vsib_address_operand" "Tv") (match_operand:VI48_512 0 "register_operand" "v") @@ -12566,10 +12581,83 @@ (set_attr "prefix" "evex") (set_attr "mode" "XI")]) -(define_expand "avx512pf_scatterpf<mode>" +;; Packed double variants +(define_expand "avx512pf_gatherpf<mode>df" [(unspec [(match_operand:<avx512fmaskmode> 0 "register_or_constm1_operand") - (mem:<ssescalarmode> + (mem:V8DF + (match_par_dup 5 + [(match_operand 2 "vsib_address_operand") + (match_operand:VI4_256_8_512 1 "register_operand") + (match_operand:SI 3 "const1248_operand")])) + (match_operand:SI 4 "const_0_to_1_operand")] + UNSPEC_GATHER_PREFETCH)] + "TARGET_AVX512PF" +{ + operands[5] + = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1], + operands[3]), UNSPEC_VSIBADDR); +}) + +(define_insn "*avx512pf_gatherpf<mode>df_mask" + [(unspec + [(match_operand:<avx512fmaskmode> 0 "register_operand" "k") + (match_operator:V8DF 5 "vsib_mem_operator" + [(unspec:P + [(match_operand:P 2 "vsib_address_operand" "Tv") + (match_operand:VI4_256_8_512 1 "register_operand" "v") + (match_operand:SI 3 "const1248_operand" "n")] + UNSPEC_VSIBADDR)]) + (match_operand:SI 4 "const_0_to_1_operand" "n")] + UNSPEC_GATHER_PREFETCH)] + "TARGET_AVX512PF" +{ + switch (INTVAL (operands[4])) + { + case 0: + return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}"; + case 1: + return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}"; + default: + gcc_unreachable (); + } +} + [(set_attr "type" "sse") + (set_attr "prefix" "evex") + (set_attr "mode" "XI")]) + +(define_insn "*avx512pf_gatherpf<mode>df" + [(unspec + [(const_int -1) + (match_operator:V8DF 4 "vsib_mem_operator" + [(unspec:P + [(match_operand:P 1 "vsib_address_operand" "Tv") + (match_operand:VI4_256_8_512 0 "register_operand" "v") + (match_operand:SI 2 "const1248_operand" "n")] + UNSPEC_VSIBADDR)]) + (match_operand:SI 3 "const_0_to_1_operand" "n")] + UNSPEC_GATHER_PREFETCH)] + "TARGET_AVX512PF" +{ + switch (INTVAL (operands[3])) + { + case 0: + return "vgatherpf0<ssemodesuffix>pd\t{%4|%4}"; + case 1: + return "vgatherpf1<ssemodesuffix>pd\t{%4|%4}"; + default: + gcc_unreachable (); + } +} + [(set_attr "type" "sse") + (set_attr "prefix" "evex") + (set_attr "mode" "XI")]) + +;; Packed float variants +(define_expand "avx512pf_scatterpf<mode>sf" + [(unspec + [(match_operand:<avx512fmaskmode> 0 "register_or_constm1_operand") + (mem:<GATHER_SCATTER_SF_MEM_MODE> (match_par_dup 5 [(match_operand 2 "vsib_address_operand") (match_operand:VI48_512 1 "register_operand") @@ -12583,10 +12671,10 @@ operands[3]), UNSPEC_VSIBADDR); }) -(define_insn "*avx512pf_scatterpf<mode>_mask" +(define_insn "*avx512pf_scatterpf<mode>sf_mask" [(unspec [(match_operand:<avx512fmaskmode> 0 "register_operand" "k") - (match_operator:<ssescalarmode> 5 "vsib_mem_operator" + (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator" [(unspec:P [(match_operand:P 2 "vsib_address_operand" "Tv") (match_operand:VI48_512 1 "register_operand" "v") @@ -12610,10 +12698,10 @@ (set_attr "prefix" "evex") (set_attr "mode" "XI")]) -(define_insn "*avx512pf_scatterpf<mode>" +(define_insn "*avx512pf_scatterpf<mode>sf" [(unspec [(const_int -1) - (match_operator:<ssescalarmode> 4 "vsib_mem_operator" + (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 4 "vsib_mem_operator" [(unspec:P [(match_operand:P 1 "vsib_address_operand" "Tv") (match_operand:VI48_512 0 "register_operand" "v") @@ -12637,6 +12725,78 @@ (set_attr "prefix" "evex") (set_attr "mode" "XI")]) +;; Packed double variants +(define_expand "avx512pf_scatterpf<mode>df" + [(unspec + [(match_operand:<avx512fmaskmode> 0 "register_or_constm1_operand") + (mem:V8DF + (match_par_dup 5 + [(match_operand 2 "vsib_address_operand") + (match_operand:VI4_256_8_512 1 "register_operand") + (match_operand:SI 3 "const1248_operand")])) + (match_operand:SI 4 "const_0_to_1_operand")] + UNSPEC_SCATTER_PREFETCH)] + "TARGET_AVX512PF" +{ + operands[5] + = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1], + operands[3]), UNSPEC_VSIBADDR); +}) + +(define_insn "*avx512pf_scatterpf<mode>df_mask" + [(unspec + [(match_operand:<avx512fmaskmode> 0 "register_operand" "k") + (match_operator:V8DF 5 "vsib_mem_operator" + [(unspec:P + [(match_operand:P 2 "vsib_address_operand" "Tv") + (match_operand:VI4_256_8_512 1 "register_operand" "v") + (match_operand:SI 3 "const1248_operand" "n")] + UNSPEC_VSIBADDR)]) + (match_operand:SI 4 "const_0_to_1_operand" "n")] + UNSPEC_SCATTER_PREFETCH)] + "TARGET_AVX512PF" +{ + switch (INTVAL (operands[4])) + { + case 0: + return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}"; + case 1: + return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}"; + default: + gcc_unreachable (); + } +} + [(set_attr "type" "sse") + (set_attr "prefix" "evex") + (set_attr "mode" "XI")]) + +(define_insn "*avx512pf_scatterpf<mode>df" + [(unspec + [(const_int -1) + (match_operator:V8DF 4 "vsib_mem_operator" + [(unspec:P + [(match_operand:P 1 "vsib_address_operand" "Tv") + (match_operand:VI4_256_8_512 0 "register_operand" "v") + (match_operand:SI 2 "const1248_operand" "n")] + UNSPEC_VSIBADDR)]) + (match_operand:SI 3 "const_0_to_1_operand" "n")] + UNSPEC_SCATTER_PREFETCH)] + "TARGET_AVX512PF" +{ + switch (INTVAL (operands[3])) + { + case 0: + return "vscatterpf0<ssemodesuffix>pd\t{%4|%4}"; + case 1: + return "vscatterpf1<ssemodesuffix>pd\t{%4|%4}"; + default: + gcc_unreachable (); + } +} + [(set_attr "type" "sse") + (set_attr "prefix" "evex") + (set_attr "mode" "XI")]) + (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>" [(set (match_operand:VF_512 0 "register_operand" "=v") (unspec:VF_512 @@ -15201,6 +15361,18 @@ "TARGET_AVX512F" "operands[2] = CONST0_RTX (<MODE>mode);") +(define_insn "avx512f_expand<mode>" + [(set (match_operand:VI48F_512 0 "register_operand" "=v,v") + (unspec:VI48F_512 + [(match_operand:VI48F_512 1 "nonimmediate_operand" "v,m")] + UNSPEC_EXPAND_NOMASK))] + "TARGET_AVX512F" + "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0|%0, %1}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") + (set_attr "memory" "none,load") + (set_attr "mode" "<sseinsnmode>")]) + (define_insn "avx512f_expand<mode>_mask" [(set (match_operand:VI48F_512 0 "register_operand" "=v,v") (unspec:VI48F_512 diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md index 46a7eddd96d..367f2539fc9 100644 --- a/gcc/config/microblaze/microblaze.md +++ b/gcc/config/microblaze/microblaze.md @@ -74,7 +74,7 @@ ;; bshift Shift operations (define_attr "type" - "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt" + "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap" (const_string "unknown")) ;; Main data type used by the insn @@ -2201,6 +2201,14 @@ (set_attr "mode" "none") (set_attr "length" "4")]) +;; Trap instruction pattern for __builtin_trap. Same as the glibc ABORT_INSTRUCTION +(define_insn "trap" + [(trap_if (const_int 1) (const_int 0))] + "" + "brki\tr0,-1" + [(set_attr "type" "trap")] +) + ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference ;; between "mfs" and "addik" instructions. (define_insn "set_got" diff --git a/gcc/config/mips/constraints.md b/gcc/config/mips/constraints.md index 196b3e1bb02..49e48954f51 100644 --- a/gcc/config/mips/constraints.md +++ b/gcc/config/mips/constraints.md @@ -92,12 +92,6 @@ ;; but the DSP version allows any accumulator target. (define_register_constraint "ka" "ISA_HAS_DSP_MULT ? ACC_REGS : MD_REGS") -;; The register class to use for an allocatable division result. -;; MIPS16 uses M16_REGS because LO is fixed. -(define_register_constraint "kl" - "TARGET_MIPS16 ? M16_REGS : TARGET_BIG_ENDIAN ? MD1_REG : MD0_REG" - "@internal") - (define_constraint "kf" "@internal" (match_operand 0 "force_to_mem_operand")) diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 5bad0f8b122..59c0b26d16e 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -17084,9 +17084,9 @@ mips_option_override (void) mips_r10k_cache_barrier = R10K_CACHE_BARRIER_NONE; } - /* If TARGET_DSPR2, enable MASK_DSP. */ + /* If TARGET_DSPR2, enable TARGET_DSP. */ if (TARGET_DSPR2) - target_flags |= MASK_DSP; + TARGET_DSP = true; /* .eh_frame addresses should be the same width as a C pointer. Most MIPS ABIs support only one pointer size, so the assembler diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index bc9d301291c..150cf0c3136 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -588,10 +588,6 @@ struct mips_cpu_info { #define TARGET_ENDIAN_DEFAULT MASK_BIG_ENDIAN #endif -#ifndef TARGET_FP_EXCEPTIONS_DEFAULT -#define TARGET_FP_EXCEPTIONS_DEFAULT MASK_FP_EXCEPTIONS -#endif - #ifdef IN_LIBGCC2 #undef TARGET_64BIT /* Make this compile time constant for libgcc2 */ diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index fb47a890c4c..4f643604008 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -2559,56 +2559,129 @@ ;; VR4120 errata MD(A1): signed division instructions do not work correctly ;; with negative operands. We use special libgcc functions instead. -;; +(define_expand "divmod<mode>4" + [(parallel + [(set (match_operand:GPR 0 "register_operand") + (div:GPR (match_operand:GPR 1 "register_operand") + (match_operand:GPR 2 "register_operand"))) + (set (match_operand:GPR 3 "register_operand") + (mod:GPR (match_dup 1) + (match_dup 2)))])] + "ISA_HAS_<D>DIV && !TARGET_FIX_VR4120" +{ + if (TARGET_MIPS16) + { + rtx lo = gen_rtx_REG (<MODE>mode, LO_REGNUM); + emit_insn (gen_divmod<mode>4_mips16 (operands[0], operands[1], + operands[2], operands[3], lo)); + DONE; + } +}) + +(define_insn_and_split "*divmod<mode>4" + [(set (match_operand:GPR 0 "register_operand" "=l") + (div:GPR (match_operand:GPR 1 "register_operand" "d") + (match_operand:GPR 2 "register_operand" "d"))) + (set (match_operand:GPR 3 "register_operand" "=d") + (mod:GPR (match_dup 1) + (match_dup 2)))] + "ISA_HAS_<D>DIV && !TARGET_FIX_VR4120 && !TARGET_MIPS16" + "#" + "&& reload_completed" + [(const_int 0)] +{ + emit_insn (gen_divmod<mode>4_split (operands[3], operands[1], operands[2])); + DONE; +} + [(set_attr "type" "idiv") + (set_attr "mode" "<MODE>") + (set_attr "insn_count" "2")]) + ;; Expand generates divmod instructions for individual division and modulus ;; operations. We then rely on CSE to reuse earlier divmods where possible. ;; This means that, when generating MIPS16 code, it is better not to expose ;; the fixed LO register until after CSE has finished. However, it's still ;; better to split before register allocation, so that we don't allocate ;; one of the scarce MIPS16 registers to an unused result. -(define_insn_and_split "divmod<mode>4" - [(set (match_operand:GPR 0 "register_operand" "=kl") +(define_insn_and_split "divmod<mode>4_mips16" + [(set (match_operand:GPR 0 "register_operand" "=d") (div:GPR (match_operand:GPR 1 "register_operand" "d") (match_operand:GPR 2 "register_operand" "d"))) (set (match_operand:GPR 3 "register_operand" "=d") (mod:GPR (match_dup 1) - (match_dup 2)))] - "ISA_HAS_<D>DIV && !TARGET_FIX_VR4120" + (match_dup 2))) + (clobber (match_operand:GPR 4 "lo_operand" "=l"))] + "ISA_HAS_<D>DIV && !TARGET_FIX_VR4120 && TARGET_MIPS16" "#" - "&& ((TARGET_MIPS16 && cse_not_expected) || reload_completed)" + "&& cse_not_expected" [(const_int 0)] { emit_insn (gen_divmod<mode>4_split (operands[3], operands[1], operands[2])); - if (TARGET_MIPS16) - emit_move_insn (operands[0], gen_rtx_REG (<MODE>mode, LO_REGNUM)); + emit_move_insn (operands[0], operands[4]); DONE; } [(set_attr "type" "idiv") (set_attr "mode" "<MODE>") - ;; Worst case for MIPS16. (set_attr "insn_count" "3")]) -;; See the comment above "divmod<mode>4" for the MIPS16 handling. -(define_insn_and_split "udivmod<mode>4" - [(set (match_operand:GPR 0 "register_operand" "=kl") +(define_expand "udivmod<mode>4" + [(parallel + [(set (match_operand:GPR 0 "register_operand") + (udiv:GPR (match_operand:GPR 1 "register_operand") + (match_operand:GPR 2 "register_operand"))) + (set (match_operand:GPR 3 "register_operand") + (umod:GPR (match_dup 1) + (match_dup 2)))])] + "ISA_HAS_<D>DIV && !TARGET_FIX_VR4120" +{ + if (TARGET_MIPS16) + { + rtx lo = gen_rtx_REG (<MODE>mode, LO_REGNUM); + emit_insn (gen_udivmod<mode>4_mips16 (operands[0], operands[1], + operands[2], operands[3], lo)); + DONE; + } +}) + +(define_insn_and_split "*udivmod<mode>4" + [(set (match_operand:GPR 0 "register_operand" "=l") (udiv:GPR (match_operand:GPR 1 "register_operand" "d") (match_operand:GPR 2 "register_operand" "d"))) (set (match_operand:GPR 3 "register_operand" "=d") (umod:GPR (match_dup 1) (match_dup 2)))] - "ISA_HAS_<D>DIV" + "ISA_HAS_<D>DIV && !TARGET_MIPS16" "#" - "(TARGET_MIPS16 && cse_not_expected) || reload_completed" + "reload_completed" [(const_int 0)] { emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1], operands[2])); - if (TARGET_MIPS16) - emit_move_insn (operands[0], gen_rtx_REG (<MODE>mode, LO_REGNUM)); DONE; } [(set_attr "type" "idiv") (set_attr "mode" "<MODE>") - ;; Worst case for MIPS16. + (set_attr "insn_count" "2")]) + +;; See the comment above "divmod<mode>4_mips16" for the split timing. +(define_insn_and_split "udivmod<mode>4_mips16" + [(set (match_operand:GPR 0 "register_operand" "=d") + (udiv:GPR (match_operand:GPR 1 "register_operand" "d") + (match_operand:GPR 2 "register_operand" "d"))) + (set (match_operand:GPR 3 "register_operand" "=d") + (umod:GPR (match_dup 1) + (match_dup 2))) + (clobber (match_operand:GPR 4 "lo_operand" "=l"))] + "ISA_HAS_<D>DIV && TARGET_MIPS16" + "#" + "cse_not_expected" + [(const_int 0)] +{ + emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1], operands[2])); + emit_move_insn (operands[0], operands[4]); + DONE; +} + [(set_attr "type" "idiv") + (set_attr "mode" "<MODE>") (set_attr "insn_count" "3")]) (define_expand "<u>divmod<mode>4_split" diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt index 877ec594f56..be551a7a452 100644 --- a/gcc/config/mips/mips.opt +++ b/gcc/config/mips/mips.opt @@ -116,11 +116,11 @@ Target Report RejectNegative InverseMask(SINGLE_FLOAT, DOUBLE_FLOAT) Allow hardware floating-point instructions to cover both 32-bit and 64-bit operations mdsp -Target Report Mask(DSP) +Target Report Var(TARGET_DSP) Use MIPS-DSP instructions mdspr2 -Target Report Mask(DSPR2) +Target Report Var(TARGET_DSPR2) Use MIPS-DSP REV 2 instructions mdebug @@ -190,7 +190,7 @@ Target Report Var(TARGET_4300_MUL_FIX) Work around an early 4300 hardware bug mfp-exceptions -Target Report Mask(FP_EXCEPTIONS) +Target Report Var(TARGET_FP_EXCEPTIONS) Init(1) FP exceptions are enabled mfp32 @@ -206,7 +206,7 @@ Target RejectNegative Joined Var(mips_cache_flush_func) Init(CACHE_FLUSH_FUNC) -mflush-func=FUNC Use FUNC to flush the cache before calling stack trampolines mfused-madd -Target Report Mask(FUSED_MADD) +Target Report Var(TARGET_FUSED_MADD) Init(1) Generate floating-point multiply-add instructions mabs= @@ -264,7 +264,7 @@ Target Report RejectNegative Mask(MIPS16) Generate MIPS16 code mips3d -Target Report RejectNegative Mask(MIPS3D) +Target Report RejectNegative Var(TARGET_MIPS3D) Use MIPS-3D instructions mllsc @@ -324,7 +324,7 @@ Target Report RejectNegative InverseMask(MIPS16) Generate normal-mode code mno-mips3d -Target Report RejectNegative InverseMask(MIPS3D) +Target Report RejectNegative Var(TARGET_MIPS3D, 0) Do not use MIPS-3D instructions mpaired-single diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h index a707999c5cd..c3aeefedb5a 100644 --- a/gcc/config/msp430/msp430.h +++ b/gcc/config/msp430/msp430.h @@ -52,7 +52,7 @@ extern bool msp430x; #define ENDFILE_SPEC "crtend.o%s crtn.o%s -lgcc" #define ASM_SPEC "-mP " /* Enable polymorphic instructions. */ \ - "%{mcpu=*:-mmcu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on to the assembler. */ \ + "%{mcpu=*:-mcpu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on to the assembler. */ \ "%{mrelax=-mQ} " /* Pass the relax option on to the assembler. */ \ "%{mlarge:-ml} " /* Tell the assembler if we are building for the LARGE pointer model. */ \ "%{!msim:-md} %{msim:%{mlarge:-md}}" /* Copy data from ROM to RAM if necessary. */ \ @@ -71,8 +71,8 @@ extern bool msp430x; %{msim:-lsim} \ %{!msim:-lnosys} \ --end-group \ -%{!T*:%{!msim:%{mmcu=*:--script=%*/memory.ld --script=%*/peripherals.ld}}} \ -%{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \ +%{!T*:%{!msim:%{mmcu=*:--script=%*.ld}}} \ +%{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \ %{!T*:%{msim:%{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}} \ " diff --git a/gcc/config/msp430/t-msp430 b/gcc/config/msp430/t-msp430 index 3cbb61cd975..4779e62d5fd 100644 --- a/gcc/config/msp430/t-msp430 +++ b/gcc/config/msp430/t-msp430 @@ -27,6 +27,14 @@ MULTILIB_DIRNAMES = 430x large MULTILIB_MATCHES = mcpu?msp430x=mcpu?msp430X MULTILIB_MATCHES += mcpu?msp430x=mcpu?msp430xv2 MULTILIB_MATCHES += mcpu?msp430x=mcpu?msp430Xv2 +MULTILIB_MATCHES += mcpu?msp430x=mmcu?msp430x +MULTILIB_MATCHES += mcpu?msp430x=mmcu?msp430X +MULTILIB_MATCHES += mcpu?msp430x=mmcu?msp430xv2 +MULTILIB_MATCHES += mcpu?msp430x=mmcu?msp430Xv2 +MULTILIB_MATCHES += mcpu?msp430x=mcpu?430x +MULTILIB_MATCHES += mcpu?msp430x=mcpu?430X +MULTILIB_MATCHES += mcpu?msp430x=mcpu?430xv2 +MULTILIB_MATCHES += mcpu?msp430x=mcpu?430Xv2 # Add additional MCU matches like this: # MULTILIB_MATCHES += mcpu?msp430x=mmcu?xxxxxxxxxx diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index d17a1af43c4..c5f87eab5d2 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -8106,10 +8106,10 @@ pa_attr_length_indirect_call (rtx insn) return 8; if (flag_pic) - return 24; + return 20; if (TARGET_PORTABLE_RUNTIME) - return 20; + return 16; /* Out of reach, can use ble. */ return 12; @@ -8154,28 +8154,28 @@ pa_output_indirect_call (rtx insn, rtx call_dest) return ".CALL\tARGW0=GR\n\tldil L'$$dyncall,%%r2\n\tble R'$$dyncall(%%sr4,%%r2)\n\tcopy %%r31,%%r2"; /* Long millicode call for portable runtime. */ - if (pa_attr_length_indirect_call (insn) == 20) - return "ldil L'$$dyncall,%%r31\n\tldo R'$$dyncall(%%r31),%%r31\n\tblr %%r0,%%r2\n\tbv,n %%r0(%%r31)\n\tnop"; + if (pa_attr_length_indirect_call (insn) == 16) + return "ldil L'$$dyncall,%%r31\n\tldo R'$$dyncall(%%r31),%%r31\n\tblr %%r0,%%r2\n\tbv,n %%r0(%%r31)"; /* We need a long PIC call to $$dyncall. */ xoperands[0] = NULL_RTX; - output_asm_insn ("{bl|b,l} .+8,%%r1", xoperands); + output_asm_insn ("{bl|b,l} .+8,%%r2", xoperands); if (TARGET_SOM || !TARGET_GAS) { xoperands[0] = gen_label_rtx (); - output_asm_insn ("addil L'$$dyncall-%0,%%r1", xoperands); + output_asm_insn ("addil L'$$dyncall-%0,%%r2", xoperands); targetm.asm_out.internal_label (asm_out_file, "L", CODE_LABEL_NUMBER (xoperands[0])); output_asm_insn ("ldo R'$$dyncall-%0(%%r1),%%r1", xoperands); } else { - output_asm_insn ("addil L'$$dyncall-$PIC_pcrel$0+4,%%r1", xoperands); + output_asm_insn ("addil L'$$dyncall-$PIC_pcrel$0+4,%%r2", xoperands); output_asm_insn ("ldo R'$$dyncall-$PIC_pcrel$0+8(%%r1),%%r1", xoperands); } - output_asm_insn ("blr %%r0,%%r2", xoperands); - output_asm_insn ("bv,n %%r0(%%r1)\n\tnop", xoperands); + output_asm_insn ("bv %%r0(%%r1)", xoperands); + output_asm_insn ("ldo 12(%%r2),%%r2", xoperands); return ""; } diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index 94ba162a43e..e55d0b86b90 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -7087,7 +7087,17 @@ add,l %2,%3,%3\;bv,n %%r0(%3)" if (TARGET_PORTABLE_RUNTIME) op = force_reg (SImode, XEXP (operands[0], 0)); else - op = XEXP (operands[0], 0); + { + op = XEXP (operands[0], 0); + + /* Generate indirect long calls to non-local functions. */ + if (!TARGET_64BIT && TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF) + { + tree call_decl = SYMBOL_REF_DECL (op); + if (!(call_decl && targetm.binds_local_p (call_decl))) + op = force_reg (word_mode, op); + } + } if (TARGET_64BIT) { @@ -7575,11 +7585,29 @@ add,l %2,%3,%3\;bv,n %%r0(%3)" rtx op; rtx dst = operands[0]; rtx nb = operands[2]; + bool call_powf = false; if (TARGET_PORTABLE_RUNTIME) op = force_reg (SImode, XEXP (operands[1], 0)); else - op = XEXP (operands[1], 0); + { + op = XEXP (operands[1], 0); + if (GET_CODE (op) == SYMBOL_REF) + { + /* Handle special call to buggy powf function. */ + if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT + && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf")) + call_powf = true; + + /* Generate indirect long calls to non-local functions. */ + else if (!TARGET_64BIT && TARGET_LONG_CALLS) + { + tree call_decl = SYMBOL_REF_DECL (op); + if (!(call_decl && targetm.binds_local_p (call_decl))) + op = force_reg (word_mode, op); + } + } + } if (TARGET_64BIT) { @@ -7639,8 +7667,7 @@ add,l %2,%3,%3\;bv,n %%r0(%3)" rtx r4 = gen_rtx_REG (word_mode, 4); if (GET_CODE (op) == SYMBOL_REF) { - if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT - && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf")) + if (call_powf) emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4)); else emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4)); @@ -7659,18 +7686,14 @@ add,l %2,%3,%3\;bv,n %%r0(%3)" { rtx r4 = gen_rtx_REG (word_mode, 4); - if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT - && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), - "powf")) + if (call_powf) emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4)); else emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4)); } else { - if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT - && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), - "powf")) + if (call_powf) emit_call_insn (gen_call_val_powf (dst, op, nb)); else emit_call_insn (gen_call_val_symref (dst, op, nb)); diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 0bfc85e4ead..7b1121ddb76 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -270,7 +270,7 @@ { HOST_WIDE_INT r; - if (!TARGET_QUAD_MEMORY) + if (!TARGET_QUAD_MEMORY && !TARGET_QUAD_MEMORY_ATOMIC) return 0; if (GET_CODE (op) == SUBREG) @@ -624,6 +624,7 @@ (match_test "offsettable_nonstrict_memref_p (op)"))) ;; Return 1 if the operand is suitable for load/store quad memory. +;; This predicate only checks for non-atomic loads/stores. (define_predicate "quad_memory_operand" (match_code "mem") { diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 2072b76c26e..acdd4b49777 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -339,6 +339,10 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags, rs6000_define_or_undefine_macro (define_p, "__HTM__"); if ((flags & OPTION_MASK_P8_VECTOR) != 0) rs6000_define_or_undefine_macro (define_p, "__POWER8_VECTOR__"); + if ((flags & OPTION_MASK_QUAD_MEMORY) != 0) + rs6000_define_or_undefine_macro (define_p, "__QUAD_MEMORY__"); + if ((flags & OPTION_MASK_QUAD_MEMORY_ATOMIC) != 0) + rs6000_define_or_undefine_macro (define_p, "__QUAD_MEMORY_ATOMIC__"); if ((flags & OPTION_MASK_CRYPTO) != 0) rs6000_define_or_undefine_macro (define_p, "__CRYPTO__"); diff --git a/gcc/config/rs6000/rs6000-cpus.def b/gcc/config/rs6000/rs6000-cpus.def index bf109a0454c..b17fd0d7207 100644 --- a/gcc/config/rs6000/rs6000-cpus.def +++ b/gcc/config/rs6000/rs6000-cpus.def @@ -53,7 +53,8 @@ | OPTION_MASK_CRYPTO \ | OPTION_MASK_DIRECT_MOVE \ | OPTION_MASK_HTM \ - | OPTION_MASK_QUAD_MEMORY) + | OPTION_MASK_QUAD_MEMORY \ + | OPTION_MASK_QUAD_MEMORY_ATOMIC) #define POWERPC_7400_MASK (OPTION_MASK_PPC_GFXOPT | OPTION_MASK_ALTIVEC) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a479219e261..801b9dc04cf 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3039,7 +3039,8 @@ rs6000_option_override_internal (bool global_init_p) calculation works better for RTL loop invariant motion on targets with enough (>= 32) registers. It is an expensive optimization. So it is on only for peak performance. */ - if (optimize >= 3 && global_init_p) + if (optimize >= 3 && global_init_p + && !global_options_set.x_flag_ira_loop_pressure) flag_ira_loop_pressure = 1; /* Set the pointer size. */ @@ -3356,14 +3357,37 @@ rs6000_option_override_internal (bool global_init_p) /* The quad memory instructions only works in 64-bit mode. In 32-bit mode, silently turn off quad memory mode. */ - if (TARGET_QUAD_MEMORY && !TARGET_POWERPC64) + if ((TARGET_QUAD_MEMORY || TARGET_QUAD_MEMORY_ATOMIC) && !TARGET_POWERPC64) { if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY) != 0) warning (0, N_("-mquad-memory requires 64-bit mode")); + if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) != 0) + warning (0, N_("-mquad-memory-atomic requires 64-bit mode")); + + rs6000_isa_flags &= ~(OPTION_MASK_QUAD_MEMORY + | OPTION_MASK_QUAD_MEMORY_ATOMIC); + } + + /* Non-atomic quad memory load/store are disabled for little endian, since + the words are reversed, but atomic operations can still be done by + swapping the words. */ + if (TARGET_QUAD_MEMORY && !WORDS_BIG_ENDIAN) + { + if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY) != 0) + warning (0, N_("-mquad-memory is not available in little endian mode")); + rs6000_isa_flags &= ~OPTION_MASK_QUAD_MEMORY; } + /* Assume if the user asked for normal quad memory instructions, they want + the atomic versions as well, unless they explicity told us not to use quad + word atomic instructions. */ + if (TARGET_QUAD_MEMORY + && !TARGET_QUAD_MEMORY_ATOMIC + && ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) == 0)) + rs6000_isa_flags |= OPTION_MASK_QUAD_MEMORY_ATOMIC; + /* Enable power8 fusion if we are tuning for power8, even if we aren't generating power8 instructions. */ if (!(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION)) @@ -5939,7 +5963,8 @@ direct_move_p (rtx op0, rtx op1) return false; } -/* Return true if this is a load or store quad operation. */ +/* Return true if this is a load or store quad operation. This function does + not handle the atomic quad memory instructions. */ bool quad_load_store_p (rtx op0, rtx op1) @@ -30115,22 +30140,6 @@ rs6000_expand_vec_perm_const_1 (rtx target, rtx op0, rtx op1, vmode = GET_MODE (target); gcc_assert (GET_MODE_NUNITS (vmode) == 2); dmode = mode_for_vector (GET_MODE_INNER (vmode), 4); - - /* For little endian, swap operands and invert/swap selectors - to get the correct xxpermdi. The operand swap sets up the - inputs as a little endian array. The selectors are swapped - because they are defined to use big endian ordering. The - selectors are inverted to get the correct doublewords for - little endian ordering. */ - if (!BYTES_BIG_ENDIAN) - { - int n; - perm0 = 3 - perm0; - perm1 = 3 - perm1; - n = perm0, perm0 = perm1, perm1 = n; - x = op0, op0 = op1, op1 = x; - } - x = gen_rtx_VEC_CONCAT (dmode, op0, op1); v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1)); x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v)); @@ -30753,6 +30762,7 @@ static struct rs6000_opt_mask const rs6000_opt_masks[] = { "powerpc-gfxopt", OPTION_MASK_PPC_GFXOPT, false, true }, { "powerpc-gpopt", OPTION_MASK_PPC_GPOPT, false, true }, { "quad-memory", OPTION_MASK_QUAD_MEMORY, false, true }, + { "quad-memory-atomic", OPTION_MASK_QUAD_MEMORY_ATOMIC, false, true }, { "recip-precision", OPTION_MASK_RECIP_PRECISION, false, true }, { "string", OPTION_MASK_STRING, false, true }, { "update", OPTION_MASK_NO_UPDATE, true , true }, diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 1a37a5df981..5e30879a065 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -533,8 +533,11 @@ extern int rs6000_vector_align[]; /* Byte/char syncs were added as phased in for ISA 2.06B, but are not present in power7, so conditionalize them on p8 features. TImode syncs need quad memory support. */ -#define TARGET_SYNC_HI_QI (TARGET_QUAD_MEMORY || TARGET_DIRECT_MOVE) -#define TARGET_SYNC_TI TARGET_QUAD_MEMORY +#define TARGET_SYNC_HI_QI (TARGET_QUAD_MEMORY \ + || TARGET_QUAD_MEMORY_ATOMIC \ + || TARGET_DIRECT_MOVE) + +#define TARGET_SYNC_TI TARGET_QUAD_MEMORY_ATOMIC /* Power7 has both 32-bit load and store integer for the FPRs, so we don't need to allocate the SDmode stack slot to get the value into the proper location diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 3240a7516bb..4c1a02a524a 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -571,7 +571,11 @@ Use ISA 2.07 transactional memory (HTM) instructions mquad-memory Target Report Mask(QUAD_MEMORY) Var(rs6000_isa_flags) -Generate the quad word memory instructions (lq/stq/lqarx/stqcx). +Generate the quad word memory instructions (lq/stq). + +mquad-memory-atomic +Target Report Mask(QUAD_MEMORY_ATOMIC) Var(rs6000_isa_flags) +Generate the quad word memory atomic instructions (lqarx/stqcx). mcompat-align-parm Target Report Var(rs6000_compat_align_parm) Init(0) Save diff --git a/gcc/config/rs6000/sync.md b/gcc/config/rs6000/sync.md index 45de1bd1328..7db439074cd 100644 --- a/gcc/config/rs6000/sync.md +++ b/gcc/config/rs6000/sync.md @@ -204,25 +204,46 @@ "<QHI:larx> %0,%y1" [(set_attr "type" "load_l")]) -;; Use PTImode to get even/odd register pairs +;; Use PTImode to get even/odd register pairs. +;; Use a temporary register to force getting an even register for the +;; lqarx/stqcrx. instructions. Normal optimizations will eliminate this extra +;; copy on big endian systems. + +;; On little endian systems where non-atomic quad word load/store instructions +;; are not used, the address can be register+offset, so make sure the address +;; is indexed or indirect before register allocation. + (define_expand "load_lockedti" [(use (match_operand:TI 0 "quad_int_reg_operand" "")) (use (match_operand:TI 1 "memory_operand" ""))] "TARGET_SYNC_TI" { - /* Use a temporary register to force getting an even register for the - lqarx/stqcrx. instructions. Normal optimizations will eliminate this - extra copy. */ + rtx op0 = operands[0]; + rtx op1 = operands[1]; rtx pti = gen_reg_rtx (PTImode); - emit_insn (gen_load_lockedpti (pti, operands[1])); - emit_move_insn (operands[0], gen_lowpart (TImode, pti)); + + if (!indexed_or_indirect_operand (op1, TImode)) + { + rtx old_addr = XEXP (op1, 0); + rtx new_addr = force_reg (Pmode, old_addr); + operands[1] = op1 = change_address (op1, TImode, new_addr); + } + + emit_insn (gen_load_lockedpti (pti, op1)); + if (WORDS_BIG_ENDIAN) + emit_move_insn (op0, gen_lowpart (TImode, pti)); + else + { + emit_move_insn (gen_lowpart (DImode, op0), gen_highpart (DImode, pti)); + emit_move_insn (gen_highpart (DImode, op0), gen_lowpart (DImode, pti)); + } DONE; }) (define_insn "load_lockedpti" [(set (match_operand:PTI 0 "quad_int_reg_operand" "=&r") (unspec_volatile:PTI - [(match_operand:TI 1 "memory_operand" "Z")] UNSPECV_LL))] + [(match_operand:TI 1 "indexed_or_indirect_operand" "Z")] UNSPECV_LL))] "TARGET_SYNC_TI && !reg_mentioned_p (operands[0], operands[1]) && quad_int_reg_operand (operands[0], PTImode)" @@ -238,6 +259,14 @@ "<stcx> %2,%y1" [(set_attr "type" "store_c")]) +;; Use a temporary register to force getting an even register for the +;; lqarx/stqcrx. instructions. Normal optimizations will eliminate this extra +;; copy on big endian systems. + +;; On little endian systems where non-atomic quad word load/store instructions +;; are not used, the address can be register+offset, so make sure the address +;; is indexed or indirect before register allocation. + (define_expand "store_conditionalti" [(use (match_operand:CC 0 "cc_reg_operand" "")) (use (match_operand:TI 1 "memory_operand" "")) @@ -247,21 +276,36 @@ rtx op0 = operands[0]; rtx op1 = operands[1]; rtx op2 = operands[2]; - rtx pti_op1 = change_address (op1, PTImode, XEXP (op1, 0)); - rtx pti_op2 = gen_reg_rtx (PTImode); - - /* Use a temporary register to force getting an even register for the - lqarx/stqcrx. instructions. Normal optimizations will eliminate this - extra copy. */ - emit_move_insn (pti_op2, gen_lowpart (PTImode, op2)); - emit_insn (gen_store_conditionalpti (op0, pti_op1, pti_op2)); + rtx addr = XEXP (op1, 0); + rtx pti_mem; + rtx pti_reg; + + if (!indexed_or_indirect_operand (op1, TImode)) + { + rtx new_addr = force_reg (Pmode, addr); + operands[1] = op1 = change_address (op1, TImode, new_addr); + addr = new_addr; + } + + pti_mem = change_address (op1, PTImode, addr); + pti_reg = gen_reg_rtx (PTImode); + + if (WORDS_BIG_ENDIAN) + emit_move_insn (pti_reg, gen_lowpart (PTImode, op2)); + else + { + emit_move_insn (gen_lowpart (DImode, pti_reg), gen_highpart (DImode, op2)); + emit_move_insn (gen_highpart (DImode, pti_reg), gen_lowpart (DImode, op2)); + } + + emit_insn (gen_store_conditionalpti (op0, pti_mem, pti_reg)); DONE; }) (define_insn "store_conditionalpti" [(set (match_operand:CC 0 "cc_reg_operand" "=x") (unspec_volatile:CC [(const_int 0)] UNSPECV_SC)) - (set (match_operand:PTI 1 "memory_operand" "=Z") + (set (match_operand:PTI 1 "indexed_or_indirect_operand" "=Z") (match_operand:PTI 2 "quad_int_reg_operand" "r"))] "TARGET_SYNC_TI && quad_int_reg_operand (operands[2], PTImode)" "stqcx. %2,%y1" diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 145bf2793d4..a63e34e0ff5 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -1634,9 +1634,32 @@ (match_operand 4 "const_2_to_3_operand" "")])))] "VECTOR_MEM_VSX_P (<MODE>mode)" { - int mask = (INTVAL (operands[3]) << 1) | (INTVAL (operands[4]) - 2); + int op3, op4, mask; + + /* For little endian, swap operands and invert/swap selectors + to get the correct xxpermdi. The operand swap sets up the + inputs as a little endian array. The selectors are swapped + because they are defined to use big endian ordering. The + selectors are inverted to get the correct doublewords for + little endian ordering. */ + if (BYTES_BIG_ENDIAN) + { + op3 = INTVAL (operands[3]); + op4 = INTVAL (operands[4]); + } + else + { + op3 = 3 - INTVAL (operands[4]); + op4 = 3 - INTVAL (operands[3]); + } + + mask = (op3 << 1) | (op4 - 2); operands[3] = GEN_INT (mask); - return "xxpermdi %x0,%x1,%x2,%3"; + + if (BYTES_BIG_ENDIAN) + return "xxpermdi %x0,%x1,%x2,%3"; + else + return "xxpermdi %x0,%x2,%x1,%3"; } [(set_attr "type" "vecperm")]) diff --git a/gcc/config/sh/sh-mem.cc b/gcc/config/sh/sh-mem.cc index e29ff775449..45af23acb48 100644 --- a/gcc/config/sh/sh-mem.cc +++ b/gcc/config/sh/sh-mem.cc @@ -344,7 +344,6 @@ sh_expand_cmpnstr (rtx *operands) rtx L_loop_long = gen_label_rtx (); rtx L_end_loop_long = gen_label_rtx (); - rtx L_small = gen_label_rtx (); int align = INTVAL (operands[4]); int bytes = INTVAL (operands[3]); @@ -403,33 +402,59 @@ sh_expand_cmpnstr (rtx *operands) jump = emit_jump_insn (gen_branch_false (L_loop_long)); add_int_reg_note (jump, REG_BR_PROB, prob_likely); + int sbytes = bytes % 4; + /* end loop. Reached max iterations. */ - if (bytes % 4 == 0) + if (! sbytes) { - /* Done. */ jump = emit_jump_insn (gen_jump_compact (L_return)); emit_barrier_after (jump); } else { - /* Remaining bytes to read. */ - jump = emit_jump_insn (gen_jump_compact (L_small)); + /* Remaining bytes to check. */ + + addr1 = adjust_automodify_address (addr1, QImode, s1_addr, 0); + addr2 = adjust_automodify_address (addr2, QImode, s2_addr, 0); + + while (sbytes--) + { + emit_insn (gen_extendqisi2 (tmp1, addr1)); + emit_insn (gen_extendqisi2 (tmp2, addr2)); + + emit_insn (gen_cmpeqsi_t (tmp2, const0_rtx)); + jump = emit_jump_insn (gen_branch_true (L_end_loop_byte)); + add_int_reg_note (jump, REG_BR_PROB, prob_unlikely); + + emit_insn (gen_cmpeqsi_t (tmp1, tmp2)); + if (flag_delayed_branch) + emit_insn (gen_zero_extendqisi2 (tmp2, + gen_lowpart (QImode, + tmp2))); + jump = emit_jump_insn (gen_branch_false (L_end_loop_byte)); + add_int_reg_note (jump, REG_BR_PROB, prob_unlikely); + + addr1 = adjust_address (addr1, QImode, + GET_MODE_SIZE (QImode)); + addr2 = adjust_address (addr2, QImode, + GET_MODE_SIZE (QImode)); + } + + jump = emit_jump_insn (gen_jump_compact( L_end_loop_byte)); emit_barrier_after (jump); } emit_label (L_end_loop_long); /* Found last word. Restart it byte per byte. */ - bytes = 4; + emit_move_insn (s1_addr, plus_constant (Pmode, s1_addr, -GET_MODE_SIZE (SImode))); emit_move_insn (s2_addr, plus_constant (Pmode, s2_addr, -GET_MODE_SIZE (SImode))); - } - emit_label (L_small); - - gcc_assert (bytes <= 7); + /* fall thru. */ + } addr1 = adjust_automodify_address (addr1, QImode, s1_addr, 0); addr2 = adjust_automodify_address (addr2, QImode, s2_addr, 0); @@ -445,7 +470,8 @@ sh_expand_cmpnstr (rtx *operands) emit_insn (gen_cmpeqsi_t (tmp1, tmp2)); if (flag_delayed_branch) - emit_insn (gen_zero_extendqisi2 (tmp2, gen_lowpart (QImode, tmp2))); + emit_insn (gen_zero_extendqisi2 (tmp2, + gen_lowpart (QImode, tmp2))); jump = emit_jump_insn (gen_branch_false (L_end_loop_byte)); add_int_reg_note (jump, REG_BR_PROB, prob_unlikely); diff --git a/gcc/config/tilegx/sync.md b/gcc/config/tilegx/sync.md index 586025760f4..3d9349301ca 100644 --- a/gcc/config/tilegx/sync.md +++ b/gcc/config/tilegx/sync.md @@ -150,15 +150,22 @@ (match_operand:SI 3 "const_int_operand" "")] ;; model "" { + rtx addend; enum memmodel model = (enum memmodel) INTVAL (operands[3]); if (operands[2] != const0_rtx) - emit_move_insn (operands[2], gen_rtx_NEG (<MODE>mode, operands[2])); + { + addend = gen_reg_rtx (<MODE>mode); + emit_move_insn (addend, + gen_rtx_MINUS (<MODE>mode, const0_rtx, operands[2])); + } + else + addend = operands[2]; tilegx_pre_atomic_barrier (model); emit_insn (gen_atomic_fetch_add_bare<mode> (operands[0], operands[1], - operands[2])); + addend)); tilegx_post_atomic_barrier (model); DONE; }) diff --git a/gcc/config/tilegx/tilegx-c.c b/gcc/config/tilegx/tilegx-c.c index 909659b1d95..e71965cfae8 100644 --- a/gcc/config/tilegx/tilegx-c.c +++ b/gcc/config/tilegx/tilegx-c.c @@ -47,6 +47,9 @@ tilegx_cpu_cpp_builtins (struct cpp_reader *pfile) if (TARGET_32BIT) builtin_define ("__tilegx32__"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); + TILEGX_CPU_CPP_ENDIAN_BUILTINS (); GNU_USER_TARGET_OS_CPP_BUILTINS (); } diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 654f83666b9..f3c68e3c50f 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -220,10 +220,18 @@ tilegx_function_arg (cumulative_args_t cum_v, CUMULATIVE_ARGS cum = *get_cumulative_args (cum_v); int byte_size = ((mode == BLKmode) ? int_size_in_bytes (type) : GET_MODE_SIZE (mode)); + bool doubleword_aligned_p; if (cum >= TILEGX_NUM_ARG_REGS) return NULL_RTX; + /* See whether the argument has doubleword alignment. */ + doubleword_aligned_p = + tilegx_function_arg_boundary (mode, type) > BITS_PER_WORD; + + if (doubleword_aligned_p) + cum += cum & 1; + /* The ABI does not allow parameters to be passed partially in reg and partially in stack. */ if ((cum + (byte_size + UNITS_PER_WORD - 1) / UNITS_PER_WORD) @@ -245,6 +253,14 @@ tilegx_function_arg_advance (cumulative_args_t cum_v, int byte_size = ((mode == BLKmode) ? int_size_in_bytes (type) : GET_MODE_SIZE (mode)); int word_size = (byte_size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + bool doubleword_aligned_p; + + /* See whether the argument has doubleword alignment. */ + doubleword_aligned_p = + tilegx_function_arg_boundary (mode, type) > BITS_PER_WORD; + + if (doubleword_aligned_p) + *cum += *cum & 1; /* If the current argument does not fit in the pretend_args space, skip over it. */ @@ -417,7 +433,7 @@ tilegx_setup_incoming_varargs (cumulative_args_t cum, generates code equivalent to: - paddedsize = (sizeof(TYPE) + 3) & -4; + paddedsize = (sizeof(TYPE) + 7) & -8; if ( (VALIST.__args + paddedsize > VALIST.__skip) & (VALIST.__args <= VALIST.__skip)) addr = VALIST.__skip + STACK_POINTER_OFFSET; @@ -457,9 +473,23 @@ tilegx_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, size = int_size_in_bytes (type); rsize = ((size + UNITS_PER_WORD - 1) / UNITS_PER_WORD) * UNITS_PER_WORD; - /* Assert alignment assumption. */ - gcc_assert (STACK_BOUNDARY == PARM_BOUNDARY); + /* If the alignment of the type is greater than the default for a + parameter, align to the STACK_BOUNDARY. */ + if (TYPE_ALIGN (type) > PARM_BOUNDARY) + { + /* Assert the only case we generate code for: when + stack boundary = 2 * parm boundary. */ + gcc_assert (STACK_BOUNDARY == PARM_BOUNDARY * 2); + + tmp = build2 (BIT_AND_EXPR, sizetype, + fold_convert (sizetype, unshare_expr (args)), + size_int (PARM_BOUNDARY / 8)); + tmp = build2 (POINTER_PLUS_EXPR, ptr_type_node, + unshare_expr (args), tmp); + gimplify_assign (unshare_expr (args), tmp, pre_p); + } + /* Build conditional expression to calculate addr. The expression will be gimplified later. */ tmp = fold_build_pointer_plus_hwi (unshare_expr (args), rsize); @@ -719,6 +749,16 @@ tilegx_init_expanders (void) } +/* Implement TARGET_EXPAND_TO_RTL_HOOK. */ +static void +tilegx_expand_to_rtl_hook (void) +{ + /* Exclude earlier sets of crtl->uses_pic_offset_table, because we + only care about uses actually emitted. */ + crtl->uses_pic_offset_table = 0; +} + + /* Implement TARGET_SHIFT_TRUNCATION_MASK. DImode shifts use the mode matching insns and therefore guarantee that the shift count is modulo 64. SImode shifts sometimes use the 64 bit version so do @@ -3560,6 +3600,12 @@ tilegx_expand_builtin (tree exp, } if (!pat) return NULL_RTX; + + /* If we are generating a prefetch, tell the scheduler not to move + it around. */ + if (GET_CODE (pat) == PREFETCH) + PREFETCH_SCHEDULE_BARRIER_P (pat) = true; + emit_insn (pat); if (nonvoid) @@ -4385,10 +4431,12 @@ tilegx_gen_bundles (void) basic_block bb; FOR_EACH_BB_FN (bb, cfun) { - rtx insn, next; + rtx insn, next, prev; rtx end = NEXT_INSN (BB_END (bb)); - for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn; insn = next) + prev = NULL_RTX; + for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn; + prev = insn, insn = next) { next = next_insn_to_bundle (NEXT_INSN (insn), end); @@ -4413,6 +4461,18 @@ tilegx_gen_bundles (void) PUT_MODE (insn, SImode); } } + + /* Delete barrier insns, because they can mess up the + emitting of bundle braces. If it is end-of-bundle, then + the previous insn must be marked end-of-bundle. */ + if (get_attr_type (insn) == TYPE_NOTHING) { + if (GET_MODE (insn) == QImode && prev != NULL + && GET_MODE (prev) == SImode) + { + PUT_MODE (prev, QImode); + } + delete_insn (insn); + } } } } @@ -5515,6 +5575,9 @@ tilegx_file_end (void) #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS tilegx_rtx_costs +#undef TARGET_EXPAND_TO_RTL_HOOK +#define TARGET_EXPAND_TO_RTL_HOOK tilegx_expand_to_rtl_hook + #undef TARGET_SHIFT_TRUNCATION_MASK #define TARGET_SHIFT_TRUNCATION_MASK tilegx_shift_truncation_mask diff --git a/gcc/config/tilegx/tilegx.h b/gcc/config/tilegx/tilegx.h index 68f466cbc3d..9eab51e68e2 100644 --- a/gcc/config/tilegx/tilegx.h +++ b/gcc/config/tilegx/tilegx.h @@ -59,9 +59,9 @@ #define UNITS_PER_WORD 8 #define PARM_BOUNDARY BITS_PER_WORD -#define STACK_BOUNDARY 64 +#define STACK_BOUNDARY 128 #define FUNCTION_BOUNDARY 64 -#define BIGGEST_ALIGNMENT 64 +#define BIGGEST_ALIGNMENT 128 #define STRICT_ALIGNMENT 1 #define INT_TYPE_SIZE 32 @@ -74,7 +74,7 @@ #define PCC_BITFIELD_TYPE_MATTERS 1 #define FASTEST_ALIGNMENT 64 -#define BIGGEST_FIELD_ALIGNMENT 64 +#define BIGGEST_FIELD_ALIGNMENT 128 #define WIDEST_HARDWARE_FP_SIZE 64 /* Unaligned moves trap and are very slow. */ diff --git a/gcc/config/tilegx/tilegx.md b/gcc/config/tilegx/tilegx.md index 1e82abccba7..c8c7af682a8 100644 --- a/gcc/config/tilegx/tilegx.md +++ b/gcc/config/tilegx/tilegx.md @@ -5171,10 +5171,8 @@ ;; Network intrinsics -;; Note the "pseudo" text is handled specially by the -;; asm_output_opcode routine. If the output is an empty string, the -;; instruction would bypass the asm_output_opcode routine, bypassing -;; the bundle handling code. +;; Note the this barrier is of type "nothing," which is deleted after +;; the final scheduling pass so that nothing is emitted for it. (define_insn "tilegx_network_barrier" [(unspec_volatile:SI [(const_int 0)] UNSPEC_NETWORK_BARRIER)] "" diff --git a/gcc/config/tilepro/tilepro-c.c b/gcc/config/tilepro/tilepro-c.c index dc2e3d0066e..4fd03378267 100644 --- a/gcc/config/tilepro/tilepro-c.c +++ b/gcc/config/tilepro/tilepro-c.c @@ -44,6 +44,11 @@ tilepro_cpu_cpp_builtins (struct cpp_reader *pfile) builtin_define ("__tile_chip__=1"); builtin_define ("__tile_chip_rev__=0"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); + builtin_define ("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); + TILEPRO_CPU_CPP_ENDIAN_BUILTINS (); GNU_USER_TARGET_OS_CPP_BUILTINS (); } diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index 615d49040bc..74f88008fc7 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -3184,6 +3184,12 @@ tilepro_expand_builtin (tree exp, } if (!pat) return NULL_RTX; + + /* If we are generating a prefetch, tell the scheduler not to move + it around. */ + if (GET_CODE (pat) == PREFETCH) + PREFETCH_SCHEDULE_BARRIER_P (pat) = true; + emit_insn (pat); if (nonvoid) diff --git a/gcc/config/tilepro/tilepro.md b/gcc/config/tilepro/tilepro.md index adf49baee7a..314dd90bfe0 100644 --- a/gcc/config/tilepro/tilepro.md +++ b/gcc/config/tilepro/tilepro.md @@ -795,7 +795,7 @@ (define_expand "ctzdi2" [(set (match_operand:DI 0 "register_operand" "") - (ctz:DI (match_operand:DI 1 "reg_or_0_operand" "")))] + (ctz:DI (match_operand:DI 1 "register_operand" "")))] "" { rtx lo, hi, ctz_lo, ctz_hi, ctz_hi_plus_32, result; @@ -823,7 +823,7 @@ (define_expand "clzdi2" [(set (match_operand:DI 0 "register_operand" "") - (clz:DI (match_operand:DI 1 "reg_or_0_operand" "")))] + (clz:DI (match_operand:DI 1 "register_operand" "")))] "" { rtx lo, hi, clz_lo, clz_hi, clz_lo_plus_32, result; @@ -851,7 +851,7 @@ (define_expand "ffsdi2" [(set (match_operand:DI 0 "register_operand" "") - (ffs:DI (match_operand:DI 1 "reg_or_0_operand" "")))] + (ffs:DI (match_operand:DI 1 "register_operand" "")))] "" { rtx lo, hi, ctz_lo, ctz_hi, ctz_hi_plus_32, ctz, ctz_plus_1,ctz_cond; diff --git a/gcc/configure b/gcc/configure index 5a58b59699e..53e772f2629 100755 --- a/gcc/configure +++ b/gcc/configure @@ -11287,8 +11287,13 @@ else /* | A-Za-z:\\/* ) realsrcdir=${srcdir};; *) realsrcdir=../${srcdir};; esac + # Clearing GMPINC is necessary to prevent host headers being + # used by the build compiler. Defining GENERATOR_FILE stops + # system.h from including gmp.h. CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ - LDFLAGS="${LDFLAGS_FOR_BUILD}" GMPINC="" \ + CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ + LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ + GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ --target=$target_alias --host=$build_alias --build=$build_alias @@ -17918,7 +17923,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17921 "configure" +#line 17926 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18024,7 +18029,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18027 "configure" +#line 18032 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 0023b2a572f..ac3d842733a 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1529,8 +1529,13 @@ else /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};; *) realsrcdir=../${srcdir};; esac + # Clearing GMPINC is necessary to prevent host headers being + # used by the build compiler. Defining GENERATOR_FILE stops + # system.h from including gmp.h. CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ - LDFLAGS="${LDFLAGS_FOR_BUILD}" GMPINC="" \ + CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ + LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ + GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ --target=$target_alias --host=$build_alias --build=$build_alias diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 671b36cc193..66e5cb5e065 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,156 @@ +2014-01-27 Jason Merrill <jason@redhat.com> + + PR c++/59823 + Core DR 1138 + * call.c (reference_binding): Pass LOOKUP_NO_TEMP_BIND for + list-initialization. A conversion to rvalue ref that involves + an lvalue-rvalue conversion is bad. + (convert_like_real): Give helpful error message. + + PR c++/54652 + * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL. + + PR c++/58504 + * pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Use tsubst for + types. + + PR c++/58606 + * pt.c (template_parm_to_arg): Call convert_from_reference. + (tsubst_template_arg): Don't strip reference refs. + + PR c++/58639 + * call.c (build_aggr_conv): Reject value-initialization of reference. + + PR c++/58812 + PR c++/58651 + * call.c (convert_like_real): Give helpful error about excess braces + for ck_rvalue of scalar type. + + Core DR 1288 + * call.c (reference_binding): Only elide braces if the single + element is reference-related. + + PR c++/58814 + * typeck.c (cp_build_modify_expr): Make the RHS an rvalue before + stabilizing. + + PR c++/58837 + * typeck.c (cp_truthvalue_conversion): Use explicit comparison for + FUNCTION_DECL. + + PR c++/59097 + * decl.c (compute_array_index_type): Don't call + maybe_constant_value for a non-integral expression. + +2014-01-24 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * call.c (magic_varargs_p): Replaced flag_enable_cilkplus with + flag_cilkplus. + * cp-gimplify.c (cp_genericize): Likewise. + * decl.c (grokfndecl): Likewise. + * parser.c (cp_parser_postfix_expression): Likewise. + (cp_parser_postfix_open_square_expression): Likewise. + (cp_parser_direct_declarator): Likewise. + (is_cilkplus_vector_p): Likewise. + (cp_parser_omp_clause_name): Likewise. + (cp_parser_omp_all_clauses): Likewise. + * pt.c (apply_late_template_attributes): Likewise. + * typeck.c (cp_build_array_ref): Likewise. + (cp_build_compound_expr): Likewise. + (check_return_expr): Likewise. + +2014-01-24 Jason Merrill <jason@redhat.com> + + PR c++/58550 + * decl.c (grokdeclarator): Turn pedwarn about auto return type in + c++11 into error. + + PR c++/59886 + PR c++/59659 + * typeck2.c (process_init_constructor_array): Don't create + RANGE_EXPR yet. + +2014-01-24 Jakub Jelinek <jakub@redhat.com> + + * typeck2.c (split_nonconstant_init_1): Fix num_split_elts + handling for RANGE_ARRAY case. + +2014-01-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57524 + * name-lookup.c (push_using_directive): Use timevar_cond_start. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59846 + * typeck.c (cp_build_binary_op): Pass location to shorten_compare. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/58346 + * typeck.c (pointer_diff): Give an error on arithmetic on pointer to + an empty aggregate. + +2014-01-23 Jason Merrill <jason@redhat.com> + + PR c++/55189 + * cp-tree.h (struct language_function): Add infinite_loop and + infinite_loops. + (current_function_infinite_loop): New. + * semantics.c (begin_maybe_infinite_loop, end_maybe_infinite_loop) + (break_maybe_infinite_loop): New. + (finish_while_stmt_cond, finish_while_stmt, begin_do_stmt) + (finish_do_stmt, finish_for_cond, finish_for_stmt) + (begin_range_for_stmt): Use them. + * decl.c (finish_function): Don't warn about missing return + if current_function_infinite_loop. + * pt.c (instantiate_decl): Copy current_function_infinite_loop. + * parser.c (cp_parser_jump_statement): Call break_maybe_infinite_loop. + + * call.c (build_op_delete_call): Use make_tree_vector and + release_tree_vector. + +2014-01-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58980 + * parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as + nested_name_specifier. + +2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled + see if there is an attribute after function decl. If so, then + parse them now. + (cp_parser_late_return_type_opt): Handle parsing of Cilk Plus SIMD + enabled function late parsing. + (cp_parser_gnu_attribute_list): Parse all the tokens for the vector + attribute for a SIMD-enabled function. + (cp_parser_omp_all_clauses): Skip parsing to the end of pragma when + the function is used by SIMD-enabled function (indicated by NULL + pragma token). Added 3 new clauses: PRAGMA_CILK_CLAUSE_MASK, + PRAGMA_CILK_CLAUSE_NOMASK and PRAGMA_CILK_CLAUSE_VECTORLENGTH + (cp_parser_cilk_simd_vectorlength): Modified this function to handle + vectorlength clause in SIMD-enabled function and #pragma SIMD's + vectorlength clause. Added a new bool parameter to differentiate + between the two. + (cp_parser_cilk_simd_fn_vector_attrs): New function. + (is_cilkplus_vector_p): Likewise. + (cp_parser_late_parsing_elem_fn_info): Likewise. + (cp_parser_omp_clause_name): Added a check for "mask", "nomask" + and "vectorlength" clauses when Cilk Plus is enabled. + (cp_parser_omp_clause_linear): Added a new parameter of type bool + and emit a sorry message when step size is a parameter. + * parser.h (cp_parser::cilk_simd_fn_info): New field. + * decl.c (grokfndecl): Added flag_enable_cilkplus along with + flag_openmp. + * pt.c (apply_late_template_attributes): Likewise. + +2014-01-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58809 + * semantics.c (finish_omp_reduction_clause): Reject + BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs. + 2014-01-22 Ville Voutilainen <ville.voutilainen@gmail.com> PR c++/59482 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 46b3748ead5..f6566cff1a2 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -894,6 +894,9 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) if (i < CONSTRUCTOR_NELTS (ctor)) val = CONSTRUCTOR_ELT (ctor, i)->value; + else if (TREE_CODE (ftype) == REFERENCE_TYPE) + /* Value-initialization of reference is ill-formed. */ + return NULL; else { if (empty_ctor == NULL_TREE) @@ -1460,16 +1463,29 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags, if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)) { maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); - conv = implicit_conversion (to, from, expr, c_cast_p, - flags, complain); - if (!CLASS_TYPE_P (to) - && CONSTRUCTOR_NELTS (expr) == 1) + /* DR 1288: Otherwise, if the initializer list has a single element + of type E and ... [T's] referenced type is reference-related to E, + the object or reference is initialized from that element... */ + if (CONSTRUCTOR_NELTS (expr) == 1) { - expr = CONSTRUCTOR_ELT (expr, 0)->value; - if (error_operand_p (expr)) + tree elt = CONSTRUCTOR_ELT (expr, 0)->value; + if (error_operand_p (elt)) return NULL; - from = TREE_TYPE (expr); + tree etype = TREE_TYPE (elt); + if (reference_related_p (to, etype)) + { + expr = elt; + from = etype; + goto skip; + } } + /* Otherwise, if T is a reference type, a prvalue temporary of the + type referenced by T is copy-list-initialized or + direct-list-initialized, depending on the kind of initialization + for the reference, and the reference is bound to that temporary. */ + conv = implicit_conversion (to, from, expr, c_cast_p, + flags|LOOKUP_NO_TEMP_BIND, complain); + skip:; } if (TREE_CODE (from) == REFERENCE_TYPE) @@ -1621,9 +1637,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags, /* [dcl.init.ref] - Otherwise, the reference shall be to a non-volatile const type. - - Under C++0x, [8.5.3/5 dcl.init.ref] it may also be an rvalue reference */ + Otherwise, the reference shall be an lvalue reference to a + non-volatile const type, or the reference shall be an rvalue + reference. */ if (!CP_TYPE_CONST_NON_VOLATILE_P (to) && !TYPE_REF_IS_RVALUE (rto)) return NULL; @@ -1661,7 +1677,16 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags, /* This reference binding, unlike those above, requires the creation of a temporary. */ conv->need_temporary_p = true; - conv->rvaluedness_matches_p = TYPE_REF_IS_RVALUE (rto); + if (TYPE_REF_IS_RVALUE (rto)) + { + conv->rvaluedness_matches_p = 1; + /* In the second case, if the reference is an rvalue reference and + the second standard conversion sequence of the user-defined + conversion sequence includes an lvalue-to-rvalue conversion, the + program is ill-formed. */ + if (conv->user_conv_p && next_conversion (conv)->kind == ck_rvalue) + conv->bad_p = 1; + } return conv; } @@ -5714,13 +5739,12 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, else { tree ret; - vec<tree, va_gc> *args; - vec_alloc (args, 2); + vec<tree, va_gc> *args = make_tree_vector (); args->quick_push (addr); if (FUNCTION_ARG_CHAIN (fn) != void_list_node) args->quick_push (size); ret = cp_build_function_call_vec (fn, &args, complain); - vec_free (args); + release_tree_vector (args); return ret; } } @@ -5866,10 +5890,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, && convs->kind != ck_list && convs->kind != ck_ambig && (convs->kind != ck_ref_bind - || convs->user_conv_p) - && convs->kind != ck_rvalue + || (convs->user_conv_p && next_conversion (convs)->bad_p)) + && (convs->kind != ck_rvalue + || SCALAR_TYPE_P (totype)) && convs->kind != ck_base) { + bool complained = false; conversion *t = convs; /* Give a helpful error if this is bad because of excess braces. */ @@ -5877,7 +5903,13 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, && SCALAR_TYPE_P (totype) && CONSTRUCTOR_NELTS (expr) > 0 && BRACE_ENCLOSED_INITIALIZER_P (CONSTRUCTOR_ELT (expr, 0)->value)) - permerror (loc, "too many braces around initializer for %qT", totype); + { + complained = permerror (loc, "too many braces around initializer " + "for %qT", totype); + while (BRACE_ENCLOSED_INITIALIZER_P (expr) + && CONSTRUCTOR_NELTS (expr) == 1) + expr = CONSTRUCTOR_ELT (expr, 0)->value; + } for (; t ; t = next_conversion (t)) { @@ -5913,9 +5945,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, else if (t->kind == ck_identity) break; } - if (permerror (loc, "invalid conversion from %qT to %qT", - TREE_TYPE (expr), totype) - && fn) + if (!complained) + complained = permerror (loc, "invalid conversion from %qT to %qT", + TREE_TYPE (expr), totype); + if (complained && fn) inform (DECL_SOURCE_LOCATION (fn), "initializing argument %P of %qD", argnum, fn); @@ -6149,7 +6182,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, if (convs->bad_p && !next_conversion (convs)->bad_p) { gcc_assert (TYPE_REF_IS_RVALUE (ref_type) - && real_lvalue_p (expr)); + && (real_lvalue_p (expr) + || next_conversion(convs)->kind == ck_rvalue)); error_at (loc, "cannot bind %qT lvalue to %qT", TREE_TYPE (expr), totype); @@ -6569,7 +6603,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) bool magic_varargs_p (tree fn) { - if (flag_enable_cilkplus && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE) + if (flag_cilkplus && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE) return true; if (DECL_BUILT_IN (fn)) @@ -7192,7 +7226,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray, /* If it is a built-in array notation function, then the return type of the function is the element type of the array passed in as array notation (i.e. the first parameter of the function). */ - if (flag_enable_cilkplus && TREE_CODE (fn) == CALL_EXPR) + if (flag_cilkplus && TREE_CODE (fn) == CALL_EXPR) { enum built_in_function bif = is_cilkplus_reduce_builtin (CALL_EXPR_FN (fn)); diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index d75b2b773d9..ef4b04372bc 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1311,7 +1311,7 @@ cp_genericize (tree fndecl) return; /* Expand all the array notations here. */ - if (flag_enable_cilkplus + if (flag_cilkplus && contains_array_notation_expr (DECL_SAVED_TREE (fndecl))) DECL_SAVED_TREE (fndecl) = expand_array_notation_exprs (DECL_SAVED_TREE (fndecl)); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 96af562f245..ab75db837ab 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1127,6 +1127,7 @@ struct GTY(()) language_function { BOOL_BITFIELD returns_value : 1; BOOL_BITFIELD returns_null : 1; BOOL_BITFIELD returns_abnormally : 1; + BOOL_BITFIELD infinite_loop: 1; BOOL_BITFIELD x_in_function_try_handler : 1; BOOL_BITFIELD x_in_base_initializer : 1; @@ -1136,6 +1137,9 @@ struct GTY(()) language_function { htab_t GTY((param_is(struct named_label_entry))) x_named_labels; cp_binding_level *bindings; vec<tree, va_gc> *x_local_names; + /* Tracking possibly infinite loops. This is a vec<tree> only because + vec<bool> doesn't work with gtype. */ + vec<tree, va_gc> *infinite_loops; htab_t GTY((param_is (struct cxx_int_tree_map))) extern_decl_map; }; @@ -1194,6 +1198,12 @@ struct GTY(()) language_function { #define current_function_returns_abnormally \ cp_function_chain->returns_abnormally +/* Set to 0 at beginning of a function definition, set to 1 if we see an + obvious infinite loop. This can have false positives and false + negatives, so it should only be used as a heuristic. */ + +#define current_function_infinite_loop cp_function_chain->infinite_loop + /* Nonzero if we are processing a base initializer. Zero elsewhere. */ #define in_base_initializer cp_function_chain->x_in_base_initializer @@ -5671,6 +5681,7 @@ extern bool perform_or_defer_access_check (tree, tree, tree, extern int stmts_are_full_exprs_p (void); extern void init_cp_semantics (void); extern tree do_poplevel (tree); +extern void break_maybe_infinite_loop (void); extern void add_decl_expr (tree); extern tree maybe_cleanup_point_expr_void (tree); extern tree finish_expr_stmt (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5906653f0d6..c93c7831a08 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1926,9 +1926,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Merge the data types specified in the two decls. */ newtype = merge_types (TREE_TYPE (newdecl), TREE_TYPE (olddecl)); - /* If merge_types produces a non-typedef type, just use the old type. */ - if (TREE_CODE (newdecl) == TYPE_DECL - && newtype == DECL_ORIGINAL_TYPE (newdecl)) + /* For typedefs use the old type, as the new type's DECL_NAME points + at newdecl, which will be ggc_freed. */ + if (TREE_CODE (newdecl) == TYPE_DECL) newtype = oldtype; if (VAR_P (newdecl)) @@ -7674,7 +7674,7 @@ grokfndecl (tree ctype, if (TYPE_NOTHROW_P (type) || nothrow_libfn_p (decl)) TREE_NOTHROW (decl) = 1; - if (flag_openmp) + if (flag_openmp || flag_cilkplus) { /* Adjust "omp declare simd" attributes. */ tree ods = lookup_attribute ("omp declare simd", *attrlist); @@ -8262,7 +8262,9 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) abi_1_itype = error_mark_node; } - size = maybe_constant_value (size); + if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) + size = maybe_constant_value (size); + if (!TREE_CONSTANT (size)) size = osize; } @@ -9599,9 +9601,14 @@ grokdeclarator (const cp_declarator *declarator, && LAMBDA_TYPE_P (current_class_type)) /* OK for C++11 lambdas. */; else if (cxx_dialect < cxx1y) - pedwarn (input_location, 0, "%qs function uses " + { + error ("%qs function uses " "%<auto%> type specifier without trailing " "return type", name); + inform (input_location, "deduced return type " + "only available with -std=c++1y or " + "-std=gnu++1y"); + } else if (virtualp) permerror (input_location, "virtual function cannot " "have deduced return type"); @@ -14000,6 +14007,8 @@ finish_function (int flags) && !current_function_returns_value && !current_function_returns_null /* Don't complain if we abort or throw. */ && !current_function_returns_abnormally + /* Don't complain if there's an infinite loop. */ + && !current_function_infinite_loop /* Don't complain if we are declared noreturn. */ && !TREE_THIS_VOLATILE (fndecl) && !DECL_NAME (DECL_RESULT (fndecl)) @@ -14064,6 +14073,7 @@ finish_function (int flags) f->x_return_value = NULL; f->bindings = NULL; f->extern_decl_map = NULL; + f->infinite_loops = NULL; } /* Clear out the bits we don't need. */ local_names = NULL; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 28f998d7fd7..3ffcf6971fa 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5683,9 +5683,9 @@ static tree push_using_directive (tree used) { tree ret; - timevar_start (TV_NAME_LOOKUP); + bool subtime = timevar_cond_start (TV_NAME_LOOKUP); ret = push_using_directive_1 (used); - timevar_stop (TV_NAME_LOOKUP); + timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3bc943bd91e..0636445198b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -241,6 +241,8 @@ static void cp_parser_cilk_simd (cp_parser *, cp_token *); static bool cp_parser_omp_declare_reduction_exprs (tree, cp_parser *); +static tree cp_parser_cilk_simd_vectorlength + (cp_parser *, tree, bool); /* Manifest constants. */ #define CP_LEXER_BUFFER_SIZE ((256 * 1024) / sizeof (cp_token)) @@ -2115,6 +2117,9 @@ static bool cp_parser_ctor_initializer_opt_and_function_body static tree cp_parser_late_parsing_omp_declare_simd (cp_parser *, tree); +static tree cp_parser_late_parsing_cilk_simd_fn_info + (cp_parser *, tree); + static tree synthesize_implicit_template_parm (cp_parser *); static tree finish_fully_implicit_template @@ -5803,7 +5808,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, postfix_expression = cp_parser_postfix_expression (parser, false, false, false, false, &idk); - if (!flag_enable_cilkplus) + if (!flag_cilkplus) { error_at (token->location, "-fcilkplus must be enabled to use" " %<_Cilk_spawn%>"); @@ -5828,7 +5833,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, } case RID_CILK_SYNC: - if (flag_enable_cilkplus) + if (flag_cilkplus) { tree sync_expr = build_cilk_sync (); SET_EXPR_LOCATION (sync_expr, @@ -6368,7 +6373,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser, bool expr_nonconst_p; maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); index = cp_parser_braced_list (parser, &expr_nonconst_p); - if (flag_enable_cilkplus + if (flag_cilkplus && cp_lexer_peek_token (parser->lexer)->type == CPP_COLON) { error_at (cp_lexer_peek_token (parser->lexer)->location, @@ -6378,7 +6383,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser, return error_mark_node; } } - else if (flag_enable_cilkplus) + else if (flag_cilkplus) { /* Here are have these two options: ARRAY[EXP : EXP] - Array notation expr with default @@ -10636,6 +10641,8 @@ cp_parser_jump_statement (cp_parser* parser) gcc_assert ((in_statement & IN_SWITCH_STMT) || in_statement == IN_ITERATION_STMT); statement = finish_break_stmt (); + if (in_statement == IN_ITERATION_STMT) + break_maybe_infinite_loop (); break; case IN_OMP_BLOCK: error_at (token->location, "invalid exit from OpenMP structured block"); @@ -15469,9 +15476,18 @@ cp_parser_enum_specifier (cp_parser* parser) error_at (type_start_token->location, "cannot add an enumerator " "list to a template instantiation"); + if (TREE_CODE (nested_name_specifier) == TYPENAME_TYPE) + { + error_at (type_start_token->location, + "%<%T::%E%> has not been declared", + TYPE_CONTEXT (nested_name_specifier), + nested_name_specifier); + type = error_mark_node; + } /* If that scope does not contain the scope in which the class was originally declared, the program is invalid. */ - if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier)) + else if (prev_scope && !is_ancestor (prev_scope, + nested_name_specifier)) { if (at_namespace_scope_p ()) error_at (type_start_token->location, @@ -15480,7 +15496,8 @@ cp_parser_enum_specifier (cp_parser* parser) type, prev_scope, nested_name_specifier); else error_at (type_start_token->location, - "declaration of %qD in %qD which does not enclose %qD", + "declaration of %qD in %qD which does not " + "enclose %qD", type, prev_scope, nested_name_specifier); type = error_mark_node; } @@ -17121,6 +17138,24 @@ cp_parser_direct_declarator (cp_parser* parser, attrs = cp_parser_std_attribute_spec_seq (parser); + /* In here, we handle cases where attribute is used after + the function declaration. For example: + void func (int x) __attribute__((vector(..))); */ + if (flag_cilkplus + && cp_next_tokens_can_be_gnu_attribute_p (parser)) + { + cp_parser_parse_tentatively (parser); + tree attr = cp_parser_gnu_attributes_opt (parser); + if (cp_lexer_next_token_is_not (parser->lexer, + CPP_SEMICOLON) + && cp_lexer_next_token_is_not (parser->lexer, + CPP_OPEN_BRACE)) + cp_parser_abort_tentative_parse (parser); + else if (!cp_parser_parse_definitely (parser)) + ; + else + attrs = chainon (attr, attrs); + } late_return = (cp_parser_late_return_type_opt (parser, declarator, memfn ? cv_quals : -1)); @@ -17829,7 +17864,7 @@ parsing_nsdmi (void) Returns the type indicated by the type-id. In addition to this this parses any queued up omp declare simd - clauses. + clauses and Cilk Plus SIMD-enabled function's vector attributes. QUALS is either a bitmask of cv_qualifiers or -1 for a non-member function. */ @@ -17844,10 +17879,13 @@ cp_parser_late_return_type_opt (cp_parser* parser, cp_declarator *declarator, && declarator && declarator->kind == cdk_id); + bool cilk_simd_fn_vector_p = (parser->cilk_simd_fn_info + && declarator && declarator->kind == cdk_id); + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); /* A late-specified return type is indicated by an initial '->'. */ - if (token->type != CPP_DEREF && !declare_simd_p) + if (token->type != CPP_DEREF && !(declare_simd_p || cilk_simd_fn_vector_p)) return NULL_TREE; tree save_ccp = current_class_ptr; @@ -17866,6 +17904,10 @@ cp_parser_late_return_type_opt (cp_parser* parser, cp_declarator *declarator, type = cp_parser_trailing_type_id (parser); } + if (cilk_simd_fn_vector_p) + declarator->std_attributes + = cp_parser_late_parsing_cilk_simd_fn_info (parser, + declarator->std_attributes); if (declare_simd_p) declarator->std_attributes = cp_parser_late_parsing_omp_declare_simd (parser, @@ -19847,12 +19889,12 @@ cp_parser_class_head (cp_parser* parser, if (cp_lexer_next_token_is (parser->lexer, CPP_COLON)) { /* PR59482: enter the class scope so that base-specifiers are looked - up correctly */ + up correctly. */ if (type) pushclass (type); bases = cp_parser_base_clause (parser); /* PR59482: get out of the previously pushed class scope so that the - subsequent pops pop the right thing */ + subsequent pops pop the right thing. */ if (type) popclass (); } @@ -21409,6 +21451,56 @@ cp_parser_attributes_opt (cp_parser *parser) return cp_parser_std_attribute_spec_seq (parser); } +#define CILK_SIMD_FN_CLAUSE_MASK \ + ((OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_VECTORLENGTH) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_LINEAR) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_UNIFORM) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_MASK) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_NOMASK)) + +/* Parses the Cilk Plus SIMD-enabled function's attribute. Syntax: + vector [(<clauses>)] */ + +static void +cp_parser_cilk_simd_fn_vector_attrs (cp_parser *parser, cp_token *v_token) +{ + bool first_p = parser->cilk_simd_fn_info == NULL; + cp_token *token = v_token; + if (first_p) + { + parser->cilk_simd_fn_info = XNEW (cp_omp_declare_simd_data); + parser->cilk_simd_fn_info->error_seen = false; + parser->cilk_simd_fn_info->fndecl_seen = false; + parser->cilk_simd_fn_info->tokens = vNULL; + } + int paren_scope = 0; + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) + { + cp_lexer_consume_token (parser->lexer); + v_token = cp_lexer_peek_token (parser->lexer); + paren_scope++; + } + while (paren_scope > 0) + { + token = cp_lexer_peek_token (parser->lexer); + if (token->type == CPP_OPEN_PAREN) + paren_scope++; + else if (token->type == CPP_CLOSE_PAREN) + paren_scope--; + /* Do not push the last ')' */ + if (!(token->type == CPP_CLOSE_PAREN && paren_scope == 0)) + cp_lexer_consume_token (parser->lexer); + } + + token->type = CPP_PRAGMA_EOL; + parser->lexer->next_token = token; + cp_lexer_consume_token (parser->lexer); + + struct cp_token_cache *cp + = cp_token_cache_new (v_token, cp_lexer_peek_token (parser->lexer)); + parser->cilk_simd_fn_info->tokens.safe_push (cp); +} + /* Parse an (optional) series of attributes. attributes: @@ -21467,6 +21559,17 @@ cp_parser_gnu_attributes_opt (cp_parser* parser) return attributes; } +/* Returns true of NAME is an IDENTIFIER_NODE with identiifer "vector," + "__vector" or "__vector__." */ + +static inline bool +is_cilkplus_vector_p (tree name) +{ + if (flag_cilkplus && is_attribute_p ("vector", name)) + return true; + return false; +} + /* Parse a GNU attribute-list. attribute-list: @@ -21505,8 +21608,9 @@ cp_parser_gnu_attribute_list (cp_parser* parser) { tree arguments = NULL_TREE; - /* Consume the token. */ - token = cp_lexer_consume_token (parser->lexer); + /* Consume the token, but save it since we need it for the + SIMD enabled function parsing. */ + cp_token *id_token = cp_lexer_consume_token (parser->lexer); /* Save away the identifier that indicates which attribute this is. */ @@ -21514,7 +21618,7 @@ cp_parser_gnu_attribute_list (cp_parser* parser) /* For keywords, use the canonical spelling, not the parsed identifier. */ ? ridpointers[(int) token->keyword] - : token->u.value; + : id_token->u.value; attribute = build_tree_list (identifier, NULL_TREE); @@ -21526,10 +21630,16 @@ cp_parser_gnu_attribute_list (cp_parser* parser) vec<tree, va_gc> *vec; int attr_flag = (attribute_takes_identifier_p (identifier) ? id_attr : normal_attr); - vec = cp_parser_parenthesized_expression_list - (parser, attr_flag, /*cast_p=*/false, - /*allow_expansion_p=*/false, - /*non_constant_p=*/NULL); + if (is_cilkplus_vector_p (identifier)) + { + cp_parser_cilk_simd_fn_vector_attrs (parser, id_token); + continue; + } + else + vec = cp_parser_parenthesized_expression_list + (parser, attr_flag, /*cast_p=*/false, + /*allow_expansion_p=*/false, + /*non_constant_p=*/NULL); if (vec == NULL) arguments = error_mark_node; else @@ -21540,6 +21650,11 @@ cp_parser_gnu_attribute_list (cp_parser* parser) /* Save the arguments away. */ TREE_VALUE (attribute) = arguments; } + else if (is_cilkplus_vector_p (identifier)) + { + cp_parser_cilk_simd_fn_vector_attrs (parser, id_token); + continue; + } if (arguments != error_mark_node) { @@ -26819,12 +26934,16 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_MAP; else if (!strcmp ("mergeable", p)) result = PRAGMA_OMP_CLAUSE_MERGEABLE; + else if (flag_cilkplus && !strcmp ("mask", p)) + result = PRAGMA_CILK_CLAUSE_MASK; break; case 'n': if (!strcmp ("notinbranch", p)) result = PRAGMA_OMP_CLAUSE_NOTINBRANCH; else if (!strcmp ("nowait", p)) result = PRAGMA_OMP_CLAUSE_NOWAIT; + else if (flag_cilkplus && !strcmp ("nomask", p)) + result = PRAGMA_CILK_CLAUSE_NOMASK; else if (!strcmp ("num_teams", p)) result = PRAGMA_OMP_CLAUSE_NUM_TEAMS; else if (!strcmp ("num_threads", p)) @@ -26870,6 +26989,10 @@ cp_parser_omp_clause_name (cp_parser *parser) else if (!strcmp ("untied", p)) result = PRAGMA_OMP_CLAUSE_UNTIED; break; + case 'v': + if (flag_cilkplus && !strcmp ("vectorlength", p)) + result = PRAGMA_CILK_CLAUSE_VECTORLENGTH; + break; } } @@ -27622,7 +27745,8 @@ cp_parser_omp_clause_aligned (cp_parser *parser, tree list) linear ( variable-list : expression ) */ static tree -cp_parser_omp_clause_linear (cp_parser *parser, tree list) +cp_parser_omp_clause_linear (cp_parser *parser, tree list, + bool is_cilk_simd_fn) { tree nlist, c, step = integer_one_node; bool colon; @@ -27637,6 +27761,11 @@ cp_parser_omp_clause_linear (cp_parser *parser, tree list) { step = cp_parser_expression (parser, false, NULL); + if (is_cilk_simd_fn && TREE_CODE (step) == PARM_DECL) + { + sorry ("using parameters for %<linear%> step is not supported yet"); + step = integer_one_node; + } if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, /*or_comma=*/false, @@ -27958,6 +28087,7 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, tree clauses = NULL; bool first = true; cp_token *token = NULL; + bool cilk_simd_fn = false; while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL)) { @@ -28054,11 +28184,13 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, c_name = "untied"; break; case PRAGMA_OMP_CLAUSE_INBRANCH: + case PRAGMA_CILK_CLAUSE_MASK: clauses = cp_parser_omp_clause_branch (parser, OMP_CLAUSE_INBRANCH, clauses, token->location); c_name = "inbranch"; break; case PRAGMA_OMP_CLAUSE_NOTINBRANCH: + case PRAGMA_CILK_CLAUSE_NOMASK: clauses = cp_parser_omp_clause_branch (parser, OMP_CLAUSE_NOTINBRANCH, clauses, token->location); @@ -28127,7 +28259,9 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, c_name = "aligned"; break; case PRAGMA_OMP_CLAUSE_LINEAR: - clauses = cp_parser_omp_clause_linear (parser, clauses); + if (((mask >> PRAGMA_CILK_CLAUSE_VECTORLENGTH) & 1) != 0) + cilk_simd_fn = true; + clauses = cp_parser_omp_clause_linear (parser, clauses, cilk_simd_fn); c_name = "linear"; break; case PRAGMA_OMP_CLAUSE_DEPEND: @@ -28163,6 +28297,10 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, token->location); c_name = "simdlen"; break; + case PRAGMA_CILK_CLAUSE_VECTORLENGTH: + clauses = cp_parser_cilk_simd_vectorlength (parser, clauses, true); + c_name = "simdlen"; + break; default: cp_parser_error (parser, "expected %<#pragma omp%> clause"); goto saw_error; @@ -28179,7 +28317,10 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, } } saw_error: - cp_parser_skip_to_pragma_eol (parser, pragma_tok); + /* In Cilk Plus SIMD enabled functions there is no pragma_token, so + no reason to skip to the end. */ + if (!(flag_cilkplus && pragma_tok == NULL)) + cp_parser_skip_to_pragma_eol (parser, pragma_tok); if (finish_p) return finish_omp_clauses (clauses); return clauses; @@ -30181,6 +30322,63 @@ cp_parser_omp_declare_simd (cp_parser *parser, cp_token *pragma_tok, } } +/* Handles the delayed parsing of the Cilk Plus SIMD-enabled function. + This function is modelled similar to the late parsing of omp declare + simd. */ + +static tree +cp_parser_late_parsing_cilk_simd_fn_info (cp_parser *parser, tree attrs) +{ + struct cp_token_cache *ce; + cp_omp_declare_simd_data *info = parser->cilk_simd_fn_info; + int ii = 0; + + if (parser->omp_declare_simd != NULL) + { + error ("%<#pragma omp declare simd%> cannot be used in the same function" + " marked as a Cilk Plus SIMD-enabled function"); + XDELETE (parser->cilk_simd_fn_info); + parser->cilk_simd_fn_info = NULL; + return attrs; + } + if (!info->error_seen && info->fndecl_seen) + { + error ("vector attribute not immediately followed by a single function" + " declaration or definition"); + info->error_seen = true; + } + if (info->error_seen) + return attrs; + + FOR_EACH_VEC_ELT (info->tokens, ii, ce) + { + tree c, cl; + + cp_parser_push_lexer_for_tokens (parser, ce); + parser->lexer->in_pragma = true; + cl = cp_parser_omp_all_clauses (parser, CILK_SIMD_FN_CLAUSE_MASK, + "SIMD-enabled functions attribute", + NULL); + cp_parser_pop_lexer (parser); + if (cl) + cl = tree_cons (NULL_TREE, cl, NULL_TREE); + + c = build_tree_list (get_identifier ("cilk simd function"), NULL_TREE); + TREE_CHAIN (c) = attrs; + attrs = c; + + c = build_tree_list (get_identifier ("omp declare simd"), cl); + TREE_CHAIN (c) = attrs; + if (processing_template_decl) + ATTR_IS_DEPENDENT (c) = 1; + attrs = c; + } + info->fndecl_seen = true; + XDELETE (parser->cilk_simd_fn_info); + parser->cilk_simd_fn_info = NULL; + return attrs; +} + /* Finalize #pragma omp declare simd clauses after direct declarator has been parsed, and put that into "omp declare simd" attribute. */ @@ -31361,35 +31559,63 @@ c_parse_file (void) the_parser = NULL; } -/* Parses the Cilk Plus #pragma simd vectorlength clause: +/* Parses the Cilk Plus #pragma simd and SIMD-enabled function attribute's + vectorlength clause: Syntax: vectorlength ( constant-expression ) */ static tree -cp_parser_cilk_simd_vectorlength (cp_parser *parser, tree clauses) +cp_parser_cilk_simd_vectorlength (cp_parser *parser, tree clauses, + bool is_simd_fn) { location_t loc = cp_lexer_peek_token (parser->lexer)->location; tree expr; - /* The vectorlength clause behaves exactly like OpenMP's safelen - clause. Thus, vectorlength is represented as OMP 4.0 - safelen. */ - check_no_duplicate_clause (clauses, OMP_CLAUSE_SAFELEN, "vectorlength", loc); - + /* The vectorlength clause in #pragma simd behaves exactly like OpenMP's + safelen clause. Thus, vectorlength is represented as OMP 4.0 + safelen. For SIMD-enabled function it is represented by OMP 4.0 + simdlen. */ + if (!is_simd_fn) + check_no_duplicate_clause (clauses, OMP_CLAUSE_SAFELEN, "vectorlength", + loc); + else + check_no_duplicate_clause (clauses, OMP_CLAUSE_SIMDLEN, "vectorlength", + loc); + if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return error_mark_node; expr = cp_parser_constant_expression (parser, false, NULL); expr = maybe_constant_value (expr); - - if (TREE_CONSTANT (expr) + + /* If expr == error_mark_node, then don't emit any errors nor + create a clause. if any of the above functions returns + error mark node then they would have emitted an error message. */ + if (expr == error_mark_node) + ; + else if (!TREE_TYPE (expr) + || !TREE_CONSTANT (expr) + || !INTEGRAL_TYPE_P (TREE_TYPE (expr))) + error_at (loc, "vectorlength must be an integer constant"); + else if (TREE_CONSTANT (expr) && exact_log2 (TREE_INT_CST_LOW (expr)) == -1) error_at (loc, "vectorlength must be a power of 2"); - else if (expr != error_mark_node) + else { - tree c = build_omp_clause (loc, OMP_CLAUSE_SAFELEN); - OMP_CLAUSE_SAFELEN_EXPR (c) = expr; - OMP_CLAUSE_CHAIN (c) = clauses; - clauses = c; + tree c; + if (!is_simd_fn) + { + c = build_omp_clause (loc, OMP_CLAUSE_SAFELEN); + OMP_CLAUSE_SAFELEN_EXPR (c) = expr; + OMP_CLAUSE_CHAIN (c) = clauses; + clauses = c; + } + else + { + c = build_omp_clause (loc, OMP_CLAUSE_SIMDLEN); + OMP_CLAUSE_SIMDLEN_EXPR (c) = expr; + OMP_CLAUSE_CHAIN (c) = clauses; + clauses = c; + } } if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) @@ -31552,7 +31778,7 @@ cp_parser_cilk_simd_all_clauses (cp_parser *parser, cp_token *pragma_token) pragma_omp_clause c_kind; c_kind = cp_parser_cilk_simd_clause_name (parser); if (c_kind == PRAGMA_CILK_CLAUSE_VECTORLENGTH) - clauses = cp_parser_cilk_simd_vectorlength (parser, clauses); + clauses = cp_parser_cilk_simd_vectorlength (parser, clauses, false); else if (c_kind == PRAGMA_CILK_CLAUSE_LINEAR) clauses = cp_parser_cilk_simd_linear (parser, clauses); else if (c_kind == PRAGMA_CILK_CLAUSE_PRIVATE) diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h index 484a8cd5538..d558c607f4d 100644 --- a/gcc/cp/parser.h +++ b/gcc/cp/parser.h @@ -362,6 +362,13 @@ typedef struct GTY(()) cp_parser { data structure with everything needed for parsing the clauses. */ cp_omp_declare_simd_data * GTY((skip)) omp_declare_simd; + /* When parsing the vector attribute in Cilk Plus SIMD-enabled function, + this is a pointer to data structure with everything needed for parsing + the clauses. The cp_omp_declare_simd_data struct will hold all the + necessary information, so creating another struct for this is not + necessary. */ + cp_omp_declare_simd_data * GTY((skip)) cilk_simd_fn_info; + /* Nonzero if parsing a parameter list where 'auto' should trigger an implicit template parameter. */ bool auto_is_implicit_function_template_parm_p; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2e7cf60ba7d..47d07dbd7c0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3854,6 +3854,7 @@ template_parm_to_arg (tree t) SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec)); #endif + t = convert_from_reference (t); TREE_VEC_ELT (vec, 0) = make_pack_expansion (t); t = make_node (NONTYPE_ARGUMENT_PACK); @@ -8613,7 +8614,7 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, { *p = TREE_CHAIN (t); TREE_CHAIN (t) = NULL_TREE; - if (flag_openmp + if ((flag_openmp || flag_cilkplus) && is_attribute_p ("omp declare simd", get_attribute_name (t)) && TREE_VALUE (t)) @@ -9281,10 +9282,6 @@ tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl) /*integral_constant_expression_p=*/true); if (!(complain & tf_warning)) --c_inhibit_evaluation_warnings; - /* Preserve the raw-reference nature of T. */ - if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE - && REFERENCE_REF_P (r)) - r = TREE_OPERAND (r, 0); } return r; } @@ -14977,12 +14974,12 @@ tsubst_copy_and_build (tree t, case TRAIT_EXPR: { - tree type1 = tsubst_copy (TRAIT_EXPR_TYPE1 (t), args, - complain, in_decl); + tree type1 = tsubst (TRAIT_EXPR_TYPE1 (t), args, + complain, in_decl); tree type2 = TRAIT_EXPR_TYPE2 (t); if (type2) - type2 = tsubst_copy (type2, args, complain, in_decl); + type2 = tsubst (type2, args, complain, in_decl); RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2)); } @@ -19670,6 +19667,10 @@ instantiate_decl (tree d, int defer_ok, so that finish_function knows where we are. */ input_location = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus; + + /* Remember if we saw an infinite loop in the template. */ + current_function_infinite_loop + = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop; } /* We don't need the local specializations any more. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index eb04266aee8..3a8dacad8ce 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -486,6 +486,62 @@ push_cleanup (tree decl, tree cleanup, bool eh_only) CLEANUP_BODY (stmt) = push_stmt_list (); } +/* Simple infinite loop tracking for -Wreturn-type. We keep a stack of all + the current loops, represented by 'NULL_TREE' if we've seen a possible + exit, and 'error_mark_node' if not. This is currently used only to + suppress the warning about a function with no return statements, and + therefore we don't bother noting returns as possible exits. We also + don't bother with gotos. */ + +static void +begin_maybe_infinite_loop (tree cond) +{ + /* Only track this while parsing a function, not during instantiation. */ + if (!cfun || (DECL_TEMPLATE_INSTANTIATION (current_function_decl) + && !processing_template_decl)) + return; + bool maybe_infinite = true; + if (cond) + { + cond = fold_non_dependent_expr (cond); + cond = maybe_constant_value (cond); + maybe_infinite = integer_nonzerop (cond); + } + vec_safe_push (cp_function_chain->infinite_loops, + maybe_infinite ? error_mark_node : NULL_TREE); + +} + +/* A break is a possible exit for the current loop. */ + +void +break_maybe_infinite_loop (void) +{ + if (!cfun) + return; + cp_function_chain->infinite_loops->last() = NULL_TREE; +} + +/* If we reach the end of the loop without seeing a possible exit, we have + an infinite loop. */ + +static void +end_maybe_infinite_loop (tree cond) +{ + if (!cfun || (DECL_TEMPLATE_INSTANTIATION (current_function_decl) + && !processing_template_decl)) + return; + tree current = cp_function_chain->infinite_loops->pop(); + if (current != NULL_TREE) + { + cond = fold_non_dependent_expr (cond); + cond = maybe_constant_value (cond); + if (integer_nonzerop (cond)) + current_function_infinite_loop = 1; + } +} + + /* Begin a conditional that might contain a declaration. When generating normal code, we want the declaration to appear before the statement containing the conditional. When generating template code, we want the @@ -732,7 +788,9 @@ begin_while_stmt (void) void finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep) { - finish_cond (&WHILE_COND (while_stmt), maybe_convert_cond (cond)); + cond = maybe_convert_cond (cond); + finish_cond (&WHILE_COND (while_stmt), cond); + begin_maybe_infinite_loop (cond); if (ivdep && cond != error_mark_node) WHILE_COND (while_stmt) = build2 (ANNOTATE_EXPR, TREE_TYPE (WHILE_COND (while_stmt)), @@ -747,6 +805,7 @@ finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep) void finish_while_stmt (tree while_stmt) { + end_maybe_infinite_loop (boolean_true_node); WHILE_BODY (while_stmt) = do_poplevel (WHILE_BODY (while_stmt)); } @@ -757,6 +816,7 @@ tree begin_do_stmt (void) { tree r = build_stmt (input_location, DO_STMT, NULL_TREE, NULL_TREE); + begin_maybe_infinite_loop (boolean_true_node); add_stmt (r); DO_BODY (r) = push_stmt_list (); return r; @@ -784,6 +844,7 @@ void finish_do_stmt (tree cond, tree do_stmt, bool ivdep) { cond = maybe_convert_cond (cond); + end_maybe_infinite_loop (cond); if (ivdep && cond != error_mark_node) cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, build_int_cst (integer_type_node, annot_expr_ivdep_kind)); @@ -891,7 +952,9 @@ finish_for_init_stmt (tree for_stmt) void finish_for_cond (tree cond, tree for_stmt, bool ivdep) { - finish_cond (&FOR_COND (for_stmt), maybe_convert_cond (cond)); + cond = maybe_convert_cond (cond); + finish_cond (&FOR_COND (for_stmt), cond); + begin_maybe_infinite_loop (cond); if (ivdep && cond != error_mark_node) FOR_COND (for_stmt) = build2 (ANNOTATE_EXPR, TREE_TYPE (FOR_COND (for_stmt)), @@ -940,6 +1003,8 @@ finish_for_expr (tree expr, tree for_stmt) void finish_for_stmt (tree for_stmt) { + end_maybe_infinite_loop (boolean_true_node); + if (TREE_CODE (for_stmt) == RANGE_FOR_STMT) RANGE_FOR_BODY (for_stmt) = do_poplevel (RANGE_FOR_BODY (for_stmt)); else @@ -968,6 +1033,8 @@ begin_range_for_stmt (tree scope, tree init) { tree r; + begin_maybe_infinite_loop (boolean_false_node); + r = build_stmt (input_location, RANGE_FOR_STMT, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); @@ -4971,6 +5038,10 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor) case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: + if (FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE) + break; + predefined = true; + break; case TRUTH_ANDIF_EXPR: case TRUTH_ORIF_EXPR: if (FLOAT_TYPE_P (type)) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 84e287e56bc..6268f7bfbba 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3012,7 +3012,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx, /* If an array's index is an array notation, then its rank cannot be greater than one. */ - if (flag_enable_cilkplus && contains_array_notation_expr (idx)) + if (flag_cilkplus && contains_array_notation_expr (idx)) { size_t rank = 0; @@ -4838,7 +4838,8 @@ cp_build_binary_op (location_t location, tree xop0 = op0, xop1 = op1, xresult_type = result_type; enum tree_code xresultcode = resultcode; tree val - = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode); + = shorten_compare (location, &xop0, &xop1, &xresult_type, + &xresultcode); if (val != 0) return cp_convert (boolean_type_node, val, complain); op0 = xop0, op1 = xop1; @@ -5043,6 +5044,14 @@ pointer_diff (tree op0, tree op1, tree ptrtype, tsubst_flags_t complain) return error_mark_node; } + if (pointer_to_zero_sized_aggr_p (TREE_TYPE (op1))) + { + if (complain & tf_error) + error ("arithmetic on pointer to an empty aggregate"); + else + return error_mark_node; + } + op1 = (TYPE_PTROB_P (ptrtype) ? size_in_bytes (target_type) : integer_one_node); @@ -5173,7 +5182,9 @@ tree cp_truthvalue_conversion (tree expr) { tree type = TREE_TYPE (expr); - if (TYPE_PTRDATAMEM_P (type)) + if (TYPE_PTRDATAMEM_P (type) + /* Avoid ICE on invalid use of non-static member function. */ + || TREE_CODE (expr) == FUNCTION_DECL) return build_binary_op (EXPR_LOCATION (expr), NE_EXPR, expr, nullptr_node, 1); else if (TYPE_PTR_P (type) || TYPE_PTRMEMFUNC_P (type)) @@ -6179,7 +6190,7 @@ cp_build_compound_expr (tree lhs, tree rhs, tsubst_flags_t complain) if (lhs == error_mark_node || rhs == error_mark_node) return error_mark_node; - if (flag_enable_cilkplus + if (flag_cilkplus && (TREE_CODE (lhs) == CILK_SPAWN_STMT || TREE_CODE (rhs) == CILK_SPAWN_STMT)) { @@ -7388,8 +7399,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, side effect associated with any single compound assignment operator. -- end note ] */ lhs = stabilize_reference (lhs); - if (TREE_SIDE_EFFECTS (rhs)) - rhs = mark_rvalue_use (rhs); + rhs = rvalue (rhs); rhs = stabilize_expr (rhs, &init); newrhs = cp_build_binary_op (input_location, modifycode, lhs, rhs, @@ -8314,7 +8324,7 @@ check_return_expr (tree retval, bool *no_warning) *no_warning = false; - if (flag_enable_cilkplus && retval && TREE_CODE (retval) == CILK_SPAWN_STMT) + if (flag_cilkplus && retval && TREE_CODE (retval) == CILK_SPAWN_STMT) { error_at (EXPR_LOCATION (retval), "use of %<_Cilk_spawn%> in a return " "statement is not allowed"); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 25edbacce96..a3fe2e39820 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -643,6 +643,8 @@ split_nonconstant_init_1 (tree dest, tree init) code = build_vec_init (sub, max, value, false, 0, tf_warning_or_error); add_stmt (code); + if (tree_fits_shwi_p (max)) + num_split_elts += tree_to_shwi (max); } else { @@ -1199,42 +1201,40 @@ process_init_constructor_array (tree type, tree init, flags |= picflag_from_initializer (ce->value); } - /* No more initializers. If the array is unbounded, or we've initialized - all the elements, we are done. Otherwise, we must add initializers - ourselves. */ - if (!unbounded && i < len) - { - tree next; - - if (type_build_ctor_call (TREE_TYPE (type))) - { - /* If this type needs constructors run for default-initialization, - we can't rely on the back end to do it for us, so make the - initialization explicit by list-initializing from {}. */ - next = build_constructor (init_list_type_node, NULL); - next = massage_init_elt (TREE_TYPE (type), next, complain); - if (initializer_zerop (next)) - /* The default zero-initialization is fine for us; don't - add anything to the CONSTRUCTOR. */ - next = NULL_TREE; - } - else if (!zero_init_p (TREE_TYPE (type))) - next = build_zero_init (TREE_TYPE (type), - /*nelts=*/NULL_TREE, - /*static_storage_p=*/false); - else - /* The default zero-initialization is fine for us; don't - add anything to the CONSTRUCTOR. */ - next = NULL_TREE; - - if (next) - { - flags |= picflag_from_initializer (next); - tree index = build2 (RANGE_EXPR, sizetype, size_int (i), - size_int (len - 1)); - CONSTRUCTOR_APPEND_ELT (v, index, next); - } - } + /* No more initializers. If the array is unbounded, we are done. Otherwise, + we must add initializers ourselves. */ + if (!unbounded) + for (; i < len; ++i) + { + tree next; + + if (type_build_ctor_call (TREE_TYPE (type))) + { + /* If this type needs constructors run for default-initialization, + we can't rely on the back end to do it for us, so make the + initialization explicit by list-initializing from {}. */ + next = build_constructor (init_list_type_node, NULL); + next = massage_init_elt (TREE_TYPE (type), next, complain); + if (initializer_zerop (next)) + /* The default zero-initialization is fine for us; don't + add anything to the CONSTRUCTOR. */ + next = NULL_TREE; + } + else if (!zero_init_p (TREE_TYPE (type))) + next = build_zero_init (TREE_TYPE (type), + /*nelts=*/NULL_TREE, + /*static_storage_p=*/false); + else + /* The default zero-initialization is fine for us; don't + add anything to the CONSTRUCTOR. */ + next = NULL_TREE; + + if (next) + { + flags |= picflag_from_initializer (next); + CONSTRUCTOR_APPEND_ELT (v, size_int (i), next); + } + } CONSTRUCTOR_ELTS (init) = v; return flags; diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c index f0d539b231b..8b2c6b4d3d2 100644 --- a/gcc/cppbuiltin.c +++ b/gcc/cppbuiltin.c @@ -105,7 +105,7 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile) cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d", flag_finite_math_only); - if (flag_enable_cilkplus) + if (flag_cilkplus) cpp_define (pfile, "__cilk=200"); } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6fe8cd2d7df..de4104bc596 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -919,6 +919,7 @@ See RS/6000 and PowerPC Options. -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol -mcrypto -mno-crypto -mdirect-move -mno-direct-move @gol -mquad-memory -mno-quad-memory @gol +-mquad-memory-atomic -mno-quad-memory-atomic @gol -mcompat-align-parm -mno-compat-align-parm} @emph{RX Options} @@ -18858,7 +18859,8 @@ following options: -mpopcntb -mpopcntd -mpowerpc64 @gol -mpowerpc-gpopt -mpowerpc-gfxopt -msingle-float -mdouble-float @gol -msimple-fpu -mstring -mmulhw -mdlmzb -mmfpgpr -mvsx @gol --mcrypto -mdirect-move -mpower8-fusion -mpower8-vector -mquad-memory} +-mcrypto -mdirect-move -mpower8-fusion -mpower8-vector @gol +-mquad-memory -mquad-memory-atomic} The particular options set for any particular CPU varies between compiler versions, depending on what setting seems to produce optimal @@ -19045,10 +19047,18 @@ the vector instructions. @itemx -mno-quad-memory @opindex mquad-memory @opindex mno-quad-memory -Generate code that uses (does not use) the quad word memory +Generate code that uses (does not use) the non-atomic quad word memory instructions. The @option{-mquad-memory} option requires use of 64-bit mode. +@item -mquad-memory-atomic +@itemx -mno-quad-memory-atomic +@opindex mquad-memory-atomic +@opindex mno-quad-memory-atomic +Generate code that uses (does not use) the atomic quad word memory +instructions. The @option{-mquad-memory-atomic} option requires use of +64-bit mode. + @item -mfloat-gprs=@var{yes/single/double/no} @itemx -mfloat-gprs @opindex mfloat-gprs diff --git a/gcc/expmed.h b/gcc/expmed.h index 9681e41fbde..4d01d1f0ec8 100644 --- a/gcc/expmed.h +++ b/gcc/expmed.h @@ -221,12 +221,21 @@ expmed_mode_index (enum machine_mode mode) case MODE_INT: return mode - MIN_MODE_INT; case MODE_PARTIAL_INT: - return mode - MIN_MODE_PARTIAL_INT + NUM_MODE_INT; + /* If there are no partial integer modes, help the compiler + to figure out this will never happen. See PR59934. */ + if (MIN_MODE_PARTIAL_INT != VOIDmode) + return mode - MIN_MODE_PARTIAL_INT + NUM_MODE_INT; + break; case MODE_VECTOR_INT: - return mode - MIN_MODE_VECTOR_INT + NUM_MODE_IP_INT; + /* If there are no vector integer modes, help the compiler + to figure out this will never happen. See PR59934. */ + if (MIN_MODE_VECTOR_INT != VOIDmode) + return mode - MIN_MODE_VECTOR_INT + NUM_MODE_IP_INT; + break; default: - gcc_unreachable (); + break; } + gcc_unreachable (); } /* Return a pointer to a boolean contained in EOC indicating whether diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 802ca732148..aacf31b3c6b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2014-01-26 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/58007 + * module.c (read_module): Assert for component name correctness. + 2014-01-18 Mikael Morin <mikael@gcc.gnu.org> PR fortran/58007 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 90fe7b94841..52fdebe340c 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4613,6 +4613,7 @@ read_module (void) for (c = sym->components; c; c = c->next) { pointer_info *p; + const char *comp_name; int n; mio_lparen (); /* component opening. */ @@ -4620,6 +4621,8 @@ read_module (void) p = get_integer (n); if (p->u.pointer == NULL) associate_integer_pointer (p, c); + mio_pool_string (&comp_name); + gcc_assert (comp_name == c->name); skip_list (1); /* component end. */ } mio_rparen (); /* component list closing. */ diff --git a/gcc/gimple-builder.h b/gcc/gimple-builder.h index a00d979ba12..1b5afdc6f91 100644 --- a/gcc/gimple-builder.h +++ b/gcc/gimple-builder.h @@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_GIMPLE_BUILDER_H #define GCC_GIMPLE_BUILDER_H -tree create_gimple_tmp (tree, tree lhs = NULL_TREE); gimple build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE); gimple build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE); gimple build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE); diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 68784052b05..c571d4d5a4b 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2014-01-24 Chris Manghane <cmang@google.com> + + * go-gcc.cc (Gcc_backend::unary_expression): New function. + 2014-01-16 Chris Manghane <cmang@google.com> * go-gcc.cc (Gcc_backend::conditional_expression): Add btype diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 6a0d1e7a001..b2760f131d8 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -254,6 +254,9 @@ class Gcc_backend : public Backend Location); Bexpression* + unary_expression(Operator, Bexpression*, Location); + + Bexpression* binary_expression(Operator, Bexpression*, Bexpression*, Location); // Statements. @@ -1081,6 +1084,47 @@ Gcc_backend::conditional_expression(Btype* btype, Bexpression* condition, return this->make_expression(ret); } +// Return an expression for the unary operation OP EXPR. + +Bexpression* +Gcc_backend::unary_expression(Operator op, Bexpression* expr, Location location) +{ + tree expr_tree = expr->get_tree(); + if (expr_tree == error_mark_node + || TREE_TYPE(expr_tree) == error_mark_node) + return this->error_expression(); + + tree type_tree = TREE_TYPE(expr_tree); + enum tree_code code; + switch (op) + { + case OPERATOR_MINUS: + { + tree computed_type = excess_precision_type(type_tree); + if (computed_type != NULL_TREE) + { + expr_tree = convert(computed_type, expr_tree); + type_tree = computed_type; + } + code = NEGATE_EXPR; + break; + } + case OPERATOR_NOT: + code = TRUTH_NOT_EXPR; + break; + case OPERATOR_XOR: + code = BIT_NOT_EXPR; + break; + default: + gcc_unreachable(); + break; + } + + tree ret = fold_build1_loc(location.gcc_location(), code, type_tree, + expr_tree); + return this->make_expression(ret); +} + // Convert a gofrontend operator to an equivalent tree_code. static enum tree_code diff --git a/gcc/go/gofrontend/backend.h b/gcc/go/gofrontend/backend.h index e3025167fd4..cbe5f22b6ad 100644 --- a/gcc/go/gofrontend/backend.h +++ b/gcc/go/gofrontend/backend.h @@ -298,6 +298,12 @@ class Backend Bexpression* then_expr, Bexpression* else_expr, Location) = 0; + // Return an expression for the unary operation OP EXPR. + // Supported values of OP are (from operators.h): + // MINUS, NOT, XOR. + virtual Bexpression* + unary_expression(Operator op, Bexpression* expr, Location) = 0; + // Return an expression for the binary operation LEFT OP RIGHT. // Supported values of OP are (from operators.h): // EQEQ, NOTEQ, LT, LE, GT, GE, PLUS, MINUS, OR, XOR, MULT, DIV, MOD, diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 544996ea6cb..5bc6a87e5c5 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -1464,6 +1464,10 @@ class Func_code_reference_expression : public Expression do_traverse(Traverse*) { return TRAVERSE_CONTINUE; } + bool + do_is_immutable() const + { return true; } + Type* do_type() { return Type::make_pointer_type(Type::make_void_type()); } @@ -2941,6 +2945,10 @@ class Nil_expression : public Expression do_is_constant() const { return true; } + bool + do_is_immutable() const + { return true; } + Type* do_type() { return Type::make_nil_type(); } @@ -3682,10 +3690,17 @@ class Unary_expression : public Expression Expression* do_lower(Gogo*, Named_object*, Statement_inserter*, int); + Expression* + do_flatten(Gogo*, Named_object*, Statement_inserter*); + bool do_is_constant() const; bool + do_is_immutable() const + { return this->expr_->is_immutable(); } + + bool do_numeric_constant_value(Numeric_constant*) const; Type* @@ -3806,6 +3821,45 @@ Unary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int) return this; } +// Flatten expression if a nil check must be performed and create temporary +// variables if necessary. + +Expression* +Unary_expression::do_flatten(Gogo* gogo, Named_object*, + Statement_inserter* inserter) +{ + Location location = this->location(); + if (this->op_ == OPERATOR_MULT + && !this->expr_->is_variable()) + { + go_assert(this->expr_->type()->points_to() != NULL); + Type* ptype = this->expr_->type()->points_to(); + if (!ptype->is_void_type()) + { + Btype* pbtype = ptype->get_backend(gogo); + size_t s = gogo->backend()->type_size(pbtype); + if (s >= 4096 || this->issue_nil_check_) + { + Temporary_statement* temp = + Statement::make_temporary(NULL, this->expr_, location); + inserter->insert(temp); + this->expr_ = + Expression::make_temporary_reference(temp, location); + } + } + } + + if (this->create_temp_ && !this->expr_->is_variable()) + { + Temporary_statement* temp = + Statement::make_temporary(NULL, this->expr_, location); + inserter->insert(temp); + this->expr_ = Expression::make_temporary_reference(temp, location); + } + + return this; +} + // Return whether a unary expression is a constant. bool @@ -3821,8 +3875,8 @@ Unary_expression::do_is_constant() const else if (this->op_ == OPERATOR_AND) { // Taking the address of a variable is constant if it is a - // global variable, not constant otherwise. In other cases - // taking the address is probably not a constant. + // global variable, not constant otherwise. In other cases taking the + // address is probably not a constant. Var_expression* ve = this->expr_->var_expression(); if (ve != NULL) { @@ -4151,58 +4205,40 @@ Unary_expression::do_get_tree(Translate_context* context) { Temporary_statement* temp = sut->temporary(); Bvariable* bvar = temp->get_backend_variable(context); - tree var_tree = var_to_tree(bvar); - Expression* val = sut->expression(); - tree val_tree = val->get_tree(context); - if (var_tree == error_mark_node || val_tree == error_mark_node) - return error_mark_node; - tree addr_tree = build_fold_addr_expr_loc(loc.gcc_location(), - var_tree); - return build2_loc(loc.gcc_location(), COMPOUND_EXPR, - TREE_TYPE(addr_tree), - build2_loc(sut->location().gcc_location(), - MODIFY_EXPR, void_type_node, - var_tree, val_tree), - addr_tree); + Bexpression* bvar_expr = gogo->backend()->var_expression(bvar, loc); + + Expression* val = sut->expression(); + Bexpression* bval = tree_to_expr(val->get_tree(context)); + + Bstatement* bassign = + gogo->backend()->assignment_statement(bvar_expr, bval, loc); + Bexpression* bvar_addr = + gogo->backend()->address_expression(bvar_expr, loc); + Bexpression* ret = + gogo->backend()->compound_expression(bassign, bvar_addr, loc); + return expr_to_tree(ret); } } + Bexpression* ret; tree expr = this->expr_->get_tree(context); - if (expr == error_mark_node) - return error_mark_node; - + Bexpression* bexpr = tree_to_expr(expr); + Btype* btype = this->expr_->type()->get_backend(gogo); switch (this->op_) { case OPERATOR_PLUS: - return expr; + ret = bexpr; + break; case OPERATOR_MINUS: - { - tree type = TREE_TYPE(expr); - tree compute_type = excess_precision_type(type); - if (compute_type != NULL_TREE) - expr = ::convert(compute_type, expr); - tree ret = fold_build1_loc(loc.gcc_location(), NEGATE_EXPR, - (compute_type != NULL_TREE - ? compute_type - : type), - expr); - if (compute_type != NULL_TREE) - ret = ::convert(type, ret); - return ret; - } + ret = gogo->backend()->unary_expression(this->op_, bexpr, loc); + ret = gogo->backend()->convert_expression(btype, ret, loc); + break; case OPERATOR_NOT: - if (TREE_CODE(TREE_TYPE(expr)) == BOOLEAN_TYPE) - return fold_build1_loc(loc.gcc_location(), TRUTH_NOT_EXPR, - TREE_TYPE(expr), expr); - else - return fold_build2_loc(loc.gcc_location(), NE_EXPR, boolean_type_node, - expr, build_int_cst(TREE_TYPE(expr), 0)); - case OPERATOR_XOR: - return fold_build1_loc(loc.gcc_location(), BIT_NOT_EXPR, TREE_TYPE(expr), - expr); + ret = gogo->backend()->unary_expression(this->op_, bexpr, loc); + break; case OPERATOR_AND: if (!this->create_temp_) @@ -4211,127 +4247,91 @@ Unary_expression::do_get_tree(Translate_context* context) // where we would see one should have been moved onto the // heap at parse time. Taking the address of a nonconstant // constructor will not do what the programmer expects. - go_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr)); - go_assert(TREE_CODE(expr) != ADDR_EXPR); + + go_assert(!this->expr_->is_composite_literal() + || this->expr_->is_immutable()); + Unary_expression* ue = static_cast<Unary_expression*>(this->expr_); + go_assert(ue == NULL || ue->op() != OPERATOR_AND); } // Build a decl for a constant constructor. - if (TREE_CODE(expr) == CONSTRUCTOR && TREE_CONSTANT(expr)) - { - tree decl = build_decl(this->location().gcc_location(), VAR_DECL, - create_tmp_var_name("C"), TREE_TYPE(expr)); - DECL_EXTERNAL(decl) = 0; - TREE_PUBLIC(decl) = 0; - TREE_READONLY(decl) = 1; - TREE_CONSTANT(decl) = 1; - TREE_STATIC(decl) = 1; - TREE_ADDRESSABLE(decl) = 1; - DECL_ARTIFICIAL(decl) = 1; - DECL_INITIAL(decl) = expr; - rest_of_decl_compilation(decl, 1, 0); - expr = decl; - } - - if (this->create_temp_ - && !TREE_ADDRESSABLE(TREE_TYPE(expr)) - && (TREE_CODE(expr) == CONST_DECL || !DECL_P(expr)) - && TREE_CODE(expr) != INDIRECT_REF - && TREE_CODE(expr) != COMPONENT_REF) - { - if (current_function_decl != NULL) - { - tree tmp = create_tmp_var(TREE_TYPE(expr), get_name(expr)); - DECL_IGNORED_P(tmp) = 1; - DECL_INITIAL(tmp) = expr; - TREE_ADDRESSABLE(tmp) = 1; - return build2_loc(loc.gcc_location(), COMPOUND_EXPR, - build_pointer_type(TREE_TYPE(expr)), - build1_loc(loc.gcc_location(), DECL_EXPR, - void_type_node, tmp), - build_fold_addr_expr_loc(loc.gcc_location(), - tmp)); - } - else - { - tree tmp = build_decl(loc.gcc_location(), VAR_DECL, - create_tmp_var_name("A"), TREE_TYPE(expr)); - DECL_EXTERNAL(tmp) = 0; - TREE_PUBLIC(tmp) = 0; - TREE_STATIC(tmp) = 1; - DECL_ARTIFICIAL(tmp) = 1; - TREE_ADDRESSABLE(tmp) = 1; - tree make_tmp; - if (!TREE_CONSTANT(expr)) - make_tmp = fold_build2_loc(loc.gcc_location(), INIT_EXPR, - void_type_node, tmp, expr); - else - { - TREE_READONLY(tmp) = 1; - TREE_CONSTANT(tmp) = 1; - DECL_INITIAL(tmp) = expr; - make_tmp = NULL_TREE; - } - rest_of_decl_compilation(tmp, 1, 0); - tree addr = build_fold_addr_expr_loc(loc.gcc_location(), tmp); - if (make_tmp == NULL_TREE) - return addr; - return build2_loc(loc.gcc_location(), COMPOUND_EXPR, - TREE_TYPE(addr), make_tmp, addr); - } - } + if ((this->expr_->is_composite_literal() + || this->expr_->string_expression() != NULL) + && this->expr_->is_immutable()) + { + static unsigned int counter; + char buf[100]; + snprintf(buf, sizeof buf, "C%u", counter); + ++counter; + + Bvariable* decl = + gogo->backend()->immutable_struct(buf, true, false, btype, loc); + gogo->backend()->immutable_struct_set_init(decl, buf, true, false, + btype, loc, bexpr); + bexpr = gogo->backend()->var_expression(decl, loc); + } - return build_fold_addr_expr_loc(loc.gcc_location(), expr); + go_assert(!this->create_temp_ || this->expr_->is_variable()); + ret = gogo->backend()->address_expression(bexpr, loc); + break; case OPERATOR_MULT: { - go_assert(POINTER_TYPE_P(TREE_TYPE(expr))); + go_assert(this->expr_->type()->points_to() != NULL); // If we are dereferencing the pointer to a large struct, we // need to check for nil. We don't bother to check for small // structs because we expect the system to crash on a nil // pointer dereference. However, if we know the address of this // expression is being taken, we must always check for nil. - tree target_type_tree = TREE_TYPE(TREE_TYPE(expr)); - if (!VOID_TYPE_P(target_type_tree)) + + Type* ptype = this->expr_->type()->points_to(); + Btype* pbtype = ptype->get_backend(gogo); + if (!ptype->is_void_type()) { - HOST_WIDE_INT s = int_size_in_bytes(target_type_tree); - if (s == -1 || s >= 4096 || this->issue_nil_check_) + size_t s = gogo->backend()->type_size(pbtype); + if (s >= 4096 || this->issue_nil_check_) { - if (!DECL_P(expr)) - expr = save_expr(expr); - tree compare = fold_build2_loc(loc.gcc_location(), EQ_EXPR, - boolean_type_node, - expr, - fold_convert(TREE_TYPE(expr), - null_pointer_node)); + go_assert(this->expr_->is_variable()); + + Expression* nil_expr = Expression::make_nil(loc); + Bexpression* nil = tree_to_expr(nil_expr->get_tree(context)); + Bexpression* compare = + gogo->backend()->binary_expression(OPERATOR_EQEQ, bexpr, + nil, loc); + Expression* crash_expr = gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE, loc); - tree crash = crash_expr->get_tree(context); - expr = fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR, - TREE_TYPE(expr), build3(COND_EXPR, - void_type_node, - compare, crash, - NULL_TREE), - expr); + Bexpression* crash = + tree_to_expr(crash_expr->get_tree(context)); + bexpr = gogo->backend()->conditional_expression(btype, compare, + crash, bexpr, + loc); + } } // If the type of EXPR is a recursive pointer type, then we // need to insert a cast before indirecting. - if (VOID_TYPE_P(target_type_tree)) - { - Type* pt = this->expr_->type()->points_to(); - tree ind = type_to_tree(pt->get_backend(gogo)); - expr = fold_convert_loc(loc.gcc_location(), + tree expr = expr_to_tree(bexpr); + tree target_type_tree = TREE_TYPE(TREE_TYPE(expr)); + if (VOID_TYPE_P(target_type_tree)) + { + tree ind = type_to_tree(pbtype); + expr = fold_convert_loc(loc.gcc_location(), build_pointer_type(ind), expr); - } + bexpr = tree_to_expr(expr); + } - return build_fold_indirect_ref_loc(loc.gcc_location(), expr); + ret = gogo->backend()->indirect_expression(bexpr, false, loc); } + break; default: go_unreachable(); } + + return expr_to_tree(ret); } // Export a unary expression. @@ -12232,6 +12232,9 @@ class Struct_construction_expression : public Expression int do_traverse(Traverse* traverse); + bool + do_is_immutable() const; + Type* do_type() { return this->type_; } @@ -12334,6 +12337,23 @@ Struct_construction_expression::is_constant_struct() const return true; } +// Return whether this struct is immutable. + +bool +Struct_construction_expression::do_is_immutable() const +{ + if (this->vals_ == NULL) + return true; + for (Expression_list::const_iterator pv = this->vals_->begin(); + pv != this->vals_->end(); + ++pv) + { + if (*pv != NULL && !(*pv)->is_immutable()) + return false; + } + return true; +} + // Final type determination. void @@ -12546,6 +12566,9 @@ protected: int do_traverse(Traverse* traverse); + bool + do_is_immutable() const; + Type* do_type() { return this->type_; } @@ -12624,6 +12647,23 @@ Array_construction_expression::is_constant_array() const return true; } +// Return whether this is an immutable array initializer. + +bool +Array_construction_expression::do_is_immutable() const +{ + if (this->vals_ == NULL) + return true; + for (Expression_list::const_iterator pv = this->vals_->begin(); + pv != this->vals_->end(); + ++pv) + { + if (*pv != NULL && !(*pv)->is_immutable()) + return false; + } + return true; +} + // Final type determination. void @@ -14390,6 +14430,10 @@ class Type_descriptor_expression : public Expression do_type() { return Type::make_type_descriptor_ptr_type(); } + bool + do_is_immutable() const + { return true; } + void do_determine_type(const Type_context*) { } diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 9ddd17122f2..575df0f08ee 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -403,6 +403,11 @@ class Expression is_constant() const { return this->do_is_constant(); } + // Return whether this is an immutable expression. + bool + is_immutable() const + { return this->do_is_immutable(); } + // If this is not a numeric constant, return false. If it is one, // return true, and set VAL to hold the value. bool @@ -758,6 +763,11 @@ class Expression do_is_constant() const { return false; } + // Return whether this is an immutable expression. + virtual bool + do_is_immutable() const + { return false; } + // Return whether this is a constant expression of numeric type, and // set the Numeric_constant to the value. virtual bool @@ -1196,6 +1206,10 @@ class String_expression : public Expression { return true; } bool + do_is_immutable() const + { return true; } + + bool do_string_constant_value(std::string* val) const { *val = this->val_; diff --git a/gcc/go/gofrontend/go.cc b/gcc/go/gofrontend/go.cc index 26e83a1db64..ac772a095f7 100644 --- a/gcc/go/gofrontend/go.cc +++ b/gcc/go/gofrontend/go.cc @@ -119,6 +119,9 @@ go_parse_input_files(const char** filenames, unsigned int filename_count, // Use temporary variables to force order of evaluation. ::gogo->order_evaluations(); + // Convert named types to backend representation. + ::gogo->convert_named_types(); + // Flatten the parse tree. ::gogo->flatten(); diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index b04e660a92d..1950090b9e0 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -755,7 +755,6 @@ sort_var_inits(Gogo* gogo, Var_inits* var_inits) void Gogo::write_globals() { - this->convert_named_types(); this->build_interface_method_tables(); Bindings* bindings = this->current_bindings(); diff --git a/gcc/input.c b/gcc/input.c index 290680c1e5a..547c177b09f 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -293,11 +293,8 @@ add_file_to_cache_tab (const char *file_path) { FILE *fp = fopen (file_path, "r"); - if (ferror (fp)) - { - fclose (fp); - return NULL; - } + if (fp == NULL) + return NULL; unsigned highest_use_count = 0; fcache *r = evicted_cache_tab_entry (&highest_use_count); diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 12ee84c5465..5f47e0b4e1a 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -1597,7 +1597,7 @@ inline_small_functions (void) max_size = compute_max_insns (overall_size); min_size = overall_size; - /* Populate the heeap with all edges we might inline. */ + /* Populate the heap with all edges we might inline. */ FOR_EACH_DEFINED_FUNCTION (node) { diff --git a/gcc/ira.c b/gcc/ira.c index 772646a3981..7c49b7f6b74 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -2405,7 +2405,7 @@ ira_setup_eliminable_regset (void) || (SUPPORTS_STACK_ALIGNMENT && crtl->stack_realign_needed) /* We need a frame pointer for all Cilk Plus functions that use Cilk keywords. */ - || (flag_enable_cilkplus && cfun->is_cilk_function) + || (flag_cilkplus && cfun->is_cilk_function) || targetm.frame_pointer_required ()); /* The chance that FRAME_POINTER_NEEDED is changed from inspecting diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 7454229a7d6..34159f75a10 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -1291,9 +1291,20 @@ simplify_operand_subreg (int nop, enum machine_mode reg_mode) && ! LRA_SUBREG_P (operand)) || CONSTANT_P (reg) || GET_CODE (reg) == PLUS || MEM_P (reg)) { - /* The class will be defined later in curr_insn_transform. */ - enum reg_class rclass - = (enum reg_class) targetm.preferred_reload_class (reg, ALL_REGS); + enum reg_class rclass; + + if (REG_P (reg) + && curr_insn_set != NULL_RTX + && (REG_P (SET_SRC (curr_insn_set)) + || GET_CODE (SET_SRC (curr_insn_set)) == SUBREG)) + /* There is big probability that we will get the same class + for the new pseudo and we will get the same insn which + means infinite looping. So spill the new pseudo. */ + rclass = NO_REGS; + else + /* The class will be defined later in curr_insn_transform. */ + rclass + = (enum reg_class) targetm.preferred_reload_class (reg, ALL_REGS); if (get_reload_reg (curr_static_id->operand[nop].type, reg_mode, reg, rclass, "subreg reg", &new_reg)) diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 152fa233e9e..8eede88031c 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,8 @@ +2014-01-24 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * lto-lang.c (lto_init): Replaced flag_enable_cilkplus with + flag_cilkplus. + 2014-01-09 Richard Biener <rguenther@suse.de> * lto.c (gimple_canonical_types_compatible_p): Fix comment. diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index d29b8e52617..b5e5d6a6b57 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1183,7 +1183,7 @@ lto_init (void) build_reference_type (va_list_type_node)); } - if (flag_enable_cilkplus) + if (flag_cilkplus) cilk_init_builtins (); targetm.init_builtins (); diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 5a09b33b2d3..eeba4ae8470 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -8328,7 +8328,7 @@ static bool gate_expand_omp (void) { return ((flag_openmp != 0 || flag_openmp_simd != 0 - || flag_enable_cilkplus != 0) && !seen_error ()); + || flag_cilkplus != 0) && !seen_error ()); } namespace { @@ -10139,7 +10139,7 @@ execute_lower_omp (void) /* This pass always runs, to provide PROP_gimple_lomp. But there is nothing to do unless -fopenmp is given. */ - if (flag_openmp == 0 && flag_openmp_simd == 0 && flag_enable_cilkplus == 0) + if (flag_openmp == 0 && flag_openmp_simd == 0 && flag_cilkplus == 0) return 0; all_contexts = splay_tree_new (splay_tree_compare_pointers, 0, @@ -10258,7 +10258,7 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p, #endif bool cilkplus_block = false; - if (flag_enable_cilkplus) + if (flag_cilkplus) { if ((branch_ctx && gimple_code (branch_ctx) == GIMPLE_OMP_FOR @@ -10587,7 +10587,7 @@ diagnose_omp_structured_block_errors (void) static bool gate_diagnose_omp_blocks (void) { - return flag_openmp || flag_enable_cilkplus; + return flag_openmp || flag_cilkplus; } namespace { @@ -10696,7 +10696,7 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, be cloned have a distinctive artificial label in addition to "omp declare simd". */ bool cilk_clone - = (flag_enable_cilkplus + = (flag_cilkplus && lookup_attribute ("cilk simd function", DECL_ATTRIBUTES (node->decl))); @@ -11781,7 +11781,7 @@ public: /* opt_pass methods: */ bool gate () { return ((flag_openmp || flag_openmp_simd - || flag_enable_cilkplus || (in_lto_p && !flag_wpa)) + || flag_cilkplus || (in_lto_p && !flag_wpa)) && (targetm.simd_clone.compute_vecsize_and_simdlen != NULL)); } unsigned int execute () { return ipa_omp_simd_clone (); } diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 6cf339f1c80..5f2a4454a0f 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -51,6 +51,8 @@ static int sawclose = 0; static int indent; +static bool in_call_function_usage; + static void print_rtx (const_rtx); /* String printed at beginning of each RTL when it is dumped. @@ -153,7 +155,8 @@ print_rtx (const_rtx in_rtx) if ((GET_CODE (in_rtx) == EXPR_LIST || GET_CODE (in_rtx) == INSN_LIST || GET_CODE (in_rtx) == INT_LIST) - && (int)GET_MODE (in_rtx) < REG_NOTE_MAX) + && (int)GET_MODE (in_rtx) < REG_NOTE_MAX + && !in_call_function_usage) fprintf (outfile, ":%s", GET_REG_NOTE_NAME (GET_MODE (in_rtx))); @@ -350,7 +353,14 @@ print_rtx (const_rtx in_rtx) print_rtx_head, indent * 2, ""); if (!sawclose) fprintf (outfile, " "); - print_rtx (XEXP (in_rtx, i)); + if (i == 8 && CALL_P (in_rtx)) + { + in_call_function_usage = true; + print_rtx (XEXP (in_rtx, i)); + in_call_function_usage = false; + } + else + print_rtx (XEXP (in_rtx, i)); indent -= 2; break; diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index aff8f53e6f4..7a9efecddda 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -5051,23 +5051,24 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest, ??? This mode check should perhaps look more like the mode check in simplify_comparison in combine. */ - - if ((GET_CODE (SET_SRC (set)) == COMPARE - || (((code == NE - || (code == LT - && val_signbit_known_set_p (inner_mode, - STORE_FLAG_VALUE)) + if (((GET_MODE_CLASS (mode) == MODE_CC) + != (GET_MODE_CLASS (inner_mode) == MODE_CC)) + && mode != VOIDmode + && inner_mode != VOIDmode) + break; + if (GET_CODE (SET_SRC (set)) == COMPARE + || (((code == NE + || (code == LT + && val_signbit_known_set_p (inner_mode, + STORE_FLAG_VALUE)) #ifdef FLOAT_STORE_FLAG_VALUE - || (code == LT - && SCALAR_FLOAT_MODE_P (inner_mode) - && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode), - REAL_VALUE_NEGATIVE (fsfv))) + || (code == LT + && SCALAR_FLOAT_MODE_P (inner_mode) + && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode), + REAL_VALUE_NEGATIVE (fsfv))) #endif - )) - && COMPARISON_P (SET_SRC (set)))) - && (((GET_MODE_CLASS (mode) == MODE_CC) - == (GET_MODE_CLASS (inner_mode) == MODE_CC)) - || mode == VOIDmode || inner_mode == VOIDmode)) + )) + && COMPARISON_P (SET_SRC (set)))) x = SET_SRC (set); else if (((code == EQ || (code == GE @@ -5080,15 +5081,25 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest, REAL_VALUE_NEGATIVE (fsfv))) #endif )) - && COMPARISON_P (SET_SRC (set)) - && (((GET_MODE_CLASS (mode) == MODE_CC) - == (GET_MODE_CLASS (inner_mode) == MODE_CC)) - || mode == VOIDmode || inner_mode == VOIDmode)) - + && COMPARISON_P (SET_SRC (set))) { reverse_code = 1; x = SET_SRC (set); } + else if ((code == EQ || code == NE) + && GET_CODE (SET_SRC (set)) == XOR) + /* Handle sequences like: + + (set op0 (xor X Y)) + ...(eq|ne op0 (const_int 0))... + + in which case: + + (eq op0 (const_int 0)) reduces to (eq X Y) + (ne op0 (const_int 0)) reduces to (ne X Y) + + This is the form used by MIPS16, for example. */ + x = SET_SRC (set); else break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3204dd683cc..c85c2c23868 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,207 @@ +2014-01-27 Steve Ellcey <sellcey@mips.com> + + * gcc.target/mips/pr52125.c: Add -mno-optgp option. + +2014-01-27 Allan Sandfeld Jensen <sandfeld@kde.org> + + * g++.dg/ext/mv16.C: New tests. + +2014-01-27 Ilya Tocar <ilya.tocar@intel.com> + + * gcc.target/i386/avx512f-vexpandpd-1.c: Also test _mm512_expand_pd. + * gcc.target/i386/avx512f-vexpandpd-2.c: Ditto. + * gcc.target/i386/avx512f-vexpandps-1.c: Also test _mm512_expand_ps. + * gcc.target/i386/avx512f-vexpandps-2.c: Ditto. + * gcc.target/i386/avx512f-vmovdqu64-1.c: Also test _mm512_storeu_epi64. + * gcc.target/i386/avx512f-vmovdqu64-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpged-1.c: New. + * gcc.target/i386/avx512f-vpcmpged-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeud-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeud-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeuq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpgeuq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpled-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpled-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleud-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleud-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleuq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpleuq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltd-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltd-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltud-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltud-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltuq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpltuq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpneqd-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpneqd-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpneqq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpneqq-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpnequd-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpnequd-2.c: Ditto. + * gcc.target/i386/avx512f-vpcmpnequq-1.c: Ditto. + * gcc.target/i386/avx512f-vpcmpnequq-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovdb-1.c: Also test + _mm512_mask_cvtepi32_storeu_epi8. + * gcc.target/i386/avx512f-vpmovdb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovdw-1.c: Also test + _mm512_mask_cvtepi32_storeu_epi16. + * gcc.target/i386/avx512f-vpmovdw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovqb-1.c: Also test + _mm512_mask_cvtepi64_storeu_epi8. + * gcc.target/i386/avx512f-vpmovqb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovqw-1.c: Also test + _mm512_mask_cvtepi64_storeu_epi16. + * gcc.target/i386/avx512f-vpmovqw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovqd-1.c: Also test + _mm512_mask_cvtepi64_storeu_epi32. + * gcc.target/i386/avx512f-vpmovqd-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovsdb-1.c: Also test + _mm512_mask_cvtsepi32_storeu_epi8. + * gcc.target/i386/avx512f-vpmovsdb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovsdw-1.c: Also test + _mm512_mask_cvtsepi32_storeu_epi16. + * gcc.target/i386/avx512f-vpmovsdw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovsqb-1.c: Also test + _mm512_mask_cvtsepi64_storeu_epi8. + * gcc.target/i386/avx512f-vpmovsqb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovsqw-1.c: Also test + _mm512_mask_cvtsepi64_storeu_epi16. + * gcc.target/i386/avx512f-vpmovsqw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovsqd-1.c: Also test + _mm512_mask_cvtsepi64_storeu_epi32. + * gcc.target/i386/avx512f-vpmovsqd-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovusdb-1.c: Also test + _mm512_mask_cvtusepi32_storeu_epi8. + * gcc.target/i386/avx512f-vpmovusdb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovusdw-1.c: Also test + _mm512_mask_cvtusepi32_storeu_epi16. + * gcc.target/i386/avx512f-vpmovusdw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovusqb-1.c: Also test + _mm512_mask_cvtusepi64_storeu_epi8. + * gcc.target/i386/avx512f-vpmovusqb-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovusqw-1.c: Also test + _mm512_mask_cvtusepi64_storeu_epi16. + * gcc.target/i386/avx512f-vpmovusqw-2.c: Ditto. + * gcc.target/i386/avx512f-vpmovusqd-1.c: Also test + _mm512_mask_cvtusepi64_storeu_epi32. + * gcc.target/i386/avx512f-vpmovusqd-2.c: Ditto. + * gcc.target/i386/m128-check.h: Add checkVs, checkVb. + +2014-01-27 Kirill Yukhin <kirill.yukhin@intel.com> + + * gcc.target/i386/avx512pf-vgatherpf0dpd-1.c: New. + * gcc.target/i386/avx512pf-vgatherpf0qpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vgatherpf1dpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vgatherpf1qpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vscatterpf0dpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vscatterpf0qpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vscatterpf1dpd-1.c: Ditto. + * gcc.target/i386/avx512pf-vscatterpf1qpd-1.c: Ditto. + * gcc.target/i386/sse-14.c: Add new built-ins, fix AVX-512ER + built-ins roudning immediate. + * gcc.target/i386/sse-22.c: Add new built-ins. + * gcc.target/i386/sse-23.c: Ditto. + * gcc.target/i386/avx-1.c: Ditto. + +2014-01-27 Christian Bruel <christian.bruel@st.com> + + * gcc.target/sh/torture/strncmp.c: New tests. + +2014-01-25 Richard Sandiford <rdsandiford@googlemail.com> + + * gcc.dg/unroll_1.c: Add -fenable-rtl-loop2. + +2014-01-25 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * gcc.dg/vect/vect-nop-move.c (main): Check for vect runtime. + +2014-01-24 Jeff Law <law@redhat.com> + + PR tree-optimization/59919 + * gcc.c-torture/compile/pr59919.c: New test. + +2014-01-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57524 + * g++.dg/ext/timevar2.C: New. + +2014-01-24 Marek Polacek <polacek@redhat.com> + + * gcc.dg/pr59846.c (fn1, fn2): Use ULL suffix. + +2014-01-23 H.J. Lu <hongjiu.lu@intel.com> + + PR target/59929 + * gcc.target/i386/pr59929.c: New test. + +2014-01-23 Michael Meissner <meissner@linux.vnet.ibm.com> + + PR target/59909 + * gcc.target/powerpc/quad-atomic.c: New file to test power8 quad + word atomic functions at runtime. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59846 + * gcc.dg/pr59846.c: New test. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/58346 + * c-c++-common/pr58346-1.c: New test. + * c-c++-common/pr58346-2.c: New test. + * c-c++-common/pr58346-3.c: New test. + +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59871 + * gcc.dg/20020220-2.c: Adjust dg-warning message. + * gcc.dg/pr59871.c: New test. + +2014-01-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58980 + * g++.dg/parse/enum11.C: New. + +2014-01-23 Alex Velenko <Alex.Velenko@arm.com> + + * gcc.target/aarch64/sshr64_1.c: New testcase. + +2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com> + + * g++.dg/cilk-plus/cilk-plus.exp: Called the C/C++ common tests for + SIMD enabled function. + * g++.dg/cilk-plus/ef_test.C: New test. + * c-c++-common/cilk-plus/ef_error3.c: Made certain messages C specific + and added C++ ones. + * c-c++-common/cilk-plus/vlength_errors.c: Added new dg-error tags + to differenciate C error messages from C++ ones. + +2014-01-23 Alex Velenko <Alex.Velenko@arm.com> + + * gcc.target/aarch64/vld1-vst1_1.c: New test_case. + +2014-01-23 David Holsgrove <david.holsgrove@xilinx.com> + + * gcc.target/microblaze/others/builtin-trap.c: New test, + +2014-01-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58809 + * c-c++-common/gomp/pr58809.c: New test. + +2014-01-23 Dominique Dhumieres <dominiq@lps.ens.fr> + + PR sanitizer/59897 + * c-c++-common/asan/use-after-return-1.c: Fixed + to pass on darwin. + 2014-01-23 Dodji Seketeli <dodji@redhat.com> PR preprocessor/58580 diff --git a/gcc/testsuite/c-c++-common/asan/use-after-return-1.c b/gcc/testsuite/c-c++-common/asan/use-after-return-1.c index 435637d5323..49933e531b9 100644 --- a/gcc/testsuite/c-c++-common/asan/use-after-return-1.c +++ b/gcc/testsuite/c-c++-common/asan/use-after-return-1.c @@ -48,6 +48,6 @@ int main(int argc, char **argv) { } /* { dg-output "WRITE of size 1 at .* thread T0.*" } */ -/* { dg-output " #0.*Func2.*use-after-return-1.c:31.*" } */ +/* { dg-output " #0.*(Func2)?.*use-after-return-1.(c:31)?.*" } */ /* { dg-output "is located in stack of thread T0 at offset.*" } */ /* { dg-output "\'local\' <== Memory access at offset 32 is inside this variable" } */ diff --git a/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error3.c b/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error3.c index ab55fae0c32..195e9f1d7a6 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error3.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/SE/ef_error3.c @@ -1,9 +1,9 @@ /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus -Wall" } */ -__attribute__((vector (linear (x:y)))) +__attribute__((vector (linear (x:y)))) /* { dg-message "parameter" "" { target c++ } } */ int func2 (int x, int y) -{ /* { dg-message "using parameters for" } */ +{ /* { dg-message "using parameters for" "" { target c } } */ return (x+y); } diff --git a/gcc/testsuite/c-c++-common/cilk-plus/SE/vlength_errors.c b/gcc/testsuite/c-c++-common/cilk-plus/SE/vlength_errors.c index 38d610a8679..1bcf2a27ab9 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/SE/vlength_errors.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/SE/vlength_errors.c @@ -5,7 +5,8 @@ int z = Q; -__attribute__ ((vector (uniform(x), vectorlength (), linear (y:1) ))) /* { dg-error "expected expression" } */ +__attribute__ ((vector (uniform(x), vectorlength (), linear (y:1) ))) /* { dg-error "expected expression" "" { target c } } */ + /* { dg-error "expected primary-expression" "" { target c++ } 8 } */ int func2 (int x, int y) { int zq = 5; @@ -19,7 +20,8 @@ int func3 (int x, int y) return x + (y*zq); } -__attribute__ ((vector (uniform(x), linear (y:1), vectorlength (z) ))) /* { dg-error "vectorlength must be an integer" } */ +__attribute__ ((vector (uniform(x), linear (y:1), vectorlength (z) ))) /* { dg-error "vectorlength must be an integer" "" { target c } } */ + /* { dg-error "constant" "" { target c++ } 23 } */ int func4 (int x, int y) { int zq = 5; @@ -33,7 +35,8 @@ int func5 (int x, int y) return x + (y*zq); } -__attribute__ ((vector (uniform(x), vectorlength (z), linear (y:1)))) /* { dg-error "vectorlength must be an integer" } */ +__attribute__ ((vector (uniform(x), vectorlength (z), linear (y:1)))) /* { dg-error "vectorlength must be an integer" "" { target c } } */ + /* { dg-error "constant" "" { target c++ } 38 } */ int func6 (int x, int y) { int zq = 5; diff --git a/gcc/testsuite/c-c++-common/gomp/pr58809.c b/gcc/testsuite/c-c++-common/gomp/pr58809.c new file mode 100644 index 00000000000..f4fd7c4834d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr58809.c @@ -0,0 +1,31 @@ +/* PR middle-end/58809 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +_Complex int j; +_Complex double d; + +void +foo (void) +{ + #pragma omp parallel reduction (&:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (|:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (^:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (min:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (max:j) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (&:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (|:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (^:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (min:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; + #pragma omp parallel reduction (max:d) /* { dg-error "has invalid type for|user defined reduction not found for" } */ + ; +} diff --git a/gcc/testsuite/c-c++-common/pr58346-1.c b/gcc/testsuite/c-c++-common/pr58346-1.c new file mode 100644 index 00000000000..371fcf48454 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr58346-1.c @@ -0,0 +1,24 @@ +/* PR c/58346 */ +/* { dg-do compile } */ + +struct U { +#ifdef __cplusplus + char a[0]; +#endif +}; +static struct U b[6]; +static struct U *u1, *u2; + +int +foo (struct U *p, struct U *q) +{ + return q - p; /* { dg-error "arithmetic on pointer to an empty aggregate" } */ +} + +void +bar (void) +{ + __PTRDIFF_TYPE__ d = u1 - u2; /* { dg-error "arithmetic on pointer to an empty aggregate" } */ + __asm volatile ("" : "+g" (d)); + foo (&b[0], &b[4]); +} diff --git a/gcc/testsuite/c-c++-common/pr58346-2.c b/gcc/testsuite/c-c++-common/pr58346-2.c new file mode 100644 index 00000000000..195060e420c --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr58346-2.c @@ -0,0 +1,8 @@ +/* PR c/58346 */ +/* { dg-do compile } */ + +__PTRDIFF_TYPE__ +foo (int p[3][0], int q[3][0]) +{ + return p - q; /* { dg-error "arithmetic on pointer to an empty aggregate" } */ +} diff --git a/gcc/testsuite/c-c++-common/pr58346-3.c b/gcc/testsuite/c-c++-common/pr58346-3.c new file mode 100644 index 00000000000..41627ed953c --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr58346-3.c @@ -0,0 +1,16 @@ +/* PR c/58346 */ +/* { dg-do compile } */ + +void +foo (void) +{ + __PTRDIFF_TYPE__ d; + const int i = 0; + int a1[2][0], a2[2][0]; + int b1[3][i], b2[4][i]; + d = a1 - a2; /* { dg-error "arithmetic on pointer to an empty aggregate" } */ + __asm volatile ("" : "+g" (d)); + /* No error here for C. */ + d = b1 - b2; /* { dg-error "arithmetic on pointer to an empty aggregate" "" { target c++ } } */ + __asm volatile ("" : "+g" (d)); +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp index 37b8ccbe70a..204a754585b 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp @@ -33,6 +33,9 @@ set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs" dg-init # Run the tests that are shared with C. g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] "" +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-O3" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] " " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-g -O2" " " # Run the C++ only tests. g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" dg-finish diff --git a/gcc/testsuite/g++.dg/cilk-plus/ef_test.C b/gcc/testsuite/g++.dg/cilk-plus/ef_test.C new file mode 100644 index 00000000000..3e75cbd9253 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/ef_test.C @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + + +__attribute__((vector (nomask), vector(mask), vector(mask,linear(x:1)))) +int func (int x) +{ + return x+5; +} + + +__attribute__((vector(mask,uniform (y), linear(x:1)))) +__attribute__((vector (nomask, uniform (x), linear(y:1)))) +int func2 (int x, int y) +{ + return x+y; +} + +int func4 (int x, int y) __attribute__((vector, vector (nomask), vector (uniform(y), linear(x:1)))); + + +template <class T, class R> +__attribute__((vector, vector(mask,uniform (y), linear(x:1)))) +T func3 (T x, R y) +{ + return x+(T)y; +} + + + +int main (void) +{ + if ((func3 (5, 4) + func2 (5, 4) + func (5) + (int) func3<long, int> (5, 4)) != + (5 + 4) + (5 + 4) + (5 + 5) + (int) ((long)5 +(int)4)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto41.C b/gcc/testsuite/g++.dg/cpp0x/auto41.C new file mode 100644 index 00000000000..6f102e7c9f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto41.C @@ -0,0 +1,5 @@ +// PR c++/58550 +// { dg-options "-std=c++11" } + +auto foo(); // { dg-error "auto" } +auto fp = foo; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist22.C b/gcc/testsuite/g++.dg/cpp0x/initlist22.C index f913aebb906..19aefd304d5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist22.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist22.C @@ -1,4 +1,4 @@ -// Core issue 934 +// Core issue 934/1288 // { dg-options "-std=c++11" } int i; @@ -13,12 +13,12 @@ struct A { int i; } a; A& r5 { i }; // { dg-error "" } reference to temporary A&& r6 { i }; // OK, aggregate initialization of temporary -A& r7 { a }; // { dg-error "" } invalid aggregate initializer for A -A&& r8 { a }; // { dg-error "" } invalid aggregate initializer for A +A& r7 { a }; // OK, direct-initialization +A&& r8 { a }; // { dg-error "lvalue" } binding && to lvalue struct B { B(int); int i; } b(0); B& r9 { i }; // { dg-error "" } reference to temporary B&& r10 { i }; // OK, make temporary with B(int) constructor -B& r11 { b }; // { dg-error "" } reference to temporary -B&& r12 { b }; // OK, make temporary with copy constructor +B& r11 { b }; // OK, direct-initialization +B&& r12 { b }; // { dg-error "lvalue" } binding && to lvalue diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist76.C b/gcc/testsuite/g++.dg/cpp0x/initlist76.C new file mode 100644 index 00000000000..ac419dde8cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist76.C @@ -0,0 +1,5 @@ +// PR c++/58812 +// { dg-require-effective-target c++11 } + +int i; +int&& j{{ i }}; // { dg-error "too many braces" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist77.C b/gcc/testsuite/g++.dg/cpp0x/initlist77.C new file mode 100644 index 00000000000..49b9079fb44 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist77.C @@ -0,0 +1,10 @@ +// PR c++/58651 +// { dg-require-effective-target c++11 } + +struct A +{ + int i; + A(int j) : i{{j}} {} // { dg-error "too many braces" } +}; + +A a(0); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist78.C b/gcc/testsuite/g++.dg/cpp0x/initlist78.C new file mode 100644 index 00000000000..648ec5307df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist78.C @@ -0,0 +1,12 @@ +// PR c++/58639 +// { dg-require-effective-target c++11 } + +struct node { + node &parent; +}; + +struct vector { + node n; +}; + +vector v({}); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/overload3.C b/gcc/testsuite/g++.dg/cpp0x/overload3.C new file mode 100644 index 00000000000..e521b35bd0d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/overload3.C @@ -0,0 +1,17 @@ +// PR c++/59823 +// { dg-options "-std=c++11" } + +struct X { }; + +void f(X&&); + +struct wrap +{ + operator const X&() const; +}; + +int main() +{ + wrap w; + f(w); // { dg-error "lvalue" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert9.C b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C new file mode 100644 index 00000000000..fccaa449c17 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C @@ -0,0 +1,7 @@ +// PR c++/58837 +// { dg-require-effective-target c++11 } + +void f(); +static_assert(f, ""); +struct A {}; +static_assert(A::~A, ""); // { dg-error "non-static member function" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic146.C b/gcc/testsuite/g++.dg/cpp0x/variadic146.C new file mode 100644 index 00000000000..0c91db581d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic146.C @@ -0,0 +1,9 @@ +// PR c++/58606 +// { dg-require-effective-target c++11 } + +template<int&...I> struct A +{ + template<typename> struct B; + + template<typename T> struct B<T*> {}; +}; diff --git a/gcc/testsuite/g++.dg/eh/uncaught1.C b/gcc/testsuite/g++.dg/eh/uncaught1.C index afbf5af4d22..e96af334a8c 100644 --- a/gcc/testsuite/g++.dg/eh/uncaught1.C +++ b/gcc/testsuite/g++.dg/eh/uncaught1.C @@ -13,7 +13,7 @@ struct Check { static Check const data[] = { { 0, 0, false }, // construct [0] - { 1, 0, true }, // [1] = [0] + { 1, 0, false }, // [1] = [0] { 0, 0, true }, // destruct [0] { 2, 1, true }, // [2] = [1] { 2, 2, true }, // destruct [2] diff --git a/gcc/testsuite/g++.dg/eh/uncaught4.C b/gcc/testsuite/g++.dg/eh/uncaught4.C new file mode 100644 index 00000000000..227d11b330b --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/uncaught4.C @@ -0,0 +1,29 @@ +// PR c++/41174 +// { dg-do run } + +#include <exception> + +#define assert(E) if (!(E)) __builtin_abort(); + +struct e { + e() + { + assert( !std::uncaught_exception() ); + try { + throw 1; + } catch (int i) { + assert( !std::uncaught_exception() ); + throw; + } + } +}; + +int main() +{ + try { + throw e(); + } catch (int i) { + assert( !std::uncaught_exception() ); + } + assert( !std::uncaught_exception() ); +} diff --git a/gcc/testsuite/g++.dg/ext/attrib48.C b/gcc/testsuite/g++.dg/ext/attrib48.C new file mode 100644 index 00000000000..19a9959109d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib48.C @@ -0,0 +1,6 @@ +// PR c++/54652 + +typedef unsigned L __attribute__ ((aligned)); +typedef unsigned L __attribute__ ((aligned)); + +L l; diff --git a/gcc/testsuite/g++.dg/ext/mv16.C b/gcc/testsuite/g++.dg/ext/mv16.C new file mode 100644 index 00000000000..8992bfc6fc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv16.C @@ -0,0 +1,65 @@ +// Test that dispatching can choose the right multiversion +// for Intel CPUs with the same internal GCC processor id +// but slighly different sets of x86 extensions. + +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-ifunc "" } +// { dg-options "-O2" } + +#include <assert.h> + +int __attribute__ ((target("default"))) +foo () +{ + return 0; +} + +int __attribute__ ((target("arch=nehalem"))) +foo () +{ + return 4; +} + +int __attribute__ ((target("arch=westmere"))) +foo () +{ + return 5; +} + +int __attribute__ ((target("arch=sandybridge"))) +foo () +{ + return 8; +} + +int __attribute__ ((target("arch=ivybridge"))) +foo () +{ + return 9; +} + +int __attribute__ ((target("arch=haswell"))) +foo () +{ + return 12; +} + +int main () +{ + int val = foo (); + + if (__builtin_cpu_is ("nehalem")) + assert (val == 4); + else if (__builtin_cpu_is ("westmere")) + assert (val == 5); + else if (__builtin_cpu_is ("sandybridge")) + assert (val == 8); + else if (__builtin_cpu_is ("ivybridge")) + assert (val == 9); + else if (__builtin_cpu_is ("haswell")) + assert (val == 12); + else + assert (val == 0); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr15.C b/gcc/testsuite/g++.dg/ext/stmtexpr15.C new file mode 100644 index 00000000000..83a831cdd4c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr15.C @@ -0,0 +1,7 @@ +// PR c++/59097 +// { dg-options "" } + +void foo() +{ + int x[({ return; })]; // { dg-error "non-integral" } +} diff --git a/gcc/testsuite/g++.dg/ext/timevar2.C b/gcc/testsuite/g++.dg/ext/timevar2.C new file mode 100644 index 00000000000..74c4fc8cfae --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/timevar2.C @@ -0,0 +1,14 @@ +// PR c++/57524 +// { dg-options "-ftime-report" } +// { dg-prune-output "wall" } +// { dg-prune-output "times" } +// { dg-prune-output "TOTAL" } +// { dg-prune-output "checks" } + +namespace detail { +namespace indirect_traits {} +using namespace indirect_traits; +void fn1() { +using namespace detail; +} +} diff --git a/gcc/testsuite/g++.dg/ext/traits1.C b/gcc/testsuite/g++.dg/ext/traits1.C new file mode 100644 index 00000000000..24099e53cd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/traits1.C @@ -0,0 +1,4 @@ +// PR c++/58504 + +template<bool = __has_nothrow_assign(void)> struct A {}; +A<> a; diff --git a/gcc/testsuite/g++.dg/ext/vector25.C b/gcc/testsuite/g++.dg/ext/vector25.C new file mode 100644 index 00000000000..6c1f5d09878 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector25.C @@ -0,0 +1,6 @@ +volatile int i __attribute__((vector_size(8))); + +void foo() +{ + i += i; +} diff --git a/gcc/testsuite/g++.dg/init/aggr10.C b/gcc/testsuite/g++.dg/init/aggr10.C new file mode 100644 index 00000000000..e494e20a3bf --- /dev/null +++ b/gcc/testsuite/g++.dg/init/aggr10.C @@ -0,0 +1,6 @@ +// PR c++/59886 + +struct A { A (); ~A (); }; +struct B { A b[4]; }; +struct C { B c[5]; }; +const C e = {}; diff --git a/gcc/testsuite/g++.dg/opt/value-init2.C b/gcc/testsuite/g++.dg/opt/value-init2.C deleted file mode 100644 index 515cca07ac1..00000000000 --- a/gcc/testsuite/g++.dg/opt/value-init2.C +++ /dev/null @@ -1,13 +0,0 @@ -// PR c++/59659 -// { dg-options "-fdump-tree-gimple" } -// { dg-final { scan-tree-dump-times "S::S" 1 "gimple" } } -// { dg-final { cleanup-tree-dump "gimple" } } - -struct S { S (); S (int i); int i; }; -struct A { S s[100]; }; - -void -foo () -{ - A a = {{}}; -} diff --git a/gcc/testsuite/g++.dg/parse/enum11.C b/gcc/testsuite/g++.dg/parse/enum11.C new file mode 100644 index 00000000000..68ddedbeeec --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/enum11.C @@ -0,0 +1,6 @@ +// PR c++/58980 + +template<typename> struct A +{ + enum A::B::C {}; // { dg-error "has not been declared" } +}; diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-9.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-9.C new file mode 100644 index 00000000000..1c4d5b8d1d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-9.C @@ -0,0 +1,60 @@ +// related to PR c++/55189 +// { dg-options "-Wreturn-type" } + +int f1() +{ + while (true) { } +} +int f2() +{ + while (true) { break; } +} // { dg-warning "no return statement" } + +int f3() +{ + for (;;) {} +} +int f4() +{ + for (;;) {break;} +} // { dg-warning "no return statement" } + +int f5() +{ + do {} while(true); +} +int f6() +{ + do {break;} while(true); +} // { dg-warning "no return statement" } + +int f7() +{ + for(;;) + while (true) {break;} +} + +int f8() +{ + for(;;) + { + while (true) {} + break; + } +} + +template <class T> +T f9() +{ + for(;;) { } +} + +template int f9(); + +template <class T> +T f10() +{ + for(;;) { break; } +} // { dg-warning "no return statement" } + +template int f10(); diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59919.c b/gcc/testsuite/gcc.c-torture/compile/pr59919.c new file mode 100644 index 00000000000..6809caaf9f3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr59919.c @@ -0,0 +1,18 @@ +typedef int jmp_buf[10]; +struct S +{ + int i; + jmp_buf buf; +}; + +void setjmp (jmp_buf); +void foo (int *); +__attribute__ ((__noreturn__, __nonnull__)) void bar (struct S *); + +void +baz (struct S *p) +{ + bar (p); + setjmp (p->buf); + foo (&p->i); +} diff --git a/gcc/testsuite/gcc.dg/20020220-2.c b/gcc/testsuite/gcc.dg/20020220-2.c index c6c57a92136..95606703cc5 100644 --- a/gcc/testsuite/gcc.dg/20020220-2.c +++ b/gcc/testsuite/gcc.dg/20020220-2.c @@ -1,5 +1,5 @@ /* PR c/4697 - Test whether value computed not used warning is given for compound + Test whether operand has no effect warning is given for compound expression. */ /* { dg-do compile } */ /* { dg-options "-O2 -Wunused" } */ @@ -7,6 +7,6 @@ int b; int foo (int a) { - a = a + 1, 5 * b; /* { dg-warning "value computed is not used" } */ + a = a + 1, 5 * b; /* { dg-warning "right-hand operand of comma expression has no effect" } */ return a; } diff --git a/gcc/testsuite/gcc.dg/pr59846.c b/gcc/testsuite/gcc.dg/pr59846.c new file mode 100644 index 00000000000..b3dd0de9ea6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59846.c @@ -0,0 +1,39 @@ +/* PR c/59846 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-op -Wtype-limits" } */ + +_Bool +fn1 (unsigned int p) +{ + return 0ULL > p; /* { dg-warning "15:comparison is always false due to limited range of data type" } */ +} + +_Bool +fn2 (unsigned int p) +{ + return 0ULL <= p; /* { dg-warning "15:comparison is always true due to limited range of data type" } */ +} + +_Bool +fn3 (unsigned int p) +{ + return p >= 0U; /* { dg-warning "12:comparison of unsigned expression >= 0 is always true" } */ +} + +_Bool +fn4 (unsigned int p) +{ + return p < 0U; /* { dg-warning "12:comparison of unsigned expression < 0 is always false" } */ +} + +_Bool +fn5 (_Bool p) +{ + return p || !p; /* { dg-warning "12:logical" } */ +} + +_Bool +fn6 (_Bool p) +{ + return p && !p; /* { dg-warning "12:logical" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr59871.c b/gcc/testsuite/gcc.dg/pr59871.c new file mode 100644 index 00000000000..c881aa198d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59871.c @@ -0,0 +1,22 @@ +/* PR c/59871 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +extern int bar (); + +void +foo (int *p, int i) +{ + p[0] = (bar (), 1, bar ()); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + p[1] = (1, bar ()); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + bar (), 1, bar (); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), 1; /* { dg-warning "right-hand operand of comma expression has no effect" } */ + 1, bar (); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + (bar (), 1); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), 5 * i; /* { dg-warning "right-hand operand of comma expression has no effect" } */ + (bar (), 5 * i); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7))))))); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7)))))); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (7, bar ())))))); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (7, bar ()))))))); /* { dg-warning "left-hand operand of comma expression has no effect" } */ +} diff --git a/gcc/testsuite/gcc.dg/unroll_1.c b/gcc/testsuite/gcc.dg/unroll_1.c index 378f819ed68..b1d3e7c6926 100644 --- a/gcc/testsuite/gcc.dg/unroll_1.c +++ b/gcc/testsuite/gcc.dg/unroll_1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll" } */ +/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2 -fenable-rtl-loop2_unroll" } */ unsigned a[100], b[100]; inline void bar() diff --git a/gcc/testsuite/gcc.dg/vect/vect-nop-move.c b/gcc/testsuite/gcc.dg/vect/vect-nop-move.c index 6e82c34fd52..f8c980a3bcd 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-nop-move.c +++ b/gcc/testsuite/gcc.dg/vect/vect-nop-move.c @@ -2,6 +2,8 @@ /* { dg-require-effective-target vect_float } */ /* { dg-additional-options "-fdump-rtl-combine-details" } */ +#include "tree-vect.h" + extern void abort (void); #define NOINLINE __attribute__((noinline)) @@ -48,8 +50,8 @@ foo32x2_le (float32x2_t x) return bar (x[0]); } -int -main() +NOINLINE int +test (void) { float32x4_t a = { 0.0f, 1.0f, 2.0f, 3.0f }; float32x2_t b = { 0.0f, 1.0f }; @@ -69,6 +71,13 @@ main() return 0; } +int +main () +{ + check_vect (); + return test (); +} + /* { dg-final { scan-rtl-dump "deleting noop move" "combine" { target aarch64*-*-* } } } */ /* { dg-final { cleanup-rtl-dump "combine" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sshr64_1.c b/gcc/testsuite/gcc.target/aarch64/sshr64_1.c new file mode 100644 index 00000000000..89c6096ad39 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sshr64_1.c @@ -0,0 +1,115 @@ +/* Test SIMD shift works correctly. */ +/* { dg-do run } */ +/* { dg-options "-O3 --save-temps" } */ + +#include "arm_neon.h" + +extern void abort (void); + +int __attribute__ ((noinline)) +test_sshr64 () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 64); + got = vget_lane_s64 (result, 0); + exp = 0; + /* Expect: "result" = 0000000000000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_sshr64_neg () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0xffffffff80000000); + result = vshr_n_s64 (arg, 64); + got = vget_lane_s64 (result, 0); + exp = 0xffffffffffffffff; + /* Expect: "result" = -1. */ + if (exp != got) + return 1; + return 0; +} + +int +__attribute__ ((noinline)) +test_other () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 4); + got = vget_lane_s64 (result, 0); + exp = 0x0000000008000000; + /* Expect: "result" = 0x0000000008000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_other_neg () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0xffffffff80000000); + result = vshr_n_s64 (arg, 4); + got = vget_lane_s64 (result, 0); + exp = 0xfffffffff8000000; + /* Expect: "result" = 0xfffffffff8000000. */ + if (exp != got) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_no_sshr0 () +{ + int64x1_t arg; + int64x1_t result; + int64_t got; + int64_t exp; + arg = vcreate_s64 (0x0000000080000000); + result = vshr_n_s64 (arg, 0); + got = vget_lane_s64 (result, 0); + exp = 0x0000000080000000; + /* Expect: "result" = 0x0000000080000000. */ + if (exp != got) + return 1; + return 0; +} + +/* { dg-final { scan-assembler-not "sshr\\td\[0-9\]+, d\[0-9\]+, 0" } } */ +int +main () +{ + if (test_sshr64 ()) + abort (); + if (test_other ()) + abort (); + + if (test_sshr64_neg ()) + abort (); + if (test_other_neg ()) + abort (); + + if (test_no_sshr0 ()) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/vld1-vst1_1.c b/gcc/testsuite/gcc.target/aarch64/vld1-vst1_1.c new file mode 100644 index 00000000000..d1834a26470 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/vld1-vst1_1.c @@ -0,0 +1,52 @@ +/* Test vld1 and vst1 maintain consistent indexing. */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +#include <arm_neon.h> + +extern void abort (void); + +int __attribute__ ((noinline)) +test_vld1_vst1 () +{ + int8x8_t a; + int8x8_t b; + int i = 0; + int8_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; + int8_t d[8]; + a = vld1_s8 (c); + asm volatile ("":::"memory"); + vst1_s8 (d, a); + asm volatile ("":::"memory"); + for (; i < 8; i++) + if (c[i] != d[i]) + return 1; + return 0; +} + +int __attribute__ ((noinline)) +test_vld1q_vst1q () +{ + int16x8_t a; + int16x8_t b; + int i = 0; + int16_t c[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; + int16_t d[8]; + a = vld1q_s16 (c); + asm volatile ("":::"memory"); + vst1q_s16 (d, a); + asm volatile ("":::"memory"); + for (; i < 8; i++) + if (c[i] != d[i]) + return 1; + return 0; +} + +int +main () +{ + if (test_vld1_vst1 ()) + abort (); + if (test_vld1q_vst1q ()) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/avx-1.c b/gcc/testsuite/gcc.target/i386/avx-1.c index 12674adf18a..8fb6fb880c1 100644 --- a/gcc/testsuite/gcc.target/i386/avx-1.c +++ b/gcc/testsuite/gcc.target/i386/avx-1.c @@ -362,6 +362,10 @@ #define __builtin_ia32_gatherpfqps(A, B, C, D, E) __builtin_ia32_gatherpfqps(A, B, C, 1, 1) #define __builtin_ia32_scatterpfdps(A, B, C, D, E) __builtin_ia32_scatterpfdps(A, B, C, 1, 1) #define __builtin_ia32_scatterpfqps(A, B, C, D, E) __builtin_ia32_scatterpfqps(A, B, C, 1, 1) +#define __builtin_ia32_gatherpfdpd(A, B, C, D, E) __builtin_ia32_gatherpfdpd(A, B, C, 1, 1) +#define __builtin_ia32_gatherpfqpd(A, B, C, D, E) __builtin_ia32_gatherpfqpd(A, B, C, 1, 1) +#define __builtin_ia32_scatterpfdpd(A, B, C, D, E) __builtin_ia32_scatterpfdpd(A, B, C, 1, 1) +#define __builtin_ia32_scatterpfqpd(A, B, C, D, E) __builtin_ia32_scatterpfqpd(A, B, C, 1, 1) /* shaintrin.h */ #define __builtin_ia32_sha1rnds4(A, B, C) __builtin_ia32_sha1rnds4(A, B, 1) diff --git a/gcc/testsuite/gcc.target/i386/avx512f-mask-type.h b/gcc/testsuite/gcc.target/i386/avx512f-mask-type.h index 53c439e24d1..2dacdd67a2a 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-mask-type.h +++ b/gcc/testsuite/gcc.target/i386/avx512f-mask-type.h @@ -2,7 +2,9 @@ #if SIZE <= 8 #define MASK_TYPE __mmask8 #define MASK_VALUE 0xB9 +#define MASK_ALL_ONES 0xFF #elif SIZE <= 16 #define MASK_TYPE __mmask16 #define MASK_VALUE 0xA6BA +#define MASK_ALL_ONES 0xFFFF #endif diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-1.c index fc121656f20..c8fa9cfde1a 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vexpandpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]" 5 } } */ /* { dg-final { scan-assembler-times "vexpandpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 2 } } */ /* { dg-final { scan-assembler-times "vexpandpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\{z\}" 2 } } */ @@ -12,6 +13,7 @@ volatile __mmask8 m; void extern avx512f_test (void) { + x = _mm512_expand_pd (x); x = _mm512_mask_expand_pd (x, m, x); x = _mm512_maskz_expand_pd (m, x); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-2.c index 088a2dd02e1..b59096bb281 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vexpandpd-2.c @@ -24,43 +24,50 @@ CALC (double *s, double *r, MASK_TYPE mask) static void TEST (void) { - UNION_TYPE (AVX512F_LEN, d) s1, res1, res2, res3, res4; + UNION_TYPE (AVX512F_LEN, d) s1, res1, res2, res3, res4, res5; MASK_TYPE mask = MASK_VALUE; double s2[SIZE]; double res_ref1[SIZE]; double res_ref2[SIZE]; + double res_ref3[SIZE]; int i, sign = 1; for (i = 0; i < SIZE; i++) { s1.a[i] = 123.456 * (i + 200) * sign; s2[i] = 789.012 * (i + 300) * sign; - res1.a[i] = DEFAULT_VALUE; - res3.a[i] = DEFAULT_VALUE; + res2.a[i] = DEFAULT_VALUE; + res4.a[i] = DEFAULT_VALUE; sign = -sign; } - res1.x = INTRINSIC (_mask_expand_pd) (res1.x, mask, s1.x); - res2.x = INTRINSIC (_maskz_expand_pd) (mask, s1.x); - res3.x = INTRINSIC (_mask_expandloadu_pd) (res3.x, mask, s2); - res4.x = INTRINSIC (_maskz_expandloadu_pd) (mask, s2); + res1.x = INTRINSIC (_expand_pd) (s1.x); + res2.x = INTRINSIC (_mask_expand_pd) (res2.x, mask, s1.x); + res3.x = INTRINSIC (_maskz_expand_pd) (mask, s1.x); + res4.x = INTRINSIC (_mask_expandloadu_pd) (res4.x, mask, s2); + res5.x = INTRINSIC (_maskz_expandloadu_pd) (mask, s2); - CALC (s1.a, res_ref1, mask); - CALC (s2, res_ref2, mask); + /* no mask is the same as all ones mask. */ + CALC (s1.a, res_ref1, MASK_ALL_ONES); + CALC (s1.a, res_ref2, mask); + CALC (s2, res_ref3, mask); - MASK_MERGE (d) (res_ref1, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref1)) abort (); - MASK_ZERO (d) (res_ref1, mask, SIZE); - if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref1)) + MASK_MERGE (d) (res_ref2, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref2)) abort (); - MASK_MERGE (d) (res_ref2, mask, SIZE); + MASK_ZERO (d) (res_ref2, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref2)) abort (); - MASK_ZERO (d) (res_ref2, mask, SIZE); - if (UNION_CHECK (AVX512F_LEN, d) (res4, res_ref2)) + MASK_MERGE (d) (res_ref3, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res4, res_ref3)) + abort (); + + MASK_ZERO (d) (res_ref3, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res5, res_ref3)) abort (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-1.c index fcf87642b40..faf6150c5cd 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vexpandps\[ \\t\]+\[^\n\]*%zmm\[0-9\]" 5 } } */ /* { dg-final { scan-assembler-times "vexpandps\[ \\t\]+\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 2 } } */ /* { dg-final { scan-assembler-times "vexpandps\[ \\t\]+\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\{z\}" 2 } } */ @@ -12,6 +13,7 @@ volatile __mmask16 m; void extern avx512f_test (void) { + x = _mm512_expand_ps (x); x = _mm512_mask_expand_ps (x, m, x); x = _mm512_maskz_expand_ps (m, x); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-2.c index 1faf3dfe917..e4dc68f2f2a 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vexpandps-2.c @@ -24,43 +24,49 @@ CALC (float *s, float *r, MASK_TYPE mask) static void TEST (void) { - UNION_TYPE (AVX512F_LEN, ) s1, res1, res2, res3, res4; + UNION_TYPE (AVX512F_LEN, ) s1, res1, res2, res3, res4, res5; MASK_TYPE mask = MASK_VALUE; float s2[SIZE]; float res_ref1[SIZE]; float res_ref2[SIZE]; + float res_ref3[SIZE]; int i, sign = 1; for (i = 0; i < SIZE; i++) { s1.a[i] = 123.456 * (i + 200) * sign; s2[i] = 789.012 * (i + 300) * sign; - res1.a[i] = DEFAULT_VALUE; - res3.a[i] = DEFAULT_VALUE; + res2.a[i] = DEFAULT_VALUE; + res4.a[i] = DEFAULT_VALUE; sign = -sign; } - res1.x = INTRINSIC (_mask_expand_ps) (res1.x, mask, s1.x); - res2.x = INTRINSIC (_maskz_expand_ps) (mask, s1.x); - res3.x = INTRINSIC (_mask_expandloadu_ps) (res3.x, mask, s2); - res4.x = INTRINSIC (_maskz_expandloadu_ps) (mask, s2); + res1.x = INTRINSIC (_expand_ps) (s1.x); + res2.x = INTRINSIC (_mask_expand_ps) (res2.x, mask, s1.x); + res3.x = INTRINSIC (_maskz_expand_ps) (mask, s1.x); + res4.x = INTRINSIC (_mask_expandloadu_ps) (res4.x, mask, s2); + res5.x = INTRINSIC (_maskz_expandloadu_ps) (mask, s2); - CALC (s1.a, res_ref1, mask); - CALC (s2, res_ref2, mask); + CALC (s1.a, res_ref1, MASK_ALL_ONES); + CALC (s1.a, res_ref2, mask); + CALC (s2, res_ref3, mask); - MASK_MERGE () (res_ref1, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, ) (res1, res_ref1)) abort (); - MASK_ZERO () (res_ref1, mask, SIZE); - if (UNION_CHECK (AVX512F_LEN, ) (res2, res_ref1)) + MASK_MERGE () (res_ref2, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, ) (res2, res_ref2)) abort (); - MASK_MERGE () (res_ref2, mask, SIZE); + MASK_ZERO () (res_ref2, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, ) (res3, res_ref2)) abort (); - MASK_ZERO () (res_ref2, mask, SIZE); - if (UNION_CHECK (AVX512F_LEN, ) (res4, res_ref2)) + MASK_MERGE () (res_ref3, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, ) (res4, res_ref3)) + abort (); + + MASK_ZERO () (res_ref3, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, ) (res5, res_ref3)) abort (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-1.c index 806d1f5867a..5bfb6c16a01 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-1.c @@ -3,6 +3,7 @@ /* { dg-final { scan-assembler-times "vmovdqu64\[ \\t\]+\[^\n\]*\\)\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vmovdqu64\[ \\t\]+\[^\n\]*\\)\[^\n\]*%zmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ /* { dg-final { scan-assembler-times "vmovdqu64\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n\]*\\)\{%k\[1-7\]\}\[^\{\]" 1 } } */ +/* { dg-final { scan-assembler-times "vmovdqu64\[ \\t\]+\[^\n\]*%zmm\[0-9\]" 4 } } */ #include <immintrin.h> @@ -17,4 +18,5 @@ avx512f_test (void) x = _mm512_maskz_loadu_epi64 (m, p); _mm512_mask_storeu_epi64 (p, m, x); + _mm512_storeu_epi64 (p, x); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-2.c index 867a2517d54..6a9a8369e0b 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vmovdqu64-2.c @@ -19,7 +19,7 @@ static void TEST (void) { UNION_TYPE (AVX512F_LEN, i_q) s2, res1, res2; - EVAL(unaligned_array, AVX512F_LEN,) s1, res3; + EVAL(unaligned_array, AVX512F_LEN,) s1, res3, res4; MASK_TYPE mask = MASK_VALUE; int i, sign = 1; @@ -35,6 +35,7 @@ TEST (void) res1.x = INTRINSIC (_mask_loadu_epi64) (res1.x, mask, s1.a); res2.x = INTRINSIC (_maskz_loadu_epi64) (mask, s1.a); INTRINSIC (_mask_storeu_epi64) (res3.a, mask, s2.x); + INTRINSIC (_storeu_epi64) (res4.a, s2.x); MASK_MERGE (i_q) (s1.a, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, i_q) (res1, s1.a)) @@ -44,6 +45,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN, i_q) (res2, s1.a)) abort (); + if (UNION_CHECK (AVX512F_LEN, i_q) (s2, res4.a)) + abort (); + MASK_MERGE (i_q) (s2.a, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, i_q) (s2, res3.a)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-1.c new file mode 100644 index 00000000000..83c259eeeec --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpge_epi32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-2.c new file mode 100644 index 00000000000..988587810bd --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpged-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] >= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpge_epi32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-1.c new file mode 100644 index 00000000000..ec7a175107a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpge_epi64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-2.c new file mode 100644 index 00000000000..dfff1dc3484 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] >= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpge_epi64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-1.c new file mode 100644 index 00000000000..3db73a9fe38 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpud\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpge_epu32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-2.c new file mode 100644 index 00000000000..7bb36678397 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeud-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] >= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpge_epu32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-1.c new file mode 100644 index 00000000000..4d9c3f4ef28 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpuq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpge_epu64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-2.c new file mode 100644 index 00000000000..78cae6941ca --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpgeuq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] >= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpge_epu64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-1.c new file mode 100644 index 00000000000..68f085ace4b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmple_epi32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-2.c new file mode 100644 index 00000000000..15573766c31 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpled-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] <= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmple_epi32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-1.c new file mode 100644 index 00000000000..0d5b6fab684 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmple_epi64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-2.c new file mode 100644 index 00000000000..5fdf9d75203 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] <= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmple_epi64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-1.c new file mode 100644 index 00000000000..902f4ab05a9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpud\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmple_epu32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-2.c new file mode 100644 index 00000000000..22c825a09b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleud-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] <= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmple_epu32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-1.c new file mode 100644 index 00000000000..5c5f0e5cc00 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpuq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmple_epu64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-2.c new file mode 100644 index 00000000000..e7843d1e4fe --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpleuq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] <= s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmple_epu64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-1.c new file mode 100644 index 00000000000..16bb1bf1c71 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmplt_epi32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-2.c new file mode 100644 index 00000000000..f8728cd0db1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltd-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] < s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmplt_epi32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-1.c new file mode 100644 index 00000000000..0e87ad14e50 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmplt_epi64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-2.c new file mode 100644 index 00000000000..204b69e5753 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] < s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmplt_epi64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-1.c new file mode 100644 index 00000000000..0ad8fd19579 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpud\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmplt_epu32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-2.c new file mode 100644 index 00000000000..aea70ec84c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltud-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] < s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmplt_epu32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-1.c new file mode 100644 index 00000000000..d428b006476 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpuq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmplt_epu64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-2.c new file mode 100644 index 00000000000..83becbd6f3d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpltuq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] < s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmplt_epu64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-1.c new file mode 100644 index 00000000000..2cffad59455 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpneq_epi32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-2.c new file mode 100644 index 00000000000..fd9bfc5aa4a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqd-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] != s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpneq_epi32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-1.c new file mode 100644 index 00000000000..4a2928acbf5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpneq_epi64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-2.c new file mode 100644 index 00000000000..1beacd44901 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpneqq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] != s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpneq_epi64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-1.c new file mode 100644 index 00000000000..2c204790d79 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpud\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask16 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpneq_epu32_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-2.c new file mode 100644 index 00000000000..09d11f52ca8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequd-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 32) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, int *s1, int *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] != s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) src1, src2; + MASK_TYPE res_ref, res1; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpneq_epu32_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res_ref != res1) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-1.c new file mode 100644 index 00000000000..7701493998e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpcmpuq\[ \\t\]+\[^\n\]*%zmm\[0-9\]\[^\n^k\]*%k\[0-9\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i x; +volatile __mmask8 m; + +void extern +avx512f_test (void) +{ + m = _mm512_cmpneq_epu64_mask (x, x); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-2.c new file mode 100644 index 00000000000..41e1f5b63a3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpcmpnequq-2.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" + +CALC (MASK_TYPE *r, long long *s1, long long *s2) +{ + int i; + *r = 0; + MASK_TYPE one = 1; + + for (i = 0; i < SIZE; i++) + if (s1[i] != s2[i]) + *r = *r | (one << i); +} + +void static +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_q) src1, src2; + MASK_TYPE res1, res_ref; + MASK_TYPE mask = MASK_VALUE; + res1 = 0; + + for (i = 0; i < SIZE / 2; i++) + { + src1.a[i * 2] = i; + src1.a[i * 2 + 1] = i * i; + src2.a[i * 2] = 2 * i; + src2.a[i * 2 + 1] = i * i; + } + + res1 = INTRINSIC (_cmpneq_epu64_mask) (src1.x, src2.x); + + CALC (&res_ref, src1.a, src2.a); + + if (res1 != res_ref) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-1.c index c634d888d68..5f1190399b0 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovdb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtepi32_epi8 (s); res = _mm512_mask_cvtepi32_epi8 (res, m, s); res = _mm512_maskz_cvtepi32_epi8 (m, s); + _mm512_mask_cvtepi32_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-2.c index d153cfef26d..cc63f481654 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdb-2.c @@ -23,6 +23,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + char res4[16]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; char res_ref[16]; @@ -33,11 +34,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtepi32_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtepi32_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtepi32_epi8) (mask, src.x); + INTRINSIC (_mask_cvtepi32_storeu_epi8) (res4, mask, src.x); CALC (res_ref, src.a); @@ -48,6 +51,9 @@ TEST (void) if (UNION_CHECK (128, i_b) (res2, res_ref)) abort (); + if (checkVc (res4, res_ref, 16)) + abort (); + MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-1.c index bd66defe6c5..a4652a675d7 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovdw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtepi32_epi16 (s); res = _mm512_mask_cvtepi32_epi16 (res, m, s); res = _mm512_maskz_cvtepi32_epi16 (m, s); + _mm512_mask_cvtepi32_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-2.c index 79fb5d89a42..43fe8cb163a 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovdw-2.c @@ -24,6 +24,7 @@ TEST (void) { int i, sign; UNION_TYPE (AVX512F_LEN_HALF, i_w) res1, res2, res3; + short res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; short res_ref[SIZE_HALF]; @@ -34,11 +35,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtepi32_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtepi32_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtepi32_epi16) (mask, src.x); + INTRINSIC (_mask_cvtepi32_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -49,6 +52,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-1.c index 7fc5980c3a6..76b6ca5076f 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovqb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtepi64_epi8 (s); res = _mm512_mask_cvtepi64_epi8 (res, m, s); res = _mm512_maskz_cvtepi64_epi8 (m, s); + _mm512_mask_cvtepi64_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-2.c index ae4eae15469..1b0fbbb3d05 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqb-2.c @@ -9,10 +9,12 @@ #define SIZE (AVX512F_LEN / 64) #include "avx512f-mask-type.h" -CALC (char *r, long long *s) +CALC (char *r, long long *s, int mem) { int i; - for (i = 0; i < 16; i++) + /* Don't zero out upper half if destination is memory. */ + int len = mem ? 8 : 16; + for (i = 0; i < len; i++) { r[i] = (i < SIZE) ? (char) s[i] : 0; } @@ -23,9 +25,11 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + char res4[16]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; char res_ref[16]; + char res_ref2[16]; sign = -1; for (i = 0; i < SIZE; i++) @@ -33,13 +37,21 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; + } + + for (i = SIZE; i < 16; i++) + { + /* To check that memory is not touched. */ + res4[i] = DEFAULT_VALUE * 2; + res_ref2[i] = DEFAULT_VALUE * 2; } res1.x = INTRINSIC (_cvtepi64_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtepi64_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtepi64_epi8) (mask, src.x); - CALC (res_ref, src.a); + CALC (res_ref, src.a, 0); if (UNION_CHECK (128, i_b) (res1, res_ref)) abort (); @@ -51,4 +63,13 @@ TEST (void) MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); + + + INTRINSIC (_mask_cvtepi64_storeu_epi8) (res4, mask, src.x); + + CALC (res_ref2, src.a, 1); + MASK_MERGE (i_b) (res_ref2, mask, SIZE); + + if (checkVc (res4, res_ref2, 16)) + abort (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-1.c index f0f80b10175..4055bf8ac4d 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovqd\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtepi64_epi32 (s); res = _mm512_mask_cvtepi64_epi32 (res, m, s); res = _mm512_maskz_cvtepi64_epi32 (m, s); + _mm512_mask_cvtepi64_storeu_epi32 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-2.c index 19b5cb89ae6..db5054b9323 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqd-2.c @@ -23,7 +23,8 @@ void static TEST (void) { int i, sign; - UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3; + UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3, res5; + int res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; int res_ref[SIZE_HALF]; @@ -34,11 +35,14 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtepi64_epi32) (src.x); res2.x = INTRINSIC (_mask_cvtepi64_epi32) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtepi64_epi32) (mask, src.x); + INTRINSIC (_mask_cvtepi64_storeu_epi32) (res4, mask, src.x); + CALC (res_ref, src.a); @@ -49,6 +53,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref)) abort (); + if (checkVi (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_d) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-1.c index 20011ee75a9..e63136364de 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovqw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtepi64_epi16 (s); res = _mm512_mask_cvtepi64_epi16 (res, m, s); res = _mm512_maskz_cvtepi64_epi16 (m, s); + _mm512_mask_cvtepi64_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-2.c index 3734adf0878..9bdd6e10d6f 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovqw-2.c @@ -23,6 +23,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_w) res1, res2, res3; + short res4[8]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; short res_ref[8]; @@ -33,11 +34,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtepi64_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtepi64_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtepi64_epi16) (mask, src.x); + INTRINSIC (_mask_cvtepi64_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -48,6 +51,9 @@ TEST (void) if (UNION_CHECK (128, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, 8)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-1.c index c14dc04e004..1b68d9ca76e 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovsdb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovsdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtsepi32_epi8 (s); res = _mm512_mask_cvtsepi32_epi8 (res, m, s); res = _mm512_maskz_cvtsepi32_epi8 (m, s); + _mm512_mask_cvtsepi32_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-2.c index 99ecd943361..4ac69b51717 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdb-2.c @@ -30,6 +30,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + char res4[16]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; char res_ref[16]; @@ -40,11 +41,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtsepi32_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtsepi32_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtsepi32_epi8) (mask, src.x); + INTRINSIC (_mask_cvtsepi32_storeu_epi8) (res4, mask, src.x); CALC (res_ref, src.a); @@ -55,6 +58,9 @@ TEST (void) if (UNION_CHECK (128, i_b) (res2, res_ref)) abort (); + if (checkVc (res4, res_ref, 16)) + abort (); + MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-1.c index 4984626ae06..ee10c12f03e 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovsdw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovsdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtsepi32_epi16 (s); res = _mm512_mask_cvtsepi32_epi16 (res, m, s); res = _mm512_maskz_cvtsepi32_epi16 (m, s); + _mm512_mask_cvtsepi32_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-2.c index 0e5cb4a2ad0..98d8745d9fe 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsdw-2.c @@ -31,6 +31,7 @@ TEST (void) { int i, sign; UNION_TYPE (AVX512F_LEN_HALF, i_w) res1, res2, res3; + short res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; short res_ref[SIZE_HALF]; @@ -41,11 +42,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtsepi32_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtsepi32_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtsepi32_epi16) (mask, src.x); + INTRINSIC (_mask_cvtsepi32_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -56,6 +59,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-1.c index bcd6992b902..9b2e00449d9 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovsqb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovsqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtsepi64_epi8 (s); res = _mm512_mask_cvtsepi64_epi8 (res, m, s); res = _mm512_maskz_cvtsepi64_epi8 (m, s); + _mm512_mask_cvtsepi64_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-2.c index 3f4d3aa1179..0fb7883de05 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqb-2.c @@ -10,10 +10,11 @@ #include "avx512f-mask-type.h" #include <limits.h> -CALC (char *r, long long *s) +CALC (char *r, long long *s, int mem) { int i; - for (i = 0; i < 16; i++) + int len = mem ? 8 : 16; + for (i = 0; i < len; i++) { if (s[i] < CHAR_MIN) r[i] = CHAR_MIN; @@ -30,9 +31,11 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + char res4[16]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; char res_ref[16]; + char res_ref2[16]; sign = -1; for (i = 0; i < SIZE; i++) @@ -40,13 +43,20 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; + } + + for (i = SIZE; i < 16; i++) + { + res_ref2[i] = DEFAULT_VALUE * 2; + res4[i] = DEFAULT_VALUE * 2; } res1.x = INTRINSIC (_cvtsepi64_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtsepi64_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtsepi64_epi8) (mask, src.x); - CALC (res_ref, src.a); + CALC (res_ref, src.a, 0); if (UNION_CHECK (128, i_b) (res1, res_ref)) abort (); @@ -58,4 +68,12 @@ TEST (void) MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); + + INTRINSIC (_mask_cvtsepi64_storeu_epi8) (res4, mask, src.x); + + CALC (res_ref2, src.a, 1); + MASK_MERGE (i_b) (res_ref2, mask, SIZE); + + if (checkVc (res4, res_ref2, 16)) + abort (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-1.c index acec81bb32d..ba61989351b 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovsqd\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovsqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtsepi64_epi32 (s); res = _mm512_mask_cvtsepi64_epi32 (res, m, s); res = _mm512_maskz_cvtsepi64_epi32 (m, s); + _mm512_mask_cvtsepi64_storeu_epi32 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-2.c index 2dbc4a276a9..3230528a3b0 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqd-2.c @@ -31,6 +31,7 @@ TEST (void) { int i, sign; UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3; + int res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; int res_ref[SIZE_HALF]; @@ -41,11 +42,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtsepi64_epi32) (src.x); res2.x = INTRINSIC (_mask_cvtsepi64_epi32) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtsepi64_epi32) (mask, src.x); + INTRINSIC (_mask_cvtsepi64_storeu_epi32) (res4, mask, src.x); CALC (res_ref, src.a); @@ -56,6 +59,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref)) abort (); + if (checkVi (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_d) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-1.c index 2952aca0764..a47e76741ea 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovsqw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovsqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovsqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtsepi64_epi16 (s); res = _mm512_mask_cvtsepi64_epi16 (res, m, s); res = _mm512_maskz_cvtsepi64_epi16 (m, s); + _mm512_mask_cvtsepi64_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-2.c index 163bc16a220..25e54a73dee 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovsqw-2.c @@ -30,6 +30,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_w) res1, res2, res3; + short res4[8]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; short res_ref[8]; @@ -40,11 +41,13 @@ TEST (void) src.a[i] = 1 + 34 * i * sign; sign = sign * -1; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtsepi64_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtsepi64_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtsepi64_epi16) (mask, src.x); + INTRINSIC (_mask_cvtsepi64_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -55,6 +58,9 @@ TEST (void) if (UNION_CHECK (128, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, 8)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-1.c index 90019f3f39d..bc0d3d5049f 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovusdb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovusdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusdb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtusepi32_epi8 (s); res = _mm512_mask_cvtusepi32_epi8 (res, m, s); res = _mm512_maskz_cvtusepi32_epi8 (m, s); + _mm512_mask_cvtusepi32_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-2.c index b86b14efe80..f13bb95b3d8 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdb-2.c @@ -25,6 +25,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + unsigned char res4[16]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; unsigned char res_ref[16]; @@ -33,11 +34,13 @@ TEST (void) { src.a[i] = 1 + 34 * i; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtusepi32_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtusepi32_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtusepi32_epi8) (mask, src.x); + INTRINSIC (_mask_cvtusepi32_storeu_epi8) (res4, mask, src.x); CALC (res_ref, src.a); @@ -48,6 +51,9 @@ TEST (void) if (UNION_CHECK (128, i_b) (res2, res_ref)) abort (); + if (checkVc (res4, res_ref, 16)) + abort (); + MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-1.c index 0ee86c982c6..ea987eb2f84 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovusdw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovusdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtusepi32_epi16 (s); res = _mm512_mask_cvtusepi32_epi16 (res, m, s); res = _mm512_maskz_cvtusepi32_epi16 (m, s); + _mm512_mask_cvtusepi32_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-2.c index 7840545d38f..c33a10b7115 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusdw-2.c @@ -26,6 +26,7 @@ TEST (void) { int i, sign; UNION_TYPE (AVX512F_LEN_HALF, i_w) res1, res2, res3; + unsigned short res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_d) src; MASK_TYPE mask = MASK_VALUE; unsigned short res_ref[SIZE_HALF]; @@ -34,11 +35,13 @@ TEST (void) { src.a[i] = 1 + 34 * i; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtusepi32_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtusepi32_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtusepi32_epi16) (mask, src.x); + INTRINSIC (_mask_cvtusepi32_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -49,6 +52,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-1.c index 4da4076bcb0..805b72403ce 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovusqb\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovusqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqb\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtusepi64_epi8 (s); res = _mm512_mask_cvtusepi64_epi8 (res, m, s); res = _mm512_maskz_cvtusepi64_epi8 (m, s); + _mm512_mask_cvtusepi64_storeu_epi8 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-2.c index 4d02eaf35dc..43fb9d275cc 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqb-2.c @@ -10,10 +10,11 @@ #include "avx512f-mask-type.h" #include <limits.h> -CALC (unsigned char *r, unsigned long long *s) +CALC (unsigned char *r, unsigned long long *s, int mem) { int i; - for (i = 0; i < 16; i++) + int len = mem ? 8 : 16; + for (i = 0; i < len; i++) { r[i] = (s[i] > UCHAR_MAX) ? UCHAR_MAX : s[i]; r[i] = (i < SIZE) ? r[i] : 0; @@ -25,21 +26,30 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_b) res1, res2, res3; + unsigned char res4[16]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; unsigned char res_ref[16]; + unsigned char res_ref2[16]; for (i = 0; i < SIZE; i++) { src.a[i] = 1 + 34 * i; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; + } + + for (i = SIZE; i < 16; i++) + { + res4[i] = DEFAULT_VALUE * 2; + res_ref2[i] = DEFAULT_VALUE * 2; } res1.x = INTRINSIC (_cvtusepi64_epi8) (src.x); res2.x = INTRINSIC (_mask_cvtusepi64_epi8) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtusepi64_epi8) (mask, src.x); - CALC (res_ref, src.a); + CALC (res_ref, src.a, 0); if (UNION_CHECK (128, i_b) (res1, res_ref)) abort (); @@ -51,4 +61,13 @@ TEST (void) MASK_ZERO (i_b) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_b) (res3, res_ref)) abort (); + + INTRINSIC (_mask_cvtusepi64_storeu_epi8) (res4, mask, src.x); + + CALC (res_ref2, src.a, 1); + MASK_MERGE (i_b) (res_ref2, mask, SIZE); + + if (checkVc (res4, res_ref2, 16)) + abort (); + } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-1.c index 69520d91d91..11d7ccbcf12 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovusqd\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovusqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtusepi64_epi32 (s); res = _mm512_mask_cvtusepi64_epi32 (res, m, s); res = _mm512_maskz_cvtusepi64_epi32 (m, s); + _mm512_mask_cvtusepi64_storeu_epi32 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-2.c index 7b79d3e50c5..79613b36ac3 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqd-2.c @@ -26,6 +26,7 @@ TEST (void) { int i, sign; UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3; + unsigned int res4[SIZE_HALF]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; unsigned int res_ref[SIZE_HALF]; @@ -34,11 +35,13 @@ TEST (void) { src.a[i] = 1 + 34 * i; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtusepi64_epi32) (src.x); res2.x = INTRINSIC (_mask_cvtusepi64_epi32) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtusepi64_epi32) (mask, src.x); + INTRINSIC (_mask_cvtusepi64_storeu_epi32) (res4, mask, src.x); CALC (res_ref, src.a); @@ -49,6 +52,9 @@ TEST (void) if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref)) abort (); + if (checkVi (res4, res_ref, SIZE_HALF)) + abort (); + MASK_ZERO (i_d) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-1.c index e6ca2283c4b..1f6eb241178 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpmovusqw\[ \\t\]+\[^\n\]*" 4 } } */ /* { dg-final { scan-assembler-times "vpmovusqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\[^\{\]" 1 } } */ /* { dg-final { scan-assembler-times "vpmovusqw\[ \\t\]+\[^\n\]*%xmm\[0-9\]\{%k\[1-7\]\}\{z\}" 1 } } */ @@ -16,4 +17,5 @@ avx512f_test (void) res = _mm512_cvtusepi64_epi16 (s); res = _mm512_mask_cvtusepi64_epi16 (res, m, s); res = _mm512_maskz_cvtusepi64_epi16 (m, s); + _mm512_mask_cvtusepi64_storeu_epi16 ((void *) &res, m, s); } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-2.c index 34fcd474f8e..f905eed83f0 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpmovusqw-2.c @@ -25,6 +25,7 @@ TEST (void) { int i, sign; UNION_TYPE (128, i_w) res1, res2, res3; + unsigned short res4[8]; UNION_TYPE (AVX512F_LEN, i_q) src; MASK_TYPE mask = MASK_VALUE; unsigned short res_ref[8]; @@ -33,11 +34,13 @@ TEST (void) { src.a[i] = 1 + 34 * i; res2.a[i] = DEFAULT_VALUE; + res4[i] = DEFAULT_VALUE; } res1.x = INTRINSIC (_cvtusepi64_epi16) (src.x); res2.x = INTRINSIC (_mask_cvtusepi64_epi16) (res2.x, mask, src.x); res3.x = INTRINSIC (_maskz_cvtusepi64_epi16) (mask, src.x); + INTRINSIC (_mask_cvtusepi64_storeu_epi16) (res4, mask, src.x); CALC (res_ref, src.a); @@ -48,6 +51,9 @@ TEST (void) if (UNION_CHECK (128, i_w) (res2, res_ref)) abort (); + if (checkVs (res4, res_ref, 8)) + abort (); + MASK_ZERO (i_w) (res_ref, mask, SIZE); if (UNION_CHECK (128, i_w) (res3, res_ref)) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0dpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0dpd-1.c new file mode 100644 index 00000000000..1368b7a459d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0dpd-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vgatherpf0dpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m256i idx; +volatile __mmask8 m8; +void *base; + +void extern +avx512pf_test (void) +{ + _mm512_mask_prefetch_i32gather_pd (idx, m8, base, 8, 0); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0qpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0qpd-1.c new file mode 100644 index 00000000000..61a81bb29ae --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf0qpd-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vgatherpf0qpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i idx; +volatile __mmask8 m8; +int *base; + +void extern +avx512pf_test (void) +{ + _mm512_mask_prefetch_i64gather_pd (idx, m8, base, 8, 0); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1dpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1dpd-1.c new file mode 100644 index 00000000000..5bc7599712e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1dpd-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vgatherpf1dpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m256i idx; +volatile __mmask8 m8; +int *base; + +void extern +avx512pf_test (void) +{ + _mm512_mask_prefetch_i32gather_pd (idx, m8, base, 8, 1); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1qpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1qpd-1.c new file mode 100644 index 00000000000..96610dbe243 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vgatherpf1qpd-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vgatherpf1qpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i idx; +volatile __mmask8 m8; +int *base; + +void extern +avx512pf_test (void) +{ + _mm512_mask_prefetch_i64gather_pd (idx, m8, base, 8, 1); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0dpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0dpd-1.c new file mode 100644 index 00000000000..83c31cc4594 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0dpd-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vscatterpf0dpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 2 } } */ +/* { dg-final { scan-assembler-times "vscatterpf0dpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m256i idx; +volatile __mmask8 m8; +void *base; + +void extern +avx512pf_test (void) +{ + _mm512_prefetch_i32scatter_pd (base, idx, 8, 0); + _mm512_mask_prefetch_i32scatter_pd (base, m8, idx, 8, 0); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0qpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0qpd-1.c new file mode 100644 index 00000000000..31172f85586 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf0qpd-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vscatterpf0qpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]" 2 } } */ +/* { dg-final { scan-assembler-times "vscatterpf0qpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i idx; +volatile __mmask8 m8; +void *base; + +void extern +avx512pf_test (void) +{ + _mm512_prefetch_i64scatter_pd (base, idx, 8, 0); + _mm512_mask_prefetch_i64scatter_pd (base, m8, idx, 8, 0); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1dpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1dpd-1.c new file mode 100644 index 00000000000..205505b8597 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1dpd-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vscatterpf1dpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 2 } } */ +/* { dg-final { scan-assembler-times "vscatterpf1dpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m256i idx; +volatile __mmask8 m8; +void *base; + +void extern +avx512pf_test (void) +{ + _mm512_prefetch_i32scatter_pd (base, idx, 8, 1); + _mm512_mask_prefetch_i32scatter_pd (base, m8, idx, 8, 1); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1qpd-1.c b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1qpd-1.c new file mode 100644 index 00000000000..64d7dfa95f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512pf-vscatterpf1qpd-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512pf -O2" } */ +/* { dg-final { scan-assembler-times "vscatterpf1qpd\[ \\t\]+\[^\n\]*%zmm\[0-9\]" 2 } } */ +/* { dg-final { scan-assembler-times "vscatterpf1qpd\[ \\t\]+\[^\n\]*\{%k\[1-7\]" 1 } } */ + +#include <immintrin.h> + +volatile __m512i idx; +volatile __mmask8 m8; +int *base; + +void extern +avx512pf_test (void) +{ + _mm512_prefetch_i64scatter_pd (base, idx, 8, 1); + _mm512_mask_prefetch_i64scatter_pd (base, m8, idx, 8, 1); +} diff --git a/gcc/testsuite/gcc.target/i386/m128-check.h b/gcc/testsuite/gcc.target/i386/m128-check.h index 6336717280f..98dc2699839 100644 --- a/gcc/testsuite/gcc.target/i386/m128-check.h +++ b/gcc/testsuite/gcc.target/i386/m128-check.h @@ -113,6 +113,8 @@ checkV##ARRAY (const TYPE *v, const TYPE *e, int n) \ return err; \ } +CHECK_ARRAY(c, char, "0x%hhx") +CHECK_ARRAY(s, short, "0x%hx") CHECK_ARRAY(i, int, "0x%x") CHECK_ARRAY(l, long long, "0x%llx") diff --git a/gcc/testsuite/gcc.target/i386/pr59929.c b/gcc/testsuite/gcc.target/i386/pr59929.c new file mode 100644 index 00000000000..4591dc4d601 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr59929.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-O0 -mno-accumulate-outgoing-args" } */ +/* { dg-options "-O0 -mno-accumulate-outgoing-args -mx32 -maddress-mode=short" { target x32 } } */ + +void +__attribute__ ((noinline)) +test (float x1, float x2, float x3, float x4, float x5, float x6, + float x7, float x8, float x9, float x10, float x11, float x12, + float x13, float x14, float x15, float x16) +{ + if (x1 != 91 + || x2 != 92 + || x3 != 93 + || x4 != 94 + || x5 != 95 + || x6 != 96 + || x7 != 97 + || x8 != 98 + || x9 != 99 + || x10 != 100 + || x11 != 101 + || x12 != 102 + || x13 != 103 + || x14 != 104 + || x15 != 105 + || x16 != 106) + __builtin_abort (); +} + +float x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, + x14, x15, x16; + +int +main () +{ + x1 = 91; + x2 = 92; + x3 = 93; + x4 = 94; + x5 = 95; + x6 = 96; + x7 = 97; + x8 = 98; + x9 = 99; + x10 = 100; + x11 = 101; + x12 = 102; + x13 = 103; + x14 = 104; + x15 = 105; + x16 = 106; + test (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, + x14, x15, x16); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/sse-14.c b/gcc/testsuite/gcc.target/i386/sse-14.c index ad7ca7600f7..643eb992f48 100644 --- a/gcc/testsuite/gcc.target/i386/sse-14.c +++ b/gcc/testsuite/gcc.target/i386/sse-14.c @@ -523,6 +523,10 @@ test_3vx (_mm512_mask_prefetch_i32gather_ps, __m512i, __mmask16, void const *, 1 test_3vx (_mm512_mask_prefetch_i32scatter_ps, void const *, __mmask16, __m512i, 1, 1) test_3vx (_mm512_mask_prefetch_i64gather_ps, __m512i, __mmask8, void const *, 1, 1) test_3vx (_mm512_mask_prefetch_i64scatter_ps, void const *, __mmask8, __m512i, 1, 1) +test_3vx (_mm512_mask_prefetch_i32gather_pd, __m256i, __mmask8, void const *, 1, 1) +test_3vx (_mm512_mask_prefetch_i32scatter_pd, void const *, __mmask8, __m256i, 1, 1) +test_3vx (_mm512_mask_prefetch_i64gather_pd, __m512i, __mmask8, void const *, 1, 1) +test_3vx (_mm512_mask_prefetch_i64scatter_pd, void const *, __mmask8, __m512i, 1, 1) /* avx512erintrin.h */ test_1 (_mm512_exp2a23_round_pd, __m512d, __m512d, 5) diff --git a/gcc/testsuite/gcc.target/i386/sse-22.c b/gcc/testsuite/gcc.target/i386/sse-22.c index 630c952ab69..7d68be1a5ed 100644 --- a/gcc/testsuite/gcc.target/i386/sse-22.c +++ b/gcc/testsuite/gcc.target/i386/sse-22.c @@ -646,6 +646,11 @@ test_3vx (_mm512_mask_prefetch_i32scatter_ps, void const *, __mmask16, __m512i, test_3vx (_mm512_mask_prefetch_i64gather_ps, __m512i, __mmask8, void const *, 1, 1) test_3vx (_mm512_mask_prefetch_i64scatter_ps, void const *, __mmask8, __m512i, 1, 1) +test_3vx (_mm512_mask_prefetch_i32gather_pd, __m256i, __mmask8, void const *, 1, 1) +test_3vx (_mm512_mask_prefetch_i32scatter_pd, void const *, __mmask8, __m256i, 1, 1) +test_3vx (_mm512_mask_prefetch_i64gather_pd, __m512i, __mmask8, long long *, 1, 1) +test_3vx (_mm512_mask_prefetch_i64scatter_pd, void const *, __mmask8, __m512i, 1, 1) + /* avx512erintrin.h */ test_1 (_mm512_exp2a23_round_pd, __m512d, __m512d, 5) test_1 (_mm512_exp2a23_round_ps, __m512, __m512, 5) diff --git a/gcc/testsuite/gcc.target/i386/sse-23.c b/gcc/testsuite/gcc.target/i386/sse-23.c index 309cd739e60..77c8d67af39 100644 --- a/gcc/testsuite/gcc.target/i386/sse-23.c +++ b/gcc/testsuite/gcc.target/i386/sse-23.c @@ -365,6 +365,10 @@ #define __builtin_ia32_gatherpfqps(A, B, C, D, E) __builtin_ia32_gatherpfqps(A, B, C, 1, 1) #define __builtin_ia32_scatterpfdps(A, B, C, D, E) __builtin_ia32_scatterpfdps(A, B, C, 1, 1) #define __builtin_ia32_scatterpfqps(A, B, C, D, E) __builtin_ia32_scatterpfqps(A, B, C, 1, 1) +#define __builtin_ia32_gatherpfdpd(A, B, C, D, E) __builtin_ia32_gatherpfdpd(A, B, C, 1, 1) +#define __builtin_ia32_gatherpfqpd(A, B, C, D, E) __builtin_ia32_gatherpfqpd(A, B, C, 1, 1) +#define __builtin_ia32_scatterpfdpd(A, B, C, D, E) __builtin_ia32_scatterpfdpd(A, B, C, 1, 1) +#define __builtin_ia32_scatterpfqpd(A, B, C, D, E) __builtin_ia32_scatterpfqpd(A, B, C, 1, 1) /* avx512erintrin.h */ #define __builtin_ia32_exp2pd_mask(A, B, C, D) __builtin_ia32_exp2pd_mask (A, B, C, 5) diff --git a/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c b/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c new file mode 100644 index 00000000000..fdcde1fa7de --- /dev/null +++ b/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void trap () +{ + __builtin_trap (); +} + +/* { dg-final { scan-assembler "brki\tr0,-1" } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.target/mips/pr52125.c b/gcc/testsuite/gcc.target/mips/pr52125.c index cfa8d68d10b..2ac80672060 100644 --- a/gcc/testsuite/gcc.target/mips/pr52125.c +++ b/gcc/testsuite/gcc.target/mips/pr52125.c @@ -1,4 +1,4 @@ -/* { dg-options "addressing=absolute" } */ +/* { dg-options "-mno-gpopt addressing=absolute" } */ int a, b, c, d; diff --git a/gcc/testsuite/gcc.target/powerpc/quad-atomic.c b/gcc/testsuite/gcc.target/powerpc/quad-atomic.c new file mode 100644 index 00000000000..6cf278852d7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/quad-atomic.c @@ -0,0 +1,67 @@ +/* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */ +/* { dg-require-effective-target p8vector_hw } */ +/* { dg-options "-mcpu=power8 -O2" } */ + +/* Test whether we get the right bits for quad word atomic instructions. */ +#include <stdlib.h> + +static __int128_t quad_fetch_and (__int128_t *, __int128_t value) __attribute__((__noinline__)); +static __int128_t quad_fetch_or (__int128_t *, __int128_t value) __attribute__((__noinline__)); +static __int128_t quad_fetch_add (__int128_t *, __int128_t value) __attribute__((__noinline__)); + +static __int128_t +quad_fetch_and (__int128_t *ptr, __int128_t value) +{ + return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE); +} + +static __int128_t +quad_fetch_or (__int128_t *ptr, __int128_t value) +{ + return __atomic_fetch_or (ptr, value, __ATOMIC_ACQUIRE); +} + +static __int128_t +quad_fetch_add (__int128_t *ptr, __int128_t value) +{ + return __atomic_fetch_add (ptr, value, __ATOMIC_ACQUIRE); +} + +int +main (void) +{ + __int128_t result; + __int128_t value; + __int128_t and_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL)); + __int128_t and_value = ((((__int128_t) 0xfffffffffffffff0ULL) << 64) | ((__int128_t) 0xfffffffffffffff0ULL)); + __int128_t and_exp = ((((__int128_t) 0x1234567890abcde0ULL) << 64) | ((__int128_t) 0xfedcba0987654320ULL)); + + __int128_t or_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL)); + __int128_t or_value = ((((__int128_t) 0x0000000000000010ULL) << 64) | ((__int128_t) 0x000000000000000eULL)); + __int128_t or_exp = ((((__int128_t) 0x1234567890abcdffULL) << 64) | ((__int128_t) 0xfedcba098765432fULL)); + + __int128_t add_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL)); + __int128_t add_value = ((((__int128_t) 0x0000000001000000ULL) << 64) | ((__int128_t) 0x0000001000000000ULL)); + __int128_t add_exp = ((((__int128_t) 0x1234567891abcdefULL) << 64) | ((__int128_t) 0xfedcba1987654321ULL)); + + + value = and_input; + result = quad_fetch_and (&value, and_value); + if (result != and_input || value != and_exp) + abort (); + + value = or_input; + result = quad_fetch_or (&value, or_value); + if (result != or_input || value != or_exp) + abort (); + + value = add_input; + result = quad_fetch_add (&value, add_value); + if (result != add_input || value != add_exp) + abort (); + + return 0; +} + diff --git a/gcc/testsuite/gcc.target/sh/torture/strncmp.c b/gcc/testsuite/gcc.target/sh/torture/strncmp.c new file mode 100644 index 00000000000..cd50f5c05a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/torture/strncmp.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +extern void abort (void); + +const char *s="astc"; +const char *s1="-----BEGIN RSA PRIVATE KEY-----"; +const char *s2="atextaac"; + +main() +{ + if (! __builtin_strncmp ("astb", s, 4)) + abort(); + + if (__builtin_strncmp(s1, "-----BEGIN ", 11)) + abort(); + + if (! __builtin_strncmp ("atextaacb", s2, 9)) + abort(); + + return 0; +} + diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index f6da19252c6..7aa732ddbb9 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4534,12 +4534,21 @@ infer_value_range (gimple stmt, tree op, enum tree_code *comp_code_p, tree *val_ if (stmt_could_throw_p (stmt)) return false; - /* If STMT is the last statement of a basic block with no + /* If STMT is the last statement of a basic block with no normal successors, there is no point inferring anything about any of its operands. We would not be able to find a proper insertion point for the assertion, anyway. */ - if (stmt_ends_bb_p (stmt) && EDGE_COUNT (gimple_bb (stmt)->succs) == 0) - return false; + if (stmt_ends_bb_p (stmt)) + { + edge_iterator ei; + edge e; + + FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->succs) + if (!(e->flags & EDGE_ABNORMAL)) + break; + if (e == NULL) + return false; + } if (infer_nonnull_range (stmt, op, true, true)) { diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index cfa785079f6..512c08bb120 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -2481,7 +2481,8 @@ static bool local_get_addr_clear_given_value (const void *v ATTRIBUTE_UNUSED, void **slot, void *x) { - if (vt_get_canonicalize_base ((rtx)*slot) == x) + if (*slot != NULL + && vt_get_canonicalize_base ((rtx)*slot) == x) *slot = NULL; return true; } @@ -2501,7 +2502,8 @@ val_reset (dataflow_set *set, decl_or_value dv) gcc_assert (var->n_var_parts == 1); - if (var->onepart == ONEPART_VALUE) + if (var->onepart == ONEPART_VALUE + && local_get_addr_cache != NULL) { rtx x = dv_as_value (dv); void **slot; @@ -6934,12 +6936,12 @@ vt_find_locations (void) bool success = true; timevar_push (TV_VAR_TRACKING_DATAFLOW); - /* Compute reverse completion order of depth first search of the CFG + /* Compute reverse top sord order of the inverted CFG so that the data-flow runs faster. */ - rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS); + rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); bb_order = XNEWVEC (int, last_basic_block_for_fn (cfun)); - pre_and_rev_post_order_compute (NULL, rc_order, false); - for (i = 0; i < n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS; i++) + int num = inverted_post_order_compute (rc_order); + for (i = 0; i < num; i++) bb_order[rc_order[i]] = i; free (rc_order); diff --git a/gnattools/ChangeLog b/gnattools/ChangeLog index 7039b834ba2..a7bd840efb1 100644 --- a/gnattools/ChangeLog +++ b/gnattools/ChangeLog @@ -1,3 +1,8 @@ +2014-01-27 Eric Botcazou <ebotcazou@adacore.com> + + * configure.ac (*-*-lynxos*): Delete. + * configure: Regenerate. + 2013-12-12 Eric Botcazou <ebotcazou@adacore.com> Iain Sandoe <iain@codesourcery.com> diff --git a/gnattools/configure b/gnattools/configure index 883b705f6cc..05183085265 100755 --- a/gnattools/configure +++ b/gnattools/configure @@ -2049,11 +2049,6 @@ case "${target}" in mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \ indepsw.adb<indepsw-gnu.adb" ;; - *-*-lynxos*) - TOOLS_TARGET_PAIRS="\ - mlib-tgt-specific.adb<mlib-tgt-specific-lynxos.adb \ - indepsw.adb<indepsw-gnu.adb" - ;; *-*-solaris*) TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-solaris.adb" ;; diff --git a/gnattools/configure.ac b/gnattools/configure.ac index 5edaadfcf58..46658fb3fba 100644 --- a/gnattools/configure.ac +++ b/gnattools/configure.ac @@ -89,11 +89,6 @@ case "${target}" in mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \ indepsw.adb<indepsw-gnu.adb" ;; - *-*-lynxos*) - TOOLS_TARGET_PAIRS="\ - mlib-tgt-specific.adb<mlib-tgt-specific-lynxos.adb \ - indepsw.adb<indepsw-gnu.adb" - ;; *-*-solaris*) TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-solaris.adb" ;; diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog index 36a60033c1b..14df41c99ea 100644 --- a/libdecnumber/ChangeLog +++ b/libdecnumber/ChangeLog @@ -1,3 +1,8 @@ +2014-01-23 Marek Polacek <polacek@redhat.com> + + PR c/59871 + * decNumberLocal.h (UBFROMUS, UBFROMUI): Remove last argument. + 2014-01-02 Richard Sandiford <rdsandiford@googlemail.com> Update copyright years diff --git a/libdecnumber/decNumberLocal.h b/libdecnumber/decNumberLocal.h index 94e7f7f9b1f..4936231f2a2 100644 --- a/libdecnumber/decNumberLocal.h +++ b/libdecnumber/decNumberLocal.h @@ -153,10 +153,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define UBTOUI(b) (memcpy((void *)&uiwork, b, 4), uiwork) /* Store a uInt, etc., into bytes starting at a char* or uByte*. */ - /* Returns i, evaluated, for convenience; has to use uiwork because */ - /* i may be an expression. */ - #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork) - #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork) + /* Has to use uiwork because i may be an expression. */ + #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2)) + #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4)) /* X10 and X100 -- multiply integer i by 10 or 100 */ /* [shifts are usually faster than multiply; could be conditional] */ diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index cb6885e7ce8..845c8f4faac 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,104 @@ +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilepro/atomic.c: Include tconfig.h. Don't include + config.h or system.h. + (bool) Define. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilepro/atomic.c (pre_atomic_barrier): Mark inline. + (post_atomic_barrier): Ditto. + (__fetch_and_do): New macro. + (__atomic_fetch_and_do): Use __fetch_and_do. + (__sync_fetch_and_do): New macro. + (__sync_fetch_and_add_4): New function. + (__sync_fetch_and_sub_4): New function. + (__sync_fetch_and_or_4): New function. + (__sync_fetch_and_and_4): New function. + (__sync_fetch_and_xor_4): New function. + (__sync_fetch_and_nand_4): New function. + (__sync_fetch_and_add_8): New function. + (__sync_fetch_and_sub_8): New function. + (__sync_fetch_and_or_8): New function. + (__sync_fetch_and_and_8): New function. + (__sync_fetch_and_xor_8): New function. + (__sync_fetch_and_nand_8): New function. + (__do_and_fetch): New macro. + (__atomic_do_and_fetch): Use __do_and_fetch. + (__sync_do_and_fetch): New macro. + (__sync_add_and_fetch_4): New function. + (__sync_sub_and_fetch_4): New function. + (__sync_or_and_fetch_4): New function. + (__sync_and_and_fetch_4): New function. + (__sync_xor_and_fetch_4): New function. + (__sync_nand_and_fetch_4): New function. + (__sync_add_and_fetch_8): New function. + (__sync_sub_and_fetch_8): New function. + (__sync_or_and_fetch_8): New function. + (__sync_and_and_fetch_8): New function. + (__sync_xor_and_fetch_8): New function. + (__sync_nand_and_fetch_8): New function. + (__sync_exchange_methods): New macro. + (__sync_val_compare_and_swap_4): New function. + (__sync_bool_compare_and_swap_4): New function. + (__sync_lock_test_and_test_4): New function. + (__sync_val_compare_and_swap_8): New function. + (__sync_bool_compare_and_swap_8): New function. + (__sync_lock_test_and_test_8): New function. + (__subword_cmpxchg_body): New macro. + (__atomic_compare_exchange_1): Use __subword_cmpxchg_body. + (__atomic_compare_exchange_2): Ditto. + (__sync_subword_cmpxchg): New macro. + (__sync_val_compare_and_swap_1): New function. + (__sync_bool_compare_and_swap_1): New function. + (__sync_val_compare_and_swap_2): New function. + (__sync_bool_compare_and_swap_2): New function. + (__atomic_subword): Rename to ... + (__subword): ... New name. + (__atomic_subword_fetch): Use __subword. + (__sync_subword_fetch): New macro. + (__sync_fetch_and_add_1): New function. + (__sync_fetch_and_sub_1): New function. + (__sync_fetch_and_or_1): New function. + (__sync_fetch_and_and_1): New function. + (__sync_fetch_and_xor_1): New function. + (__sync_fetch_and_nand_1): New function. + (__sync_fetch_and_add_2): New function. + (__sync_fetch_and_sub_2): New function. + (__sync_fetch_and_or_2): New function. + (__sync_fetch_and_and_2): New function. + (__sync_fetch_and_xor_2): New function. + (__sync_fetch_and_nand_2): New function. + (__sync_add_and_fetch_1): New function. + (__sync_sub_and_fetch_1): New function. + (__sync_or_and_fetch_1): New function. + (__sync_and_and_fetch_1): New function. + (__sync_xor_and_fetch_1): New function. + (__sync_nand_and_fetch_1): New function. + (__sync_add_and_fetch_2): New function. + (__sync_sub_and_fetch_2): New function. + (__sync_or_and_fetch_2): New function. + (__sync_and_and_fetch_2): New function. + (__sync_xor_and_fetch_2): New function. + (__sync_nand_and_fetch_2): New function. + (__atomic_subword_lock): Use __subword. + (__sync_subword_lock): New macro. + (__sync_lock_test_and_set_1): New function. + (__sync_lock_test_and_set_2): New function. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilepro/atomic.c (BIT_OFFSET): Define. + (__atomic_subword_cmpxchg): Use BIT_OFFSET. + (__atomic_subword): Ditto. + +2014-01-25 Walter Lee <walt@tilera.com> + + * config/tilepro/atomic.c (__atomic_do_and_fetch): Add + a prefix op argument. + (__atomic_nand_fetch_4): Add prefix op. + (__atomic_nand_fetch_8): Ditto. + 2014-01-21 Baruch Siach <barch@tkos.co.il> * config.host (tmake_file): add t-slibgcc-libgcc for xtensa*-*-linux*. diff --git a/libgcc/config/tilepro/atomic.c b/libgcc/config/tilepro/atomic.c index b3458ae7a65..66ef8fd7daa 100644 --- a/libgcc/config/tilepro/atomic.c +++ b/libgcc/config/tilepro/atomic.c @@ -21,15 +21,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" -#include "system.h" +#include "tconfig.h" #include "coretypes.h" #include "atomic.h" +#define bool unsigned char + /* This code should be inlined by the compiler, but for now support it as out-of-line methods in libgcc. */ -static void +static inline void pre_atomic_barrier (int model) { switch ((enum memmodel) model) @@ -45,7 +46,7 @@ pre_atomic_barrier (int model) return; } -static void +static inline void post_atomic_barrier (int model) { switch ((enum memmodel) model) @@ -63,16 +64,21 @@ post_atomic_barrier (int model) #define __unused __attribute__((unused)) -#define __atomic_fetch_and_do(type, size, opname) \ -type \ -__atomic_fetch_##opname##_##size(type* p, type i, int model) \ +#define __fetch_and_do(proto, type, size, opname, top, bottom) \ +proto \ { \ - pre_atomic_barrier(model); \ + top; \ type rv = arch_atomic_##opname(p, i); \ - post_atomic_barrier(model); \ + bottom; \ return rv; \ } +#define __atomic_fetch_and_do(type, size, opname) \ + __fetch_and_do(type __atomic_fetch_##opname##_##size(type* p, type i, int model), \ + type, size, opname, \ + pre_atomic_barrier(model), \ + post_atomic_barrier(model)) \ + __atomic_fetch_and_do (int, 4, add) __atomic_fetch_and_do (int, 4, sub) __atomic_fetch_and_do (int, 4, or) @@ -85,27 +91,73 @@ __atomic_fetch_and_do (long long, 8, or) __atomic_fetch_and_do (long long, 8, and) __atomic_fetch_and_do (long long, 8, xor) __atomic_fetch_and_do (long long, 8, nand) -#define __atomic_do_and_fetch(type, size, opname, op) \ -type \ -__atomic_##opname##_fetch_##size(type* p, type i, int model) \ -{ \ - pre_atomic_barrier(model); \ - type rv = arch_atomic_##opname(p, i) op i; \ - post_atomic_barrier(model); \ - return rv; \ + +#define __sync_fetch_and_do(type, size, opname) \ + __fetch_and_do(type __sync_fetch_and_##opname##_##size(type* p, type i), \ + type, size, opname, \ + arch_atomic_write_barrier(), \ + arch_atomic_read_barrier()) + +__sync_fetch_and_do (int, 4, add) +__sync_fetch_and_do (int, 4, sub) +__sync_fetch_and_do (int, 4, or) +__sync_fetch_and_do (int, 4, and) +__sync_fetch_and_do (int, 4, xor) +__sync_fetch_and_do (int, 4, nand) +__sync_fetch_and_do (long long, 8, add) +__sync_fetch_and_do (long long, 8, sub) +__sync_fetch_and_do (long long, 8, or) +__sync_fetch_and_do (long long, 8, and) +__sync_fetch_and_do (long long, 8, xor) +__sync_fetch_and_do (long long, 8, nand) + +#define __do_and_fetch(proto, type, size, opname, op, op2, top, bottom) \ +proto \ +{ \ + top; \ + type rv = op2 (arch_atomic_##opname(p, i) op i); \ + bottom; \ + return rv; \ } -__atomic_do_and_fetch (int, 4, add, +) -__atomic_do_and_fetch (int, 4, sub, -) -__atomic_do_and_fetch (int, 4, or, |) -__atomic_do_and_fetch (int, 4, and, &) -__atomic_do_and_fetch (int, 4, xor, |) -__atomic_do_and_fetch (int, 4, nand, &) -__atomic_do_and_fetch (long long, 8, add, +) -__atomic_do_and_fetch (long long, 8, sub, -) -__atomic_do_and_fetch (long long, 8, or, |) -__atomic_do_and_fetch (long long, 8, and, &) -__atomic_do_and_fetch (long long, 8, xor, |) -__atomic_do_and_fetch (long long, 8, nand, &) + +#define __atomic_do_and_fetch(type, size, opname, op, op2) \ + __do_and_fetch(type __atomic_##opname##_fetch_##size(type* p, type i, int model), \ + type, size, opname, op, op2, \ + pre_atomic_barrier(model), \ + post_atomic_barrier(model)) \ + +__atomic_do_and_fetch (int, 4, add, +, ) +__atomic_do_and_fetch (int, 4, sub, -, ) +__atomic_do_and_fetch (int, 4, or, |, ) +__atomic_do_and_fetch (int, 4, and, &, ) +__atomic_do_and_fetch (int, 4, xor, |, ) +__atomic_do_and_fetch (int, 4, nand, &, ~) +__atomic_do_and_fetch (long long, 8, add, +, ) +__atomic_do_and_fetch (long long, 8, sub, -, ) +__atomic_do_and_fetch (long long, 8, or, |, ) +__atomic_do_and_fetch (long long, 8, and, &, ) +__atomic_do_and_fetch (long long, 8, xor, |, ) +__atomic_do_and_fetch (long long, 8, nand, &, ~) + +#define __sync_do_and_fetch(type, size, opname, op, op2) \ + __do_and_fetch(type __sync_##opname##_and_fetch_##size(type* p, type i), \ + type, size, opname, op, op2, \ + arch_atomic_write_barrier(), \ + arch_atomic_read_barrier()) \ + +__sync_do_and_fetch (int, 4, add, +, ) +__sync_do_and_fetch (int, 4, sub, -, ) +__sync_do_and_fetch (int, 4, or, |, ) +__sync_do_and_fetch (int, 4, and, &, ) +__sync_do_and_fetch (int, 4, xor, |, ) +__sync_do_and_fetch (int, 4, nand, &, ~) +__sync_do_and_fetch (long long, 8, add, +, ) +__sync_do_and_fetch (long long, 8, sub, -, ) +__sync_do_and_fetch (long long, 8, or, |, ) +__sync_do_and_fetch (long long, 8, and, &, ) +__sync_do_and_fetch (long long, 8, xor, |, ) +__sync_do_and_fetch (long long, 8, nand, &, ~) + #define __atomic_exchange_methods(type, size) \ bool \ __atomic_compare_exchange_##size(volatile type* ptr, type* oldvalp, \ @@ -129,49 +181,117 @@ __atomic_exchange_##size(volatile type* ptr, type val, int model) \ post_atomic_barrier(model); \ return retval; \ } + __atomic_exchange_methods (int, 4) __atomic_exchange_methods (long long, 8) +#define __sync_exchange_methods(type, size) \ +type \ +__sync_val_compare_and_swap_##size(type* ptr, type oldval, type newval) \ +{ \ + arch_atomic_write_barrier(); \ + type retval = arch_atomic_val_compare_and_exchange(ptr, oldval, newval); \ + arch_atomic_read_barrier(); \ + return retval; \ +} \ + \ +bool \ +__sync_bool_compare_and_swap_##size(type* ptr, type oldval, type newval) \ +{ \ + arch_atomic_write_barrier(); \ + bool retval = arch_atomic_bool_compare_and_exchange(ptr, oldval, newval); \ + arch_atomic_read_barrier(); \ + return retval; \ +} \ + \ +type \ +__sync_lock_test_and_set_##size(type* ptr, type val) \ +{ \ + type retval = arch_atomic_exchange(ptr, val); \ + arch_atomic_acquire_barrier_value(retval); \ + return retval; \ +} + +__sync_exchange_methods (int, 4) +__sync_exchange_methods (long long, 8) + +#ifdef __LITTLE_ENDIAN__ +#define BIT_OFFSET(n, type) ((n) * 8) +#else +#define BIT_OFFSET(n, type) ((4 - sizeof(type) - (n)) * 8) +#endif + /* Subword methods require the same approach for both TILEPro and TILE-Gx. We load the background data for the word, insert the desired subword piece, then compare-and-exchange it into place. */ #define u8 unsigned char #define u16 unsigned short + +#define __subword_cmpxchg_body(type, size, ptr, guess, val) \ + ({ \ + unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ + const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \ + const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \ + const unsigned int bgmask = ~(valmask << shift); \ + unsigned int oldword = *p; \ + type oldval = (oldword >> shift) & valmask; \ + if (__builtin_expect((oldval == guess), 1)) { \ + unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \ + oldword = arch_atomic_val_compare_and_exchange(p, oldword, word); \ + oldval = (oldword >> shift) & valmask; \ + } \ + oldval; \ + }) \ + #define __atomic_subword_cmpxchg(type, size) \ \ bool \ -__atomic_compare_exchange_##size(volatile type* ptr, type* guess, \ +__atomic_compare_exchange_##size(volatile type* ptr, type* guess_ptr, \ type val, bool weak __unused, int models, \ int modelf __unused) \ { \ pre_atomic_barrier(models); \ - unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ - const int shift = ((unsigned long)ptr & 3UL) * 8; \ - const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \ - const unsigned int bgmask = ~(valmask << shift); \ - unsigned int oldword = *p; \ - type oldval = (oldword >> shift) & valmask; \ - if (__builtin_expect((oldval == *guess), 1)) { \ - unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \ - oldword = arch_atomic_val_compare_and_exchange(p, oldword, word); \ - oldval = (oldword >> shift) & valmask; \ - } \ + type guess = *guess_ptr; \ + type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \ post_atomic_barrier(models); \ - bool success = (oldval == *guess); \ - *guess = oldval; \ + bool success = (oldval == guess); \ + *guess_ptr = oldval; \ return success; \ } + __atomic_subword_cmpxchg (u8, 1) __atomic_subword_cmpxchg (u16, 2) + +#define __sync_subword_cmpxchg(type, size) \ + \ +type \ +__sync_val_compare_and_swap_##size(type* ptr, type guess, type val) \ +{ \ + arch_atomic_write_barrier(); \ + type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \ + arch_atomic_read_barrier(); \ + return oldval; \ +} \ + \ +bool \ +__sync_bool_compare_and_swap_##size(type* ptr, type guess, type val) \ +{ \ + type oldval = __sync_val_compare_and_swap_##size(ptr, guess, val); \ + return oldval == guess; \ +} + +__sync_subword_cmpxchg (u8, 1) +__sync_subword_cmpxchg (u16, 2) + /* For the atomic-update subword methods, we use the same approach as above, but we retry until we succeed if the compare-and-exchange fails. */ -#define __atomic_subword(type, proto, top, expr, bottom) \ +#define __subword(type, proto, top, expr, bottom) \ proto \ { \ top \ unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ - const int shift = ((unsigned long)ptr & 3UL) * 8; \ + const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \ const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \ const unsigned int bgmask = ~(valmask << shift); \ unsigned int oldword, xword = *p; \ @@ -185,42 +305,93 @@ proto \ } while (__builtin_expect(xword != oldword, 0)); \ bottom \ } + #define __atomic_subword_fetch(type, funcname, expr, retval) \ - __atomic_subword(type, \ - type __atomic_ ## funcname(volatile type *ptr, type i, int model), \ - pre_atomic_barrier(model);, \ - expr, \ - post_atomic_barrier(model); return retval;) + __subword(type, \ + type __atomic_ ## funcname(volatile type *ptr, type i, int model), \ + pre_atomic_barrier(model);, \ + expr, \ + post_atomic_barrier(model); return retval;) + __atomic_subword_fetch (u8, fetch_add_1, oldval + i, oldval) __atomic_subword_fetch (u8, fetch_sub_1, oldval - i, oldval) __atomic_subword_fetch (u8, fetch_or_1, oldval | i, oldval) __atomic_subword_fetch (u8, fetch_and_1, oldval & i, oldval) __atomic_subword_fetch (u8, fetch_xor_1, oldval ^ i, oldval) __atomic_subword_fetch (u8, fetch_nand_1, ~(oldval & i), oldval) + __atomic_subword_fetch (u16, fetch_add_2, oldval + i, oldval) __atomic_subword_fetch (u16, fetch_sub_2, oldval - i, oldval) __atomic_subword_fetch (u16, fetch_or_2, oldval | i, oldval) __atomic_subword_fetch (u16, fetch_and_2, oldval & i, oldval) __atomic_subword_fetch (u16, fetch_xor_2, oldval ^ i, oldval) __atomic_subword_fetch (u16, fetch_nand_2, ~(oldval & i), oldval) + __atomic_subword_fetch (u8, add_fetch_1, oldval + i, val) __atomic_subword_fetch (u8, sub_fetch_1, oldval - i, val) __atomic_subword_fetch (u8, or_fetch_1, oldval | i, val) __atomic_subword_fetch (u8, and_fetch_1, oldval & i, val) __atomic_subword_fetch (u8, xor_fetch_1, oldval ^ i, val) __atomic_subword_fetch (u8, nand_fetch_1, ~(oldval & i), val) + __atomic_subword_fetch (u16, add_fetch_2, oldval + i, val) __atomic_subword_fetch (u16, sub_fetch_2, oldval - i, val) __atomic_subword_fetch (u16, or_fetch_2, oldval | i, val) __atomic_subword_fetch (u16, and_fetch_2, oldval & i, val) __atomic_subword_fetch (u16, xor_fetch_2, oldval ^ i, val) __atomic_subword_fetch (u16, nand_fetch_2, ~(oldval & i), val) + +#define __sync_subword_fetch(type, funcname, expr, retval) \ + __subword(type, \ + type __sync_ ## funcname(type *ptr, type i), \ + arch_atomic_read_barrier();, \ + expr, \ + arch_atomic_write_barrier(); return retval;) + +__sync_subword_fetch (u8, fetch_and_add_1, oldval + i, oldval) +__sync_subword_fetch (u8, fetch_and_sub_1, oldval - i, oldval) +__sync_subword_fetch (u8, fetch_and_or_1, oldval | i, oldval) +__sync_subword_fetch (u8, fetch_and_and_1, oldval & i, oldval) +__sync_subword_fetch (u8, fetch_and_xor_1, oldval ^ i, oldval) +__sync_subword_fetch (u8, fetch_and_nand_1, ~(oldval & i), oldval) + +__sync_subword_fetch (u16, fetch_and_add_2, oldval + i, oldval) +__sync_subword_fetch (u16, fetch_and_sub_2, oldval - i, oldval) +__sync_subword_fetch (u16, fetch_and_or_2, oldval | i, oldval) +__sync_subword_fetch (u16, fetch_and_and_2, oldval & i, oldval) +__sync_subword_fetch (u16, fetch_and_xor_2, oldval ^ i, oldval) +__sync_subword_fetch (u16, fetch_and_nand_2, ~(oldval & i), oldval) + +__sync_subword_fetch (u8, add_and_fetch_1, oldval + i, val) +__sync_subword_fetch (u8, sub_and_fetch_1, oldval - i, val) +__sync_subword_fetch (u8, or_and_fetch_1, oldval | i, val) +__sync_subword_fetch (u8, and_and_fetch_1, oldval & i, val) +__sync_subword_fetch (u8, xor_and_fetch_1, oldval ^ i, val) +__sync_subword_fetch (u8, nand_and_fetch_1, ~(oldval & i), val) + +__sync_subword_fetch (u16, add_and_fetch_2, oldval + i, val) +__sync_subword_fetch (u16, sub_and_fetch_2, oldval - i, val) +__sync_subword_fetch (u16, or_and_fetch_2, oldval | i, val) +__sync_subword_fetch (u16, and_and_fetch_2, oldval & i, val) +__sync_subword_fetch (u16, xor_and_fetch_2, oldval ^ i, val) +__sync_subword_fetch (u16, nand_and_fetch_2, ~(oldval & i), val) + #define __atomic_subword_lock(type, size) \ - \ -__atomic_subword(type, \ - type __atomic_exchange_##size(volatile type* ptr, type nval, int model), \ - pre_atomic_barrier(model);, \ - nval, \ - post_atomic_barrier(model); return oldval;) + __subword(type, \ + type __atomic_exchange_##size(volatile type* ptr, type nval, int model), \ + pre_atomic_barrier(model);, \ + nval, \ + post_atomic_barrier(model); return oldval;) + __atomic_subword_lock (u8, 1) __atomic_subword_lock (u16, 2) + +#define __sync_subword_lock(type, size) \ + __subword(type, \ + type __sync_lock_test_and_set_##size(type* ptr, type nval), \ + , \ + nval, \ + arch_atomic_acquire_barrier_value(oldval); return oldval;) + +__sync_subword_lock (u8, 1) +__sync_subword_lock (u16, 2) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 30a26bcd4ef..f4cc57f83f1 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,12 @@ +2014-01-23 Yury Gribov <y.gribov@samsung.com> + Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/57316 + * configure.ac: Check for missing syscalls. + * Makefile.am: Likewise. + * configure: Regenerate. + * Makefile.in: Regenerate. + 2014-01-09 Jakub Jelinek <jakub@redhat.com> * sanitizer_common/sanitizer_symbolizer_libbacktrace.h diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am index a17f7b6af86..b0dc582ccfb 100644 --- a/libsanitizer/Makefile.am +++ b/libsanitizer/Makefile.am @@ -1,5 +1,6 @@ ACLOCAL_AMFLAGS = -I .. -I ../config +if SANITIZER_SUPPORTED SUBDIRS = sanitizer_common if !USING_MAC_INTERPOSE SUBDIRS += interception @@ -11,6 +12,7 @@ SUBDIRS += lsan asan ubsan if TSAN_SUPPORTED SUBDIRS += tsan endif +endif ## May be used by toolexeclibdir. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in index b7986304400..8ecf555e75d 100644 --- a/libsanitizer/Makefile.in +++ b/libsanitizer/Makefile.in @@ -52,9 +52,9 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception -@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = libbacktrace -@TSAN_SUPPORTED_TRUE@am__append_3 = tsan +@SANITIZER_SUPPORTED_TRUE@@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception +@LIBBACKTRACE_SUPPORTED_TRUE@@SANITIZER_SUPPORTED_TRUE@am__append_2 = libbacktrace +@SANITIZER_SUPPORTED_TRUE@@TSAN_SUPPORTED_TRUE@am__append_3 = tsan subdir = . DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ @@ -272,8 +272,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I .. -I ../config -SUBDIRS = sanitizer_common $(am__append_1) $(am__append_2) lsan asan \ - ubsan $(am__append_3) +@SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_1) \ +@SANITIZER_SUPPORTED_TRUE@ $(am__append_2) lsan asan ubsan \ +@SANITIZER_SUPPORTED_TRUE@ $(am__append_3) gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) # Work around what appears to be a GNU make bug handling MAKEFLAGS diff --git a/libsanitizer/configure b/libsanitizer/configure index 1e66431e36b..6dd42a4340d 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -612,6 +612,8 @@ ALLOC_FILE VIEW_FILE BACKTRACE_SUPPORTED FORMAT_FILE +SANITIZER_SUPPORTED_FALSE +SANITIZER_SUPPORTED_TRUE USING_MAC_INTERPOSE_FALSE USING_MAC_INTERPOSE_TRUE link_liblsan @@ -12022,7 +12024,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12025 "configure" +#line 12022 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12128,7 +12130,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12131 "configure" +#line 12128 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15591,6 +15593,47 @@ fi backtrace_supported=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for necessary platform features" >&5 +$as_echo_n "checking for necessary platform features... " >&6; } +case "$target" in + *-*-linux*) + # Some old Linux distributions miss required syscalls. + sanitizer_supported=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <sys/syscall.h> +int +main () +{ + + syscall (__NR_gettid); + syscall (__NR_futex); + syscall (__NR_exit_group); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + sanitizer_supported=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + *) + sanitizer_supported=yes + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sanitizer_supported" >&5 +$as_echo "$sanitizer_supported" >&6; } + if test "$sanitizer_supported" = yes; then + SANITIZER_SUPPORTED_TRUE= + SANITIZER_SUPPORTED_FALSE='#' +else + SANITIZER_SUPPORTED_TRUE='#' + SANITIZER_SUPPORTED_FALSE= +fi + + # Test for __sync support. { $as_echo "$as_me:${as_lineno-$LINENO}: checking __sync extensions" >&5 $as_echo_n "checking __sync extensions... " >&6; } @@ -16461,6 +16504,10 @@ if test -z "${USING_MAC_INTERPOSE_TRUE}" && test -z "${USING_MAC_INTERPOSE_FALSE as_fn_error "conditional \"USING_MAC_INTERPOSE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${SANITIZER_SUPPORTED_TRUE}" && test -z "${SANITIZER_SUPPORTED_FALSE}"; then + as_fn_error "conditional \"SANITIZER_SUPPORTED\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${LIBBACKTRACE_SUPPORTED_TRUE}" && test -z "${LIBBACKTRACE_SUPPORTED_FALSE}"; then as_fn_error "conditional \"LIBBACKTRACE_SUPPORTED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index c4641d47286..e6721312d0c 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -132,6 +132,24 @@ AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE) backtrace_supported=yes +AC_MSG_CHECKING([for necessary platform features]) +case "$target" in + *-*-linux*) + # Some old Linux distributions miss required syscalls. + sanitizer_supported=no + AC_TRY_COMPILE([#include <sys/syscall.h>],[ + syscall (__NR_gettid); + syscall (__NR_futex); + syscall (__NR_exit_group); + ], [sanitizer_supported=yes]) + ;; + *) + sanitizer_supported=yes + ;; +esac +AC_MSG_RESULT($sanitizer_supported) +AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes) + # Test for __sync support. AC_CACHE_CHECK([__sync extensions], [libsanitizer_cv_sys_sync], diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3d78f785927..da708305497 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,107 @@ +2014-01-27 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/59215 + * include/bits/shared_ptr_base.h + (_Sp_counted_base<_S_atomic>::_M_add_ref_lock()): Use relaxed atomic + load. + +2014-01-27 Jason Merrill <jason@redhat.com> + + Core DR 475 + PR c++/41174 + PR c++/59224 + * libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions. + * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception) + (__cxa_allocate_exception): Don't set it here. + +2014-01-26 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/stl_map.h: Remove anachronistic comment. + * include/bits/stl_multimap.h: Add whitespace. + * testsuite/23_containers/map/modifiers/emplace/1.cc: Use + -std=gnu++11 instead of -std=c++11. + * testsuite/23_containers/map/operators/2.cc: Likewise. + * testsuite/23_containers/multimap/modifiers/emplace/1.cc: Likewise. + * testsuite/23_containers/multiset/modifiers/emplace/1.cc: Likewise. + * testsuite/23_containers/set/modifiers/emplace/1.cc: Likewise. + + * acinclude.m4 (GLIBCXX_ENABLE_C99): Fix typo. + * configure: Regenerate. + +2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> + + PR libstdc++/59531 + * testsuite/experimental/string_view/operations/copy/char/1.cc: New. + * testsuite/experimental/string_view/operations/copy/wchar_t/1.cc: New. + +2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> + Peter A. Bigot <pab@pabigot.com> + + PR libstdc++/59531 + * include/experimental/string_view + (copy(_CharT*, size_type, size_type) const): Correct throw string. + Correct copy start location. + +2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> + Peter A. Bigot <pab@pabigot.com> + + PR libstdc++/59530 + * include/experimental/string_view (operator[](size_type) const): + Fix one-off index error in debug check. + * testsuite/experimental/string_view/element_access/char/1.cc: Don't + test basic_string_view at size(). + * testsuite/experimental/string_view/element_access/wchar_t/1.cc: Ditto. + +2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> + Peter A. Bigot <pab@pabigot.com> + + PR libstdc++/59529 + * include/experimental/string_view + (basic_string_view(const _CharT*, size_type)): Don't care if len == 0. + * testsuite/experimental/string_view/operations/substr/char/1.cc: + Comment out catch of out_of_range; No terminating null + in basic_string_view. Check begin == end. + * testsuite/experimental/string_view/operations/substr/wchar_t/1.cc: + Ditto. + +2014-01-24 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/59548 + * include/debug/safe_base.h (_Safe_sequence_base): Define copy + constructor to prevent it being implicitly defined as deleted, but + do not copy anything. + * include/debug/safe_unordered_base.h (_Safe_unordered_container_base): + Define copy and move constructors similar to _Safe_sequence_base's. + * testsuite/23_containers/unordered_map/59548.cc: New. + +2014-01-23 Bernhard Reutner-Fischer <aldot@gcc.gnu.org> + Steve Ellcey <sellcey@mips.com> + + * acinclude.m4 (GLIBCXX_CHECK_TMPNAM): New check for tmpnam + function. + * configure.ac: Use GLIBCXX_CHECK_TMPNAM. + * (configure, config.h.in): Regenerate. + * include/c_global/cstdio: Guard ::tmpnam with _GLIBCXX_USE_TMPNAM + +2014-01-23 Jonathan Wakely <jwakely@redhat.com> + + * doc/xml/faq.xml (a-how_to_set_paths): Expand FAQ answer. + * doc/xml/manual/abi.xml (abi.versioning.history): Correct symver. + + PR libstdc++/59872 + * include/bits/stl_map.h (map::operator=(map&&)): Fix comment. + * include/bits/stl_multimap.h (multimap::operator=(multimap&&)): + Likewise. + * include/bits/stl_multiset.h (multiset::operator=(multiset&&)): + Likewise. + * include/bits/stl_set.h (set::operator=(set&&)): Likewise. + * include/bits/stl_tree.h (_Rb_tree::_M_move_data): New overloaded + functions to perform moving or copying of elements from rvalue tree. + (_Rb_tree::_Rb_tree(_Rb_tree&&)): Use _M_move_data. + (_Rb_tree::_Rb_tree(_Rb_tree&&, _Node_allocator&&)): Likewise. + * testsuite/23_containers/map/59872.cc: New. + * testsuite/23_containers/map/56613.cc: Remove duplicate include. + 2014-01-22 Jonathan Wakely <jwakely@redhat.com> * include/bits/stl_deque.h (_Deque_impl): Move comment. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index fcdcd9ac865..b3ce3dbe3d9 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -922,7 +922,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [ # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__ # undefined and fake C99 facilities - like pre-standard snprintf - may be # spuriously enabled. - # Long term, -std=c++0x could be even better, could manage to explicitely + # Long term, -std=c++0x could be even better, could manage to explicitly # request C99 facilities to the underlying C headers. ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -std=c++98" @@ -3771,6 +3771,33 @@ AC_DEFUN([GLIBCXX_ENABLE_WERROR], [ GLIBCXX_CONDITIONAL(ENABLE_WERROR, test $enable_werror = yes) ]) +dnl +dnl Check whether obsolescent tmpnam is available in <stdio.h>, +dnl and define _GLIBCXX_USE_TMPNAM. +dnl +AC_DEFUN([GLIBCXX_CHECK_TMPNAM], [dnl +dnl + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -fno-exceptions" +dnl + AC_MSG_CHECKING([for tmpnam]) + AC_CACHE_VAL(glibcxx_cv_TMPNAM, [dnl + GCC_TRY_COMPILE_OR_LINK( + [#include <stdio.h>], + [char *tmp = tmpnam(NULL);], + [glibcxx_cv_TMPNAM=yes], + [glibcxx_cv_TMPNAM=no]) + ]) + if test $glibcxx_cv_TMPNAM = yes; then + AC_DEFINE(_GLIBCXX_USE_TMPNAM, 1, [Define if obsolescent tmpnam is available in <stdio.h>.]) + fi + AC_MSG_RESULT($glibcxx_cv_TMPNAM) +dnl + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE +]) dnl dnl Check to see if sys/sdt.h exists and that it is suitable for use. diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 4c029d21ff2..adc7d44ee48 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -867,6 +867,9 @@ /* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */ #undef _GLIBCXX_USE_SYSCTL_HW_NCPU +/* Define if obsolescent tmpnam is available in <stdio.h>. */ +#undef _GLIBCXX_USE_TMPNAM + /* Define if code specialized for wchar_t should be used. */ #undef _GLIBCXX_USE_WCHAR_T diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index f969f12d16c..7e2dca68e90 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -16547,7 +16547,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__ # undefined and fake C99 facilities - like pre-standard snprintf - may be # spuriously enabled. - # Long term, -std=c++0x could be even better, could manage to explicitely + # Long term, -std=c++0x could be even better, could manage to explicitly # request C99 facilities to the underlying C headers. ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -std=c++98" @@ -20120,6 +20120,81 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# Check for tmpnam which is obsolescent in POSIX.1-2008 + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -fno-exceptions" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tmpnam" >&5 +$as_echo_n "checking for tmpnam... " >&6; } + if test "${glibcxx_cv_TMPNAM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test x$gcc_no_link = xyes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +char *tmp = tmpnam(NULL); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_TMPNAM=yes +else + glibcxx_cv_TMPNAM=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + if test x$gcc_no_link = xyes; then + as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +char *tmp = tmpnam(NULL); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + glibcxx_cv_TMPNAM=yes +else + glibcxx_cv_TMPNAM=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + +fi + + if test $glibcxx_cv_TMPNAM = yes; then + +$as_echo "#define _GLIBCXX_USE_TMPNAM 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_TMPNAM" >&5 +$as_echo "$glibcxx_cv_TMPNAM" >&6; } + CXXFLAGS="$ac_save_CXXFLAGS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default" if test "x$ac_cv_header_locale_h" = x""yes; then : diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 22fc840f68b..1de0f6c1cbf 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -213,6 +213,9 @@ GLIBCXX_CHECK_GETTIMEOFDAY # For clock_gettime, nanosleep and sched_yield support. GLIBCXX_ENABLE_LIBSTDCXX_TIME +# Check for tmpnam which is obsolescent in POSIX.1-2008 +GLIBCXX_CHECK_TMPNAM + AC_LC_MESSAGES # For hardware_concurrency diff --git a/libstdc++-v3/doc/xml/faq.xml b/libstdc++-v3/doc/xml/faq.xml index 501f1618475..b4a53a2f19b 100644 --- a/libstdc++-v3/doc/xml/faq.xml +++ b/libstdc++-v3/doc/xml/faq.xml @@ -344,7 +344,7 @@ <para> Depending on your platform and library version, the error message might be similar to one of the following: - </para> + </para> <screen> ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory @@ -358,11 +358,34 @@ executable is run the linker finds and loads the required shared libraries by searching a pre-configured list of directories. If the directory where you've installed libstdc++ is not in this list - then the libraries won't be found. The simplest way to fix this is + then the libraries won't be found. + </para> + + <para> + If you already have an older version of libstdc++ installed then the + error might look like one of the following instead: + </para> + + <screen> + ./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found + ./a.out: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found + </screen> + + <para> + This means the linker found <filename>/usr/lib/libstdc++.so.6</filename> + but that library belongs to an older version of GCC than was used to + compile and link the program <filename>a.out</filename> (or some part + of it). The program depends on code defined in the newer libstdc++ + that belongs to the newer version of GCC, so the linker must be told + how to find the newer libstdc++ shared library. + </para> + + <para> + The simplest way to fix this is to use the <literal>LD_LIBRARY_PATH</literal> environment variable, which is a colon-separated list of directories in which the linker will search for shared libraries: - </para> + </para> <screen> LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH @@ -370,6 +393,11 @@ </screen> <para> + Here the shell variable <command>${prefix}</command> is assumed to contain + the directory prefix where GCC was installed to. The directory containing + the library might depend on whether you want the 32-bit or 64-bit copy + of the library, so for example would be + <filename>${prefix}/lib64</filename> on some systems. The exact environment variable to use will depend on your platform, e.g. DYLD_LIBRARY_PATH for Darwin, LD_LIBRARY_PATH_32/LD_LIBRARY_PATH_64 for Solaris 32-/64-bit @@ -379,7 +407,8 @@ See the man pages for <command>ld</command>, <command>ldd</command> and <command>ldconfig</command> for more information. The dynamic linker has different names on different platforms but the man page - is usually called something such as <filename>ld.so/rtld/dld.so</filename>. + is usually called something such as <filename>ld.so</filename>, + <filename>rtld</filename> or <filename>dld.so</filename>. </para> <para> Using LD_LIBRARY_PATH is not always the best solution, <link linkend="manual.intro.using.linkage.dynamic">Finding Dynamic or Shared diff --git a/libstdc++-v3/doc/xml/manual/abi.xml b/libstdc++-v3/doc/xml/manual/abi.xml index 25d1b307f00..d1c622cdd1a 100644 --- a/libstdc++-v3/doc/xml/manual/abi.xml +++ b/libstdc++-v3/doc/xml/manual/abi.xml @@ -328,7 +328,7 @@ compatible. <listitem><para>GCC 4.7.0: GLIBCXX_3.4.17, CXXABI_1.3.6</para></listitem> <listitem><para>GCC 4.8.0: GLIBCXX_3.4.18, CXXABI_1.3.7</para></listitem> <listitem><para>GCC 4.8.3: GLIBCXX_3.4.19, CXXABI_1.3.7</para></listitem> - <listitem><para>GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.7</para></listitem> + <listitem><para>GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8</para></listitem> </itemizedlist> </listitem> diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 83724e4fbb1..1c3a47dfb6e 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -233,7 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_add_ref_lock() { // Perform lock-free add-if-not-zero operation. - _Atomic_word __count = _M_use_count; + _Atomic_word __count = _M_get_use_count(); do { if (__count == 0) diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index e261be8ed18..334c54f4c90 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -154,8 +154,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; // [23.3.1.1] construct/copy/destroy - // (get_allocator() is normally listed in this section, but seems to have - // been accidentally omitted in the printed standard) + // (get_allocator() is also listed in this section) + /** * @brief Default constructor creates no elements. */ @@ -301,8 +301,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief %Map move assignment operator. * @param __x A %map of identical element and allocator types. * - * The contents of @a __x are moved into this map (without copying). - * @a __x is a valid, but unspecified %map. + * The contents of @a __x are moved into this map (without copying + * if the allocators compare equal or get moved on assignment). + * Afterwards @a __x is in a valid, but unspecified state. */ map& operator=(map&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 84046cbb191..c7b80c9944e 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -153,6 +153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // [23.3.2] construct/copy/destroy // (get_allocator() is also listed in this section) + /** * @brief Default constructor creates no elements. */ @@ -295,8 +296,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief %Multimap move assignment operator. * @param __x A %multimap of identical element and allocator types. * - * The contents of @a __x are moved into this multimap (without copying). - * @a __x is a valid, but unspecified multimap. + * The contents of @a __x are moved into this multimap (without copying + * if the allocators compare equal or get moved on assignment). + * Afterwards @a __x is in a valid, but unspecified state. */ multimap& operator=(multimap&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 3305107efdd..6d71c1b8621 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -267,9 +267,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief %Multiset move assignment operator. * @param __x A %multiset of identical element and allocator types. * - * The contents of @a __x are moved into this %multiset - * (without copying). @a __x is a valid, but unspecified - * %multiset. + * The contents of @a __x are moved into this %multiset (without + * copying if the allocators compare equal or get moved on assignment). + * Afterwards @a __x is in a valid, but unspecified state. */ multiset& operator=(multiset&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 652be58d977..3a391545ec8 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -271,8 +271,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief %Set move assignment operator. * @param __x A %set of identical element and allocator types. * - * The contents of @a __x are moved into this %set (without copying). - * @a __x is a valid, but unspecified %set. + * The contents of @a __x are moved into this %set (without copying + * if the allocators compare equal or get moved on assignment). + * Afterwards @a __x is in a valid, but unspecified state. */ set& operator=(set&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index e41b1340e69..d24b1f750bc 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -698,8 +698,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _Rb_tree(_Rb_tree&& __x) - : _Rb_tree(std::move(__x), std::move(__x._M_get_Node_allocator())) - { } + : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator()) + { + if (__x._M_root() != 0) + _M_move_data(__x, std::true_type()); + } _Rb_tree(_Rb_tree&& __x, const allocator_type& __a) : _Rb_tree(std::move(__x), _Node_allocator(__a)) @@ -948,6 +951,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L bool _M_move_assign(_Rb_tree&); + + private: + // Move elements from container with equal allocator. + void + _M_move_data(_Rb_tree&, std::true_type); + + // Move elements from container with possibly non-equal allocator, + // which might result in a copy not a move. + void + _M_move_data(_Rb_tree&, std::false_type); #endif }; @@ -1013,30 +1026,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) : _M_impl(__x._M_impl._M_key_compare, std::move(__a)) { + using __eq = integral_constant<bool, _Alloc_traits::_S_always_equal()>; if (__x._M_root() != 0) - { - if (!_Alloc_traits::_S_always_equal() - && __x._M_get_Node_allocator() != __a) - { - _M_root() = _M_copy(__x._M_begin(), _M_end()); - _M_leftmost() = _S_minimum(_M_root()); - _M_rightmost() = _S_maximum(_M_root()); - _M_impl._M_node_count = __x._M_impl._M_node_count; - } - else - { - _M_root() = __x._M_root(); - _M_leftmost() = __x._M_leftmost(); - _M_rightmost() = __x._M_rightmost(); - _M_root()->_M_parent = _M_end(); + _M_move_data(__x, __eq()); + } - __x._M_root() = 0; - __x._M_leftmost() = __x._M_end(); - __x._M_rightmost() = __x._M_end(); + template<typename _Key, typename _Val, typename _KeyOfValue, + typename _Compare, typename _Alloc> + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_data(_Rb_tree& __x, std::true_type) + { + _M_root() = __x._M_root(); + _M_leftmost() = __x._M_leftmost(); + _M_rightmost() = __x._M_rightmost(); + _M_root()->_M_parent = _M_end(); - this->_M_impl._M_node_count = __x._M_impl._M_node_count; - __x._M_impl._M_node_count = 0; - } + __x._M_root() = 0; + __x._M_leftmost() = __x._M_end(); + __x._M_rightmost() = __x._M_end(); + + this->_M_impl._M_node_count = __x._M_impl._M_node_count; + __x._M_impl._M_node_count = 0; + } + + template<typename _Key, typename _Val, typename _KeyOfValue, + typename _Compare, typename _Alloc> + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_data(_Rb_tree& __x, std::false_type) + { + if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) + _M_move_data(__x, std::true_type()); + else + { + _M_root() = _M_copy(__x._M_begin(), _M_end()); + _M_leftmost() = _S_minimum(_M_root()); + _M_rightmost() = _S_maximum(_M_root()); + _M_impl._M_node_count = __x._M_impl._M_node_count; } } @@ -1052,19 +1079,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { clear(); if (__x._M_root() != 0) - { - _M_root() = __x._M_root(); - _M_leftmost() = __x._M_leftmost(); - _M_rightmost() = __x._M_rightmost(); - _M_root()->_M_parent = _M_end(); - - __x._M_root() = 0; - __x._M_leftmost() = __x._M_end(); - __x._M_rightmost() = __x._M_end(); - - this->_M_impl._M_node_count = __x._M_impl._M_node_count; - __x._M_impl._M_node_count = 0; - } + _M_move_data(__x, std::true_type()); if (_Alloc_traits::_S_propagate_on_move_assign()) std::__alloc_on_move(_M_get_Node_allocator(), __x._M_get_Node_allocator()); diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio index 25d942220fe..6043b3de2bf 100644 --- a/libstdc++-v3/include/c_global/cstdio +++ b/libstdc++-v3/include/c_global/cstdio @@ -137,7 +137,9 @@ namespace std using ::sprintf; using ::sscanf; using ::tmpfile; +#if _GLIBCXX_USE_TMPNAM using ::tmpnam; +#endif using ::ungetc; using ::vfprintf; using ::vprintf; diff --git a/libstdc++-v3/include/debug/safe_base.h b/libstdc++-v3/include/debug/safe_base.h index 4b1d082d264..631ac773ddb 100644 --- a/libstdc++-v3/include/debug/safe_base.h +++ b/libstdc++-v3/include/debug/safe_base.h @@ -193,6 +193,9 @@ namespace __gnu_debug { } #if __cplusplus >= 201103L + _Safe_sequence_base(const _Safe_sequence_base&) noexcept + : _Safe_sequence_base() { } + _Safe_sequence_base(_Safe_sequence_base&& __x) noexcept : _Safe_sequence_base() { _M_swap(__x); } diff --git a/libstdc++-v3/include/debug/safe_unordered_base.h b/libstdc++-v3/include/debug/safe_unordered_base.h index 9cde781364c..bbb274f34e4 100644 --- a/libstdc++-v3/include/debug/safe_unordered_base.h +++ b/libstdc++-v3/include/debug/safe_unordered_base.h @@ -133,9 +133,19 @@ namespace __gnu_debug protected: // Initialize with a version number of 1 and no iterators _Safe_unordered_container_base() - : _M_local_iterators(0), _M_const_local_iterators(0) + : _M_local_iterators(nullptr), _M_const_local_iterators(nullptr) { } + // Initialize with a version number of 1 and no iterators + _Safe_unordered_container_base(const _Safe_unordered_container_base&) + noexcept + : _Safe_unordered_container_base() { } + + _Safe_unordered_container_base(_Safe_unordered_container_base&& __x) + noexcept + : _Safe_unordered_container_base() + { this->_M_swap(__x); } + /** Notify all iterators that reference this container that the container is being destroyed. */ ~_Safe_unordered_container_base() diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index ab6943d806b..bebeb6b62ea 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr basic_string_view(const _CharT* __str, size_type __len) : _M_len{__str == nullptr ? 0 :__len}, - _M_str{__str == nullptr || __len == 0 ? _S_empty_str : __str} + _M_str{__str == nullptr ? _S_empty_str : __str} { } basic_string_view& @@ -182,7 +182,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator[](size_type __pos) const { // TODO: Assert to restore in a way compatible with the constexpr. - // _GLIBCXX_DEBUG_ASSERT(__pos <= this->_M_len); + // _GLIBCXX_DEBUG_ASSERT(__pos < this->_M_len); return *(this->_M_str + __pos); } @@ -259,14 +259,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION copy(_CharT* __str, size_type __n, size_type __pos = 0) const { __glibcxx_requires_string_len(__str, __n); - if (__pos >= this->_M_len) - __throw_out_of_range_fmt(__N("basic_string_view::at: __pos " - "(which is %zu) >= this->size() " + if (__pos > this->_M_len) + __throw_out_of_range_fmt(__N("basic_string_view::copy: __pos " + "(which is %zu) > this->size() " "(which is %zu)"), __pos, this->size()); size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})}; for (auto __begin = this->_M_str + __pos, - __end = this->_M_str + __rlen; __begin != __end;) + __end = __begin + __rlen; __begin != __end;) *__str++ = *__begin++; return __rlen; } @@ -277,11 +277,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr basic_string_view substr(size_type __pos, size_type __n=npos) const { - return __pos < this->_M_len + return __pos <= this->_M_len ? basic_string_view{this->_M_str + __pos, std::min(__n, size_type{this->_M_len - __pos})} - : (__throw_out_of_range_fmt(__N("basic_string_view::at: __pos " - "(which is %zu) >= this->size() " + : (__throw_out_of_range_fmt(__N("basic_string_view::substr: __pos " + "(which is %zu) > this->size() " "(which is %zu)"), __pos, this->size()), basic_string_view{}); } diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc index 01eed979508..752f5db5a3f 100644 --- a/libstdc++-v3/libsupc++/eh_alloc.cc +++ b/libstdc++-v3/libsupc++/eh_alloc.cc @@ -129,12 +129,6 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW std::terminate (); } - // We have an uncaught exception as soon as we allocate memory. This - // yields uncaught_exception() true during the copy-constructor that - // initializes the exception object. See Issue 475. - __cxa_eh_globals *globals = __cxa_get_globals (); - globals->uncaughtExceptions += 1; - memset (ret, 0, sizeof (__cxa_refcounted_exception)); return (void *)((char *)ret + sizeof (__cxa_refcounted_exception)); @@ -191,12 +185,6 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW std::terminate (); } - // We have an uncaught exception as soon as we allocate memory. This - // yields uncaught_exception() true during the copy-constructor that - // initializes the exception object. See Issue 475. - __cxa_eh_globals *globals = __cxa_get_globals (); - globals->uncaughtExceptions += 1; - memset (ret, 0, sizeof (__cxa_dependent_exception)); return ret; diff --git a/libstdc++-v3/libsupc++/eh_throw.cc b/libstdc++-v3/libsupc++/eh_throw.cc index ffd28d82208..e9a34e29229 100644 --- a/libstdc++-v3/libsupc++/eh_throw.cc +++ b/libstdc++-v3/libsupc++/eh_throw.cc @@ -62,6 +62,9 @@ __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo, { PROBE2 (throw, obj, tinfo); + __cxa_eh_globals *globals = __cxa_get_globals (); + globals->uncaughtExceptions += 1; + // Definitely a primary. __cxa_refcounted_exception *header = __get_refcounted_exception_header_from_obj (obj); diff --git a/libstdc++-v3/testsuite/23_containers/map/56613.cc b/libstdc++-v3/testsuite/23_containers/map/56613.cc index 3c1164fb1ed..6ef24908235 100644 --- a/libstdc++-v3/testsuite/23_containers/map/56613.cc +++ b/libstdc++-v3/testsuite/23_containers/map/56613.cc @@ -24,7 +24,6 @@ // { dg-options "-std=gnu++11" } // libstdc++/56613 -#include <map> // A conforming C++03 allocator, should still work in C++11 mode. template<typename T> diff --git a/libstdc++-v3/testsuite/23_containers/map/59872.cc b/libstdc++-v3/testsuite/23_containers/map/59872.cc new file mode 100644 index 00000000000..be8413bfd38 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/59872.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// libstdc++/59872 + +#include <map> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly(const MoveOnly&) = delete; +}; + +using test_type = std::map<int, MoveOnly>; + +test_type p; +test_type q(std::move(p)); +test_type r(std::move(p), test_type::allocator_type()); diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc index fb055474b20..44543f5462d 100644 --- a/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/1.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=c++11" } +// { dg-options "-std=gnu++11" } // Copyright (C) 2012-2014 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/map/operators/2.cc b/libstdc++-v3/testsuite/23_containers/map/operators/2.cc index 850eda9accc..53c1adbf335 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operators/2.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operators/2.cc @@ -17,7 +17,7 @@ // This test verifies that the value type of a map need not be default copyable. -// { dg-options "-std=c++11" } +// { dg-options "-std=gnu++11" } #include <map> #include <testsuite_hooks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc index dfdf621e793..fa98f43291d 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/1.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=c++11" } +// { dg-options "-std=gnu++11" } // Copyright (C) 2012-2014 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc index d6b738e33c0..a013ef700f6 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/1.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=c++11" } +// { dg-options "-std=gnu++11" } // Copyright (C) 2012-2014 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc index ab6d4364d15..12ea12eb087 100644 --- a/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/1.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=c++11" } +// { dg-options "-std=gnu++11" } // Copyright (C) 2012-2014 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc new file mode 100644 index 00000000000..1e81bb74110 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// { dg-require-debug-mode "" } + +// Copyright (C) 2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// libstdc++/59548 + +#include <unordered_map> + +int main() +{ + std::unordered_map<int,int> foo{ {0,1} }; + auto i = foo.begin(); + { + auto bar = foo; + } + return i->first; +} diff --git a/libstdc++-v3/testsuite/experimental/string_view/element_access/char/1.cc b/libstdc++-v3/testsuite/experimental/string_view/element_access/char/1.cc index 562ed20bc53..0a0b19f60be 100644 --- a/libstdc++-v3/testsuite/experimental/string_view/element_access/char/1.cc +++ b/libstdc++-v3/testsuite/experimental/string_view/element_access/char/1.cc @@ -41,8 +41,9 @@ test01() csz01 = str01.size(); cref cref1 = str01[csz01 - 1]; VERIFY( cref1 == 'a' ); - cref cref2 = str01[csz01]; - VERIFY( cref2 == char() ); + // Undefined behavior at size(). + //cref cref2 = str01[csz01]; + //VERIFY( cref2 == char() ); // const_reference at(size_type pos) const; csz01 = str01.size(); diff --git a/libstdc++-v3/testsuite/experimental/string_view/element_access/wchar_t/1.cc b/libstdc++-v3/testsuite/experimental/string_view/element_access/wchar_t/1.cc index e125c03e5ee..e3df84d41f0 100644 --- a/libstdc++-v3/testsuite/experimental/string_view/element_access/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/experimental/string_view/element_access/wchar_t/1.cc @@ -41,8 +41,9 @@ test01() csz01 = str01.size(); cref cref1 = str01[csz01 - 1]; VERIFY( cref1 == L'a' ); - cref cref2 = str01[csz01]; - VERIFY( cref2 == wchar_t() ); + // Undefined behavior at size(). + //cref cref2 = str01[csz01]; + //VERIFY( cref2 == wchar_t() ); // const_reference at(size_type pos) const; csz01 = str01.size(); diff --git a/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc b/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc new file mode 100644 index 00000000000..25b2af133d3 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view::copy + +#include <experimental/string_view> +#include <stdexcept> +#include <testsuite_hooks.h> + +bool +test01() +{ + bool test [[gnu::unused]] = true; + + typedef std::experimental::string_view::size_type csize_type; + + const char str_lit01[] = "123456789A"; + const std::experimental::string_view str01(str_lit01); + char buffer[4] = { 0 }; + + csize_type len = str01.copy(buffer, sizeof(buffer), 8); + VERIFY( 2 == len ); + VERIFY( '9' == buffer[0] ); + + return test; +} + +int +main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc b/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc new file mode 100644 index 00000000000..0348e1f98fc --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// basic_string_view::copy + +#include <experimental/string_view> +#include <stdexcept> +#include <testsuite_hooks.h> + +bool +test01() +{ + bool test [[gnu::unused]] = true; + + typedef std::experimental::wstring_view::size_type csize_type; + csize_type csz01; + + const wchar_t str_lit01[] = L"123456789A"; + const std::experimental::wstring_view str01(str_lit01); + wchar_t buffer[4] = { 0 }; + + csize_type len = str01.copy(buffer, sizeof(buffer), 8); + VERIFY( 2 == len ); + VERIFY( L'9' == buffer[0] ); + + return test; +} + +int +main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/string_view/operations/substr/char/1.cc b/libstdc++-v3/testsuite/experimental/string_view/operations/substr/char/1.cc index 1cd03f49611..2f430ba1652 100644 --- a/libstdc++-v3/testsuite/experimental/string_view/operations/substr/char/1.cc +++ b/libstdc++-v3/testsuite/experimental/string_view/operations/substr/char/1.cc @@ -63,10 +63,8 @@ test01() { str02 = str01.substr(csz01); VERIFY( str02.size() == 0 ); - } - catch(std::out_of_range& fail) - { - VERIFY( true ); // No terminating null in basic_string_view + VERIFY( str02.begin() == str01.end() ); + VERIFY( true ); } catch(...) { diff --git a/libstdc++-v3/testsuite/experimental/string_view/operations/substr/wchar_t/1.cc b/libstdc++-v3/testsuite/experimental/string_view/operations/substr/wchar_t/1.cc index e81844a21f4..6be8838e0d2 100644 --- a/libstdc++-v3/testsuite/experimental/string_view/operations/substr/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/experimental/string_view/operations/substr/wchar_t/1.cc @@ -63,10 +63,8 @@ test01() { str02 = str01.substr(csz01); VERIFY( str02.size() == 0 ); - } - catch(std::out_of_range& fail) - { - VERIFY( true ); // No terminating null in basic_string_view + VERIFY( str02.begin() == str01.end() ); + VERIFY( true ); } catch(...) { |