diff options
author | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2017-02-15 13:53:20 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2017-02-15 13:53:20 +0000 |
commit | c7b9220587caa2451917e8519ca4673dea890439 (patch) | |
tree | 715f5cb2b2042d51307a71824010c5792bb83620 | |
parent | e29fb9fcbf209958cf39f84b09e23c1aedc8b518 (diff) | |
parent | e4f2849a9b7fc24e9d79d5e759c5b98d60004414 (diff) |
Merge from gcc-6-branch.ARM/embedded-6-branch-2017q1-prerelease
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ARM/embedded-6-branch@245482 138bc75d-0d04-0410-961f-82ee72b054a4
146 files changed, 3011 insertions, 1185 deletions
diff --git a/config/ChangeLog b/config/ChangeLog index a446126d3d4..e2360c80ad8 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,8 @@ +2017-01-24 Uros Bizjak <ubizjak@gmail.com> + + PR target/78478 + * ax_check_define.m4: New file. + 2016-12-21 Release Manager * GCC 6.3.0 released. diff --git a/config/ax_check_define.m4 b/config/ax_check_define.m4 new file mode 100644 index 00000000000..4bc694861c0 --- /dev/null +++ b/config/ax_check_define.m4 @@ -0,0 +1,92 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_define.html +# =========================================================================== +# +# SYNOPSIS +# +# AC_CHECK_DEFINE([symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT]) +# AX_CHECK_DEFINE([includes],[symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT]) +# +# DESCRIPTION +# +# Complements AC_CHECK_FUNC but it does not check for a function but for a +# define to exist. Consider a usage like: +# +# AC_CHECK_DEFINE(__STRICT_ANSI__, CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500") +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# +# This program 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 of the License, or (at your +# option) any later version. +# +# This program 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 program. If not, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 8 + +AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE]) +AC_DEFUN([AC_CHECK_DEFINE],[ +AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1])dnl +AC_CACHE_CHECK([for $1 defined], ac_var, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifdef $1 + int ok; + #else + choke me + #endif +]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)])) +AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl +AS_VAR_POPDEF([ac_var])dnl +]) + +AU_ALIAS([AX_CHECK_DEFINED], [AX_CHECK_DEFINE]) +AC_DEFUN([AX_CHECK_DEFINE],[ +AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2_$1])dnl +AC_CACHE_CHECK([for $2 defined in $1], ac_var, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <$1>]], [[ + #ifdef $2 + int ok; + #else + choke me + #endif +]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)])) +AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl +AS_VAR_POPDEF([ac_var])dnl +]) + +AC_DEFUN([AX_CHECK_FUNC], +[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl +AC_CACHE_CHECK([for $2], ac_var, +dnl AC_LANG_FUNC_LINK_TRY +[AC_LINK_IFELSE([AC_LANG_PROGRAM([$1 + #undef $2 + char $2 ();],[ + char (*f) () = $2; + return f != $2; ])], + [AS_VAR_SET(ac_var, yes)], + [AS_VAR_SET(ac_var, no)])]) +AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl +AS_VAR_POPDEF([ac_var])dnl +])# AC_CHECK_FUNC diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog index 73d229c16c4..15e3c3b811e 100644 --- a/fixincludes/ChangeLog +++ b/fixincludes/ChangeLog @@ -1,3 +1,16 @@ +2017-01-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + Backport from mainline + 2017-01-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + PR libstdc++/78979 + * inclhack.def (solaris_gets_c11, solaris_gets_cxx14) + (solaris_std_gets_cxx14, solaris_stdlib_noreturn): New fixes. + * fixincl.x: Regenerate. + * tests/base/iso/stdio_iso.h [SOLARIS_GETS_C11_CHECK, + SOLARIS_GETS_CXX14_CHECK, SOLARIS_STD_GETS_CXX14_CHECK, + SOLARIS_STDLIB_NORETURN_CHECK]: New tests. + 2016-12-21 Release Manager * GCC 6.3.0 released. diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index 0e76b094e6b..15467f2a3d2 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed November 18, 2016 at 12:35:01 PM by AutoGen 5.16.2 + * It has been AutoGen-ed January 5, 2017 at 06:03:22 PM by AutoGen 5.16.2 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Nov 18 12:35:01 2016 +/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Jan 5 18:03:22 CET 2017 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 236 fixup descriptions. + * This file contains 240 fixup descriptions. * * See README for more information. * @@ -6824,6 +6824,84 @@ static const char* apzSolaris_Getc_Strict_StdcPatch[] = { /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Solaris_Gets_C11 fix + */ +tSCC zSolaris_Gets_C11Name[] = + "solaris_gets_c11"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Gets_C11List[] = + "iso/stdio_iso.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Gets_C11Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Gets_C11Select0[] = + "(extern char[ \t]*\\*gets\\(char \\*\\));"; + +#define SOLARIS_GETS_C11_TEST_CT 1 +static tTestDesc aSolaris_Gets_C11Tests[] = { + { TT_EGREP, zSolaris_Gets_C11Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Gets_C11 + */ +static const char* apzSolaris_Gets_C11Patch[] = { + "format", + "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n\ +%1 __attribute__((__deprecated__));\n\ +#endif", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Solaris_Gets_Cxx14 fix + */ +tSCC zSolaris_Gets_Cxx14Name[] = + "solaris_gets_cxx14"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Gets_Cxx14List[] = + "iso/stdio_iso.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Gets_Cxx14Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Gets_Cxx14Select0[] = + "(#if __STDC_VERSION__ < 201112L)\n\ +(extern char\t\\*gets\\(char \\*\\) __ATTR_DEPRECATED;)"; + +#define SOLARIS_GETS_CXX14_TEST_CT 1 +static tTestDesc aSolaris_Gets_Cxx14Tests[] = { + { TT_EGREP, zSolaris_Gets_Cxx14Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Gets_Cxx14 + */ +static const char* apzSolaris_Gets_Cxx14Patch[] = { + "format", + "%1 && __cplusplus < 201402L\n\ +%2", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Solaris_Int_Const fix */ tSCC zSolaris_Int_ConstName[] = @@ -7576,6 +7654,45 @@ using std::__flsbuf;\n\ /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Solaris_Std_Gets_Cxx14 fix + */ +tSCC zSolaris_Std_Gets_Cxx14Name[] = + "solaris_std_gets_cxx14"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Std_Gets_Cxx14List[] = + "stdio.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Std_Gets_Cxx14Machs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Std_Gets_Cxx14Select0[] = + "using std::gets;"; + +#define SOLARIS_STD_GETS_CXX14_TEST_CT 1 +static tTestDesc aSolaris_Std_Gets_Cxx14Tests[] = { + { TT_EGREP, zSolaris_Std_Gets_Cxx14Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Std_Gets_Cxx14 + */ +static const char* apzSolaris_Std_Gets_Cxx14Patch[] = { + "format", + "#if __cplusplus < 201402L\n\ +%0\n\ +#endif", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Solaris_Stdio_Tag fix */ tSCC zSolaris_Stdio_TagName[] = @@ -7617,6 +7734,43 @@ static const char* apzSolaris_Stdio_TagPatch[] = { sed_cmd_z, /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Solaris_Stdlib_Noreturn fix + */ +tSCC zSolaris_Stdlib_NoreturnName[] = + "solaris_stdlib_noreturn"; + +/* + * File name selection pattern + */ +tSCC zSolaris_Stdlib_NoreturnList[] = + "iso/stdlib_c99.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzSolaris_Stdlib_NoreturnMachs[] = { + "*-*-solaris2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zSolaris_Stdlib_NoreturnSelect0[] = + "(extern) _Noreturn (void quick_exit\\(int\\));"; + +#define SOLARIS_STDLIB_NORETURN_TEST_CT 1 +static tTestDesc aSolaris_Stdlib_NoreturnTests[] = { + { TT_EGREP, zSolaris_Stdlib_NoreturnSelect0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Solaris_Stdlib_Noreturn + */ +static const char* apzSolaris_Stdlib_NoreturnPatch[] = { + "format", + "%1 %2 __attribute__((__noreturn__));", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Statsswtch fix */ tSCC zStatsswtchName[] = @@ -9664,9 +9818,9 @@ static const char* apzX11_SprintfPatch[] = { * * List of all fixes */ -#define REGEX_COUNT 272 +#define REGEX_COUNT 276 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 236 +#define FIX_COUNT 240 /* * Enumerate the fixes @@ -9837,6 +9991,8 @@ typedef enum { SOLARIS_COMPLEX_CXX_FIXIDX, SOLARIS_CXX_LINKAGE_FIXIDX, SOLARIS_GETC_STRICT_STDC_FIXIDX, + SOLARIS_GETS_C11_FIXIDX, + SOLARIS_GETS_CXX14_FIXIDX, SOLARIS_INT_CONST_FIXIDX, SOLARIS_INT_LIMITS_1_FIXIDX, SOLARIS_INT_LIMITS_2_FIXIDX, @@ -9855,7 +10011,9 @@ typedef enum { SOLARIS_POW_INT_OVERLOAD_FIXIDX, SOLARIS_RWLOCK_INIT_1_FIXIDX, SOLARIS_STD___FILBUF_FIXIDX, + SOLARIS_STD_GETS_CXX14_FIXIDX, SOLARIS_STDIO_TAG_FIXIDX, + SOLARIS_STDLIB_NORETURN_FIXIDX, STATSSWTCH_FIXIDX, STDIO_STDARG_H_FIXIDX, STDIO_VA_LIST_FIXIDX, @@ -10736,6 +10894,16 @@ tFixDesc fixDescList[ FIX_COUNT ] = { SOLARIS_GETC_STRICT_STDC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aSolaris_Getc_Strict_StdcTests, apzSolaris_Getc_Strict_StdcPatch, 0 }, + { zSolaris_Gets_C11Name, zSolaris_Gets_C11List, + apzSolaris_Gets_C11Machs, + SOLARIS_GETS_C11_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Gets_C11Tests, apzSolaris_Gets_C11Patch, 0 }, + + { zSolaris_Gets_Cxx14Name, zSolaris_Gets_Cxx14List, + apzSolaris_Gets_Cxx14Machs, + SOLARIS_GETS_CXX14_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Gets_Cxx14Tests, apzSolaris_Gets_Cxx14Patch, 0 }, + { zSolaris_Int_ConstName, zSolaris_Int_ConstList, apzSolaris_Int_ConstMachs, SOLARIS_INT_CONST_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, @@ -10826,11 +10994,21 @@ tFixDesc fixDescList[ FIX_COUNT ] = { SOLARIS_STD___FILBUF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aSolaris_Std___FilbufTests, apzSolaris_Std___FilbufPatch, 0 }, + { zSolaris_Std_Gets_Cxx14Name, zSolaris_Std_Gets_Cxx14List, + apzSolaris_Std_Gets_Cxx14Machs, + SOLARIS_STD_GETS_CXX14_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Std_Gets_Cxx14Tests, apzSolaris_Std_Gets_Cxx14Patch, 0 }, + { zSolaris_Stdio_TagName, zSolaris_Stdio_TagList, apzSolaris_Stdio_TagMachs, SOLARIS_STDIO_TAG_TEST_CT, FD_MACH_ONLY, aSolaris_Stdio_TagTests, apzSolaris_Stdio_TagPatch, 0 }, + { zSolaris_Stdlib_NoreturnName, zSolaris_Stdlib_NoreturnList, + apzSolaris_Stdlib_NoreturnMachs, + SOLARIS_STDLIB_NORETURN_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aSolaris_Stdlib_NoreturnTests, apzSolaris_Stdlib_NoreturnPatch, 0 }, + { zStatsswtchName, zStatsswtchList, apzStatsswtchMachs, STATSSWTCH_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 2ba12f09cbc..ef23e489e39 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -3482,6 +3482,43 @@ fix = { }; /* + * Solaris <iso/stdio_iso.h> should deprecate gets before C11. + */ +fix = { + hackname = solaris_gets_c11; + mach = "*-*-solaris2*"; + files = "iso/stdio_iso.h"; + select = "(extern char[ \t]*\\*gets\\(char \\*\\));"; + + c_fix = format; + c_fix_arg = "#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L\n" + "%1 __attribute__((__deprecated__));\n" + "#endif"; + + test_text = "extern char *gets(char *);"; +}; + +/* + * Solaris <iso/stdio_iso.h> shouldn't declare gets for C++14. + */ +fix = { + hackname = solaris_gets_cxx14; + mach = "*-*-solaris2*"; + files = "iso/stdio_iso.h"; + select = <<- _EOSelect_ +(#if __STDC_VERSION__ < 201112L) +(extern char \*gets\(char \*\) __ATTR_DEPRECATED;) +_EOSelect_; + c_fix = format; + c_fix_arg = "%1 && __cplusplus < 201402L\n%2"; + + test_text = <<- _EOText_ +#if __STDC_VERSION__ < 201112L +extern char *gets(char *) __ATTR_DEPRECATED; +_EOText_; +}; + +/* * Sun Solaris 2 has a version of sys/int_const.h that defines * UINT8_C and UINT16_C to unsigned constants. */ @@ -3871,6 +3908,21 @@ fix = { }; /* + * Solaris <stdio.h> shouldn't use std::gets for C++14. + */ +fix = { + hackname = solaris_std_gets_cxx14; + mach = "*-*-solaris2*"; + files = "stdio.h"; + select = "using std::gets;"; + + c_fix = format; + c_fix_arg = "#if __cplusplus < 201402L\n%0\n#endif"; + + test_text = "using std::gets;"; +}; + +/* * Sun Solaris 8 has what appears to be some gross workaround for * some old version of their c++ compiler. G++ doesn't want it * either, but doesn't want to be tied to SunPRO version numbers. @@ -3889,6 +3941,21 @@ fix = { }; /* + * Solaris <stdlib.h> shouldn't use _Noreturn, breaks with C++. + */ +fix = { + hackname = solaris_stdlib_noreturn; + mach = "*-*-solaris2*"; + files = "iso/stdlib_c99.h"; + select = "(extern) _Noreturn (void quick_exit\\(int\\));"; + + c_fix = format; + c_fix_arg = "%1 %2 __attribute__((__noreturn__));"; + + test_text = "extern _Noreturn void quick_exit(int);"; +}; + +/* * a missing semi-colon at the end of the statsswtch structure definition. */ fix = { diff --git a/fixincludes/tests/base/iso/stdio_iso.h b/fixincludes/tests/base/iso/stdio_iso.h index d476752f092..e2d70b4c62e 100644 --- a/fixincludes/tests/base/iso/stdio_iso.h +++ b/fixincludes/tests/base/iso/stdio_iso.h @@ -12,3 +12,16 @@ #if defined( SOLARIS_GETC_STRICT_STDC_CHECK ) #if !defined(_REENTRANT) && !defined(_LP64) && (!defined(_STRICT_STDC) || (__cplusplus >= 199711L)) #endif /* SOLARIS_GETC_STRICT_STDC_CHECK */ + + +#if defined( SOLARIS_GETS_C11_CHECK ) +#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L +extern char *gets(char *) __attribute__((__deprecated__)); +#endif +#endif /* SOLARIS_GETS_C11_CHECK */ + + +#if defined( SOLARIS_GETS_CXX14_CHECK ) +#if __STDC_VERSION__ < 201112L && __cplusplus < 201402L +extern char *gets(char *) __ATTR_DEPRECATED; +#endif /* SOLARIS_GETS_CXX14_CHECK */ diff --git a/fixincludes/tests/base/iso/stdlib_c99.h b/fixincludes/tests/base/iso/stdlib_c99.h new file mode 100644 index 00000000000..0c500dea086 --- /dev/null +++ b/fixincludes/tests/base/iso/stdlib_c99.h @@ -0,0 +1,14 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/iso/stdlib_c99.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( SOLARIS_STDLIB_NORETURN_CHECK ) +extern void quick_exit(int) __attribute__((__noreturn__)); +#endif /* SOLARIS_STDLIB_NORETURN_CHECK */ diff --git a/fixincludes/tests/base/stdio.h b/fixincludes/tests/base/stdio.h index 4ca4fafeb95..491c75da6e5 100644 --- a/fixincludes/tests/base/stdio.h +++ b/fixincludes/tests/base/stdio.h @@ -90,6 +90,13 @@ using std::__flsbuf; #endif /* SOLARIS_STD___FILBUF_CHECK */ +#if defined( SOLARIS_STD_GETS_CXX14_CHECK ) +#if __cplusplus < 201402L +using std::gets; +#endif +#endif /* SOLARIS_STD_GETS_CXX14_CHECK */ + + #if defined( STDIO_STDARG_H_CHECK ) #endif /* STDIO_STDARG_H_CHECK */ diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a2bf308267a..22144b22179 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,202 @@ +2017-02-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-02-10 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/79411 + * tree-ssa-reassoc.c (is_reassociable_op): Return false if + stmt operands are SSA_NAMEs used in abnormal phis. + (can_reassociate_p): Return false if op is SSA_NAME used in abnormal + phis. + + 2017-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c/79431 + * gimplify.c (gimplify_adjust_omp_clauses): Ignore + "omp declare target link" attribute unless is_global_var. + * omp-low.c (find_link_var_op): Likewise. + + 2017-02-07 Jakub Jelinek <jakub@redhat.com> + Richard Biener <rguenther@suse.de> + + PR middle-end/79399 + * ira-int.h (struct target_ira_int): Change x_max_struct_costs_size + type from int to size_t. + * ira-costs.c (struct_costs_size): Change type from int to size_t. + + 2017-02-04 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/79338 + * tree-parloops.c (gather_scalar_reductions): Don't call + vect_analyze_loop_form for loop->inner before destroying loop's + loop_vinfo. + + 2017-02-02 Jakub Jelinek <jakub@redhat.com> + + PR target/79197 + * config/rs6000/rs6000.md (*fixuns_trunc<mode>di2_fctiduz): Rename to ... + (fixuns_trunc<mode>di2): ... this, remove previous expander. Put all + conditions on a single line. + + 2017-01-31 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/79267 + * value-prof.c (gimple_ic): Only drop lhs for noreturn calls + if should_remove_lhs_p is true. + + 2017-01-17 Kito Cheng <kito.cheng@gmail.com> + Kuan-Lin Chen <kuanlinchentw@gmail.com> + + PR target/79079 + * internal-fn.c (expand_mul_overflow): Use convert_modes instead of + gen_lowpart. + +2017-02-14 Uros Bizjak <ubizjak@gmail.com> + + PR target/79495 + * config/i386/i386.md (*movxf_internal): Add (o,rC) alternative. + +2017-02-14 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-02-13 Martin Liska <mliska@suse.cz> + + PR c/79471 + * calls.c (expand_call): Replace XALLOCAVEC with XCNEWVEC. + +2017-02-13 Gerald Pfeifer <gerald@pfeifer.com> + + Backport from mainline + 2016-12-11 Roger Pau Monné <roger.pau@citrix.com> + + * config/i386/x86-64.h: Append --32 to the assembler options when + -m16 is used on non-glibc systems as well. + +2017-02-08 Segher Boessenkool <segher@kernel.crashing.org> + + PR translation/79397 + * config/rs6000/rs6000.opt (maltivec=le, maltivec=be): Fix spelling + of AltiVec. + +2017-02-08 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2017-02-08 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71824 + * graphite-scop-detection.c (scop_detection::build_scop_breadth): + Check all loops contained in the merged region. + + 2017-02-01 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71824 + * graphite-scop-detection.c (scop_detection::build_scop_breadth): + Verify the loops are valid in the merged SESE region. + (scop_detection::can_represent_loop_1): Check analyzing the + evolution of the number of iterations in the region succeeds. + + 2017-01-31 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77318 + * graphite-sese-to-poly.c (extract_affine): Fix assert. + (create_pw_aff_from_tree): Take loop parameter. + (add_condition_to_pbb): Pass loop of the condition to + create_pw_aff_from_tree. + +2017-02-06 Dominique d'Humieres <dominiq@lps.ens.fr> + + PR target/71017 + * config/i386/cpuid.h: Fix undefined behavior. + +2017-02-03 Carl Love <cel@us.ibm.com> + + Backport of two commits from mainline, r244943 and r244904, + dated 017-01-26 and 2017-01-25 respectively + + * config/rs6000/rs6000-c (altivec_overloaded_builtins): Fix order + of entries for ALTIVEC_BUILTIN_VEC_PACKS. Remove bogus entries + for P8V_BUILTIN_VEC_VGBBD. + +2017-02-03 Walter Lee <walt@tilera.com> + + Backport from mainline + 2017-02-03 Walter Lee <walt@tilera.com> + + PR target/78862 + * config/tilegx/tilegx.md (tilegx_expand_prologue): Add blockage + after initial stackframe link reg save. + * config/tilepro/tilepro.md (tilepro_expand_prologue): Likewise. + +2017-02-03 Maxim Ostapenko <m.ostapenko@samsung.com> + + PR lto/79061 + * asan.c (asan_add_global): Force has_dynamic_init to zero in LTO mode. + +2017-01-31 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + Backport from mainline + 2017-01-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR target/79268 + * config/rs6000/altivec.h (vec_xl): Revise #define. + (vec_xst): Likewise. + +2017-01-26 Eric Botcazou <ebotcazou@adacore.com> + + Backport from mainline + 2017-01-10 Eric Botcazou <ebotcazou@adacore.com> + + * expr.c (store_field): In the bitfield case, fetch the return value + from the registers before applying a single big-endian adjustment. + Always do a final load for a BLKmode value not larger than a word. + + 2017-01-09 Eric Botcazou <ebotcazou@adacore.com> + + * expr.c (store_field): In the bitfield case, if the value comes from + a function call and is of an aggregate type returned in registers, do + not modify the field mode; extract the value in all cases if the mode + is BLKmode and the size is not larger than a word. + +2017-01-26 Richard Biener <rguenther@suse.de> + + * tree-vrp.c (vrp_visit_assignment_or_call): Use set_defs_to_varying. + + Backport from mainline + 2016-01-10 Richard Biener <rguenther@suse.de> + + PR tree-optimization/79034 + * tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds): + Propagate out degenerate PHIs in the joiner. + + 2016-12-13 Richard Biener <rguenther@suse.de> + + PR middle-end/78742 + * tree.c (cst_and_fits_in_hwi): Look if the actual value fits. + * tree-object-size.c (compute_builtin_object_size): Use + tree_fits_shwi_p. + * tree-data-ref.c (initialize_matrix_A): Remove excess assert. + +2017-01-26 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2016-09-03 Kirill Yukhin <kirill.yukhin@intel.com> + + * ubsan.c (ubsan_use_new_style_p): Fix check for empty string. + +2017-01-24 Eric Botcazou <ebotcazou@adacore.com> + + PR target/77439 + * config/arm/arm.c (arm_function_ok_for_sibcall): Add back restriction + for long calls with APCS frame and VFP. + +2017-01-24 Uros Bizjak <ubizjak@gmail.com> + + PR target/78478 + Revert: + 2013-11-05 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/rtemself.h (LONG_DOUBLE_TYPE_SIZE): New define. + 2017-01-23 Martin Liska <mliska@suse.cz> Backport from mainline @@ -404,11 +603,11 @@ Backport from mainline 2016-11-07 Bernd Schmidt <bschmidt@redhat.com> - PR rtl-optimization/77309 - * combine.c (make_compound_operation): Allow EQ for IN_CODE, and - don't assume an equality comparison for plain COMPARE. - (simplify_comparison): Pass a more accurate code to - make_compound_operation. + PR rtl-optimization/77309 + * combine.c (make_compound_operation): Allow EQ for IN_CODE, and + don't assume an equality comparison for plain COMPARE. + (simplify_comparison): Pass a more accurate code to + make_compound_operation. 2016-12-12 Thomas Preud'homme <thomas.preudhomme@arm.com> diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index f33270b7054..b64e2d32dbf 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20170123 +20170215 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 803e9c50ab0..8e5325bc623 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,7 @@ +2017-02-12 John Marino <gnugcc@marino.st> + + * gcc-interface/Makefile.in: Support aarch64-freebsd. + 2016-12-21 Release Manager * GCC 6.3.0 released. diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index a722a77618f..b1b7e9ac447 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -1475,6 +1475,34 @@ ifeq ($(strip $(filter-out x86_64 kfreebsd%,$(target_cpu) $(target_os))),) LIBRARY_VERSION := $(LIB_VERSION) endif +# aarch64 FreeBSD +ifeq ($(strip $(filter-out %aarch64 freebsd%,$(target_cpu) $(target_os))),) + LIBGNAT_TARGET_PAIRS = \ + a-intnam.ads<a-intnam-freebsd.ads \ + s-inmaop.adb<s-inmaop-posix.adb \ + s-intman.adb<s-intman-posix.adb \ + s-mudido.adb<s-mudido-affinity.adb \ + s-osinte.adb<s-osinte-freebsd.adb \ + s-osinte.ads<s-osinte-freebsd.ads \ + s-osprim.adb<s-osprim-posix.adb \ + s-taprop.adb<s-taprop-posix.adb \ + s-taspri.ads<s-taspri-posix.ads \ + s-tpopsp.adb<s-tpopsp-posix.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.ads<system-freebsd-x86_64.ads + + TOOLS_TARGET_PAIRS = \ + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb + GNATLIB_SHARED = gnatlib-shared-dual + + EH_MECHANISM=-gcc + THREADSLIB= -lpthread + GMEM_LIB = gmemlib + LIBRARY_VERSION := $(LIB_VERSION) + MISCLIB = -lutil +endif + # x86 FreeBSD ifeq ($(strip $(filter-out %86 freebsd%,$(target_cpu) $(target_os))),) LIBGNAT_TARGET_PAIRS = \ diff --git a/gcc/asan.c b/gcc/asan.c index 398a50859d7..0f55dc03e9c 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2275,7 +2275,11 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v) CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, fold_convert (const_ptr_type_node, module_name_cst)); varpool_node *vnode = varpool_node::get (decl); - int has_dynamic_init = vnode ? vnode->dynamically_initialized : 0; + int has_dynamic_init = 0; + /* FIXME: Enable initialization order fiasco detection in LTO mode once + proper fix for PR 79061 will be applied. */ + if (!in_lto_p) + has_dynamic_init = vnode ? vnode->dynamically_initialized : 0; CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, build_int_cst (uptr, has_dynamic_init)); tree locptr = NULL_TREE; diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2b1f71855ad..05254583ae1 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2017-02-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c/79431 + * c-parser.c (c_parser_omp_declare_target): Don't invoke + symtab_node::get on automatic variables. + 2016-12-21 Jakub Jelinek <jakub@redhat.com> PR c/77767 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index c9eb8ddbae3..991f189fb9d 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -16560,8 +16560,11 @@ c_parser_omp_declare_target (c_parser *parser) } if (!at1) { - symtab_node *node = symtab_node::get (t); DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t)); + if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t)) + continue; + + symtab_node *node = symtab_node::get (t); if (node != NULL) { node->offloadable = 1; diff --git a/gcc/calls.c b/gcc/calls.c index 6cc1fc721e4..c78059fb519 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -2695,8 +2695,7 @@ expand_call (tree exp, rtx target, int ignore) n_named_args = num_actuals; /* Make a vector to hold all the information about each arg. */ - args = XALLOCAVEC (struct arg_data, num_actuals); - memset (args, 0, num_actuals * sizeof (struct arg_data)); + args = XCNEWVEC (struct arg_data, num_actuals); /* Build up entries in the ARGS array, compute the size of the arguments into ARGS_SIZE, etc. */ @@ -3710,6 +3709,7 @@ expand_call (tree exp, rtx target, int ignore) currently_expanding_call--; free (stack_usage_map_buf); + free (args); /* Join result with returned bounds so caller may use them if needed. */ target = chkp_join_splitted_slot (target, valbnd); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 52a8aeaf307..d62c245f55c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -6948,6 +6948,14 @@ arm_function_ok_for_sibcall (tree decl, tree exp) if (TARGET_VXWORKS_RTP && flag_pic && decl && !targetm.binds_local_p (decl)) return false; + /* ??? Cannot tail-call to long calls with APCS frame and VFP, because IP + may be used both as target of the call and base register for restoring + the VFP registers */ + if (TARGET_APCS_FRAME && TARGET_ARM + && TARGET_HARD_FLOAT && TARGET_VFP + && decl && arm_is_long_call_p (decl)) + return false; + /* If we are interworking and the function is not declared static then we can't tail-call it unless we know that it exists in this compilation unit (since it might be a Thumb routine). */ diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 2a946bf611a..3cf9b18edfa 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -89,7 +89,7 @@ #define bit_AVX512CD (1 << 28) #define bit_SHA (1 << 29) #define bit_AVX512BW (1 << 30) -#define bit_AVX512VL (1 << 31) +#define bit_AVX512VL (1u << 31) /* %ecx */ #define bit_PREFETCHWT1 (1 << 0) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 46987d370ad..d0b1d0061fa 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -3172,9 +3172,9 @@ ;; in alternatives 4, 6, 7 and 8. (define_insn "*movxf_internal" [(set (match_operand:XF 0 "nonimmediate_operand" - "=f,m,f,?r ,!o,?*r ,!o,!o,!o,r ,o") + "=f,m,f,?r ,!o,?*r ,!o,!o,!o,r ,o ,o") (match_operand:XF 1 "general_operand" - "fm,f,G,roF,r , *roF,*r,F ,C,roF,rF"))] + "fm,f,G,roF,r ,*roF,*r,F ,C ,roF,rF,rC"))] "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (lra_in_progress || reload_completed || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) @@ -3201,19 +3201,19 @@ } } [(set (attr "isa") - (cond [(eq_attr "alternative" "7") + (cond [(eq_attr "alternative" "7,10") (const_string "nox64") - (eq_attr "alternative" "8") + (eq_attr "alternative" "8,11") (const_string "x64") ] (const_string "*"))) (set (attr "type") - (cond [(eq_attr "alternative" "3,4,5,6,7,8,9,10") + (cond [(eq_attr "alternative" "3,4,5,6,7,8,9,10,11") (const_string "multi") ] (const_string "fmov"))) (set (attr "mode") - (cond [(eq_attr "alternative" "3,4,5,6,7,8,9,10") + (cond [(eq_attr "alternative" "3,4,5,6,7,8,9,10,11") (if_then_else (match_test "TARGET_64BIT") (const_string "DI") (const_string "SI")) @@ -3224,7 +3224,7 @@ (symbol_ref "false")] (symbol_ref "true"))) (set (attr "enabled") - (cond [(eq_attr "alternative" "9,10") + (cond [(eq_attr "alternative" "9,10,11") (if_then_else (match_test "TARGET_HARD_XF_REGS") (symbol_ref "false") diff --git a/gcc/config/i386/rtemself.h b/gcc/config/i386/rtemself.h index 8b7dc5e5d17..be711c80197 100644 --- a/gcc/config/i386/rtemself.h +++ b/gcc/config/i386/rtemself.h @@ -29,7 +29,4 @@ along with GCC; see the file COPYING3. If not see } \ while (0) -#undef LONG_DOUBLE_TYPE_SIZE -#define LONG_DOUBLE_TYPE_SIZE (TARGET_80387 ? 80 : 64) - #define IX86_NO_LIBGCC_TFMODE diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h index 204f128d5b0..8dfd2543bd1 100644 --- a/gcc/config/i386/x86-64.h +++ b/gcc/config/i386/x86-64.h @@ -49,7 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define WCHAR_TYPE_SIZE 32 #undef ASM_SPEC -#define ASM_SPEC "%{m32:--32} %{m64:--64} %{mx32:--x32}" +#define ASM_SPEC "%{m16|m32:--32} %{m64:--64} %{mx32:--x32}" #undef ASM_OUTPUT_ALIGNED_BSS #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h index f77d4466469..762264e1d31 100644 --- a/gcc/config/rs6000/altivec.h +++ b/gcc/config/rs6000/altivec.h @@ -327,8 +327,8 @@ #define vec_sqrt __builtin_vec_sqrt #define vec_vsx_ld __builtin_vec_vsx_ld #define vec_vsx_st __builtin_vec_vsx_st -#define vec_xl __builtin_vec_xl -#define vec_xst __builtin_vec_xst +#define vec_xl __builtin_vec_vsx_ld +#define vec_xst __builtin_vec_vsx_st /* Note, xxsldi and xxpermdi were added as __builtin_vsx_<xxx> functions instead of __builtin_vec_<xxx> */ diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 9eb6d545c5c..474b48cc41d 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -2133,14 +2133,14 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = { RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 }, { ALTIVEC_BUILTIN_VEC_PACKS, ALTIVEC_BUILTIN_VPKSWSS, RS6000_BTI_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 }, - { ALTIVEC_BUILTIN_VEC_VPKSWSS, ALTIVEC_BUILTIN_VPKSWSS, - RS6000_BTI_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 }, - { ALTIVEC_BUILTIN_VEC_VPKUWUS, ALTIVEC_BUILTIN_VPKUWUS, - RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 }, { ALTIVEC_BUILTIN_VEC_PACKS, P8V_BUILTIN_VPKUDUS, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, { ALTIVEC_BUILTIN_VEC_PACKS, P8V_BUILTIN_VPKSDSS, RS6000_BTI_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 }, + { ALTIVEC_BUILTIN_VEC_VPKSWSS, ALTIVEC_BUILTIN_VPKSWSS, + RS6000_BTI_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 }, + { ALTIVEC_BUILTIN_VEC_VPKUWUS, ALTIVEC_BUILTIN_VPKUWUS, + RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 }, { ALTIVEC_BUILTIN_VEC_VPKSHSS, ALTIVEC_BUILTIN_VPKSHSS, RS6000_BTI_V16QI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 }, { ALTIVEC_BUILTIN_VEC_VPKUHUS, ALTIVEC_BUILTIN_VPKUHUS, @@ -4550,11 +4550,6 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = { { P8V_BUILTIN_VEC_VUPKLSW, P8V_BUILTIN_VUPKLSW, RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 }, - { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD, - RS6000_BTI_V16QI, 0, 0, 0 }, - { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD, - RS6000_BTI_unsigned_V16QI, 0, 0, 0 }, - { P9V_BUILTIN_VEC_VSLV, P9V_BUILTIN_VSLV, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 }, diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index a73c4a2ff1e..f4e1d6cadba 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -5429,17 +5429,10 @@ [(set_attr "length" "12") (set_attr "type" "fp")]) -(define_expand "fixuns_trunc<mode>di2" - [(set (match_operand:DI 0 "register_operand" "") - (unsigned_fix:DI (match_operand:SFDF 1 "register_operand" "")))] - "TARGET_HARD_FLOAT && (TARGET_FCTIDUZ || VECTOR_UNIT_VSX_P (<MODE>mode))" - "") - -(define_insn "*fixuns_trunc<mode>di2_fctiduz" +(define_insn "fixuns_trunc<mode>di2" [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wi") (unsigned_fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fa>")))] - "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS - && TARGET_FCTIDUZ" + "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS && TARGET_FCTIDUZ" "@ fctiduz %0,%1 xscvdpuxds %x0,%x1" diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 8ac92ace449..9a25a86640b 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -142,11 +142,11 @@ Use AltiVec instructions. maltivec=le Target Report RejectNegative Var(rs6000_altivec_element_order, 1) Save -Generate Altivec instructions using little-endian element order. +Generate AltiVec instructions using little-endian element order. maltivec=be Target Report RejectNegative Var(rs6000_altivec_element_order, 2) -Generate Altivec instructions using big-endian element order. +Generate AltiVec instructions using big-endian element order. mhard-dfp Target Report Mask(DFP) Var(rs6000_isa_flags) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 78f68577db1..4fe53f929ff 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -3996,8 +3996,11 @@ tilegx_expand_prologue (void) /* Save lr first in its special location because code after this might use the link register as a scratch register. */ if (df_regs_ever_live_p (TILEGX_LINK_REGNUM) || crtl->calls_eh_return) - FRP (frame_emit_store (TILEGX_LINK_REGNUM, TILEGX_LINK_REGNUM, - stack_pointer_rtx, stack_pointer_rtx, 0)); + { + FRP (frame_emit_store (TILEGX_LINK_REGNUM, TILEGX_LINK_REGNUM, + stack_pointer_rtx, stack_pointer_rtx, 0)); + emit_insn (gen_blockage ()); + } if (total_size == 0) { diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index 628cd041384..b64564766a6 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -3534,8 +3534,11 @@ tilepro_expand_prologue (void) /* Save lr first in its special location because code after this might use the link register as a scratch register. */ if (df_regs_ever_live_p (TILEPRO_LINK_REGNUM) || crtl->calls_eh_return) - FRP (frame_emit_store (TILEPRO_LINK_REGNUM, TILEPRO_LINK_REGNUM, - stack_pointer_rtx, stack_pointer_rtx, 0)); + { + FRP (frame_emit_store (TILEPRO_LINK_REGNUM, TILEPRO_LINK_REGNUM, + stack_pointer_rtx, stack_pointer_rtx, 0)); + emit_insn (gen_blockage ()); + } if (total_size == 0) { diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c9fc345e4da..f4ce11be663 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,50 @@ +2017-02-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/79429 + * parser.c (cp_parser_omp_ordered): Don't check for non-pragma_stmt + non-pragma_compound context here. + (cp_parser_omp_target): Likewise. + (cp_parser_pragma): Don't call push_omp_privatization_clauses and + parsing for ordered and target omp pragmas in non-pragma_stmt + non-pragma_compound contexts. + + PR c/79431 + * parser.c (cp_parser_oacc_declare): Formatting fix. + (cp_parser_omp_declare_target): Don't invoke symtab_node::get on + automatic variables. + + 2017-02-06 Jakub Jelinek <jakub@redhat.com> + + PR c++/79377 + * tree.c (build_min_non_dep_op_overload): For POST{INC,DEC}REMENT_EXPR + allow one fewer than expected arguments if flag_permissive. + +2017-02-13 Nathan Sidwell <nathan@acm.org> + + PR c++/79296 - ICE mangling localized template instantiation + * decl2.c (determine_visibility): Use template fn context for + local class instantiations. + +2017-02-11 Jason Merrill <jason@redhat.com> + + PR c++/78908 - template ops and bitfields + * tree.c (build_min_non_dep): Use unlowered_expr_type. + +2017-02-10 Jason Merrill <jason@redhat.com> + + PR c++/78897 - constexpr union + * constexpr.c (cxx_eval_store_expression): A store to a union member + erases a previous store to another member. + +2017-01-26 Jason Merrill <jason@redhat.com> + + PR c++/79176 - lambda ICE with -flto -Os + * decl2.c (vague_linkage_p): Handle decloned 'tors. + * tree.c (decl_linkage): Likewise. + 2017-01-20 Marek Polacek <polacek@redhat.com> Backported from mainline diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index a6ac3c1468d..8213ef29bc8 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3239,6 +3239,11 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, tree fields = TYPE_FIELDS (DECL_CONTEXT (index)); unsigned HOST_WIDE_INT idx; + if (code == UNION_TYPE && CONSTRUCTOR_NELTS (*valp) + && CONSTRUCTOR_ELT (*valp, 0)->index != index) + /* Changing active member. */ + vec_safe_truncate (CONSTRUCTOR_ELTS (*valp), 0); + for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (*valp), idx, &cep); idx++, fields = DECL_CHAIN (fields)) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 34eb1e01821..a9511dece51 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1875,6 +1875,14 @@ vague_linkage_p (tree decl) { if (!TREE_PUBLIC (decl)) { + /* maybe_thunk_body clears TREE_PUBLIC on the maybe-in-charge 'tor + variants, check one of the "clones" for the real linkage. */ + if ((DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl) + || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)) + && DECL_CHAIN (decl) + && DECL_CLONED_FUNCTION (DECL_CHAIN (decl))) + return vague_linkage_p (DECL_CHAIN (decl)); + gcc_checking_assert (!DECL_COMDAT (decl)); return false; } @@ -2272,11 +2280,6 @@ constrain_visibility_for_template (tree decl, tree targs) void determine_visibility (tree decl) { - tree class_type = NULL_TREE; - bool use_template; - bool orig_visibility_specified; - enum symbol_visibility orig_visibility; - /* Remember that all decls get VISIBILITY_DEFAULT when built. */ /* Only relevant for names with external linkage. */ @@ -2288,25 +2291,28 @@ determine_visibility (tree decl) maybe_clone_body. */ gcc_assert (!DECL_CLONED_FUNCTION_P (decl)); - orig_visibility_specified = DECL_VISIBILITY_SPECIFIED (decl); - orig_visibility = DECL_VISIBILITY (decl); + bool orig_visibility_specified = DECL_VISIBILITY_SPECIFIED (decl); + enum symbol_visibility orig_visibility = DECL_VISIBILITY (decl); + /* The decl may be a template instantiation, which could influence + visibilty. */ + tree template_decl = NULL_TREE; if (TREE_CODE (decl) == TYPE_DECL) { if (CLASS_TYPE_P (TREE_TYPE (decl))) - use_template = CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl)); + { + if (CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl))) + template_decl = decl; + } else if (TYPE_TEMPLATE_INFO (TREE_TYPE (decl))) - use_template = 1; - else - use_template = 0; + template_decl = decl; } - else if (DECL_LANG_SPECIFIC (decl)) - use_template = DECL_USE_TEMPLATE (decl); - else - use_template = 0; + else if (DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl)) + template_decl = decl; /* If DECL is a member of a class, visibility specifiers on the class can influence the visibility of the DECL. */ + tree class_type = NULL_TREE; if (DECL_CLASS_SCOPE_P (decl)) class_type = DECL_CONTEXT (decl); else @@ -2349,8 +2355,11 @@ determine_visibility (tree decl) } /* Local classes in templates have CLASSTYPE_USE_TEMPLATE set, - but have no TEMPLATE_INFO, so don't try to check it. */ - use_template = 0; + but have no TEMPLATE_INFO. Their containing template + function does, and the local class could be constrained + by that. */ + if (template_decl) + template_decl = fn; } else if (VAR_P (decl) && DECL_TINFO_P (decl) && flag_visibility_ms_compat) @@ -2380,7 +2389,7 @@ determine_visibility (tree decl) && !CLASSTYPE_VISIBILITY_SPECIFIED (TREE_TYPE (DECL_NAME (decl)))) targetm.cxx.determine_class_data_visibility (decl); } - else if (use_template) + else if (template_decl) /* Template instantiations and specializations get visibility based on their template unless they override it with an attribute. */; else if (! DECL_VISIBILITY_SPECIFIED (decl)) @@ -2397,11 +2406,11 @@ determine_visibility (tree decl) } } - if (use_template) + if (template_decl) { /* If the specialization doesn't specify visibility, use the visibility from the template. */ - tree tinfo = get_template_info (decl); + tree tinfo = get_template_info (template_decl); tree args = TI_ARGS (tinfo); tree attribs = (TREE_CODE (decl) == TYPE_DECL ? TYPE_ATTRIBUTES (TREE_TYPE (decl)) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 390f7d0d16f..ac742f38966 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -34058,13 +34058,6 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, { location_t loc = pragma_tok->location; - if (context != pragma_stmt && context != pragma_compound) - { - cp_parser_error (parser, "expected declaration specifiers"); - cp_parser_skip_to_pragma_eol (parser, pragma_tok); - return false; - } - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -34957,13 +34950,6 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, { tree *pc = NULL, stmt; - if (context != pragma_stmt && context != pragma_compound) - { - cp_parser_error (parser, "expected declaration specifiers"); - cp_parser_skip_to_pragma_eol (parser, pragma_tok); - return false; - } - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -35345,7 +35331,7 @@ cp_parser_oacc_declare (cp_parser *parser, cp_token *pragma_tok) id = get_identifier ("omp declare target"); DECL_ATTRIBUTES (decl) - = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); + = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); if (global_bindings_p ()) { symtab_node *node = symtab_node::get (decl); @@ -35885,8 +35871,11 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) } if (!at1) { - symtab_node *node = symtab_node::get (t); DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t)); + if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t)) + continue; + + symtab_node *node = symtab_node::get (t); if (node != NULL) { node->offloadable = 1; @@ -37402,12 +37391,16 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) return true; case PRAGMA_OMP_ORDERED: + if (context != pragma_stmt && context != pragma_compound) + goto bad_stmt; stmt = push_omp_privatization_clauses (false); ret = cp_parser_omp_ordered (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); return ret; case PRAGMA_OMP_TARGET: + if (context != pragma_stmt && context != pragma_compound) + goto bad_stmt; stmt = push_omp_privatization_clauses (false); ret = cp_parser_omp_target (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5b15e9ce520..2de9b69550b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2775,7 +2775,7 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...) t = make_node (code); length = TREE_CODE_LENGTH (code); - TREE_TYPE (t) = TREE_TYPE (non_dep); + TREE_TYPE (t) = unlowered_expr_type (non_dep); TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep); for (i = 0; i < length; i++) @@ -2830,8 +2830,10 @@ build_min_non_dep_op_overload (enum tree_code op, nargs = call_expr_nargs (non_dep); expected_nargs = cp_tree_code_length (op); - if (op == POSTINCREMENT_EXPR - || op == POSTDECREMENT_EXPR) + if ((op == POSTINCREMENT_EXPR + || op == POSTDECREMENT_EXPR) + /* With -fpermissive non_dep could be operator++(). */ + && (!flag_permissive || nargs != expected_nargs)) expected_nargs += 1; gcc_assert (nargs == expected_nargs); @@ -4146,6 +4148,14 @@ decl_linkage (tree decl) if (TREE_PUBLIC (decl)) return lk_external; + /* maybe_thunk_body clears TREE_PUBLIC on the maybe-in-charge 'tor variants, + check one of the "clones" for the real linkage. */ + if ((DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl) + || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)) + && DECL_CHAIN (decl) + && DECL_CLONED_FUNCTION (DECL_CHAIN (decl))) + return decl_linkage (DECL_CHAIN (decl)); + if (TREE_CODE (decl) == NAMESPACE_DECL) return lk_external; diff --git a/gcc/expr.c b/gcc/expr.c index aad7ff5ef7f..6260f5ed7ed 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6688,13 +6688,36 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, temp = expand_normal (exp); - /* If the value has a record type and an integral mode then, if BITSIZE - is narrower than this mode and this is for big-endian data, we must - first put the value into the low-order bits. Moreover, the field may - be not aligned on a byte boundary; in this case, if it has reverse - storage order, it needs to be accessed as a scalar field with reverse - storage order and we must first put the value into target order. */ - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE + /* Handle calls that return values in multiple non-contiguous locations. + The Irix 6 ABI has examples of this. */ + if (GET_CODE (temp) == PARALLEL) + { + HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); + machine_mode temp_mode + = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); + rtx temp_target = gen_reg_rtx (temp_mode); + emit_group_store (temp_target, temp, TREE_TYPE (exp), size); + temp = temp_target; + } + + /* Handle calls that return BLKmode values in registers. */ + else if (mode == BLKmode && REG_P (temp) && TREE_CODE (exp) == CALL_EXPR) + { + rtx temp_target = gen_reg_rtx (GET_MODE (temp)); + copy_blkmode_from_reg (temp_target, temp, TREE_TYPE (exp)); + temp = temp_target; + } + + /* If the value has aggregate type and an integral mode then, if BITSIZE + is narrower than this mode and this is for big-endian data, we first + need to put the value into the low-order bits for store_bit_field, + except when MODE is BLKmode and BITSIZE larger than the word size + (see the handling of fields larger than a word in store_bit_field). + Moreover, the field may be not aligned on a byte boundary; in this + case, if it has reverse storage order, it needs to be accessed as a + scalar field with reverse storage order and we must first put the + value into target order. */ + if (AGGREGATE_TYPE_P (TREE_TYPE (exp)) && GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT) { HOST_WIDE_INT size = GET_MODE_BITSIZE (GET_MODE (temp)); @@ -6705,7 +6728,8 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, temp = flip_storage_order (GET_MODE (temp), temp); if (bitsize < size - && reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN) + && reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN + && !(mode == BLKmode && bitsize > BITS_PER_WORD)) temp = expand_shift (RSHIFT_EXPR, GET_MODE (temp), temp, size - bitsize, NULL_RTX, 1); } @@ -6715,12 +6739,10 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, && mode != TYPE_MODE (TREE_TYPE (exp))) temp = convert_modes (mode, TYPE_MODE (TREE_TYPE (exp)), temp, 1); - /* If TEMP is not a PARALLEL (see below) and its mode and that of TARGET - are both BLKmode, both must be in memory and BITPOS must be aligned - on a byte boundary. If so, we simply do a block copy. Likewise for - a BLKmode-like TARGET. */ - if (GET_CODE (temp) != PARALLEL - && GET_MODE (temp) == BLKmode + /* If the mode of TEMP and TARGET is BLKmode, both must be in memory + and BITPOS must be aligned on a byte boundary. If so, we simply do + a block copy. Likewise for a BLKmode-like TARGET. */ + if (GET_MODE (temp) == BLKmode && (GET_MODE (target) == BLKmode || (MEM_P (target) && GET_MODE_CLASS (GET_MODE (target)) == MODE_INT @@ -6739,38 +6761,13 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, return const0_rtx; } - /* Handle calls that return values in multiple non-contiguous locations. - The Irix 6 ABI has examples of this. */ - if (GET_CODE (temp) == PARALLEL) - { - HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - rtx temp_target; - if (mode == BLKmode || mode == VOIDmode) - mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); - temp_target = gen_reg_rtx (mode); - emit_group_store (temp_target, temp, TREE_TYPE (exp), size); - temp = temp_target; - } - else if (mode == BLKmode) + /* If the mode of TEMP is still BLKmode and BITSIZE not larger than the + word size, we need to load the value (see again store_bit_field). */ + if (GET_MODE (temp) == BLKmode && bitsize <= BITS_PER_WORD) { - /* Handle calls that return BLKmode values in registers. */ - if (REG_P (temp) && TREE_CODE (exp) == CALL_EXPR) - { - rtx temp_target = gen_reg_rtx (GET_MODE (temp)); - copy_blkmode_from_reg (temp_target, temp, TREE_TYPE (exp)); - temp = temp_target; - } - else - { - HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - rtx temp_target; - mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); - temp_target = gen_reg_rtx (mode); - temp_target - = extract_bit_field (temp, size * BITS_PER_UNIT, 0, 1, - temp_target, mode, mode, false); - temp = temp_target; - } + machine_mode temp_mode = smallest_mode_for_size (bitsize, MODE_INT); + temp = extract_bit_field (temp, bitsize, 0, 1, NULL_RTX, temp_mode, + temp_mode, false); } /* Store the value in the bitfield. */ diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8e30691122d..285844011b8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,28 @@ +2017-02-07 Steven G. Kargl <kargl@gcc.gnu.org> + + * trans-types.c (gfc_get_int_kind_from_width_isofortranen): Choose + REAL type with the widest precision if two (or more) have the same + storage size. + +2017-01-29 Andre Vehreschild <vehre@gcc.gnu.org> + + Backported from trunk + 2017-01-13 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70697 + * resolve.c (resolve_lock_unlock_event): Resolve the expression for + event's until_count. + +2017-01-29 Andre Vehreschild <vehre@gcc.gnu.org> + + Backport from trunk + PR fortran/70696 + * trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl + is valid before accessing it. Remove unnecessary assert. + * trans-decl.c (gfc_build_qualified_array): Add static tokens to the + parent function's scope only, when the decl-context is not the + translation unit. + 2017-01-17 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 8064d4462f1..7cf2ca24725 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8840,10 +8840,13 @@ resolve_lock_unlock_event (gfc_code *code) return; /* Check for EVENT WAIT the UNTIL_COUNT. */ - if (code->op == EXEC_EVENT_WAIT && code->expr4 - && (code->expr4->ts.type != BT_INTEGER || code->expr4->rank != 0)) - gfc_error ("UNTIL_COUNT= argument at %L must be a scalar INTEGER " - "expression", &code->expr4->where); + if (code->op == EXEC_EVENT_WAIT && code->expr4) + { + if (!gfc_resolve_expr (code->expr4) || code->expr4->ts.type != BT_INTEGER + || code->expr4->rank != 0) + gfc_error ("UNTIL_COUNT= argument at %L must be a scalar INTEGER " + "expression", &code->expr4->where); + } } diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index ba9cf06d4e4..272ac57dd58 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -887,6 +887,10 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) DECL_CONTEXT (token) = sym->ns->proc_name->backend_decl; gfc_module_add_decl (cur_module, token); } + else if (sym->attr.host_assoc + && TREE_CODE (DECL_CONTEXT (current_function_decl)) + != TRANSLATION_UNIT_DECL) + gfc_add_decl_to_parent_function (token); else gfc_add_decl_to_function (token); } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 6b61b16f969..26cd4392151 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1898,8 +1898,11 @@ gfc_get_tree_for_caf_expr (gfc_expr *expr) &expr->where); } - caf_decl = expr->symtree->n.sym->backend_decl; - gcc_assert (caf_decl); + /* Make sure the backend_decl is present before accessing it. */ + caf_decl = expr->symtree->n.sym->backend_decl == NULL_TREE + ? gfc_get_symbol_decl (expr->symtree->n.sym) + : expr->symtree->n.sym->backend_decl; + if (expr->symtree->n.sym->ts.type == BT_CLASS) caf_decl = gfc_class_data_get (caf_decl); if (expr->symtree->n.sym->attr.codimension) diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 831c84fe28e..e00487526cf 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -234,27 +234,42 @@ gfc_get_int_kind_from_width_isofortranenv (int size) return -1; } -/* Get the kind number corresponding to a real of given storage size, - following the required return values for ISO_FORTRAN_ENV REAL* constants: - -2 is returned if we support a kind of larger size, -1 otherwise. */ + +/* Get the kind number corresponding to a real of a given storage size. + If two real's have the same storage size, then choose the real with + the largest precision. If a kind type is unavailable and a real + exists with wider storage, then return -2; otherwise, return -1. */ + int gfc_get_real_kind_from_width_isofortranenv (int size) { - int i; + int digits, i, kind; size /= 8; + kind = -1; + digits = 0; + /* Look for a kind with matching storage size. */ for (i = 0; gfc_real_kinds[i].kind != 0; i++) if (int_size_in_bytes (gfc_get_real_type (gfc_real_kinds[i].kind)) == size) - return gfc_real_kinds[i].kind; + { + if (gfc_real_kinds[i].digits > digits) + { + digits = gfc_real_kinds[i].digits; + kind = gfc_real_kinds[i].kind; + } + } + + if (kind != -1) + return kind; /* Look for a kind with larger storage size. */ for (i = 0; gfc_real_kinds[i].kind != 0; i++) if (int_size_in_bytes (gfc_get_real_type (gfc_real_kinds[i].kind)) > size) - return -2; + kind = -2; - return -1; + return kind; } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 7c5cead076d..d641620262d 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8136,8 +8136,9 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p, if ((ctx->region_type & ORT_TARGET) != 0 && !(n->value & GOVD_SEEN) && GOMP_MAP_ALWAYS_P (OMP_CLAUSE_MAP_KIND (c)) == 0 - && !lookup_attribute ("omp declare target link", - DECL_ATTRIBUTES (decl))) + && (!is_global_var (decl) + || !lookup_attribute ("omp declare target link", + DECL_ATTRIBUTES (decl)))) { remove = true; /* For struct element mapping, if struct is never referenced diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 09ab5bf8f7e..cf602548242 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -3639,8 +3639,12 @@ Unary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int) if (expr->numeric_constant_value(&nc)) { Numeric_constant result; - if (Unary_expression::eval_constant(op, &nc, loc, &result)) + bool issued_error; + if (Unary_expression::eval_constant(op, &nc, loc, &result, + &issued_error)) return result.expression(loc); + else if (issued_error) + return Expression::make_error(this->location()); } } @@ -3747,12 +3751,15 @@ Unary_expression::do_is_constant() const } // Apply unary opcode OP to UNC, setting NC. Return true if this -// could be done, false if not. Issue errors for overflow. +// could be done, false if not. On overflow, issues an error and sets +// *ISSUED_ERROR. bool Unary_expression::eval_constant(Operator op, const Numeric_constant* unc, - Location location, Numeric_constant* nc) + Location location, Numeric_constant* nc, + bool* issued_error) { + *issued_error = false; switch (op) { case OPERATOR_PLUS: @@ -3897,7 +3904,12 @@ Unary_expression::eval_constant(Operator op, const Numeric_constant* unc, mpz_clear(uval); mpz_clear(val); - return nc->set_type(unc->type(), true, location); + if (!nc->set_type(unc->type(), true, location)) + { + *issued_error = true; + return false; + } + return true; } // Return the integral constant value of a unary expression, if it has one. @@ -3908,8 +3920,9 @@ Unary_expression::do_numeric_constant_value(Numeric_constant* nc) const Numeric_constant unc; if (!this->expr_->numeric_constant_value(&unc)) return false; + bool issued_error; return Unary_expression::eval_constant(this->op_, &unc, this->location(), - nc); + nc, &issued_error); } // Return the type of a unary expression. @@ -4539,13 +4552,15 @@ Binary_expression::compare_complex(const Numeric_constant* left_nc, // Apply binary opcode OP to LEFT_NC and RIGHT_NC, setting NC. Return // true if this could be done, false if not. Issue errors at LOCATION -// as appropriate. +// as appropriate, and sets *ISSUED_ERROR if it did. bool Binary_expression::eval_constant(Operator op, Numeric_constant* left_nc, Numeric_constant* right_nc, - Location location, Numeric_constant* nc) + Location location, Numeric_constant* nc, + bool* issued_error) { + *issued_error = false; switch (op) { case OPERATOR_OROR: @@ -4594,7 +4609,11 @@ Binary_expression::eval_constant(Operator op, Numeric_constant* left_nc, r = Binary_expression::eval_integer(op, left_nc, right_nc, location, nc); if (r) - r = nc->set_type(type, true, location); + { + r = nc->set_type(type, true, location); + if (!r) + *issued_error = true; + } return r; } @@ -4917,9 +4936,15 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*, else { Numeric_constant nc; + bool issued_error; if (!Binary_expression::eval_constant(op, &left_nc, &right_nc, - location, &nc)) + location, &nc, + &issued_error)) + { + if (issued_error) + return Expression::make_error(location); return this; + } return nc.expression(location); } } @@ -5254,8 +5279,9 @@ Binary_expression::do_numeric_constant_value(Numeric_constant* nc) const Numeric_constant right_nc; if (!this->right_->numeric_constant_value(&right_nc)) return false; + bool issued_error; return Binary_expression::eval_constant(this->op_, &left_nc, &right_nc, - this->location(), nc); + this->location(), nc, &issued_error); } // Note that the value is being discarded. @@ -5354,7 +5380,12 @@ Binary_expression::do_determine_type(const Type_context* context) Type_context subcontext(*context); - if (is_comparison) + if (is_constant_expr) + { + subcontext.type = NULL; + subcontext.may_be_abstract = true; + } + else if (is_comparison) { // In a comparison, the context does not determine the types of // the operands. @@ -5396,8 +5427,7 @@ Binary_expression::do_determine_type(const Type_context* context) subcontext.type = subcontext.type->make_non_abstract_type(); } - if (!is_constant_expr) - this->left_->determine_type(&subcontext); + this->left_->determine_type(&subcontext); if (is_shift_op) { @@ -5417,8 +5447,7 @@ Binary_expression::do_determine_type(const Type_context* context) subcontext.may_be_abstract = false; } - if (!is_constant_expr) - this->right_->determine_type(&subcontext); + this->right_->determine_type(&subcontext); if (is_comparison) { diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index c33e63653e6..b69443af7c8 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -1633,10 +1633,11 @@ class Unary_expression : public Expression } // Apply unary opcode OP to UNC, setting NC. Return true if this - // could be done, false if not. Issue errors for overflow. + // could be done, false if not. On overflow, issues an error and + // sets *ISSUED_ERROR. static bool eval_constant(Operator op, const Numeric_constant* unc, - Location, Numeric_constant* nc); + Location, Numeric_constant* nc, bool *issued_error); static Expression* do_import(Import*); @@ -1755,11 +1756,11 @@ class Binary_expression : public Expression // Apply binary opcode OP to LEFT_NC and RIGHT_NC, setting NC. // Return true if this could be done, false if not. Issue errors at - // LOCATION as appropriate. + // LOCATION as appropriate, and sets *ISSUED_ERROR if it did. static bool eval_constant(Operator op, Numeric_constant* left_nc, Numeric_constant* right_nc, Location location, - Numeric_constant* nc); + Numeric_constant* nc, bool* issued_error); // Compare constants LEFT_NC and RIGHT_NC according to OP, setting // *RESULT. Return true if this could be done, false if not. Issue diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 0443281dd81..805a9cff69f 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -2175,11 +2175,26 @@ Type::make_gc_symbol_var(Gogo* gogo) is_common = true; } + // The current garbage collector requires that the GC symbol be + // aligned to at least a four byte boundary. See the use of PRECISE + // and LOOP in libgo/runtime/mgc0.c. + int64_t align; + if (!sym_init->type()->backend_type_align(gogo, &align)) + go_assert(saw_errors()); + if (align < 4) + align = 4; + else + { + // Use default alignment. + align = 0; + } + // Since we are building the GC symbol in this package, we must create the // variable before converting the initializer to its backend representation // because the initializer may refer to the GC symbol for this type. this->gc_symbol_var_ = - gogo->backend()->implicit_variable(sym_name, sym_btype, false, true, is_common, 0); + gogo->backend()->implicit_variable(sym_name, sym_btype, false, true, + is_common, align); if (phash != NULL) *phash = this->gc_symbol_var_; diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index dd50a1e4ec0..f0497495e79 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -905,6 +905,18 @@ scop_detection::build_scop_breadth (sese_l s1, loop_p loop) sese_l combined = merge_sese (s1, s2); + /* Combining adjacent loops may add unrelated loops into the + region so we have to check all sub-loops of the outer loop + that are in the combined region. */ + if (combined) + for (l = loop_outer (loop)->inner; l; l = l->next) + if (bb_in_sese_p (l->header, combined) + && ! loop_is_valid_in_scop (l, combined)) + { + combined = invalid_sese; + break; + } + if (combined) s1 = combined; else @@ -931,6 +943,8 @@ scop_detection::can_represent_loop_1 (loop_p loop, sese_l scop) && niter_desc.control.no_overflow && (niter = number_of_latch_executions (loop)) && !chrec_contains_undetermined (niter) + && !chrec_contains_undetermined (scalar_evolution_in_region (scop, + loop, niter)) && graphite_can_represent_expr (scop, loop, niter); } diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 22a09a1782f..163eef41f2c 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -407,7 +407,7 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) case SSA_NAME: gcc_assert (-1 != parameter_index_in_region_1 (e, s->scop_info) - || !invariant_in_sese_p_rec (e, s->scop_info->region, NULL)); + || defined_in_sese_p (e, s->scop_info->region)); res = extract_affine_name (s, e, space); break; @@ -436,11 +436,11 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) /* Returns a linear expression for tree T evaluated in PBB. */ static isl_pw_aff * -create_pw_aff_from_tree (poly_bb_p pbb, tree t) +create_pw_aff_from_tree (poly_bb_p pbb, loop_p loop, tree t) { scop_p scop = PBB_SCOP (pbb); - t = scalar_evolution_in_region (scop->scop_info->region, pbb_loop (pbb), t); + t = scalar_evolution_in_region (scop->scop_info->region, loop, t); gcc_assert (!chrec_contains_undetermined (t)); gcc_assert (!automatically_generated_chrec_p (t)); @@ -455,8 +455,9 @@ create_pw_aff_from_tree (poly_bb_p pbb, tree t) static void add_condition_to_pbb (poly_bb_p pbb, gcond *stmt, enum tree_code code) { - isl_pw_aff *lhs = create_pw_aff_from_tree (pbb, gimple_cond_lhs (stmt)); - isl_pw_aff *rhs = create_pw_aff_from_tree (pbb, gimple_cond_rhs (stmt)); + loop_p loop = gimple_bb (stmt)->loop_father; + isl_pw_aff *lhs = create_pw_aff_from_tree (pbb, loop, gimple_cond_lhs (stmt)); + isl_pw_aff *rhs = create_pw_aff_from_tree (pbb, loop, gimple_cond_rhs (stmt)); isl_set *cond; switch (code) diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index d3962b5cd8c..736012a139f 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -1271,8 +1271,8 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1, res = expand_expr_real_2 (&ops, NULL_RTX, wmode, EXPAND_NORMAL); rtx hipart = expand_shift (RSHIFT_EXPR, wmode, res, prec, NULL_RTX, uns); - hipart = gen_lowpart (mode, hipart); - res = gen_lowpart (mode, res); + hipart = convert_modes (mode, wmode, hipart, uns); + res = convert_modes (mode, wmode, res, uns); if (uns) /* For the unsigned multiplication, there was overflow if HIPART is non-zero. */ @@ -1305,16 +1305,16 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1, unsigned int hprec = GET_MODE_PRECISION (hmode); rtx hipart0 = expand_shift (RSHIFT_EXPR, mode, op0, hprec, NULL_RTX, uns); - hipart0 = gen_lowpart (hmode, hipart0); - rtx lopart0 = gen_lowpart (hmode, op0); + hipart0 = convert_modes (hmode, mode, hipart0, uns); + rtx lopart0 = convert_modes (hmode, mode, op0, uns); rtx signbit0 = const0_rtx; if (!uns) signbit0 = expand_shift (RSHIFT_EXPR, hmode, lopart0, hprec - 1, NULL_RTX, 0); rtx hipart1 = expand_shift (RSHIFT_EXPR, mode, op1, hprec, NULL_RTX, uns); - hipart1 = gen_lowpart (hmode, hipart1); - rtx lopart1 = gen_lowpart (hmode, op1); + hipart1 = convert_modes (hmode, mode, hipart1, uns); + rtx lopart1 = convert_modes (hmode, mode, op1, uns); rtx signbit1 = const0_rtx; if (!uns) signbit1 = expand_shift (RSHIFT_EXPR, hmode, lopart1, hprec - 1, @@ -1505,11 +1505,12 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1, if (loxhi >> (bitsize / 2) == 0 (if uns). */ rtx hipartloxhi = expand_shift (RSHIFT_EXPR, mode, loxhi, hprec, NULL_RTX, 0); - hipartloxhi = gen_lowpart (hmode, hipartloxhi); + hipartloxhi = convert_modes (hmode, mode, hipartloxhi, 0); rtx signbitloxhi = const0_rtx; if (!uns) signbitloxhi = expand_shift (RSHIFT_EXPR, hmode, - gen_lowpart (hmode, loxhi), + convert_modes (hmode, mode, + loxhi, 0), hprec - 1, NULL_RTX, 0); do_compare_rtx_and_jump (signbitloxhi, hipartloxhi, NE, true, hmode, @@ -1519,7 +1520,8 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1, /* res = (loxhi << (bitsize / 2)) | (hmode) lo0xlo1; */ rtx loxhishifted = expand_shift (LSHIFT_EXPR, mode, loxhi, hprec, NULL_RTX, 1); - tem = convert_modes (mode, hmode, gen_lowpart (hmode, lo0xlo1), 1); + tem = convert_modes (mode, hmode, + convert_modes (hmode, mode, lo0xlo1, 1), 1); tem = expand_simple_binop (mode, IOR, loxhishifted, tem, res, 1, OPTAB_DIRECT); diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index f3d31e178af..fb3d2608b1d 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -73,7 +73,7 @@ static struct costs *costs; static struct costs *total_allocno_costs; /* It is the current size of struct costs. */ -static int struct_costs_size; +static size_t struct_costs_size; /* Return pointer to structure containing costs of allocno or pseudo with given NUM in array ARR. */ diff --git a/gcc/ira-int.h b/gcc/ira-int.h index 52ec0900558..8d3c1df0665 100644 --- a/gcc/ira-int.h +++ b/gcc/ira-int.h @@ -782,7 +782,7 @@ struct target_ira_int { /* Initialized once. It is a maximal possible size of the allocated struct costs. */ - int x_max_struct_costs_size; + size_t x_max_struct_costs_size; /* Allocated and initialized once, and used to initialize cost values for each insn. */ diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 57a03df8355..f6395d8fb5a 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -19890,7 +19890,9 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *) { tree t = *tp; - if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t) + if (TREE_CODE (t) == VAR_DECL + && DECL_HAS_VALUE_EXPR_P (t) + && is_global_var (t) && lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t))) { *walk_subtrees = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b4e48459c34..a7ed75f2603 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,157 @@ +2017-02-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-02-10 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/79411 + * gcc.c-torture/compile/pr79411.c: New test. + + 2017-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/79429 + * c-c++-common/gomp/pr79429.c: New test. + * g++.dg/gomp/pr79429.C: New test. + + PR c/79431 + * c-c++-common/gomp/pr79431.c: New test. + + 2017-02-06 Jakub Jelinek <jakub@redhat.com> + + PR c++/79377 + * g++.dg/lookup/pr79377.C: New test. + + 2017-02-02 Jakub Jelinek <jakub@redhat.com> + + PR target/79197 + * gcc.target/powerpc/pr79197.c: New test. + * gcc.c-torture/compile/pr79197.c: New test. + + 2017-01-31 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/79267 + * g++.dg/opt/pr79267.C: New test. + +2017-02-14 Uros Bizjak <ubizjak@gmail.com> + + PR target/79495 + * gcc.target/i386/pr79495.c: New test. + + PR middle-end/61225 + * gcc.target/i386/pr49095.c: Add -fno-shrink-wrap to dg-options. + Use dg-additional-options for ia32 target. Remove XFAIL. + +2017-02-13 Nathan Sidwell <nathan@acm.org> + + PR c++/79296 + * g++.dg/cpp0x/pr79296.C: New. + +2017-02-08 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2017-02-08 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71824 + PR tree-optimization/79409 + * gcc.dg/graphite/pr71824-3.c: New testcase. + + 2017-02-08 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71824 + * gcc.dg/graphite/pr71824-2.c: New testcase. + + 2017-02-01 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71824 + * gcc.dg/graphite/pr71824.c: New testcase. + +2017-02-03 Carl Love <cel@us.ibm.com> + + * gcc.target/powerpc/builtins-3-p8.c: Add new testfile for missing + vec_packs built-in tests. + +2017-02-03 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + Backport from mainline + 2017-01-27 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR target/65484 + * g++.dg/vect/pr36648.cc: Modify to reflect that the loop is not + vectorized on POWER unless hardware misaligned loads are + available. + +2017-01-31 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + Backport from mainline + 2017-01-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR target/79268 + * gcc.target/powerpc/pr79268.c: New file. + * gcc.target/powerpc/vsx-elemrev-1.c: Delete file. + * gcc.target/powerpc/vsx-elemrev-2.c: Likewise. + * gcc.target/powerpc/vsx-elemrev-3.c: Likewise. + * gcc.target/powerpc/vsx-elemrev-4.c: Likewise. + +2017-01-29 Andre Vehreschild <vehre@gcc.gnu.org> + + Backport from trunk + 2017-01-13 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70697 + * gfortran.dg/coarray/event_4.f08: New test. + +2017-01-29 Andre Vehreschild <vehre@gcc.gnu.org> + + Backport from trunk + 2017-01-19 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70696 + * gfortran.dg/coarray_43.f90: New test. + + 2017-01-18 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70696 + * gfortran.dg/coarray_event_1.f08: New test. + + 2017-01-13 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70696 + * gfortran.dg/coarray/event_3.f08: New test. + +2017-01-28 John David Anglin <danglin@gcc.gnu.org> + + PR testsuite/70583 + * g++.old-deja/g++.abi/vtable2.C: Adjust CMP_VPTR define on hppa. + +2017-01-26 Eric Botcazou <ebotcazou@adacore.com> + + 2017-01-09 Eric Botcazou <ebotcazou@adacore.com> + + * g++.dg/opt/call2.C: New test. + * g++.dg/opt/call3.C: Likewise. + * gnat.dg/array26.adb: New test. + * gnat.dg/array26_pkg.ad[sb]: New helper. + * gnat.dg/array27.adb: New test. + * gnat.dg/array27_pkg.ad[sb]: New helper. + * gnat.dg/array28.adb: New test. + * gnat.dg/array28_pkg.ad[sb]: New helper. + +2017-01-26 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2016-01-10 Richard Biener <rguenther@suse.de> + + PR tree-optimization/79034 + * g++.dg/torture/pr79034.C: New testcase. + + 2016-12-13 Richard Biener <rguenther@suse.de> + + PR middle-end/78742 + * gcc.dg/torture/pr78742.c: New testcase. + +2017-01-24 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.target/arm/vfp-longcall-apcs.c: New test. + 2017-01-23 Martin Liska <mliska@suse.cz> Backport from mainline @@ -250,8 +404,8 @@ Backport from mainline 2016-11-07 Bernd Schmidt <bschmidt@redhat.com> - PR rtl-optimization/77309 - * gcc.dg/torture/pr77309.c: New test. + PR rtl-optimization/77309 + * gcc.dg/torture/pr77309.c: New test. 2016-12-12 Thomas Preud'homme <thomas.preudhomme@arm.com> @@ -660,7 +814,7 @@ * g++.dg/torture/pr77822.C: New test. 2016-11-20 Harald Anlauf <anlauf@gmx.de> - + PR fortran/69741 * gfortran.dg/forall_18.f90: New testcase. diff --git a/gcc/testsuite/c-c++-common/gomp/pr79429.c b/gcc/testsuite/c-c++-common/gomp/pr79429.c new file mode 100644 index 00000000000..c9a54d5e08d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr79429.c @@ -0,0 +1,3 @@ +/* PR c++/79429 */ + +#pragma omp target /* { dg-error "expected declaration specifiers" } */ diff --git a/gcc/testsuite/c-c++-common/gomp/pr79431.c b/gcc/testsuite/c-c++-common/gomp/pr79431.c new file mode 100644 index 00000000000..62f7a059a74 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr79431.c @@ -0,0 +1,8 @@ +/* PR c/79431 */ + +void +foo (void) +{ + int a; + #pragma omp declare target (a) +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr79296.C b/gcc/testsuite/g++.dg/cpp0x/pr79296.C new file mode 100644 index 00000000000..00dc2be1019 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr79296.C @@ -0,0 +1,18 @@ +// { dg-require-effective-target lto } +// { dg-additional-options "-flto" } +// { dg-do compile { target c++11 } } + +// PR 79296 ICE mangling local class of localized instantiation + +struct X { + template <typename T> X (T const *) { + struct Z {}; + } +}; + +void Baz () +{ + struct Y { } y; + + 0, X (&y); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-union1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-union1.C new file mode 100644 index 00000000000..8aed6d9bf55 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-union1.C @@ -0,0 +1,11 @@ +// PR c++/78897 +// { dg-do compile { target c++14 } } + +struct Optional { + constexpr Optional() : _dummy{} { _value = 1; } + union { + int _dummy; + int _value; + }; +}; +Optional opt{}; diff --git a/gcc/testsuite/g++.dg/gomp/pr79429.C b/gcc/testsuite/g++.dg/gomp/pr79429.C new file mode 100644 index 00000000000..8ecbcd38963 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr79429.C @@ -0,0 +1,3 @@ +// PR c++/79429 + +#pragma omp ordered // { dg-error "expected declaration specifiers" } diff --git a/gcc/testsuite/g++.dg/lookup/pr79377.C b/gcc/testsuite/g++.dg/lookup/pr79377.C new file mode 100644 index 00000000000..baf9a256c7c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr79377.C @@ -0,0 +1,36 @@ +// PR c++/79377 +// { dg-do run } +// { dg-options "-fpermissive" } + +struct A +{ + A () : a (0) {} + A& operator++ () { ++a; ++c; return *this; } + int a; + static int c; +}; + +int A::c = 0; + +template <typename> +void +foo (A& a) +{ + a++; // { dg-warning "trying prefix operator instead" } + if (A::c != 3 || a.a != 3) __builtin_abort (); + ++a; + if (A::c != 4 || a.a != 4) __builtin_abort (); +} + +int +main () +{ + A a; + if (A::c != 0 || a.a != 0) __builtin_abort (); + ++a; + if (A::c != 1 || a.a != 1) __builtin_abort (); + a++; // { dg-warning "trying prefix operator instead" } + if (A::c != 2 || a.a != 2) __builtin_abort (); + foo<int> (a); + if (A::c != 4 || a.a != 4) __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/opt/call2.C b/gcc/testsuite/g++.dg/opt/call2.C new file mode 100644 index 00000000000..1b4d4b3fc6c --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/call2.C @@ -0,0 +1,34 @@ +// { dg-do run } +// { dg-options "-O" } + +struct Foo +{ + Foo() : a(1), b(1), c('a') {} + int a; + int b; + char c; +}; + +static Foo copy_foo(Foo) __attribute__((noinline, noclone)); + +static Foo copy_foo(Foo A) +{ + return A; +} + +struct Bar : Foo +{ + Bar(Foo t) : Foo(copy_foo(t)) {} +}; + +Foo F; + +int main (void) +{ + Bar B (F); + + if (B.a != 1 || B.b != 1 || B.c != 'a') + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/opt/call3.C b/gcc/testsuite/g++.dg/opt/call3.C new file mode 100644 index 00000000000..9aac7e2c050 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/call3.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-O" } + +struct Foo +{ + Foo() : a(1), c('a') {} + short int a; + char c; +}; + +static Foo copy_foo(Foo) __attribute__((noinline, noclone)); + +static Foo copy_foo(Foo A) +{ + return A; +} + +struct Bar : Foo +{ + Bar(Foo t) : Foo(copy_foo(t)) {} +}; + +Foo F; + +int main (void) +{ + Bar B (F); + + if (B.a != 1 || B.c != 'a') + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/opt/declone3.C b/gcc/testsuite/g++.dg/opt/declone3.C new file mode 100644 index 00000000000..d8c24921116 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone3.C @@ -0,0 +1,16 @@ +// PR c++/79176 +// { dg-do compile { target c++11 } } +// { dg-options "-flto -Os" } + +struct A {}; +struct Object { + virtual bool m_fn1(); + virtual ~Object(); +}; +struct Item : Object, virtual A { + ~Item() { + [] {}; + } + bool m_fn1(); +}; +bool Item::m_fn1() {} diff --git a/gcc/testsuite/g++.dg/opt/pr79267.C b/gcc/testsuite/g++.dg/opt/pr79267.C new file mode 100644 index 00000000000..177eee6c6f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr79267.C @@ -0,0 +1,69 @@ +// PR tree-optimization/79267 +// { dg-do compile } +// { dg-options "-O3" } + +struct A { A (int); }; +struct B +{ + virtual void av () = 0; + void aw (); + void h () { av (); aw (); } +}; +template <class T> struct G : B +{ + T ba; + G (int, T) : ba (0) {} + void av () { ba (0); } +}; +struct I +{ + B *bc; + template <class j, class T> I (j, T) try { G<T> (0, 0); } catch (...) {} + ~I () { bc->h (); } +}; +template <class M> struct C { typedef M *i; }; +template <class M> struct J +{ + J (); + template <class O, class T> J (O, T p2) : be (0, p2) {} + typename C<M>::i operator-> (); + I be; +}; +struct H : A { H () : A (0) {} }; +struct D { J<int> d; void q (); }; +template <typename = int> class bs; +int z; + +void +foo (int p1, int *, int) +{ + if (p1 == 0) + throw H (); +} + +D bar (); +template <typename T> struct L +{ + struct K { K (int); void operator() (int *) { bar ().q (); } }; + static J<T> bp () { bq (0); } + template <typename br> static void bq (br) { J<T> (0, K (0)); } +}; +struct F +{ + virtual J<int> x (int) { foo (0, 0, 0); J<bs<> > (L<bs<> >::bp ()); } +}; + +void +baz () +{ + if (z) + { + J<F> d, e; + d->x (0); + e->x (0); + } + J<F> v, i, j; + v->x (0); + i->x (0); + j->x (0); +} diff --git a/gcc/testsuite/g++.dg/template/bitfield3.C b/gcc/testsuite/g++.dg/template/bitfield3.C new file mode 100644 index 00000000000..8f1125537e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/bitfield3.C @@ -0,0 +1,20 @@ +// PR c++/78908 + +struct A { int a : 1; }; +struct F { int foo (A const &); }; +template <typename> struct O : F { int foo (A const &); }; +struct S {} b; +template <typename L, typename T> int operator<< (L, T) { return (T) 123; } +template <typename T> int O<T>::foo (A const &x) { return b << x.a; } + +int +main () +{ + A a = { 0 }; + O<int> o; + if (o.foo (a) != 123) + __builtin_abort (); + signed char d = 2; + if ((b << d) != 123) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/torture/pr79034.C b/gcc/testsuite/g++.dg/torture/pr79034.C new file mode 100644 index 00000000000..802c0aa5584 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr79034.C @@ -0,0 +1,52 @@ +/* { dg-do compile } */ + +extern "C" { + float sqrtf(float); +} + +class T { +public: + float floats[1]; + + inline float length() const { + return sqrtf(floats[0]); + } +}; + +void destruct(void *); + +class Container { + + T Ts[1]; + +public: + ~Container() { + destruct((void *)Ts); + } + + T& operator[](int n) { + return Ts[0]; + } +}; + +void fill(Container&); + +void doit() +{ + Container data; + float max = 10; + + int i, j, k; + + for (i = 0; i < 10; i++) { + for (j = 1; j < 10; j++) { + if (max < 5) + break; + fill( data); + max = data[0].length(); + for (k = 1; k < j; k++) { + max = 5; + } + } + } +} diff --git a/gcc/testsuite/g++.dg/vect/pr36648.cc b/gcc/testsuite/g++.dg/vect/pr36648.cc index e2347d29012..84b4efbff8f 100644 --- a/gcc/testsuite/g++.dg/vect/pr36648.cc +++ b/gcc/testsuite/g++.dg/vect/pr36648.cc @@ -17,7 +17,12 @@ Foo foo; int main() { } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! vect_no_align } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_no_align } } } } */ +/* On older powerpc hardware (POWER7 and earlier), the default flag + -mno-allow-movmisalign prevents vectorization. On POWER8 and later, + when vect_hw_misalign is true, vectorization occurs. For other + targets, ! vect_no_align is a sufficient test. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { { ! vect_no_align } && { ! powerpc*-*-* } } || { powerpc*-*-* && vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { { { ! vect_no_align } && { ! powerpc*-*-* } } || { powerpc*-*-* && vect_hw_misalign } } } } } */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C index b64f0fc257a..30228756f12 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C @@ -142,10 +142,24 @@ extern "C" { #define INC_VDATA(A,N) ((A) += 2*(N)) #endif #else +// HPPA uses function pointers but they point to function descriptors. +#if defined __hppa__ +#ifdef __hpux__ +#ifdef _LP64 +#define CMP_VPTR(A, B) (*(unsigned long *)(*(A)+16) == *(unsigned long *)((unsigned long)(B)+16)) +#else +#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#endif /* _LP64 */ +#else +extern "C" { unsigned int __canonicalize_funcptr_for_compare (void*); } +#define CMP_VPTR(A, B) (__canonicalize_funcptr_for_compare(*(void **)A) == __canonicalize_funcptr_for_compare((void *)B)) +#endif /* __hpux__ */ +#else #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#endif /* __hppa__ */ #define INC_VPTR(A) ((A) += 1) #define INC_VDATA(A,N) ((A) += (N)) -#endif +#endif /* __ia64__ */ int main () { diff --git a/gcc/testsuite/gcc.c-torture/compile/pr79197.c b/gcc/testsuite/gcc.c-torture/compile/pr79197.c new file mode 100644 index 00000000000..f3ac71abdb3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr79197.c @@ -0,0 +1,10 @@ +/* PR target/79197 */ + +unsigned long b; + +unsigned long +foo (float *a, float *x) +{ + __builtin_memcpy (a, x, sizeof (float)); + return *a; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr79411.c b/gcc/testsuite/gcc.c-torture/compile/pr79411.c new file mode 100644 index 00000000000..7bd545bc4c5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr79411.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/79411 */ + +typedef struct __jmp_buf_tag { char buf[1024]; } jmp_buf[1]; +extern int setjmp (jmp_buf); +extern int bar (unsigned int *); +extern jmp_buf *baz (void); +struct C { int c1; unsigned int c2, c3, c4; }; + +void +foo (struct C *x, const int *y, unsigned int *z, unsigned int e, unsigned int g) +{ + unsigned int d = 0; + unsigned long f; + setjmp (*baz ()); + f = 1 + d; + if ((x->c1 || x->c2) && g && (!e || d >= 8)) + d = 16; + else + d = 8; + if ((!x->c3 && !x->c4 || *y == 0) && !e && bar (z)) + *z = 1 + f; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824-2.c b/gcc/testsuite/gcc.dg/graphite/pr71824-2.c new file mode 100644 index 00000000000..18176568d4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr71824-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-nest-optimize" } */ + +typedef struct { float x1; } bx; +typedef struct { + int w; + short o; +} T2P; +T2P a; +int b; +void fn2(); +void fn3(bx*,short); +void fn1() { + unsigned i = 0; + int c; + bx *d; + bx **h; + if (b == 0) { + fn2(); + return; + } + for (; c; c++) + for (; i < 100; i++) { + d = h[i]; + d->x1 = a.w; + } + for (; i < 100; i++) { + d = h[i]; + d->x1 = a.w; + } + if (a.o) + for (; b;) + fn3(d, a.o); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824-3.c b/gcc/testsuite/gcc.dg/graphite/pr71824-3.c new file mode 100644 index 00000000000..37e5c3ba34d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr71824-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-distribution -floop-nest-optimize" } */ + +struct +{ + int bz; +} od, ka[2]; + +int fw; + +void +pc (void) +{ + for (od.bz = 0; od.bz < 2; ++od.bz) + { + ++fw; + ka[0] = ka[1]; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824.c b/gcc/testsuite/gcc.dg/graphite/pr71824.c new file mode 100644 index 00000000000..2a90e30e50f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr71824.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-nest-optimize" } */ + +int a, b, d; +int **c; +int fn1() { + while (a) + if (d) { + int e = -d; + for (; b < e; b++) + c[b] = &a; + } else { + for (; b; b++) + c[b] = &b; + d = 0; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr78742.c b/gcc/testsuite/gcc.dg/torture/pr78742.c new file mode 100644 index 00000000000..c83ecbcb7d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr78742.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ + +void foo(); + +void func() +{ + int m; + + int tab[m]; + + __int128 j; + for(; j; j++) + { + tab[j] = 0; + tab[j+1] = 0; + } + + foo(); +} diff --git a/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c b/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c new file mode 100644 index 00000000000..fa22b4da534 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/vfp-longcall-apcs.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-mapcs-frame -O -foptimize-sibling-calls -ffunction-sections" } */ + +extern void abort (void); + +static __attribute__((noclone, noinline, long_call)) +int foo (int a, int b, int c, int d, double i) +{ + return a; +} + +static __attribute__((noclone, noinline)) +double baz (double i) +{ + return i; +} + +static __attribute__((noclone, noinline)) +int bar (int a, int b, int c, int d, double i, double j) +{ + double l = baz (i) * j; + return foo (a, b, c, d, l); +} + +int +main (void) +{ + if (bar (0, 0, 0, 0, 0.0, 0.0) != 0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr49095.c b/gcc/testsuite/gcc.target/i386/pr49095.c index 5fde08bb286..73758f8c523 100644 --- a/gcc/testsuite/gcc.target/i386/pr49095.c +++ b/gcc/testsuite/gcc.target/i386/pr49095.c @@ -1,7 +1,7 @@ /* PR rtl-optimization/49095 */ /* { dg-do compile } */ -/* { dg-options "-Os" } */ -/* { dg-options "-Os -mregparm=2" { target ia32 } } */ +/* { dg-options "-Os -fno-shrink-wrap" } */ +/* { dg-additional-options "-mregparm=2" { target ia32 } } */ void foo (void *); @@ -70,5 +70,4 @@ G (short) G (int) G (long) -/* See PR61225 for the XFAIL. */ -/* { dg-final { scan-assembler-not "test\[lq\]" { xfail { ia32 } } } } */ +/* { dg-final { scan-assembler-not "test\[lq\]" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr79495.c b/gcc/testsuite/gcc.target/i386/pr79495.c new file mode 100644 index 00000000000..27f48facbd2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr79495.c @@ -0,0 +1,11 @@ +/* PR target/79495 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -msoft-float" } */ + +long double dnan = 1.0l/0.0l - 1.0l/0.0l; +long double x = 1.0l; +void fn1 (void) +{ + if (dnan != x) + x = 1.0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c b/gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c new file mode 100644 index 00000000000..2c06ea7106a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-mcpu=power8" } */ + +#include <altivec.h> + +vector signed int +test_vsi_packs_vsll_vsll (vector signed long long x, + vector signed long long y) +{ + return vec_packs (x, y); +} + +vector unsigned int +test_vui_packs_vull_vull (vector unsigned long long x, + vector unsigned long long y) +{ + return vec_packs (x, y); +} + +/* Expected test results: + test_vsi_packs_vsll_vsll 1 vpksdss + test_vui_packs_vull_vull 1 vpkudus */ + +/* { dg-final { scan-assembler-times "vpksdss" 1 } } */ +/* { dg-final { scan-assembler-times "vpkudus" 1 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr79197.c b/gcc/testsuite/gcc.target/powerpc/pr79197.c new file mode 100644 index 00000000000..659d76c15c1 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr79197.c @@ -0,0 +1,11 @@ +/* PR target/79197 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -mno-popcntd" } */ + +unsigned a; + +void +foo (void) +{ + a = *(double *) (__UINTPTR_TYPE__) 0x400000; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr79268.c b/gcc/testsuite/gcc.target/powerpc/pr79268.c new file mode 100644 index 00000000000..4624736422c --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr79268.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target { powerpc64le-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 " } */ + +/* Verify that vec_xl and vec_xst accept vector pixel parameters. */ + +/* Test case to resolve PR79268. */ + +#include <altivec.h> + +vector pixel a; + +vector pixel +pr79268 (vector pixel *x) +{ + vec_xst (a, 0, x); + return vec_xl (0, x); +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c b/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c deleted file mode 100644 index 7ab6d446a23..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-1.c +++ /dev/null @@ -1,143 +0,0 @@ -/* { dg-do compile { target { powerpc64le*-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ -/* { dg-options "-mcpu=power8 -O0" } */ -/* { dg-final { scan-assembler-times "lxvd2x" 18 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 18 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "xxpermdi" 24 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo7 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo8 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo9 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo10 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo11 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo27 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo28 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo29 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo30 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo31 (void) -{ - vec_xst (vui, 0, uip); -} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c b/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c deleted file mode 100644 index eb4a13081a2..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-2.c +++ /dev/null @@ -1,236 +0,0 @@ -/* { dg-do compile { target { powerpc64le*-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ -/* { dg-options "-mcpu=power9 -O0" } */ -/* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-skip-if "" { powerpc*-*-aix* } { "*" } { "" } } */ -/* { dg-final { scan-assembler-times "lxvd2x" 6 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "lxvh8x" 4 } } */ -/* { dg-final { scan-assembler-times "lxvb16x" 4 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 6 } } */ -/* { dg-final { scan-assembler-times "stxvh8x" 4 } } */ -/* { dg-final { scan-assembler-times "stxvb16x" 4 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern vector signed short vss, *vssp; -extern vector unsigned short vus, *vusp; -extern vector signed char vsc, *vscp; -extern vector unsigned char vuc, *vucp; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; -extern signed short *ssp; -extern unsigned short *usp; -extern signed char *scp; -extern unsigned char *ucp; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vss = vec_xl (0, vssp); -} - -void foo7 (void) -{ - vus = vec_xl (0, vusp); -} - -void foo8 (void) -{ - vsc = vec_xl (0, vscp); -} - -void foo9 (void) -{ - vuc = vec_xl (0, vucp); -} - -void foo10 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo11 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo12 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo13 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo14 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo15 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo16 (void) -{ - vec_xst (vss, 0, vssp); -} - -void foo17 (void) -{ - vec_xst (vus, 0, vusp); -} - -void foo18 (void) -{ - vec_xst (vsc, 0, vscp); -} - -void foo19 (void) -{ - vec_xst (vuc, 0, vucp); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vss = vec_xl (0, ssp); -} - -void foo27 (void) -{ - vus = vec_xl (0, usp); -} - -void foo28 (void) -{ - vsc = vec_xl (0, scp); -} - -void foo29 (void) -{ - vuc = vec_xl (0, ucp); -} - -void foo30 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo31 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo32 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo33 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo34 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo35 (void) -{ - vec_xst (vui, 0, uip); -} - -void foo36 (void) -{ - vec_xst (vss, 0, ssp); -} - -void foo37 (void) -{ - vec_xst (vus, 0, usp); -} - -void foo38 (void) -{ - vec_xst (vsc, 0, scp); -} - -void foo39 (void) -{ - vec_xst (vuc, 0, ucp); -} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c b/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c deleted file mode 100644 index 2888c171c4f..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-3.c +++ /dev/null @@ -1,142 +0,0 @@ -/* { dg-do compile { target { powerpc64-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ -/* { dg-options "-mcpu=power8 -O0" } */ -/* { dg-final { scan-assembler-times "lxvd2x" 16 } } */ -/* { dg-final { scan-assembler-times "lxvw4x" 8 } } */ -/* { dg-final { scan-assembler-times "stxvd2x" 16 } } */ -/* { dg-final { scan-assembler-times "stxvw4x" 8 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo7 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo8 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo9 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo10 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo11 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo27 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo28 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo29 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo30 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo31 (void) -{ - vec_xst (vui, 0, uip); -} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c b/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c deleted file mode 100644 index a116316c174..00000000000 --- a/gcc/testsuite/gcc.target/powerpc/vsx-elemrev-4.c +++ /dev/null @@ -1,230 +0,0 @@ -/* { dg-do compile { target { powerpc64-*-* } } } */ -/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ -/* { dg-options "-mcpu=power9 -O0" } */ -/* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-skip-if "" { powerpc*-*-aix* } { "*" } { "" } } */ -/* { dg-final { scan-assembler-times "lxvx" 40 } } */ -/* { dg-final { scan-assembler-times "stxvx" 40 } } */ - -#include <altivec.h> - -extern vector double vd, *vdp; -extern vector signed long long vsll, *vsllp; -extern vector unsigned long long vull, *vullp; -extern vector float vf, *vfp; -extern vector signed int vsi, *vsip; -extern vector unsigned int vui, *vuip; -extern vector signed short vss, *vssp; -extern vector unsigned short vus, *vusp; -extern vector signed char vsc, *vscp; -extern vector unsigned char vuc, *vucp; -extern double *dp; -extern signed long long *sllp; -extern unsigned long long *ullp; -extern float *fp; -extern signed int *sip; -extern unsigned int *uip; -extern signed short *ssp; -extern unsigned short *usp; -extern signed char *scp; -extern unsigned char *ucp; - -void foo0 (void) -{ - vd = vec_xl (0, vdp); -} - -void foo1 (void) -{ - vsll = vec_xl (0, vsllp); -} - -void foo2 (void) -{ - vull = vec_xl (0, vullp); -} - -void foo3 (void) -{ - vf = vec_xl (0, vfp); -} - -void foo4 (void) -{ - vsi = vec_xl (0, vsip); -} - -void foo5 (void) -{ - vui = vec_xl (0, vuip); -} - -void foo6 (void) -{ - vss = vec_xl (0, vssp); -} - -void foo7 (void) -{ - vus = vec_xl (0, vusp); -} - -void foo8 (void) -{ - vsc = vec_xl (0, vscp); -} - -void foo9 (void) -{ - vuc = vec_xl (0, vucp); -} - -void foo10 (void) -{ - vec_xst (vd, 0, vdp); -} - -void foo11 (void) -{ - vec_xst (vsll, 0, vsllp); -} - -void foo12 (void) -{ - vec_xst (vull, 0, vullp); -} - -void foo13 (void) -{ - vec_xst (vf, 0, vfp); -} - -void foo14 (void) -{ - vec_xst (vsi, 0, vsip); -} - -void foo15 (void) -{ - vec_xst (vui, 0, vuip); -} - -void foo16 (void) -{ - vec_xst (vss, 0, vssp); -} - -void foo17 (void) -{ - vec_xst (vus, 0, vusp); -} - -void foo18 (void) -{ - vec_xst (vsc, 0, vscp); -} - -void foo19 (void) -{ - vec_xst (vuc, 0, vucp); -} - -void foo20 (void) -{ - vd = vec_xl (0, dp); -} - -void foo21 (void) -{ - vsll = vec_xl (0, sllp); -} - -void foo22 (void) -{ - vull = vec_xl (0, ullp); -} - -void foo23 (void) -{ - vf = vec_xl (0, fp); -} - -void foo24 (void) -{ - vsi = vec_xl (0, sip); -} - -void foo25 (void) -{ - vui = vec_xl (0, uip); -} - -void foo26 (void) -{ - vss = vec_xl (0, ssp); -} - -void foo27 (void) -{ - vus = vec_xl (0, usp); -} - -void foo28 (void) -{ - vsc = vec_xl (0, scp); -} - -void foo29 (void) -{ - vuc = vec_xl (0, ucp); -} - -void foo30 (void) -{ - vec_xst (vd, 0, dp); -} - -void foo31 (void) -{ - vec_xst (vsll, 0, sllp); -} - -void foo32 (void) -{ - vec_xst (vull, 0, ullp); -} - -void foo33 (void) -{ - vec_xst (vf, 0, fp); -} - -void foo34 (void) -{ - vec_xst (vsi, 0, sip); -} - -void foo35 (void) -{ - vec_xst (vui, 0, uip); -} - -void foo36 (void) -{ - vec_xst (vss, 0, ssp); -} - -void foo37 (void) -{ - vec_xst (vus, 0, usp); -} - -void foo38 (void) -{ - vec_xst (vsc, 0, scp); -} - -void foo39 (void) -{ - vec_xst (vuc, 0, ucp); -} diff --git a/gcc/testsuite/gfortran.dg/coarray/event_3.f08 b/gcc/testsuite/gfortran.dg/coarray/event_3.f08 new file mode 100644 index 00000000000..f6e28b78c8d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/event_3.f08 @@ -0,0 +1,20 @@ +! { dg-do run } +! +! Check PR fortran/70696 is fixed. + +program global_event + use iso_fortran_env , only : event_type + implicit none + type(event_type) :: x[*] + + call exchange + contains + subroutine exchange + integer :: cnt + event post(x[1]) + event post(x[1]) + call event_query(x, cnt) + if (cnt /= 2) error stop 1 + event wait(x, until_count=2) + end subroutine +end diff --git a/gcc/testsuite/gfortran.dg/coarray/event_4.f08 b/gcc/testsuite/gfortran.dg/coarray/event_4.f08 new file mode 100644 index 00000000000..de901c01aa4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/event_4.f08 @@ -0,0 +1,12 @@ +! { dg-do run } +! +! Check that pr 70697 is fixed. + +program event_4 + use iso_fortran_env + integer :: nc(1) + type(event_type) done[*] + nc(1) = 1 + event post(done[1]) + event wait(done,until_count=nc(1)) +end diff --git a/gcc/testsuite/gfortran.dg/coarray_43.f90 b/gcc/testsuite/gfortran.dg/coarray_43.f90 new file mode 100644 index 00000000000..d5ee4e1a668 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_43.f90 @@ -0,0 +1,13 @@ +! { dg-do link } +! { dg-options "-fcoarray=lib -lcaf_single" } + +program coarray_43 + implicit none + integer, parameter :: STR_LEN = 50 + character(len=STR_LEN) :: str[*] + integer :: pos + write(str,"(2(a,i2))") "Greetings from image ",this_image()," of ",num_images() + block + pos = scan(str[5], set="123456789") + end block +end program diff --git a/gcc/testsuite/gfortran.dg/coarray_event_1.f08 b/gcc/testsuite/gfortran.dg/coarray_event_1.f08 new file mode 100644 index 00000000000..51fc54c162a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_event_1.f08 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib -lcaf_single" } + +! Check that pr70696 is really fixed. + + use iso_fortran_env + type(event_type) :: x[*] + + ! exchange must not be called or the link problem before the patch + ! does not occur. +contains + subroutine exchange + event post (x[1]) + end subroutine +end diff --git a/gcc/testsuite/gnat.dg/array26.adb b/gcc/testsuite/gnat.dg/array26.adb new file mode 100644 index 00000000000..659d596fc1e --- /dev/null +++ b/gcc/testsuite/gnat.dg/array26.adb @@ -0,0 +1,22 @@ +-- { dg-do run } +-- { dg-options "-O" } + +with Array26_Pkg; use Array26_Pkg; + +procedure Array26 is + + function Get return Outer_type is + Ret : Outer_Type; + begin + Ret (Inner_Type'Range) := F; + return Ret; + end; + + A : Outer_Type := Get; + B : Inner_Type := A (Inner_Type'Range); + +begin + if B /= "123" then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/array26_pkg.adb b/gcc/testsuite/gnat.dg/array26_pkg.adb new file mode 100644 index 00000000000..f324bd2ce52 --- /dev/null +++ b/gcc/testsuite/gnat.dg/array26_pkg.adb @@ -0,0 +1,8 @@ +package body Array26_Pkg is + + function F return Inner_Type is + begin + return "123"; + end; + +end Array26_Pkg; diff --git a/gcc/testsuite/gnat.dg/array26_pkg.ads b/gcc/testsuite/gnat.dg/array26_pkg.ads new file mode 100644 index 00000000000..ae84a74725c --- /dev/null +++ b/gcc/testsuite/gnat.dg/array26_pkg.ads @@ -0,0 +1,8 @@ +package Array26_Pkg is + + subtype Outer_Type is String (1 .. 4); + subtype Inner_Type is String (1 .. 3); + + function F return Inner_Type; + +end Array26_Pkg; diff --git a/gcc/testsuite/gnat.dg/array27.adb b/gcc/testsuite/gnat.dg/array27.adb new file mode 100644 index 00000000000..db821c5f82d --- /dev/null +++ b/gcc/testsuite/gnat.dg/array27.adb @@ -0,0 +1,22 @@ +-- { dg-do run } +-- { dg-options "-O" } + +with Array27_Pkg; use Array27_Pkg; + +procedure Array27 is + + function Get return Outer_type is + Ret : Outer_Type; + begin + Ret (Inner_Type'Range) := F; + return Ret; + end; + + A : Outer_Type := Get; + B : Inner_Type := A (Inner_Type'Range); + +begin + if B /= "123" then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/array27_pkg.adb b/gcc/testsuite/gnat.dg/array27_pkg.adb new file mode 100644 index 00000000000..92c61b94a32 --- /dev/null +++ b/gcc/testsuite/gnat.dg/array27_pkg.adb @@ -0,0 +1,8 @@ +package body Array27_Pkg is + + function F return Inner_Type is + begin + return "123"; + end; + +end Array27_Pkg; diff --git a/gcc/testsuite/gnat.dg/array27_pkg.ads b/gcc/testsuite/gnat.dg/array27_pkg.ads new file mode 100644 index 00000000000..1473fbb4462 --- /dev/null +++ b/gcc/testsuite/gnat.dg/array27_pkg.ads @@ -0,0 +1,8 @@ +package Array27_Pkg is + + subtype Outer_Type is String (1 .. 8); + subtype Inner_Type is String (1 .. 3); + + function F return Inner_Type; + +end Array27_Pkg; diff --git a/gcc/testsuite/gnat.dg/array28.adb b/gcc/testsuite/gnat.dg/array28.adb new file mode 100644 index 00000000000..aa31445d37d --- /dev/null +++ b/gcc/testsuite/gnat.dg/array28.adb @@ -0,0 +1,22 @@ +-- { dg-do run } +-- { dg-options "-O" } + +with Array28_Pkg; use Array28_Pkg; + +procedure Array28 is + + function Get return Outer_type is + Ret : Outer_Type; + begin + Ret (Inner_Type'Range) := F; + return Ret; + end; + + A : Outer_Type := Get; + B : Inner_Type := A (Inner_Type'Range); + +begin + if B /= "12345" then + raise Program_Error; + end if; +end; diff --git a/gcc/testsuite/gnat.dg/array28_pkg.adb b/gcc/testsuite/gnat.dg/array28_pkg.adb new file mode 100644 index 00000000000..726810b80f7 --- /dev/null +++ b/gcc/testsuite/gnat.dg/array28_pkg.adb @@ -0,0 +1,8 @@ +package body Array28_Pkg is + + function F return Inner_Type is + begin + return "12345"; + end; + +end Array28_Pkg; diff --git a/gcc/testsuite/gnat.dg/array28_pkg.ads b/gcc/testsuite/gnat.dg/array28_pkg.ads new file mode 100644 index 00000000000..6189010baf9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/array28_pkg.ads @@ -0,0 +1,8 @@ +package Array28_Pkg is + + subtype Outer_Type is String (1 .. 8); + subtype Inner_Type is String (1 .. 5); + + function F return Inner_Type; + +end Array28_Pkg; diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c index 6bbe0c36611..a7fa3cdb908 100644 --- a/gcc/tree-call-cdce.c +++ b/gcc/tree-call-cdce.c @@ -805,7 +805,18 @@ shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, vec <gimple *> conds, if (EDGE_COUNT (join_tgt_in_edge_from_call->dest->preds) > 1) join_tgt_bb = split_edge (join_tgt_in_edge_from_call); else - join_tgt_bb = join_tgt_in_edge_from_call->dest; + { + join_tgt_bb = join_tgt_in_edge_from_call->dest; + /* We may have degenerate PHIs in the destination. Propagate + those out. */ + for (gphi_iterator i = gsi_start_phis (join_tgt_bb); !gsi_end_p (i);) + { + gphi *phi = i.phi (); + replace_uses_by (gimple_phi_result (phi), + gimple_phi_arg_def (phi, 0)); + remove_phi_node (&i, true); + } + } } else { diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index f321fdda53e..0bb01f16259 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2112,8 +2112,6 @@ initialize_matrix_A (lambda_matrix A, tree chrec, unsigned index, int mult) switch (TREE_CODE (chrec)) { case POLYNOMIAL_CHREC: - gcc_assert (TREE_CODE (CHREC_RIGHT (chrec)) == INTEGER_CST); - A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec)); return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult); diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 2e55b7961d8..bd43af6dff7 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -2511,8 +2511,8 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list { gphi_iterator gsi; loop_vec_info simple_loop_info; - loop_vec_info simple_inner_loop_info = NULL; - bool allow_double_reduc = true; + auto_vec<gphi *, 4> double_reduc_phis; + auto_vec<gimple *, 4> double_reduc_stmts; if (!stmt_vec_info_vec.exists ()) init_stmt_vec_info_vec (); @@ -2542,43 +2542,55 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list if (double_reduc) { - if (!allow_double_reduc - || loop->inner->inner != NULL) + if (loop->inner->inner != NULL) continue; - if (!simple_inner_loop_info) - { - simple_inner_loop_info = vect_analyze_loop_form (loop->inner); - if (!simple_inner_loop_info) - { - allow_double_reduc = false; - continue; - } - } - - use_operand_p use_p; - gimple *inner_stmt; - bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); - gcc_assert (single_use_p); - if (gimple_code (inner_stmt) != GIMPLE_PHI) - continue; - gphi *inner_phi = as_a <gphi *> (inner_stmt); - if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi), - &iv, true)) - continue; - - gimple *inner_reduc_stmt - = vect_force_simple_reduction (simple_inner_loop_info, inner_phi, - true, &double_reduc, true); - gcc_assert (!double_reduc); - if (inner_reduc_stmt == NULL) - continue; + double_reduc_phis.safe_push (phi); + double_reduc_stmts.safe_push (reduc_stmt); + continue; } build_new_reduction (reduction_list, reduc_stmt, phi); } destroy_loop_vec_info (simple_loop_info, true); - destroy_loop_vec_info (simple_inner_loop_info, true); + + if (!double_reduc_phis.is_empty ()) + { + simple_loop_info = vect_analyze_loop_form (loop->inner); + if (simple_loop_info) + { + gphi *phi; + unsigned int i; + + FOR_EACH_VEC_ELT (double_reduc_phis, i, phi) + { + affine_iv iv; + tree res = PHI_RESULT (phi); + bool double_reduc; + + use_operand_p use_p; + gimple *inner_stmt; + bool single_use_p = single_imm_use (res, &use_p, &inner_stmt); + gcc_assert (single_use_p); + if (gimple_code (inner_stmt) != GIMPLE_PHI) + continue; + gphi *inner_phi = as_a <gphi *> (inner_stmt); + if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi), + &iv, true)) + continue; + + gimple *inner_reduc_stmt + = vect_force_simple_reduction (simple_loop_info, inner_phi, + true, &double_reduc, true); + gcc_assert (!double_reduc); + if (inner_reduc_stmt == NULL) + continue; + + build_new_reduction (reduction_list, double_reduc_stmts[i], phi); + } + destroy_loop_vec_info (simple_loop_info, true); + } + } gather_done: /* Release the claim on gimple_uid. */ diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index d23dabde7b6..db4718b24da 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -599,7 +599,18 @@ is_reassociable_op (gimple *stmt, enum tree_code code, struct loop *loop) if (is_gimple_assign (stmt) && gimple_assign_rhs_code (stmt) == code && has_single_use (gimple_assign_lhs (stmt))) - return true; + { + tree rhs1 = gimple_assign_rhs1 (stmt); + tree rhs2 = gimple_assign_rhs1 (stmt); + if (TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + return false; + if (rhs2 + && TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2)) + return false; + return true; + } return false; } @@ -4466,6 +4477,8 @@ static bool can_reassociate_p (tree op) { tree type = TREE_TYPE (op); + if (TREE_CODE (op) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op)) + return false; if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type)) || NON_SAT_FIXED_POINT_TYPE_P (type) || (flag_associative_math && FLOAT_TYPE_P (type))) diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 154df21a3e6..98caabc90c3 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -7057,8 +7057,7 @@ vrp_valueize_1 (tree name) static enum ssa_prop_result vrp_visit_assignment_or_call (gimple *stmt, tree *output_p) { - tree def, lhs; - ssa_op_iter iter; + tree lhs; enum gimple_code code = gimple_code (stmt); lhs = gimple_get_lhs (stmt); @@ -7175,8 +7174,7 @@ vrp_visit_assignment_or_call (gimple *stmt, tree *output_p) } /* Every other statement produces no useful ranges. */ - FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF) - set_value_range_to_varying (get_value_range (def)); + set_defs_to_varying (stmt); return SSA_PROP_VARYING; } diff --git a/gcc/tree.c b/gcc/tree.c index 5c9f6f42140..7ce14c93663 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1675,13 +1675,8 @@ build_low_bits_mask (tree type, unsigned bits) bool cst_and_fits_in_hwi (const_tree x) { - if (TREE_CODE (x) != INTEGER_CST) - return false; - - if (TYPE_PRECISION (TREE_TYPE (x)) > HOST_BITS_PER_WIDE_INT) - return false; - - return TREE_INT_CST_NUNITS (x) == 1; + return (TREE_CODE (x) == INTEGER_CST + && (tree_fits_shwi_p (x) || tree_fits_uhwi_p (x))); } /* Build a newly constructed VECTOR_CST node of length LEN. */ diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 56637d8f0a9..109382498fd 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1471,7 +1471,7 @@ ubsan_use_new_style_p (location_t loc) expanded_location xloc = expand_location (loc); if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0 - || xloc.file == '\0' || xloc.file[0] == '\xff' + || xloc.file[0] == '\0' || xloc.file[0] == '\xff' || xloc.file[1] == '\xff') return false; diff --git a/gcc/value-prof.c b/gcc/value-prof.c index f9574b679bd..89f6b865766 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1376,7 +1376,13 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, gimple_call_set_fndecl (dcall_stmt, direct_call->decl); dflags = flags_from_decl_or_type (direct_call->decl); if ((dflags & ECF_NORETURN) != 0) - gimple_call_set_lhs (dcall_stmt, NULL_TREE); + { + tree lhs = gimple_call_lhs (dcall_stmt); + if (lhs + && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST + && !TREE_ADDRESSABLE (TREE_TYPE (lhs))) + gimple_call_set_lhs (dcall_stmt, NULL_TREE); + } gsi_insert_before (&gsi, dcall_stmt, GSI_SAME_STMT); /* Fix CFG. */ diff --git a/libatomic/ChangeLog b/libatomic/ChangeLog index 5aa7218f7b3..c6a929383a9 100644 --- a/libatomic/ChangeLog +++ b/libatomic/ChangeLog @@ -1,3 +1,11 @@ +2017-02-07 Szabolcs Nagy <szabolcs.nagy@arm.com> + + Backport from mainline: + 2017-01-30 Szabolcs Nagy <szabolcs.nagy@arm.com> + + PR target/78945 + * config/arm/exch_n.c (libat_exchange): Check __ARM_FEATURE_SIMD32. + 2016-12-21 Release Manager * GCC 6.3.0 released. diff --git a/libatomic/config/arm/exch_n.c b/libatomic/config/arm/exch_n.c index 3b20a974fc8..c521e494561 100644 --- a/libatomic/config/arm/exch_n.c +++ b/libatomic/config/arm/exch_n.c @@ -29,7 +29,7 @@ /* When using STREX to implement sub-word exchange, we can do much better than the compiler by using the APSR.GE and APSR.C flags. */ -#if !DONE && HAVE_STREX && !HAVE_STREXBH && N == 2 +#if !DONE && __ARM_FEATURE_SIMD32 && HAVE_STREX && !HAVE_STREXBH && N == 2 UTYPE SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel) { @@ -79,7 +79,7 @@ SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel) #endif /* !HAVE_STREXBH && N == 2 */ -#if !DONE && HAVE_STREX && !HAVE_STREXBH && N == 1 +#if !DONE && __ARM_FEATURE_SIMD32 && HAVE_STREX && !HAVE_STREXBH && N == 1 UTYPE SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel) { diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 66cef90d4b2..518210d0447 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,18 @@ +2017-01-31 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/79305 + * c99_protos.h: Spell HAVE_EXPL correctly. + * intrinsics/c99_functions.c: Ditto. + +2017-01-24 Uros Bizjak <ubizjak@gmail.com> + + PR target/78478 + * acinclude.m4: Include ../config/ax_check_define.m4 + * configure.ac: Check if _SOFT_FLOAT is defined. + * configure.host (i?86 | x86_64): Use fpu-generic when + have_soft_float is set. + * configure: Regenerate. + 2016-12-21 Release Manager * GCC 6.3.0 released. @@ -13,14 +28,14 @@ Backport from trunk PR libgfortran/77707 - io/transfer.c (next_record): Flush before calculating next_record. + * io/transfer.c (next_record): Flush before calculating next_record. Correctly calculate. 2016-09-28 Steven G. Kargl <kargl@gcc.gnu.org> Backport from trunk PR fortran/77507 - * ieee/ieee_arithmetic.F90 (IEEE_VALUE_4,IEEE_VALUE_8,IEEE_VALULE_10, + * ieee/ieee_arithmetic.F90 (IEEE_VALUE_4,IEEE_VALUE_8,IEEE_VALULE_10, IEEE_VALUE_16): Use correct keyword. 2016-08-22 Release Manager @@ -82,9 +97,10 @@ (read_logical): If '!' bang encountered when not in namelist mode got bad_logical to give an error. (read_integer): Likewise reject '!'. (read_character): Remove condition testing c = '!' which is now inside - the is_separator macro. (parse_real): Reject '!' unless in namelist mode. - (read_complex): Reject '!' unless in namelist mode. (read_real): Likewise - reject '!'. + the is_separator macro. (parse_real): Reject '!' unless in + namelist mode. + (read_complex): Reject '!' unless in namelist mode. + (read_real): Likewise reject '!'. 2016-02-12 Jerry DeLisle <jvdelisle@gcc.gnu.org> diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index 7280bc37a0b..1b20d10c9f4 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -1,6 +1,7 @@ m4_include(../config/acx.m4) m4_include(../config/no-executables.m4) m4_include(../config/math.m4) +m4_include(../config/ax_check_define.m4) dnl Check that we have a working GNU Fortran compiler AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [ diff --git a/libgfortran/c99_protos.h b/libgfortran/c99_protos.h index e28d421c13c..396c20e08aa 100644 --- a/libgfortran/c99_protos.h +++ b/libgfortran/c99_protos.h @@ -332,7 +332,7 @@ extern float complex cexpf (float complex); extern double complex cexp (double complex); #endif -#if !defined(HAVE_CEXPL) && defined(HAVE_COSL) && defined(HAVE_SINL) && defined(EXPL) +#if !defined(HAVE_CEXPL) && defined(HAVE_COSL) && defined(HAVE_SINL) && defined(HAVE_EXPL) #define HAVE_CEXPL 1 extern long double complex cexpl (long double complex); #endif diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c index f726537e788..b4b655eb7b6 100644 --- a/libgfortran/caf/single.c +++ b/libgfortran/caf/single.c @@ -101,9 +101,12 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, void *local; if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC - || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC - || type == CAF_REGTYPE_EVENT_ALLOC) - local = calloc (size, sizeof (bool)); + || type == CAF_REGTYPE_CRITICAL) + local = calloc (size, sizeof (bool)); + else if (type == CAF_REGTYPE_EVENT_STATIC || type == CAF_REGTYPE_EVENT_ALLOC) + /* In the event_(wait|post) function the counter for events is a uint32, + so better allocate enough memory here. */ + local = calloc (size, sizeof (uint32_t)); else local = malloc (size); *token = malloc (sizeof (single_token_t)); diff --git a/libgfortran/configure b/libgfortran/configure index f746f6f5d1d..db607eb5954 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -10308,7 +10308,7 @@ _LT_EOF if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -14157,7 +14157,7 @@ _LT_EOF if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -25762,6 +25762,43 @@ $as_echo "#define HAVE_FP_ENABLE 1" >>confdefs.h fi +# Check if _SOFT_FLOAT is defined + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _SOFT_FLOAT defined" >&5 +$as_echo_n "checking for _SOFT_FLOAT defined... " >&6; } +if test "${ac_cv_defined__SOFT_FLOAT+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + #ifdef _SOFT_FLOAT + int ok; + #else + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_defined__SOFT_FLOAT=yes +else + ac_cv_defined__SOFT_FLOAT=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_defined__SOFT_FLOAT" >&5 +$as_echo "$ac_cv_defined__SOFT_FLOAT" >&6; } +if test $ac_cv_defined__SOFT_FLOAT != "no"; then : + have_soft_float=yes +fi + # Runs configure.host to set up necessary host-dependent shell variables. # We then display a message about it, and propagate them through the # build chain. diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 8f377bb4b50..5a264942b6d 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -551,6 +551,9 @@ AC_CHECK_FUNC([fpresetsticky],[have_fpresetsticky=yes AC_DEFINE([HAVE_FPRESETSTI AC_CHECK_FUNC([fp_trap],[have_fp_trap=yes AC_DEFINE([HAVE_FP_TRAP],[1],[fp_trap is present])]) AC_CHECK_FUNC([fp_enable],[have_fp_enable=yes AC_DEFINE([HAVE_FP_ENABLE],[1],[fp_enable is present])]) +# Check if _SOFT_FLOAT is defined +AC_CHECK_DEFINE([_SOFT_FLOAT],[have_soft_float=yes]) + # Runs configure.host to set up necessary host-dependent shell variables. # We then display a message about it, and propagate them through the # build chain. diff --git a/libgfortran/configure.host b/libgfortran/configure.host index 0a12a32fc8a..5824f253e2f 100644 --- a/libgfortran/configure.host +++ b/libgfortran/configure.host @@ -40,7 +40,11 @@ fi # the x86 denormal exception. case "${host_cpu}" in i?86 | x86_64) - fpu_host='fpu-387' + if test "x${have_soft_float}" = "xyes"; then + fpu_host='fpu-generic' + else + fpu_host='fpu-387' + fi ieee_support='yes' ;; esac diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c index daafda9bd21..410bb67e5cb 100644 --- a/libgfortran/intrinsics/c99_functions.c +++ b/libgfortran/intrinsics/c99_functions.c @@ -913,7 +913,7 @@ cexp (double complex z) } #endif -#if !defined(HAVE_CEXPL) && defined(HAVE_COSL) && defined(HAVE_SINL) && defined(EXPL) +#if !defined(HAVE_CEXPL) && defined(HAVE_COSL) && defined(HAVE_SINL) && defined(HAVE_EXPL) #define HAVE_CEXPL 1 long double complex cexpl (long double complex z); diff --git a/libgo/runtime/go-unsafe-pointer.c b/libgo/runtime/go-unsafe-pointer.c index ce82fcd4070..21ff63f4f3a 100644 --- a/libgo/runtime/go-unsafe-pointer.c +++ b/libgo/runtime/go-unsafe-pointer.c @@ -36,7 +36,8 @@ static const String reflection_string = sizeof REFLECTION - 1 }; -const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END}; +const uintptr unsafe_Pointer_gc[] __attribute__((aligned(4))) = + {sizeof(void*), GC_APTR, 0, GC_END}; const struct __go_type_descriptor unsafe_Pointer = { diff --git a/libgo/runtime/parfor.c b/libgo/runtime/parfor.c index ede921b9aaa..1e67f3aaa87 100644 --- a/libgo/runtime/parfor.c +++ b/libgo/runtime/parfor.c @@ -10,7 +10,7 @@ struct ParForThread { // the thread's iteration space [32lsb, 32msb) - uint64 pos; + uint64 pos __attribute__((aligned(8))); // stats uint64 nsteal; uint64 nstealcnt; diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 73c46e9117f..1cca43a1f5c 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -154,14 +154,14 @@ struct Lock // Futex-based impl treats it as uint32 key, // while sema-based impl as M* waitm. // Used to be a union, but unions break precise GC. - uintptr key; + uintptr key __attribute__((aligned(4))); }; struct Note { // Futex-based impl treats it as uint32 key, // while sema-based impl as M* waitm. // Used to be a union, but unions break precise GC. - uintptr key; + uintptr key __attribute__((aligned(4))); }; struct String { @@ -431,7 +431,7 @@ struct ParFor // otherwise parfor may return while other threads are still working ParForThread *thr; // array of thread descriptors // stats - uint64 nsteal; + uint64 nsteal __attribute__((aligned(8))); // force alignment for m68k uint64 nstealcnt; uint64 nprocyield; uint64 nosyield; diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 26d5254ccff..00994ec8feb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,133 @@ +2017-02-14 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2017-01-20 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/72792 + * include/bits/alloc_traits.h (__allocator_traits_base::__diff_type) + (__allocator_traits_base::__size_type): Remove. + (allocator_traits::_Ptr): New class template to detect const and void + pointer types without instantiating pointer_traits::rebind + unnecessarily. + (allocator_traits::_Diff): Likewise for detecting difference_type. + (allocator_traits::_Size): New class template to detect size_type + without instantiating make_unsigned unnecessarily. + * include/bits/ptr_traits.h (pointer_traits::element_type): Use + __detected_or_t instead of __detected_or_t_. + * include/std/type_traits (__detected_or_t_): Remove. + * testsuite/20_util/allocator_traits/members/pointers.cc: New test. + + Backport from mainline + 2017-01-20 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/72792 + PR libstdc++/72793 + * include/bits/alloc_traits.h (__allocator_traits_base::__rebind): + Replace with class template using void_t. + (__alloc_rebind): Define in terms of + __allocator_traits_base::__rebind. + (allocator_traits): Remove unconditional static_assert for + rebind_alloc. + * include/bits/ptr_traits.h (__replace_first_arg): Remove type member. + (pointer_traits::__rebind): Replace with class template using void_t. + (pointer_traits::rebind): Define in terms of __rebind. + (pointer_traits): Remove unconditional static_assert for rebind. + * testsuite/20_util/allocator_traits/members/rebind_alloc.cc: New test. + * testsuite/20_util/pointer_traits/rebind.cc: New test. + + Backport from mainline + 2017-01-20 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/69321 + * include/experimental/any (__any_caster): Avoid instantiating + manager function for types that can't be stored in any. + * testsuite/experimental/any/misc/any_cast.cc: Test non-copyable type. + + Backport from mainline + 2017-01-18 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/69301 + * include/std/atomic (atomic<T>::load, atomic<T>::exchange): Use + aligned buffer instead of default-initialized variable. + * testsuite/29_atomics/atomic/69301.cc: New test. + * include/experimental/memory (observer_ptr::release): Use reserved + name. + * include/ext/pointer.h (_Pointer_adapter::operator++(int)) + (_Pointer_adapter::operator--(int)): Likewise. + + Backport from mainline + 2017-01-17 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/79114 + * libsupc++/nested_exception.h (throw_with_nested): Use decay instead + of remove_reference. + * testsuite/18_support/nested_exception/79114.cc: New test. + + Backport from mainline + 2017-01-16 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/78702 + * include/bits/locale_classes.h (locale::facet::__shim): Change from + private to protected. + * src/c++11/cxx11-shim_facets.cc (__shim_accessor): Define helper to + make locale::facet::__shim accessible. + + Backport from mainline + 2017-01-11 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/78134 + * include/bits/stl_map.h (map::lower_bound, map::upper_bound) + (map::equal_range): Fix return type of heterogeneous overloads. + * include/bits/stl_multimap.h (multimap::lower_bound) + (multimap::upper_bound, multimap::equal_range): Likewise. + * include/bits/stl_multiset.h (multiset::lower_bound) + (multiset::upper_bound, multiset::equal_range): Likewise. + * include/bits/stl_set.h (set::lower_bound, set::upper_bound) + (set::equal_range): Likewise. + * testsuite/23_containers/map/operations/2.cc: Check return types. + * testsuite/23_containers/multimap/operations/2.cc: Likewise. + * testsuite/23_containers/multiset/operations/2.cc: Likewise. + * testsuite/23_containers/set/operations/2.cc: Likewise. + + Backport from mainline + 2017-01-11 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/78273 + * include/bits/stl_map.h (map::count<_Kt>(const _Kt&)): Don't assume + the heterogeneous comparison can only find one match. + * include/bits/stl_set.h (set::count<_Kt>(const _Kt&)): Likewise. + * testsuite/23_containers/map/operations/2.cc: Test count works with + comparison function that just partitions rather than sorting. + * testsuite/23_containers/set/operations/2.cc: Likewise. + +2017-02-01 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/78346 + * include/bits/predefined_ops.h (_Iter_equals_iter): Store iterator + not its referent. + (_Iter_comp_to_iter): Likewise. + * testsuite/25_algorithms/search/78346.cc: New test. + + PR libstdc++/79195 + * include/experimental/array (make_array): Use common_type<_Dest> + and delay instantiation of common_type until after conditional_t. + Qualify std::forward call. + (to_array): Add exception specification. + * testsuite/experimental/array/make_array.cc: Test argument types + without a common type. + + PR libstdc++/79254 + * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] + (basic_string::operator=(const basic_string&)): If source object is + small just deallocate, otherwise perform new allocation before + making any changes. + * testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc: + Test exception-safety of copy assignment when allocator propagates. + * testsuite/21_strings/basic_string/allocator/char/copy_assign.cc: + Likewise. + * testsuite/util/testsuite_allocator.h (uneq_allocator::swap): Make + std::swap visible. + 2017-01-22 Gerald Pfeifer <gerald@pfeifer.com> Backport from mainline diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index d2d13c692af..25ad9486a5b 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -44,8 +44,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __allocator_traits_base { - template<typename _Alloc, typename _Up> - using __rebind = typename _Alloc::template rebind<_Up>::other; + template<typename _Tp, typename _Up, typename = void> + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template<typename _Tp, typename _Up> + struct __rebind<_Tp, _Up, + __void_t<typename _Tp::template rebind<_Up>::other>> + { using type = typename _Tp::template rebind<_Up>::other; }; protected: template<typename _Tp> @@ -57,10 +62,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> using __cv_pointer = typename _Tp::const_void_pointer; template<typename _Tp> - using __diff_type = typename _Tp::difference_type; - template<typename _Tp> - using __size_type = typename _Tp::size_type; - template<typename _Tp> using __pocca = typename _Tp::propagate_on_container_copy_assignment; template<typename _Tp> using __pocma = typename _Tp::propagate_on_container_move_assignment; @@ -71,9 +72,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _Alloc, typename _Up> - using __alloc_rebind = __detected_or_t_<__replace_first_arg_t, - __allocator_traits_base::__rebind, - _Alloc, _Up>; + using __alloc_rebind + = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type; /** * @brief Uniform interface to all allocator types. @@ -94,15 +94,45 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ using pointer = __detected_or_t<value_type*, __pointer, _Alloc>; + private: + // Select _Func<_Alloc> or pointer_traits<pointer>::rebind<_Tp> + template<template<typename> class _Func, typename _Tp, typename = void> + struct _Ptr + { + using type = typename pointer_traits<pointer>::template rebind<_Tp>; + }; + + template<template<typename> class _Func, typename _Tp> + struct _Ptr<_Func, _Tp, __void_t<_Func<_Alloc>>> + { + using type = _Func<_Alloc>; + }; + + // Select _A2::difference_type or pointer_traits<_Ptr>::difference_type + template<typename _A2, typename _PtrT, typename = void> + struct _Diff + { using type = typename pointer_traits<_PtrT>::difference_type; }; + + template<typename _A2, typename _PtrT> + struct _Diff<_A2, _PtrT, __void_t<typename _A2::difference_type>> + { using type = typename _A2::difference_type; }; + + // Select _A2::size_type or make_unsigned<_DiffT>::type + template<typename _A2, typename _DiffT, typename = void> + struct _Size : make_unsigned<_DiffT> { }; + + template<typename _A2, typename _DiffT> + struct _Size<_A2, _DiffT, __void_t<typename _A2::size_type>> + { using type = typename _A2::size_type; }; + + public: /** * @brief The allocator's const pointer type. * * @c Alloc::const_pointer if that type exists, otherwise * <tt> pointer_traits<pointer>::rebind<const value_type> </tt> */ - using const_pointer - = __detected_or_t<__ptr_rebind<pointer, const value_type>, - __c_pointer, _Alloc>; + using const_pointer = typename _Ptr<__c_pointer, const value_type>::type; /** * @brief The allocator's void pointer type. @@ -110,8 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @c Alloc::void_pointer if that type exists, otherwise * <tt> pointer_traits<pointer>::rebind<void> </tt> */ - using void_pointer - = __detected_or_t<__ptr_rebind<pointer, void>, __v_pointer, _Alloc>; + using void_pointer = typename _Ptr<__v_pointer, void>::type; /** * @brief The allocator's const void pointer type. @@ -119,9 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @c Alloc::const_void_pointer if that type exists, otherwise * <tt> pointer_traits<pointer>::rebind<const void> </tt> */ - using const_void_pointer - = __detected_or_t<__ptr_rebind<pointer, const void>, __cv_pointer, - _Alloc>; + using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type; /** * @brief The allocator's difference type @@ -129,9 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @c Alloc::difference_type if that type exists, otherwise * <tt> pointer_traits<pointer>::difference_type </tt> */ - using difference_type - = __detected_or_t<typename pointer_traits<pointer>::difference_type, - __diff_type, _Alloc>; + using difference_type = typename _Diff<_Alloc, pointer>::type; /** * @brief The allocator's size type @@ -139,9 +164,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @c Alloc::size_type if that type exists, otherwise * <tt> make_unsigned<difference_type>::type </tt> */ - using size_type - = __detected_or_t<typename make_unsigned<difference_type>::type, - __size_type, _Alloc>; + using size_type = typename _Size<_Alloc, difference_type>::type; /** * @brief How the allocator is propagated on copy assignment @@ -184,9 +207,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; - static_assert(!is_same<rebind_alloc<value_type>, __undefined>::value, - "allocator defines rebind or is like Alloc<T, Args>"); - private: template<typename _Alloc2> static auto diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index f8f3f88cc56..0352bf49fdc 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -570,10 +570,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 if (!_Alloc_traits::_S_always_equal() && !_M_is_local() && _M_get_allocator() != __str._M_get_allocator()) { - // replacement allocator cannot free existing storage - _M_destroy(_M_allocated_capacity); - _M_data(_M_local_data()); - _M_set_length(0); + // Propagating allocator cannot free existing storage so must + // deallocate it before replacing current allocator. + if (__str.size() <= _S_local_capacity) + { + _M_destroy(_M_allocated_capacity); + _M_data(_M_local_data()); + _M_set_length(0); + } + else + { + const auto __len = __str.size(); + auto __alloc = __str._M_get_allocator(); + // If this allocation throws there are no effects: + auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1); + _M_destroy(_M_allocated_capacity); + _M_data(__ptr); + _M_capacity(__len); + _M_set_length(__len); + } } std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator()); } diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h index 04b4ab3b1d3..16ed623ccc7 100644 --- a/libstdc++-v3/include/bits/locale_classes.h +++ b/libstdc++-v3/include/bits/locale_classes.h @@ -461,10 +461,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } - class __shim; - const facet* _M_sso_shim(const id*) const; const facet* _M_cow_shim(const id*) const; + + protected: + class __shim; // For internal use only. }; diff --git a/libstdc++-v3/include/bits/predefined_ops.h b/libstdc++-v3/include/bits/predefined_ops.h index d254795c1a5..7f4bfe65f31 100644 --- a/libstdc++-v3/include/bits/predefined_ops.h +++ b/libstdc++-v3/include/bits/predefined_ops.h @@ -24,7 +24,7 @@ /** @file predefined_ops.h * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. + * You should not attempt to use it directly. @headername{algorithm} */ #ifndef _GLIBCXX_PREDEFINED_OPS_H @@ -207,17 +207,17 @@ namespace __ops template<typename _Iterator1> struct _Iter_equals_iter { - typename std::iterator_traits<_Iterator1>::reference _M_ref; + _Iterator1 _M_it1; explicit _Iter_equals_iter(_Iterator1 __it1) - : _M_ref(*__it1) + : _M_it1(__it1) { } template<typename _Iterator2> bool operator()(_Iterator2 __it2) - { return *__it2 == _M_ref; } + { return *__it2 == *_M_it1; } }; template<typename _Iterator> @@ -271,16 +271,16 @@ namespace __ops struct _Iter_comp_to_iter { _Compare _M_comp; - typename std::iterator_traits<_Iterator1>::reference _M_ref; + _Iterator1 _M_it1; _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) - : _M_comp(__comp), _M_ref(*__it1) + : _M_comp(__comp), _M_it1(__it1) { } template<typename _Iterator2> bool operator()(_Iterator2 __it2) - { return bool(_M_comp(*__it2, _M_ref)); } + { return bool(_M_comp(*__it2, *_M_it1)); } }; template<typename _Compare, typename _Iterator> diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h index 023f21efc77..98cc9c59e89 100644 --- a/libstdc++-v3/include/bits/ptr_traits.h +++ b/libstdc++-v3/include/bits/ptr_traits.h @@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Given Template<T, ...> and U return Template<U, ...>, otherwise invalid. template<typename _Tp, typename _Up> struct __replace_first_arg - { using type = __undefined; }; + { }; template<template<typename, typename...> class _Template, typename _Up, typename _Tp, typename... _Types> @@ -84,8 +84,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> using __difference_type = typename _Tp::difference_type; + template<typename _Tp, typename _Up, typename = void> + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + template<typename _Tp, typename _Up> - using __rebind = typename _Tp::template rebind<_Up>; + struct __rebind<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>>> + { using type = typename _Tp::template rebind<_Up>; }; public: /// The pointer type. @@ -93,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// The type pointed to. using element_type - = __detected_or_t_<__get_first_arg_t, __element_type, _Ptr>; + = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>; /// The type used to represent the difference between two pointers. using difference_type @@ -101,8 +105,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// A pointer to a different type. template<typename _Up> - using rebind - = __detected_or_t_<__replace_first_arg_t, __rebind, _Ptr, _Up>; + using rebind = typename __rebind<_Ptr, _Up>::type; static _Ptr pointer_to(__make_not_void<element_type>& __e) @@ -110,8 +113,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(!is_same<element_type, __undefined>::value, "pointer type defines element_type or is like SomePointer<T, Args>"); - static_assert(!is_same<rebind<element_type>, __undefined>::value, - "pointer type defines rebind<U> or is like SomePointer<T, Args>"); }; /** diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index f2934838098..48c591ce7cf 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -1129,7 +1129,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) - { return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; } + { return _M_t._M_count_tr(__x); } #endif //@} @@ -1153,8 +1153,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -1178,8 +1178,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) const - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -1198,8 +1198,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -1218,8 +1218,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) const - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -1247,8 +1247,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } #endif //@} @@ -1276,8 +1276,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) const - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<const_iterator, const_iterator>( + _M_t._M_equal_range_tr(__x))) + { + return pair<const_iterator, const_iterator>( + _M_t._M_equal_range_tr(__x)); + } #endif //@} diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index d48935e56d3..eb6b24bcbc1 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -822,8 +822,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -847,8 +847,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) const - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -867,8 +867,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -887,8 +887,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) const - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -914,8 +914,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } #endif //@} @@ -941,8 +941,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) const - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<const_iterator, const_iterator>( + _M_t._M_equal_range_tr(__x))) + { + return pair<const_iterator, const_iterator>( + _M_t._M_equal_range_tr(__x)); + } #endif //@} diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 03a3e7dc861..b45e0be962b 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -716,14 +716,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } template<typename _Kt> auto lower_bound(const _Kt& __x) const - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -746,14 +746,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } template<typename _Kt> auto upper_bound(const _Kt& __x) const - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -785,14 +785,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } template<typename _Kt> auto equal_range(const _Kt& __x) const - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } #endif //@} diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index d8cdcc5b292..2b5a787e26b 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -670,7 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER auto count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) - { return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; } + { return _M_t._M_count_tr(__x); } #endif //@} @@ -735,14 +735,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto lower_bound(const _Kt& __x) - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } template<typename _Kt> auto lower_bound(const _Kt& __x) const - -> decltype(_M_t._M_lower_bound_tr(__x)) - { return _M_t._M_lower_bound_tr(__x); } + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } #endif //@} @@ -765,14 +765,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto upper_bound(const _Kt& __x) - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } template<typename _Kt> auto upper_bound(const _Kt& __x) const - -> decltype(_M_t._M_upper_bound_tr(__x)) - { return _M_t._M_upper_bound_tr(__x); } + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } #endif //@} @@ -804,14 +804,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Kt> auto equal_range(const _Kt& __x) - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } template<typename _Kt> auto equal_range(const _Kt& __x) const - -> decltype(_M_t._M_equal_range_tr(__x)) - { return _M_t._M_equal_range_tr(__x); } + -> decltype(pair<iterator, iterator>(_M_t._M_equal_range_tr(__x))) + { return pair<iterator, iterator>(_M_t._M_equal_range_tr(__x)); } #endif //@} diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 5e091a45dda..1695f103b5c 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -425,7 +425,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> void* __any_caster(const any* __any) { - if (__any->_M_manager != &any::_Manager<decay_t<_Tp>>::_S_manage) + struct _None { }; + using _Up = decay_t<_Tp>; + using _Vp = conditional_t<is_copy_constructible<_Up>::value, _Up, _None>; + if (__any->_M_manager != &any::_Manager<_Vp>::_S_manage) return nullptr; any::_Arg __arg; __any->_M_manager(any::_Op_access, __any, &__arg); diff --git a/libstdc++-v3/include/experimental/array b/libstdc++-v3/include/experimental/array index 31a066b3ce8..c01f0f96ab5 100644 --- a/libstdc++-v3/include/experimental/array +++ b/libstdc++-v3/include/experimental/array @@ -69,9 +69,9 @@ template <typename _Up> template <typename _Dest = void, typename... _Types> constexpr auto make_array(_Types&&... __t) - -> array<conditional_t<is_void_v<_Dest>, - common_type_t<_Types...>, - _Dest>, + -> array<typename conditional_t<is_void_v<_Dest>, + common_type<_Types...>, + common_type<_Dest>>::type, sizeof...(_Types)> { static_assert(__or_< @@ -80,13 +80,12 @@ template <typename _Dest = void, typename... _Types> ::value, "make_array cannot be used without an explicit target type " "if any of the types given is a reference_wrapper"); - return {{forward<_Types>(__t)...}}; + return {{ std::forward<_Types>(__t)... }}; } template <typename _Tp, size_t _Nm, size_t... _Idx> constexpr array<remove_cv_t<_Tp>, _Nm> - __to_array(_Tp (&__a)[_Nm], - index_sequence<_Idx...>) + __to_array(_Tp (&__a)[_Nm], index_sequence<_Idx...>) { return {{__a[_Idx]...}}; } @@ -94,6 +93,7 @@ template <typename _Tp, size_t _Nm, size_t... _Idx> template <typename _Tp, size_t _Nm> constexpr array<remove_cv_t<_Tp>, _Nm> to_array(_Tp (&__a)[_Nm]) + noexcept(is_nothrow_constructible<remove_cv_t<_Tp>, _Tp&>::value) { return __to_array(__a, make_index_sequence<_Nm>{}); } diff --git a/libstdc++-v3/include/experimental/memory b/libstdc++-v3/include/experimental/memory index 885d11cb351..8b3b8844a03 100644 --- a/libstdc++-v3/include/experimental/memory +++ b/libstdc++-v3/include/experimental/memory @@ -124,9 +124,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr __pointer release() noexcept { - __pointer tmp = get(); + __pointer __tmp = get(); reset(); - return tmp; + return __tmp; } constexpr void diff --git a/libstdc++-v3/include/ext/pointer.h b/libstdc++-v3/include/ext/pointer.h index c3c98a19182..75c8fbeae45 100644 --- a/libstdc++-v3/include/ext/pointer.h +++ b/libstdc++-v3/include/ext/pointer.h @@ -449,9 +449,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _Pointer_adapter operator++(int) { - _Pointer_adapter tmp(*this); + _Pointer_adapter __tmp(*this); _Storage_policy::set(_Storage_policy::get() + 1); - return tmp; + return __tmp; } inline _Pointer_adapter& @@ -464,9 +464,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _Pointer_adapter operator--(int) { - _Pointer_adapter tmp(*this); + _Pointer_adapter __tmp(*this); _Storage_policy::set(_Storage_policy::get() - 1); - return tmp; + return __tmp; } }; // class _Pointer_adapter diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index bdc1f25e542..a218a4dcc2d 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -230,35 +230,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp load(memory_order __m = memory_order_seq_cst) const noexcept - { - _Tp tmp; - __atomic_load(&_M_i, &tmp, __m); - return tmp; + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(&_M_i, __ptr, __m); + return *__ptr; } _Tp load(memory_order __m = memory_order_seq_cst) const volatile noexcept - { - _Tp tmp; - __atomic_load(&_M_i, &tmp, __m); - return tmp; + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(&_M_i, __ptr, __m); + return *__ptr; } _Tp exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept - { - _Tp tmp; - __atomic_exchange(&_M_i, &__i, &tmp, __m); - return tmp; + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(&_M_i, &__i, __ptr, __m); + return *__ptr; } _Tp exchange(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept - { - _Tp tmp; - __atomic_exchange(&_M_i, &__i, &tmp, __m); - return tmp; + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(&_M_i, &__i, __ptr, __m); + return *__ptr; } bool diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 584b842edcd..15deb90b2ef 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -2576,12 +2576,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; - // _Op<_Args...> if that is a valid type, otherwise _Default<_Args...>. - template<template<typename...> class _Default, - template<typename...> class _Op, typename... _Args> - using __detected_or_t_ = - __detected_or_t<_Default<_Args...>, _Op, _Args...>; - /// @} group metaprogramming /** diff --git a/libstdc++-v3/libsupc++/nested_exception.h b/libstdc++-v3/libsupc++/nested_exception.h index 078af0ea16f..e2314dbd011 100644 --- a/libstdc++-v3/libsupc++/nested_exception.h +++ b/libstdc++-v3/libsupc++/nested_exception.h @@ -115,7 +115,7 @@ namespace std inline void throw_with_nested(_Tp&& __t) { - using _Up = typename remove_reference<_Tp>::type; + using _Up = typename decay<_Tp>::type; using _CopyConstructible = __and_<is_copy_constructible<_Up>, is_move_constructible<_Up>>; static_assert(_CopyConstructible::value, diff --git a/libstdc++-v3/src/c++11/cxx11-shim_facets.cc b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc index bc4b4ba1c32..47bce5445fc 100644 --- a/libstdc++-v3/src/c++11/cxx11-shim_facets.cc +++ b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc @@ -226,8 +226,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace // unnamed { + struct __shim_accessor : facet + { + using facet::__shim; // Redeclare protected member as public. + }; + using __shim = __shim_accessor::__shim; + template<typename _CharT> - struct numpunct_shim : std::numpunct<_CharT>, facet::__shim + struct numpunct_shim : std::numpunct<_CharT>, __shim { typedef typename numpunct<_CharT>::__cache_type __cache_type; @@ -251,7 +257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT> - struct collate_shim : std::collate<_CharT>, facet::__shim + struct collate_shim : std::collate<_CharT>, __shim { typedef basic_string<_CharT> string_type; @@ -276,7 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT> - struct time_get_shim : std::time_get<_CharT>, facet::__shim + struct time_get_shim : std::time_get<_CharT>, __shim { typedef typename std::time_get<_CharT>::iter_type iter_type; typedef typename std::time_get<_CharT>::char_type char_type; @@ -330,7 +336,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT, bool _Intl> - struct moneypunct_shim : std::moneypunct<_CharT, _Intl>, facet::__shim + struct moneypunct_shim : std::moneypunct<_CharT, _Intl>, __shim { typedef typename moneypunct<_CharT, _Intl>::__cache_type __cache_type; @@ -357,7 +363,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT> - struct money_get_shim : std::money_get<_CharT>, facet::__shim + struct money_get_shim : std::money_get<_CharT>, __shim { typedef typename std::money_get<_CharT>::iter_type iter_type; typedef typename std::money_get<_CharT>::char_type char_type; @@ -398,7 +404,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT> - struct money_put_shim : std::money_put<_CharT>, facet::__shim + struct money_put_shim : std::money_put<_CharT>, __shim { typedef typename std::money_put<_CharT>::iter_type iter_type; typedef typename std::money_put<_CharT>::char_type char_type; @@ -427,7 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _CharT> - struct messages_shim : std::messages<_CharT>, facet::__shim + struct messages_shim : std::messages<_CharT>, __shim { typedef messages_base::catalog catalog; typedef basic_string<_CharT> string_type; diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/79114.cc b/libstdc++-v3/testsuite/18_support/nested_exception/79114.cc new file mode 100644 index 00000000000..8afc72bcbef --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/nested_exception/79114.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2017 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 { target c++11 } } + +#include <exception> + +void +test01() +{ + std::throw_with_nested(""); + std::throw_with_nested(test01); +} diff --git a/libstdc++-v3/testsuite/20_util/allocator_traits/members/pointers.cc b/libstdc++-v3/testsuite/20_util/allocator_traits/members/pointers.cc new file mode 100644 index 00000000000..f25c54ff07e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator_traits/members/pointers.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2017 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 { target c++11 } } + +#include <memory> + +// Non-type template param means pointer_traits::rebind can't be instantiated. +template<typename T, int = 0> + struct Pointer + { + using element_type = T; + Pointer(T* p = nullptr) : ptr(p) { } + T* ptr; + }; + +template<typename T> + struct Alloc + { + using value_type = T; + using pointer = Pointer<T>; + using const_pointer = Pointer<const T>; + using void_pointer = Pointer<void>; + using const_void_pointer = Pointer<const void>; + + pointer allocate(std::size_t n) + { return std::allocator<T>().allocate(n); } + + void allocate(pointer p, std::size_t n) + { return std::allocator<T>().deallocate(p, n); } + }; + +// The nested pointer types in Alloc should be found without attempting to +// instantiate pointer_traits::rebind (which would fail): +std::allocator_traits<Alloc<int>>::pointer p; +std::allocator_traits<Alloc<int>>::const_pointer cp; +std::allocator_traits<Alloc<int>>::void_pointer vp; +std::allocator_traits<Alloc<int>>::const_void_pointer cvp; diff --git a/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc b/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc new file mode 100644 index 00000000000..60a62491143 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc @@ -0,0 +1,81 @@ +// Copyright (C) 2017 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 { target c++11 } } + +#include <memory> + +using std::is_same; + +template<typename T, typename U> + using Rebind = typename std::allocator_traits<T>::template rebind_alloc<U>; + +template<typename T> + struct HasRebind { + using value_type = T; + template<typename U> struct rebind { using other = std::allocator<U>; }; + }; + +static_assert(is_same<Rebind<HasRebind<int>, long>, + std::allocator<long>>::value, + "nested alias template is used"); + +template<typename T> + struct NoRebind0 { + using value_type = T; + }; + +static_assert(is_same<Rebind<NoRebind0<int>, long>, + NoRebind0<long>>::value, + "first template argument is replaced"); + +template<typename T, typename> + struct NoRebind1 { + using value_type = T; + }; + +static_assert(is_same<Rebind<NoRebind1<int, void>, long>, + NoRebind1<long, void>>::value, + "first template argument is replaced"); + +template<typename T, typename, typename> + struct NoRebind2 { + using value_type = T; + }; + +static_assert(is_same<Rebind<NoRebind2<int, void, void>, long>, + NoRebind2<long, void, void>>::value, + "first template argument is replaced"); + +template<typename T, typename...> + struct NoRebindN { + using value_type = T; + }; + +static_assert(is_same<Rebind<NoRebindN<int>, long>, + NoRebindN<long>>::value, + "first template argument is replaced"); +static_assert(is_same<Rebind<NoRebindN<int, void>, long>, + NoRebindN<long, void>>::value, + "first template argument is replaced"); + +template<typename T, int = 0> + struct CannotRebind { + using value_type = T; + }; +// PR libstdc++/72792 specialization of allocator_traits is still well-formed: +std::allocator_traits<CannotRebind<int>>::value_type v; diff --git a/libstdc++-v3/testsuite/20_util/pointer_traits/rebind.cc b/libstdc++-v3/testsuite/20_util/pointer_traits/rebind.cc new file mode 100644 index 00000000000..a62815988ed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pointer_traits/rebind.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2017 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 { target c++11 } } + +#include <memory> + +using std::is_same; + +template<typename T, typename U> + using Rebind = typename std::pointer_traits<T>::template rebind<U>; + +template<typename T> + struct HasRebind { + template<typename U> using rebind = U*; + }; + +static_assert(is_same<Rebind<HasRebind<int>, long>, + long*>::value, + "nested alias template is used"); + +template<typename T> struct NoRebind0 { }; + +static_assert(is_same<Rebind<NoRebind0<int>, long>, + NoRebind0<long>>::value, + "first template argument is replaced"); + +template<typename T, typename> struct NoRebind1 { }; + +static_assert(is_same<Rebind<NoRebind1<int, void>, long>, + NoRebind1<long, void>>::value, + "first template argument is replaced"); + +template<typename T, typename, typename> struct NoRebind2 { }; + +static_assert(is_same<Rebind<NoRebind2<int, void, void>, long>, + NoRebind2<long, void, void>>::value, + "first template argument is replaced"); + +template<typename T, typename...> struct NoRebindN { }; + +static_assert(is_same<Rebind<NoRebindN<int>, long>, + NoRebindN<long>>::value, + "first template argument is replaced"); +static_assert(is_same<Rebind<NoRebindN<int, void>, long>, + NoRebindN<long, void>>::value, + "first template argument is replaced"); + +template<typename T, int = 0> + struct CannotRebind { + using element_type = T; + }; +// PR libstdc++/72793 specialization of pointer_traits is still well-formed: +std::pointer_traits<CannotRebind<int>>::element_type e; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc index 3c8e440120e..645e3cb7bfe 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// Copyright (C) 2015-2017 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 @@ -20,6 +20,7 @@ #include <string> #include <testsuite_hooks.h> #include <testsuite_allocator.h> +#include <ext/throw_allocator.h> #if _GLIBCXX_USE_CXX11_ABI using C = char; @@ -100,10 +101,44 @@ void test02() VERIFY(1 == v5.get_allocator().get_personality()); } +void test03() +{ + // PR libstdc++/79254 + using throw_alloc = __gnu_cxx::throw_allocator_limit<C>; + typedef propagating_allocator<C, true, throw_alloc> alloc_type; + typedef std::basic_string<C, traits, alloc_type> test_type; + alloc_type a1(1), a2(2); + throw_alloc::set_limit(2); // Throw on third allocation (during assignment). + const C* s1 = "a string that is longer than a small string"; + const C* s2 = "another string that is longer than a small string"; + test_type v1(s1, a1); + test_type v2(s2, a2); + bool caught = false; + try { + v1 = v2; + } catch (__gnu_cxx::forced_error&) { + caught = true; + } + VERIFY( caught ); + VERIFY( v1 == s1 ); + VERIFY( v1.get_allocator() == a1 ); + + throw_alloc::set_limit(1); // Allow one more allocation (and no more). + test_type v3(s1, a1); + // No allocation when allocators are equal and capacity is sufficient: + VERIFY( v1.capacity() >= v3.size() ); + v1 = v3; + // No allocation when the contents fit in the small-string buffer: + v2 = "sso"; + v1 = v2; + VERIFY( v1.get_allocator() == a2 ); +} + int main() { test01(); test02(); + test03(); return 0; } #else diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc index 3ac15bbf821..01cdba4eead 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// Copyright (C) 2015-2017 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 @@ -20,6 +20,7 @@ #include <string> #include <testsuite_hooks.h> #include <testsuite_allocator.h> +#include <ext/throw_allocator.h> #if _GLIBCXX_USE_CXX11_ABI using C = wchar_t; @@ -100,10 +101,44 @@ void test02() VERIFY(1 == v5.get_allocator().get_personality()); } +void test03() +{ + // PR libstdc++/79254 + using throw_alloc = __gnu_cxx::throw_allocator_limit<C>; + typedef propagating_allocator<C, true, throw_alloc> alloc_type; + typedef std::basic_string<C, traits, alloc_type> test_type; + alloc_type a1(1), a2(2); + throw_alloc::set_limit(2); // Throw on third allocation (during assignment). + const C* s1 = L"a string that is longer than a small string"; + const C* s2 = L"another string that is longer than a small string"; + test_type v1(s1, a1); + test_type v2(s2, a2); + bool caught = false; + try { + v1 = v2; + } catch (__gnu_cxx::forced_error&) { + caught = true; + } + VERIFY( caught ); + VERIFY( v1 == s1 ); + VERIFY( v1.get_allocator() == a1 ); + + throw_alloc::set_limit(1); // Allow one more allocation (and no more). + test_type v3(s1, a1); + // No allocation when allocators are equal and capacity is sufficient: + VERIFY( v1.capacity() >= v3.size() ); + v1 = v3; + // No allocation when the contents fit in the small-string buffer: + v2 = L"sso"; + v1 = v2; + VERIFY( v1.get_allocator() == a2 ); +} + int main() { test01(); test02(); + test03(); return 0; } #else diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc index ea73d6ee2f5..bfdc36d223c 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operations/2.cc @@ -53,7 +53,7 @@ test01() cit = cx.find(2L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); static_assert(std::is_same<decltype(it), test_type::iterator>::value, "find returns iterator"); @@ -76,7 +76,7 @@ test02() cn = cx.count(2L); VERIFY( cn == 0 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); } void @@ -94,7 +94,12 @@ test03() cit = cx.lower_bound(2L); VERIFY( cit != cx.end() && cit->second == '4' ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "lower_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const lower_bound returns const_iterator"); } void @@ -112,7 +117,12 @@ test04() cit = cx.upper_bound(3L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "upper_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const upper_bound returns const_iterator"); } void @@ -130,9 +140,37 @@ test05() cit = cx.equal_range(2L); VERIFY( cit.first == cit.second && cit.first != cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + using pair = std::pair<test_type::iterator, test_type::iterator>; + static_assert(std::is_same<decltype(it), pair>::value, + "equal_range returns pair<iterator, iterator>"); + using cpair = std::pair<test_type::const_iterator, test_type::const_iterator>; + static_assert(std::is_same<decltype(cit), cpair>::value, + "const equal_range returns pair<const_iterator, const_iterator>"); } +void +test06() +{ + // PR libstdc++/78273 + + struct C { + bool operator()(int l, int r) const { return l < r; } + + struct Partition { }; + + bool operator()(int l, Partition) const { return l < 2; } + bool operator()(Partition, int r) const { return 4 < r; } + + using is_transparent = void; + }; + + std::map<int, int, C> m{ {1,0}, {2,0}, {3,0}, {4, 0}, {5, 0} }; + + auto n = m.count(C::Partition{}); + VERIFY( n == 3 ); +} int main() @@ -142,4 +180,5 @@ main() test03(); test04(); test05(); + test06(); } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc index 11d03a27cca..2e17d34d183 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/operations/2.cc @@ -53,7 +53,7 @@ test01() cit = cx.find(2L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); static_assert(std::is_same<decltype(it), test_type::iterator>::value, "find returns iterator"); @@ -76,7 +76,7 @@ test02() cn = cx.count(2L); VERIFY( cn == 0 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); } void @@ -94,7 +94,12 @@ test03() cit = cx.lower_bound(2L); VERIFY( cit != cx.end() && cit->second == '4' ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "lower_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const lower_bound returns const_iterator"); } void @@ -112,7 +117,12 @@ test04() cit = cx.upper_bound(3L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "upper_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const upper_bound returns const_iterator"); } void @@ -131,7 +141,14 @@ test05() cit = cx.equal_range(2L); VERIFY( cit.first == cit.second && cit.first != cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + using pair = std::pair<test_type::iterator, test_type::iterator>; + static_assert(std::is_same<decltype(it), pair>::value, + "equal_range returns pair<iterator, iterator>"); + using cpair = std::pair<test_type::const_iterator, test_type::const_iterator>; + static_assert(std::is_same<decltype(cit), cpair>::value, + "const equal_range returns pair<const_iterator, const_iterator>"); } diff --git a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc index 974a97ade3a..cedc344a6df 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/operations/2.cc @@ -53,7 +53,7 @@ test01() cit = cx.find(2L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); static_assert(std::is_same<decltype(it), test_type::iterator>::value, "find returns iterator"); @@ -76,7 +76,7 @@ test02() cn = cx.count(2L); VERIFY( cn == 0 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); } void @@ -94,7 +94,12 @@ test03() cit = cx.lower_bound(2L); VERIFY( cit != cx.end() && *cit == 3 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "lower_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const lower_bound returns const_iterator"); } void @@ -112,7 +117,12 @@ test04() cit = cx.upper_bound(5L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "upper_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const upper_bound returns const_iterator"); } void @@ -131,7 +141,14 @@ test05() cit = cx.equal_range(2L); VERIFY( cit.first == cit.second && cit.first != cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + using pair = std::pair<test_type::iterator, test_type::iterator>; + static_assert(std::is_same<decltype(it), pair>::value, + "equal_range returns pair<iterator, iterator>"); + using cpair = std::pair<test_type::const_iterator, test_type::const_iterator>; + static_assert(std::is_same<decltype(cit), cpair>::value, + "const equal_range returns pair<const_iterator, const_iterator>"); } diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc index 36d39a71f89..610f12acfd3 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc @@ -53,7 +53,7 @@ test01() cit = cx.find(2L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); static_assert(std::is_same<decltype(it), test_type::iterator>::value, "find returns iterator"); @@ -76,7 +76,7 @@ test02() cn = cx.count(2L); VERIFY( cn == 0 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); } void @@ -94,7 +94,12 @@ test03() cit = cx.lower_bound(2L); VERIFY( cit != cx.end() && *cit == 3 ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "lower_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const lower_bound returns const_iterator"); } void @@ -112,7 +117,12 @@ test04() cit = cx.upper_bound(5L); VERIFY( cit == cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + static_assert(std::is_same<decltype(it), test_type::iterator>::value, + "upper_bound returns iterator"); + static_assert(std::is_same<decltype(cit), test_type::const_iterator>::value, + "const upper_bound returns const_iterator"); } void @@ -130,7 +140,14 @@ test05() cit = cx.equal_range(2L); VERIFY( cit.first == cit.second && cit.first != cx.end() ); - VERIFY( Cmp::count == 0); + VERIFY( Cmp::count == 0 ); + + using pair = std::pair<test_type::iterator, test_type::iterator>; + static_assert(std::is_same<decltype(it), pair>::value, + "equal_range returns pair<iterator, iterator>"); + using cpair = std::pair<test_type::const_iterator, test_type::const_iterator>; + static_assert(std::is_same<decltype(cit), cpair>::value, + "const equal_range returns pair<const_iterator, const_iterator>"); } void @@ -150,6 +167,28 @@ test06() s.find(i); } +void +test07() +{ + // PR libstdc++/78273 + + struct C { + bool operator()(int l, int r) const { return l < r; } + + struct Partition { }; + + bool operator()(int l, Partition) const { return l < 2; } + bool operator()(Partition, int r) const { return 4 < r; } + + using is_transparent = void; + }; + + std::set<int, C> s{ 1, 2, 3, 4, 5 }; + + auto n = s.count(C::Partition{}); + VERIFY( n == 3 ); +} + int main() { @@ -159,4 +198,5 @@ main() test04(); test05(); test06(); + test07(); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search/78346.cc b/libstdc++-v3/testsuite/25_algorithms/search/78346.cc new file mode 100644 index 00000000000..6f003bdb9e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/78346.cc @@ -0,0 +1,118 @@ +// Copyright (C) 2017 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 run { target c++11 } } + +#include <algorithm> +#include <testsuite_hooks.h> + +bool values[100]; + +unsigned next_id() +{ + static unsigned counter = 0; + VERIFY(counter < 100); + return counter++; +} + +struct value +{ + int val; + const unsigned id; + + value(int i = 0) : val(i), id(next_id()) { values[id] = true; } + value(const value& v) : val(v.val), id(next_id()) { values[id] = true; } + value& operator=(const value& v) { val = v.val; return *this; } + ~value() { values[id] = false; } +}; + +bool operator<(const value& lhs, const value& rhs) +{ + if (!values[lhs.id]) + throw lhs.id; + if (!values[rhs.id]) + throw rhs.id; + return lhs.val < rhs.val; +} + +bool operator==(const value& lhs, const value& rhs) +{ + if (!values[lhs.id]) + throw lhs.id; + if (!values[rhs.id]) + throw rhs.id; + return lhs.val == rhs.val; +} + +// A forward iterator that fails to meet the requirement that for any +// two dereferenceable forward iterators, a == b implies &*a == &*b +struct stashing_iterator +{ + typedef std::forward_iterator_tag iterator_category; + typedef value value_type; + typedef value_type const* pointer; + typedef value_type const& reference; + typedef std::ptrdiff_t difference_type; + + stashing_iterator() : ptr(), stashed() { } + stashing_iterator(pointer p) : ptr(p), stashed() { stash(); } + stashing_iterator(const stashing_iterator&) = default; + stashing_iterator& operator=(const stashing_iterator&) = default; + + stashing_iterator& operator++() + { + ++ptr; + stash(); + return *this; + } + + stashing_iterator operator++(int) + { + stashing_iterator i = *this; + ++*this; + return i; + } + + reference operator*() const { return stashed; } + pointer operator->() const { return &**this; } + + bool operator==(const stashing_iterator& i) const { return ptr == i.ptr; } + bool operator!=(const stashing_iterator& i) const { return !(*this == i); } + +private: + void stash() + { + if (ptr) + stashed = *ptr; + } + + pointer ptr; + value_type stashed; +}; + +void +test01() +{ + value s[] = { 0, 1, 2, 3, 4, 5 }; + std::search(s, s+6, stashing_iterator(s), stashing_iterator(s+4)); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/69301.cc b/libstdc++-v3/testsuite/29_atomics/atomic/69301.cc new file mode 100644 index 00000000000..29d19d57d70 --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic/69301.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2017 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 run { target c++11 } } +// { dg-require-atomic-builtins "" } + +#include <atomic> +#include <testsuite_hooks.h> + +struct NonDefaultConstructible +{ + NonDefaultConstructible(int i) : val(i) { } + int val; +}; + +template class std::atomic<NonDefaultConstructible>; + +void +test01() +{ + std::atomic<NonDefaultConstructible> a(1); + const auto n1 = a.exchange(2); + VERIFY( n1.val == 1 ); + const auto n2 = a.load(); + VERIFY( n2.val == 2 ); +} + +void +test02() +{ + volatile std::atomic<NonDefaultConstructible> a(1); + const auto n1 = a.exchange(2); + VERIFY( n1.val == 1 ); + const auto n2 = a.load(); + VERIFY( n2.val == 2 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc b/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc index bb0f754f549..5d8e7fbfc95 100644 --- a/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc +++ b/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc @@ -106,9 +106,22 @@ void test03() MoveDeleted&& md3 = any_cast<MoveDeleted&&>(any(std::move(md))); } +void test04() +{ + // PR libstdc++/69321 + struct noncopyable { + noncopyable(noncopyable const&) = delete; + }; + + any a; + auto p = any_cast<noncopyable>(&a); + VERIFY( p == nullptr ); +} + int main() { test01(); test02(); test03(); + test04(); } diff --git a/libstdc++-v3/testsuite/experimental/array/make_array.cc b/libstdc++-v3/testsuite/experimental/array/make_array.cc index 0ae188b0f8b..75f5333639c 100644 --- a/libstdc++-v3/testsuite/experimental/array/make_array.cc +++ b/libstdc++-v3/testsuite/experimental/array/make_array.cc @@ -1,7 +1,6 @@ -// { dg-options "-std=gnu++14" } -// { dg-do compile } +// { dg-do compile { target c++14 } } -// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// Copyright (C) 2015-2017 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 @@ -19,6 +18,7 @@ // <http://www.gnu.org/licenses/>. #include <experimental/array> +#include <functional> // for std::ref and std::reference_wrapper struct MoveOnly { @@ -27,7 +27,7 @@ struct MoveOnly MoveOnly& operator=(MoveOnly&&) = default; }; -int main() +void test01() { char x[42]; std::array<char, 42> y = std::experimental::to_array(x); @@ -45,3 +45,13 @@ int main() = std::experimental::make_array(1,2L, 3); constexpr std::array<MoveOnly, 1> zzz2 = std::experimental::make_array(MoveOnly{}); } + +void test02() +{ + // PR libstdc++/79195 + struct A {}; + struct B : A {}; + struct C : A {}; + auto arr = std::experimental::make_array<A>(B{}, C{}); + static_assert(std::is_same<decltype(arr), std::array<A, 2>>::value, ""); +} diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h index 4884600bcb8..f597a3846ab 100644 --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h @@ -287,7 +287,7 @@ namespace __gnu_test Alloc& base() { return *this; } const Alloc& base() const { return *this; } - void swap_base(Alloc& b) { swap(b, this->base()); } + void swap_base(Alloc& b) { using std::swap; swap(b, this->base()); } public: typedef typename check_consistent_alloc_value_type<Tp, Alloc>::value_type |