diff options
author | Joey Ye <joey.ye@arm.com> | 2019-10-25 08:50:08 +0000 |
---|---|---|
committer | Joey Ye <joey.ye@arm.com> | 2019-10-25 08:50:08 +0000 |
commit | ba3b46f8b8bd573be85661d2c51c494611a49114 (patch) | |
tree | 3f3cb93cc306405a492c1ce8f5cb1adca5173e89 | |
parent | 06b962b09cc4dadfb62a02be9fedd44f5052e5d6 (diff) | |
parent | 384826fb0df1448f1e413a8bfc77dfce48dafe7b (diff) |
merge with gcc-9-branch@277432ARM/arm-9-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ARM/arm-9-branch@277439 138bc75d-0d04-0410-961f-82ee72b054a4
185 files changed, 4909 insertions, 941 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f840f0180e9..e98c5994b38 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,301 @@ +2019-10-24 Mihail Ionescu <mihail.ionescu@arm.com> + + Backport from mainline + 2019-10-18 Andre Vieira <andre.simoesdiasvieira@arm.com> + + * config/arm/t-multilib: Add new multilib variants and new + mappings. + +2019-10-24 Iain Sandoe <iain@sandoe.co.uk> + + * config/rs6000/darwin.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Guard + against out of range max skip or log values. + +2019-10-23 Peter Bergner <bergner@linux.ibm.com> + + Backport from mainline + 2019-10-08 Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> + + * config.gcc: Move -L usage from LINK_OS_EXTRA_SPEC32 and + LINK_OS_EXTRA_SPEC64 to MD_STARTFILE_PREFIX and + MD_STARTFILE_PREFIX_1 when using --with-advance-toolchain. + +2019-10-23 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-09-26 Martin Liska <mliska@suse.cz> + + PR tree-optimization/91885 + * tree-vectorizer.c (try_vectorize_loop_1): + Add TODO_update_ssa_only_virtuals similarly to what slp + pass does. + +2019-10-23 Eric Botcazou <ebotcazou@adacore.com> + + PR tree-optimization/92131 + * tree-vrp.c (extract_range_from_plus_minus_expr): If the resulting + range would be symbolic, drop to varying for any explicit overflow + in the constant part or if neither range is a singleton. + +2019-10-23 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-17 Richard Biener <rguenther@suse.de> + + PR debug/91887 + * dwarf2out.c (gen_formal_parameter_die): Also try to match + context_die against a DW_TAG_GNU_formal_parameter_pack parent. + +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-10-17 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/92056 + * tree-object-size.c (cond_expr_object_size): Return early if then_ + processing resulted in unknown size. + + 2019-10-05 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91734 + * generic-match-head.c: Include fold-const-call.h. + * match.pd (sqrt(x) cmp c): Check the boundary value and + in case inexact computation of c*c affects comparison of the boundary, + turn LT_EXPR into LE_EXPR, GE_EXPR into GT_EXPR, LE_EXPR into LT_EXPR + or GT_EXPR into GE_EXPR. Punt for sqrt comparisons against NaN and + for -frounding-math. For c2, try the next smaller or larger floating + point constant depending on comparison code and if it has the same + sqrt as c2, use it instead of c2. + + 2019-09-29 Jakub Jelinek <jakub@redhat.com> + + PR bootstrap/90543 + * optc-save-gen.awk: Fix up printing string option differences. + + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91920 + * gimplify.c (omp_default_clause): Predetermine DECL_IN_CONSTANT_POOL + variables as shared. + + 2019-09-11 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91723 + * tree-vect-stmts.c (vectorizable_call): Use types_compatible_p check + instead of pointer equality when checking if argument vectypes are + the same. + + 2019-09-07 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91665 + * tree-vect-loop.c (vectorizable_reduction): Punt if base has type + incompatible with the type of PHI result. + + 2019-09-06 Jakub Jelinek <jakub@redhat.com> + + * function.c (assign_parm_find_data_types): Use RECORD_OR_UNION_TYPE_P + before testing TYPE_TRANSPARENT_AGGR. + * calls.c (initialize_argument_information, load_register_parameters): + Likewise. + + 2019-09-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91001 + PR middle-end/91105 + PR middle-end/91106 + * calls.c (load_register_parameters): For TYPE_TRANSPARENT_AGGR + types, use type of their first field instead of type of + args[i].tree_value. + + 2019-09-02 Jakub Jelinek <jakub@redhat.com> + + PR go/91617 + * fold-const.c (range_check_type): For enumeral and boolean + type, pass 1 to type_for_size langhook instead of + TYPE_UNSIGNED (etype). Return unsigned_type_for result whenever + etype isn't TYPE_UNSIGNED INTEGER_TYPE. + (build_range_check): Don't call unsigned_type_for for pointer types. + * match.pd (X / C1 op C2): Don't call unsigned_type_for on + range_check_type result. + + 2019-09-01 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91623 + * optabs.c (expand_vec_cond_expr): If op0 is a VECTOR_CST and only + EQ_EXPR/NE_EXPR is supported, verify that op0 only contains + zeros or negative elements and use NE_EXPR instead of LT_EXPR against + zero vector. + + PR lto/91572 + * tree.c (find_decls_types_in_node): Also walk TREE_PURPOSE of + GIMPLE_ASM TREE_LIST operands. + + 2019-08-29 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91351 + * tree-cfg.c (generate_range_test): Use range_check_type instead of + unsigned_type_for. + * tree-cfgcleanup.c (convert_single_case_switch): Punt if + range_check_type returns NULL. + * tree-switch-conversion.c (switch_conversion::build_one_array): + Use range_check_type instead of unsigned_type_for, don't perform + linear opt if it returns NULL. + (bit_test_cluster::find_bit_tests): Formatting fix. + (bit_test_cluster::emit): Use range_check_type instead of + unsigned_type_for. + (switch_decision_tree::try_switch_expansion): Punt if range_check_type + returns NULL. + +2019-10-18 Georg-Johann Lay <avr@gjlay.de> + + Backport from 2019-10-18 trunk r277143. + + PR target/86040 + * config/avr/avr.c (avr_out_lpm): Do not shortcut-return. + +2019-10-18 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline + 2019-10-05 Iain Sandoe <iain@sandoe.co.uk> + + PR target/59888 + * config/darwin.c (darwin_rodata_section): Add relocation flag, + choose const_data section for constants with relocations. + (machopic_select_section): Pass relocation flag to + darwin_rodata_section (). + +2019-10-18 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline + 2019-09-21 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin.c (machopic_legitimize_pic_address): Check + for lra, rather than reload. + +2019-10-17 John David Anglin <danglin@gcc.gnu.org> + + * config/pa/pa.c (pa_output_indirect_call): Fix typos in last change. + +2019-10-17 Richard Earnshaw <rearnsha@arm.com> + + Backport from mainline + 2019-05-03 Richard Earnshaw <rearnsha@arm.com> + + PR target/89400 + * config/arm/arm.md (unaligned_loadsi): Add variant for thumb1. + Restrict 'all' variant to 32-bit configurations. + (unaligned_loadhiu): Likewise. + (unaligned_storehi): Likewise. + (unaligned_storesi): Likewise. + (unaligned_loadhis): Disable when compiling for thumb1. + +2019-10-16 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline + 2019-10-03 Iain Sandoe <iain@sandoe.co.uk> + + PR target/87243 + * config/darwin-driver.c (maybe_get_sysroot_from_sdkroot): New. + (darwin_driver_init): Use the sysroot provided by SDKROOT when that + is available and the user has not set one on the command line. + +2019-10-16 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline + 2019-07-03 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin.h (DRIVER_SELF_SPECS): Remove the linker cases. + (RDYNAMIC): Rename to, DARWIN_RDYNAMIC. + (DARWIN_PIE_SPEC, DARWIN_NOPIE_SPEC): Adjust to remove the Xlinker + clauses. + (LINK_COMMAND_SPEC_A): Add DARWIN_RDYNAMIC, DARWIN_PIE_SPEC and + DARWIN_NOPIE_SPEC. + + Backport from mainline + 2019-06-19 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin.h (DRIVER_SELF_SPECS): Add RDYNAMIC, DARWIN_PIE_SPEC + and DARWIN_NOPIE_SPEC. + (RDYNAMIC): New, modified from DARWIN_EXPORT_DYNAMIC. + (DARWIN_PIE_SPEC): Collate from darwin.h and darwin9.h. + (DARWIN_NOPIE_SPEC): Collate from darwin10.h. + (DARWIN_NOCOMPACT_UNWIND): New from darwin10.h + (DARWIN_EXPORT_DYNAMIC): Delete. + * config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move no_compact_unwind + and pie options processing to darwin.h. + * config/darwin9.h (DARWIN_PIE_SPEC): Move pie processing to darwin.h + +2019-10-16 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-04 Richard Biener <rguenther@suse.de> + + PR lto/91968 + * tree.c (find_decls_types_r): Do not remove LABEL_DECLs from + BLOCK_VARS. + + 2019-09-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91812 + * tree-ssa-phiprop.c (propagate_with_phi): Do not replace + volatile loads. + + 2019-09-17 Richard Biener <rguenther@suse.de> + + PR debug/91772 + * dwarf2out.c (dwarf2out_late_global_decl): If early dwarf + was missing generate locations only once. + + 2019-09-17 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91790 + * tree-vect-stmts.c (vectorizable_load): For BB vectorization + use the correct DR for setting up realignment. + +2019-10-14 Will Schmidt <will_schmidt@vnet.ibm.com> + + Backport from trunk + 2019-09-26 Will Schmidt <will_schmidt@vnet.ibm.com> + + * config/rs6000/rs6000-builtin.def: (LVSL, LVSR, LVEBX, LVEHX, + LVEWX, LVXL, LVXL_V2DF, LVXL_V2DI, LVXL_V4SF, LVXL_V4SI, LVXL_V8HI, + LVXL_V16QI, LVX, LVX_V1TI, LVX_V2DF, LVX_V2DI, LVX_V4SF, LVX_V4SI, + LVX_V8HI, LVX_V16QI, LVLX, LVLXL, LVRX, LVRXL, LXSDX, LXVD2X_V1TI, + LXVD2X_V2DF, LXVD2X_V2DI, LXVDSX, LXVW4X_V4SF, LXVW4X_V4SI, + LXVW4X_V8HI, LXVW4X_V16QI, LD_ELEMREV_V1TI, LD_ELEMREV_V2DF, + LD_ELEMREV_V2DI, LD_ELEMREV_V4SF, LD_ELEMREV_V4SI, LD_ELEMREV_V8HI, + LD_ELEMREV_V16QI): Use the PURE attribute. + +2019-10-10 Uroš Bizjak <ubizjak@gmail.com> + + PR target/92022 + * config/alpha/alpha.c (alpha_handle_trap_shadows): Skip DEBUG_INSN. + +2019-10-10 Oleg Endo <olegendo@gcc.gnu.org> + + Backport from mainline + 2019-10-10 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/88630 + * config/sh/sh.h (TARGET_FPU_SH4_300): New macro. + * config/sh/sh.c (sh_option_override): Enable fsca and fsrra insns + also for TARGET_FPU_SH4_300. + (sh_emit_mode_set): Check for TARGET_FPU_SH4_300 instead of + TARGET_SH4_300. + * config/sh/sh.md (toggle_pr): Add TARGET_FPU_SH4_300 condition. + (negsf2): Expand to either negsf2_fpscr or negsf2_no_fpscr. + (*negsf2_i): Split into ... + (negsf2_fpscr, negsf2_no_fpscr): ... these new patterns. + (abssf2): Expand to either abssf2_fpsc or abssf2_no_fpsc. + (**abssf2_i): Split into ... + (abssf2_fpscr, abssf2_no_fpscr): ... these new patterns. + (negdf2): Expand to either negdf2_fpscr or negdf2_no_fpscr. + (*negdf2_i): Split into ... + (negdf2_fpscr, negdf2_no_fpscr): ... these new patterns. + (absdf2): Expand to either absdf2_fpscr or absdf2_no_fpsc. + (**abssf2_i): Split into ... + (absdf2_fpscr, absdf2_no_fpscr): ... these new patterns. + 2019-10-10 Andreas Krebbel <krebbel@linux.ibm.com> Backport from mainline diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index caa1d99aa14..d8fb690d87b 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20191010 +20191025 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c897fe2813a..64ff4397fd4 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,23 @@ +2019-10-12 Eric Botcazou <ebotcazou@adacore.com> + + PR ada/91995 + * sem_ch8.adb (Chain_Use_Clause): Remove second argument in calls + to Defining_Entity. + * sem_elab.adb (Find_Unit_Entity): Likewise. Deal with N_Subunit + here in lieu of in Defining_Entity. + * sem_spark.adb (Check_Callable_Body): Likewise. + (Check_Package_Body): Likewise. + * sem_util.ads (Defining_Entity): Remove 2nd and 3th parameters. + * sem_util.adb (Defining_Entity): Remove 2nd and 3th parameters, + and adjust accordingly. Deal with N_Compilation_Unit. + +2019-10-11 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/decl.c (annotate_value) <INTEGER_CST>: Really test the + sign of the value when deciding to build a NEGATE_EXPR. + <PLUS_EXPR>: Remove redundant line. + <BIT_AND_EXPR>: Do the negation here. + 2019-09-23 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 4e73df0d7f0..a724ba693fd 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -8255,9 +8255,8 @@ annotate_value (tree gnu_size) { case INTEGER_CST: /* For negative values, build NEGATE_EXPR of the opposite. Such values - can appear for discriminants in expressions for variants. Note that, - sizetype being unsigned, we don't directly use tree_int_cst_sgn. */ - if (tree_int_cst_sign_bit (gnu_size)) + can appear for discriminants in expressions for variants. */ + if (tree_int_cst_sgn (gnu_size) < 0) { tree t = wide_int_to_tree (sizetype, -wi::to_wide (gnu_size)); tcode = Negate_Expr; @@ -8335,9 +8334,8 @@ annotate_value (tree gnu_size) && tree_int_cst_sign_bit (TREE_OPERAND (gnu_size, 1))) { tcode = Minus_Expr; - ops[0] = annotate_value (TREE_OPERAND (gnu_size, 0)); - wide_int op1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); - ops[1] = annotate_value (wide_int_to_tree (sizetype, op1)); + wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); + ops[1] = annotate_value (wide_int_to_tree (sizetype, wop1)); break; } @@ -8378,9 +8376,9 @@ annotate_value (tree gnu_size) Such values can appear in expressions with aligning patterns. */ if (TREE_CODE (TREE_OPERAND (gnu_size, 1)) == INTEGER_CST) { - wide_int op1 = wi::sext (wi::to_wide (TREE_OPERAND (gnu_size, 1)), - TYPE_PRECISION (sizetype)); - ops[1] = annotate_value (wide_int_to_tree (sizetype, op1)); + wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1)); + tree op1 = wide_int_to_tree (sizetype, wop1); + ops[1] = annotate_value (build1 (NEGATE_EXPR, sizetype, op1)); } break; diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index a5e821da1b4..340aa49bd11 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -4256,16 +4256,14 @@ package body Sem_Ch8 is -- Common case for compilation unit - elsif Defining_Entity (N => Parent (N), - Empty_On_Errors => True) = Current_Scope - then + elsif Defining_Entity (Parent (N)) = Current_Scope then null; else -- If declaration appears in some other scope, it must be in some -- parent unit when compiling a child. - Pack := Defining_Entity (Parent (N), Empty_On_Errors => True); + Pack := Defining_Entity (Parent (N)); if not In_Open_Scopes (Pack) then null; diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index b74f88d0461..ee0c49ba40c 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -5544,13 +5544,23 @@ package body Sem_Elab is N_Procedure_Instantiation) and then Nkind (Context) = N_Compilation_Unit then - return - Related_Instance (Defining_Entity (N, Concurrent_Subunit => True)); + return Related_Instance (Defining_Entity (N)); + + -- The unit denotes a concurrent body acting as a subunit. Such bodies + -- are generally rewritten into null statements. The proper entity is + -- that of the "original node". + + elsif Nkind (N) = N_Subunit + and then Nkind (Proper_Body (N)) = N_Null_Statement + and then Nkind_In (Original_Node (Proper_Body (N)), N_Protected_Body, + N_Task_Body) + then + return Defining_Entity (Original_Node (Proper_Body (N))); -- Otherwise the proper entity is the defining entity else - return Defining_Entity (N, Concurrent_Subunit => True); + return Defining_Entity (N); end if; end Find_Unit_Entity; diff --git a/gcc/ada/sem_spark.adb b/gcc/ada/sem_spark.adb index cfa6df81854..439d29fe9dc 100644 --- a/gcc/ada/sem_spark.adb +++ b/gcc/ada/sem_spark.adb @@ -804,7 +804,7 @@ package body Sem_SPARK is if Present (SPARK_Pragma (Defining_Entity (Body_N))) then if Get_SPARK_Mode_From_Annotation - (SPARK_Pragma (Defining_Entity (Body_N, False))) /= Opt.On + (SPARK_Pragma (Defining_Entity (Body_N))) /= Opt.On then return; end if; @@ -1914,7 +1914,7 @@ package body Sem_SPARK is CorSp : Node_Id; begin - if Present (SPARK_Pragma (Defining_Entity (Pack, False))) then + if Present (SPARK_Pragma (Defining_Entity (Pack))) then if Get_SPARK_Mode_From_Annotation (SPARK_Pragma (Defining_Entity (Pack))) /= Opt.On then diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 16c671111e4..eedfaf1376e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -5827,11 +5827,7 @@ package body Sem_Util is -- Defining_Entity -- --------------------- - function Defining_Entity - (N : Node_Id; - Empty_On_Errors : Boolean := False; - Concurrent_Subunit : Boolean := False) return Entity_Id - is + function Defining_Entity (N : Node_Id) return Entity_Id is begin case Nkind (N) is when N_Abstract_Subprogram_Declaration @@ -5882,24 +5878,11 @@ package body Sem_Util is => return Defining_Identifier (N); - when N_Subunit => - declare - Bod : constant Node_Id := Proper_Body (N); - Orig_Bod : constant Node_Id := Original_Node (Bod); - - begin - -- Retrieve the entity of the original protected or task body - -- if requested by the caller. + when N_Compilation_Unit => + return Defining_Entity (Unit (N)); - if Concurrent_Subunit - and then Nkind (Bod) = N_Null_Statement - and then Nkind_In (Orig_Bod, N_Protected_Body, N_Task_Body) - then - return Defining_Entity (Orig_Bod); - else - return Defining_Entity (Bod); - end if; - end; + when N_Subunit => + return Defining_Entity (Proper_Body (N)); when N_Function_Instantiation | N_Function_Specification @@ -5925,14 +5908,10 @@ package body Sem_Util is -- can continue semantic analysis. elsif Nam = Error then - if Empty_On_Errors then - return Empty; - else - Err := Make_Temporary (Sloc (N), 'T'); - Set_Defining_Unit_Name (N, Err); + Err := Make_Temporary (Sloc (N), 'T'); + Set_Defining_Unit_Name (N, Err); - return Err; - end if; + return Err; -- If not an entity, get defining identifier @@ -5947,11 +5926,7 @@ package body Sem_Util is return Entity (Identifier (N)); when others => - if Empty_On_Errors then - return Empty; - else - raise Program_Error; - end if; + raise Program_Error; end case; end Defining_Entity; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 4e4d4ba8826..f098ea44d97 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -543,10 +543,7 @@ package Sem_Util is -- in the case of a descendant of a generic formal type (returns Int'Last -- instead of 0). - function Defining_Entity - (N : Node_Id; - Empty_On_Errors : Boolean := False; - Concurrent_Subunit : Boolean := False) return Entity_Id; + function Defining_Entity (N : Node_Id) return Entity_Id; -- Given a declaration N, returns the associated defining entity. If the -- declaration has a specification, the entity is obtained from the -- specification. If the declaration has a defining unit name, then the @@ -557,22 +554,6 @@ package Sem_Util is -- local entities declared during loop expansion. These entities need -- debugging information, generated through Qualify_Entity_Names, and -- the loop declaration must be placed in the table Name_Qualify_Units. - -- - -- Set flag Empty_On_Error to change the behavior of this routine as - -- follows: - -- - -- * True - A declaration that lacks a defining entity returns Empty. - -- A node that does not allow for a defining entity returns Empty. - -- - -- * False - A declaration that lacks a defining entity is given a new - -- internally generated entity which is subsequently returned. A node - -- that does not allow for a defining entity raises Program_Error. - -- - -- The former semantics is appropriate for the back end; the latter - -- semantics is appropriate for the front end. - -- - -- Set flag Concurrent_Subunit to handle rewritings of concurrent bodies - -- which act as subunits. Such bodies are generally rewritten as null. function Denotes_Discriminant (N : Node_Id; diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7f786dfdfcd..6e9ed0bb17e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,20 @@ +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-10-01 Jakub Jelinek <jakub@redhat.com> + + PR c++/91925 + * c-warn.c (check_alignment_of_packed_member): Ignore FIELD_DECLs + with NULL DECL_FIELD_OFFSET. + + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/88203 + * c-common.h (c_omp_predefined_variable): Declare. + * c-omp.c (c_omp_predefined_variable): New function. + (c_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED + for predefined variables. + 2019-09-02 Martin Liska <mliska@suse.cz> Backport from mainline diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 1cf2cae6395..e9ef16aff29 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1184,6 +1184,7 @@ extern void c_omp_split_clauses (location_t, enum tree_code, omp_clause_mask, tree, tree *); extern tree c_omp_declare_simd_clauses_to_numbers (tree, tree); extern void c_omp_declare_simd_clauses_to_decls (tree, tree); +extern bool c_omp_predefined_variable (tree); extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree); /* Return next tree in the chain for chain_next walking of tree nodes. */ diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 1f288a6fbb2..ebe0b4e8155 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2023,6 +2023,25 @@ c_omp_declare_simd_clauses_to_decls (tree fndecl, tree clauses) } } +/* Return true for __func__ and similar function-local predefined + variables (which are in OpenMP predetermined shared, allowed in + shared/firstprivate clauses). */ + +bool +c_omp_predefined_variable (tree decl) +{ + if (VAR_P (decl) + && DECL_ARTIFICIAL (decl) + && TREE_READONLY (decl) + && TREE_STATIC (decl) + && DECL_NAME (decl) + && (DECL_NAME (decl) == ridpointers[RID_C99_FUNCTION_NAME] + || DECL_NAME (decl) == ridpointers[RID_FUNCTION_NAME] + || DECL_NAME (decl) == ridpointers[RID_PRETTY_FUNCTION_NAME])) + return true; + return false; +} + /* True if OpenMP sharing attribute of DECL is predetermined. */ enum omp_clause_default_kind @@ -2036,5 +2055,8 @@ c_omp_predetermined_sharing (tree decl) && INTEGRAL_TYPE_P (TREE_TYPE (decl))) return OMP_CLAUSE_DEFAULT_SHARED; + if (c_omp_predefined_variable (decl)) + return OMP_CLAUSE_DEFAULT_SHARED; + return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 322cf98eb02..67dce9e125a 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -2784,6 +2784,8 @@ check_alignment_of_packed_member (tree type, tree field, bool rvalue) /* Check alignment of the data member. */ if (TREE_CODE (field) == FIELD_DECL && (DECL_PACKED (field) || TYPE_PACKED (TREE_TYPE (field))) + /* Ignore FIELDs not laid out yet. */ + && DECL_FIELD_OFFSET (field) && (!rvalue || TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)) { /* Check the expected alignment against the field alignment. */ diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b98aa517ff2..126a51e5748 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,23 @@ +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/88203 + * c-parser.c (c_parser_predefined_identifier): New function. + (c_parser_postfix_expression): Use it. + (c_parser_omp_variable_list): Parse predefined identifiers. + * c-typeck.c (c_finish_omp_clauses): Allow predefined variables + in shared and firstprivate clauses, even when they are predetermined + shared. + + 2019-08-09 Jakub Jelinek <jakub@redhat.com> + + PR c/91401 + * c-parser.c (c_parser_omp_clause_dist_schedule): Fix up typos in the + check_no_duplicate_clause call. Comment it out, instead emit a + warning for duplicate dist_schedule clauses. + 2019-08-31 Iain Sandoe <iain@sandoe.co.uk> Backport from mainline. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 3b58dc368de..aafe8d1740b 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -8012,6 +8012,41 @@ enum tgmath_parm_kind tgmath_fixed, tgmath_real, tgmath_complex }; +/* Helper function for c_parser_postfix_expression. Parse predefined + identifiers. */ + +static struct c_expr +c_parser_predefined_identifier (c_parser *parser) +{ + location_t loc = c_parser_peek_token (parser)->location; + switch (c_parser_peek_token (parser)->keyword) + { + case RID_FUNCTION_NAME: + pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined " + "identifier", "__FUNCTION__"); + break; + case RID_PRETTY_FUNCTION_NAME: + pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined " + "identifier", "__PRETTY_FUNCTION__"); + break; + case RID_C99_FUNCTION_NAME: + pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support " + "%<__func__%> predefined identifier"); + break; + default: + gcc_unreachable (); + } + + struct c_expr expr; + expr.original_code = ERROR_MARK; + expr.original_type = NULL; + expr.value = fname_decl (loc, c_parser_peek_token (parser)->keyword, + c_parser_peek_token (parser)->value); + set_c_expr_source_range (&expr, loc, loc); + c_parser_consume_token (parser); + return expr; +} + /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2, C11 6.5.1-6.5.2). Compound literals aren't handled here; callers have to call c_parser_postfix_expression_after_paren_type on encountering them. @@ -8232,31 +8267,9 @@ c_parser_postfix_expression (c_parser *parser) switch (c_parser_peek_token (parser)->keyword) { case RID_FUNCTION_NAME: - pedwarn (loc, OPT_Wpedantic, "ISO C does not support " - "%<__FUNCTION__%> predefined identifier"); - expr.value = fname_decl (loc, - c_parser_peek_token (parser)->keyword, - c_parser_peek_token (parser)->value); - set_c_expr_source_range (&expr, loc, loc); - c_parser_consume_token (parser); - break; case RID_PRETTY_FUNCTION_NAME: - pedwarn (loc, OPT_Wpedantic, "ISO C does not support " - "%<__PRETTY_FUNCTION__%> predefined identifier"); - expr.value = fname_decl (loc, - c_parser_peek_token (parser)->keyword, - c_parser_peek_token (parser)->value); - set_c_expr_source_range (&expr, loc, loc); - c_parser_consume_token (parser); - break; case RID_C99_FUNCTION_NAME: - pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support " - "%<__func__%> predefined identifier"); - expr.value = fname_decl (loc, - c_parser_peek_token (parser)->keyword, - c_parser_peek_token (parser)->value); - set_c_expr_source_range (&expr, loc, loc); - c_parser_consume_token (parser); + expr = c_parser_predefined_identifier (parser); break; case RID_VA_ARG: { @@ -11950,15 +11963,9 @@ c_parser_omp_variable_list (c_parser *parser, { auto_vec<c_token> tokens; unsigned int tokens_avail = 0; + bool first = true; - if (kind != OMP_CLAUSE_DEPEND - && (c_parser_next_token_is_not (parser, CPP_NAME) - || c_parser_peek_token (parser)->id_kind != C_ID_ID)) - c_parser_error (parser, "expected identifier"); - - while (kind == OMP_CLAUSE_DEPEND - || (c_parser_next_token_is (parser, CPP_NAME) - && c_parser_peek_token (parser)->id_kind == C_ID_ID)) + while (1) { bool array_section_p = false; if (kind == OMP_CLAUSE_DEPEND) @@ -11979,6 +11986,7 @@ c_parser_omp_variable_list (c_parser *parser, break; c_parser_consume_token (parser); + first = false; continue; } @@ -12029,16 +12037,35 @@ c_parser_omp_variable_list (c_parser *parser, parser->tokens_avail = tokens.length (); } - tree t = lookup_name (c_parser_peek_token (parser)->value); + tree t = NULL_TREE; - if (t == NULL_TREE) + if (c_parser_next_token_is (parser, CPP_NAME) + && c_parser_peek_token (parser)->id_kind == C_ID_ID) { - undeclared_variable (c_parser_peek_token (parser)->location, - c_parser_peek_token (parser)->value); - t = error_mark_node; - } + t = lookup_name (c_parser_peek_token (parser)->value); - c_parser_consume_token (parser); + if (t == NULL_TREE) + { + undeclared_variable (c_parser_peek_token (parser)->location, + c_parser_peek_token (parser)->value); + t = error_mark_node; + } + + c_parser_consume_token (parser); + } + else if (c_parser_next_token_is (parser, CPP_KEYWORD) + && (c_parser_peek_token (parser)->keyword == RID_FUNCTION_NAME + || (c_parser_peek_token (parser)->keyword + == RID_PRETTY_FUNCTION_NAME) + || (c_parser_peek_token (parser)->keyword + == RID_C99_FUNCTION_NAME))) + t = c_parser_predefined_identifier (parser).value; + else + { + if (first) + c_parser_error (parser, "expected identifier"); + break; + } if (t == error_mark_node) ; @@ -12176,6 +12203,7 @@ c_parser_omp_variable_list (c_parser *parser, break; c_parser_consume_token (parser); + first = false; } return list; @@ -14707,7 +14735,10 @@ c_parser_omp_clause_dist_schedule (c_parser *parser, tree list) c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<,%> or %<)%>"); - check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule"); + /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, + "dist_schedule"); */ + if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE)) + warning_at (loc, 0, "too many %qs clauses", "dist_schedule"); if (t == error_mark_node) return list; diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 4a4eb08b73f..be12a0a605e 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -14713,6 +14713,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_DEFAULT_UNSPECIFIED: break; case OMP_CLAUSE_DEFAULT_SHARED: + if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) + && c_omp_predefined_variable (t)) + /* The __func__ variable and similar function-local + predefined variables may be listed in a shared or + firstprivate clause. */ + break; share_name = "shared"; break; case OMP_CLAUSE_DEFAULT_PRIVATE: diff --git a/gcc/calls.c b/gcc/calls.c index c8a42680041..56795995650 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1971,8 +1971,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, /* If TYPE is a transparent union or record, pass things the way we would pass the first field of the union or record. We have already verified that the modes are the same. */ - if ((TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE) - && TYPE_TRANSPARENT_AGGR (type)) + if (RECORD_OR_UNION_TYPE_P (type) && TYPE_TRANSPARENT_AGGR (type)) type = TREE_TYPE (first_field (type)); /* Decide where to pass this arg. @@ -2750,6 +2749,9 @@ load_register_parameters (struct arg_data *args, int num_actuals, poly_int64 size = 0; HOST_WIDE_INT const_size = 0; rtx_insn *before_arg = get_last_insn (); + tree type = TREE_TYPE (args[i].tree_value); + if (RECORD_OR_UNION_TYPE_P (type) && TYPE_TRANSPARENT_AGGR (type)) + type = TREE_TYPE (first_field (type)); /* Set non-negative if we must move a word at a time, even if just one word (e.g, partial == 4 && mode == DFmode). Set to -1 if we just use a normal move insn. This value can be @@ -2762,11 +2764,11 @@ load_register_parameters (struct arg_data *args, int num_actuals, gcc_assert (partial % UNITS_PER_WORD == 0); nregs = partial / UNITS_PER_WORD; } - else if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode) + else if (TYPE_MODE (type) == BLKmode) { /* Variable-sized parameters should be described by a PARALLEL instead. */ - const_size = int_size_in_bytes (TREE_TYPE (args[i].tree_value)); + const_size = int_size_in_bytes (type); gcc_assert (const_size >= 0); nregs = (const_size + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD; size = const_size; @@ -2893,8 +2895,7 @@ load_register_parameters (struct arg_data *args, int num_actuals, if (GET_CODE (reg) == PARALLEL) use_group_regs (call_fusage, reg); else if (nregs == -1) - use_reg_mode (call_fusage, reg, - TYPE_MODE (TREE_TYPE (args[i].tree_value))); + use_reg_mode (call_fusage, reg, TYPE_MODE (type)); else if (nregs > 0) use_regs (call_fusage, REGNO (reg), nregs); } diff --git a/gcc/config.gcc b/gcc/config.gcc index f5027bb289b..b2282ecdf0b 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4700,14 +4700,12 @@ case "${target}" in echo "#undef LINK_OS_EXTRA_SPEC32" echo "#define LINK_OS_EXTRA_SPEC32" \ "\"%(link_os_new_dtags)" \ - "-rpath $prefix/lib -rpath $at/lib" \ - "-L $prefix/lib -L $at/lib\"" + "-rpath $prefix/lib -rpath $at/lib\"" echo echo "#undef LINK_OS_EXTRA_SPEC64" echo "#define LINK_OS_EXTRA_SPEC64" \ "\"%(link_os_new_dtags)" \ - "-rpath $prefix/lib64 -rpath $at/lib64" \ - "-L $prefix/lib64 -L $at/lib64\"" + "-rpath $prefix/lib64 -rpath $at/lib64\"" echo echo "#undef LINK_OS_NEW_DTAGS_SPEC" echo "#define LINK_OS_NEW_DTAGS_SPEC" \ @@ -4720,7 +4718,10 @@ case "${target}" in echo "#define MD_EXEC_PREFIX \"$at/bin/\"" echo echo "#undef MD_STARTFILE_PREFIX" - echo "#define MD_STARTFILE_PREFIX \"$at/lib/\"") \ + echo "#define MD_STARTFILE_PREFIX \"$prefix/lib/\"" + echo + echo "#undef MD_STARTFILE_PREFIX_1" + echo "#define MD_STARTFILE_PREFIX_1 \"$at/lib/\"") \ > advance-toolchain.h else echo "Unknown advance-toolchain $with_advance_toolchain" diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 984540f0b53..524379d3763 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -8839,6 +8839,9 @@ alpha_handle_trap_shadows (void) case CODE_LABEL: goto close_shadow; + case DEBUG_INSN: + break; + default: gcc_unreachable (); } diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 0aecd03891c..ae582172ab9 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -4483,62 +4483,78 @@ ; ARMv6+ unaligned load/store instructions (used for packed structure accesses). (define_insn "unaligned_loadsi" - [(set (match_operand:SI 0 "s_register_operand" "=l,r") - (unspec:SI [(match_operand:SI 1 "memory_operand" "Uw,m")] + [(set (match_operand:SI 0 "s_register_operand" "=l,l,r") + (unspec:SI [(match_operand:SI 1 "memory_operand" "m,Uw,m")] UNSPEC_UNALIGNED_LOAD))] "unaligned_access" - "ldr%?\t%0, %1\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + ldr\t%0, %1\t@ unaligned + ldr%?\t%0, %1\t@ unaligned + ldr%?\t%0, %1\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "load_4")]) +;; The 16-bit Thumb1 variant of ldrsh requires two registers in the +;; address (there's no immediate format). That's tricky to support +;; here and we don't really need this pattern for that case, so only +;; enable for 32-bit ISAs. (define_insn "unaligned_loadhis" [(set (match_operand:SI 0 "s_register_operand" "=r") (sign_extend:SI (unspec:HI [(match_operand:HI 1 "memory_operand" "Uh")] UNSPEC_UNALIGNED_LOAD)))] - "unaligned_access" + "unaligned_access && TARGET_32BIT" "ldrsh%?\t%0, %1\t@ unaligned" [(set_attr "predicable" "yes") (set_attr "type" "load_byte")]) (define_insn "unaligned_loadhiu" - [(set (match_operand:SI 0 "s_register_operand" "=l,r") + [(set (match_operand:SI 0 "s_register_operand" "=l,l,r") (zero_extend:SI - (unspec:HI [(match_operand:HI 1 "memory_operand" "Uw,m")] + (unspec:HI [(match_operand:HI 1 "memory_operand" "m,Uw,m")] UNSPEC_UNALIGNED_LOAD)))] "unaligned_access" - "ldrh%?\t%0, %1\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + ldrh\t%0, %1\t@ unaligned + ldrh%?\t%0, %1\t@ unaligned + ldrh%?\t%0, %1\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "load_byte")]) (define_insn "unaligned_storesi" - [(set (match_operand:SI 0 "memory_operand" "=Uw,m") - (unspec:SI [(match_operand:SI 1 "s_register_operand" "l,r")] + [(set (match_operand:SI 0 "memory_operand" "=m,Uw,m") + (unspec:SI [(match_operand:SI 1 "s_register_operand" "l,l,r")] UNSPEC_UNALIGNED_STORE))] "unaligned_access" - "str%?\t%1, %0\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + str\t%1, %0\t@ unaligned + str%?\t%1, %0\t@ unaligned + str%?\t%1, %0\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "store_4")]) (define_insn "unaligned_storehi" - [(set (match_operand:HI 0 "memory_operand" "=Uw,m") - (unspec:HI [(match_operand:HI 1 "s_register_operand" "l,r")] + [(set (match_operand:HI 0 "memory_operand" "=m,Uw,m") + (unspec:HI [(match_operand:HI 1 "s_register_operand" "l,l,r")] UNSPEC_UNALIGNED_STORE))] "unaligned_access" - "strh%?\t%1, %0\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + strh\t%1, %0\t@ unaligned + strh%?\t%1, %0\t@ unaligned + strh%?\t%1, %0\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "store_4")]) diff --git a/gcc/config/arm/t-multilib b/gcc/config/arm/t-multilib index 08526302283..dc97c8f09fb 100644 --- a/gcc/config/arm/t-multilib +++ b/gcc/config/arm/t-multilib @@ -24,6 +24,8 @@ # values during the configure step. We enforce this during the # top-level configury. +s-mlib: $(srcdir)/config/arm/t-multilib $(srcdir)/config/arm/t-aprofile $(srcdir)/config/arm/t-rmprofile + MULTILIB_OPTIONS = MULTILIB_DIRNAMES = MULTILIB_EXCEPTIONS = @@ -63,6 +65,8 @@ all_early_arch := armv5tej armv6 armv6j armv6k armv6z armv6kz \ v7_a_arch_variants := $(call all_feat_combs, mp sec) v7_a_nosimd_variants := +fp +vfpv3 +vfpv3-d16-fp16 +vfpv3-fp16 +vfpv4-d16 +vfpv4 v7_a_simd_variants := +simd +neon-fp16 +neon-vfpv4 +v7_r_sp_variants := +fp.sp +fp.sp+idiv +vfpv3xd-fp16 +vfpv3xd-fp16+idiv +v7_r_dp_variants := +fp +fp+idiv +vfpv3-d16-fp16 +vfpv3-d16-fp16+idiv v7ve_nosimd_variants := +vfpv3-d16 +vfpv3 +vfpv3-d16-fp16 +vfpv3-fp16 +fp +vfpv4 v7ve_vfpv3_simd_variants := +neon +neon-fp16 v7ve_vfpv4_simd_variants := +simd @@ -86,8 +90,8 @@ SEP := $(and $(HAS_APROFILE),$(HAS_RMPROFILE),/) MULTILIB_OPTIONS += marm/mthumb MULTILIB_DIRNAMES += arm thumb -MULTILIB_OPTIONS += march=armv5te+fp/march=armv7/march=armv7+fp/$(MULTI_ARCH_OPTS_A)$(SEP)$(MULTI_ARCH_OPTS_RM) -MULTILIB_DIRNAMES += v5te v7 v7+fp $(MULTI_ARCH_DIRS_A) $(MULTI_ARCH_DIRS_RM) +MULTILIB_OPTIONS += march=armv5te+fp/march=armv7/march=armv7+fp/march=armv7-r+fp.sp/$(MULTI_ARCH_OPTS_A)$(SEP)$(MULTI_ARCH_OPTS_RM) +MULTILIB_DIRNAMES += v5te v7 v7+fp v7-r+fp.sp $(MULTI_ARCH_DIRS_A) $(MULTI_ARCH_DIRS_RM) MULTILIB_OPTIONS += mfloat-abi=soft/mfloat-abi=softfp/mfloat-abi=hard MULTILIB_DIRNAMES += nofp softfp hard @@ -100,22 +104,31 @@ MULTILIB_REQUIRED += mthumb/march=armv7/mfloat-abi=soft MULTILIB_REQUIRED += mthumb/march=armv7+fp/mfloat-abi=softfp MULTILIB_REQUIRED += mthumb/march=armv7+fp/mfloat-abi=hard -# Map v7-r down onto common v7 code. +MULTILIB_REQUIRED += mthumb/march=armv7-r+fp.sp/mfloat-abi=softfp +MULTILIB_REQUIRED += mthumb/march=armv7-r+fp.sp/mfloat-abi=hard + +# Map v7-r with double precision down onto common v7 code. MULTILIB_MATCHES += march?armv7=march?armv7-r MULTILIB_MATCHES += march?armv7=march?armv7-r+idiv -MULTILIB_MATCHES += march?armv7+fp=march?armv7-r+fp -MULTILIB_MATCHES += march?armv7+fp=march?armv7-r+fp+idiv +MULTILIB_MATCHES += $(foreach ARCH, $(v7_r_dp_variants), \ + march?armv7+fp=march?armv7-r$(ARCH)) + +# Map v7-r single precision variants to v7-r with single precision. +MULTILIB_MATCHES += $(foreach ARCH, \ + $(filter-out +fp.sp, $(v7_r_sp_variants)), \ + march?armv7-r+fp.sp=march?armv7-r$(ARCH)) MULTILIB_MATCHES += $(foreach ARCH, $(all_early_arch), \ march?armv5te+fp=march?$(ARCH)+fp) -# Map v8-r down onto common v7 code. +# Map v8-r down onto common v7 code or v7-r sp. MULTILIB_MATCHES += march?armv7=march?armv8-r MULTILIB_MATCHES += $(foreach ARCH, $(v8_r_nosimd_variants), \ march?armv7=march?armv8-r$(ARCH)) MULTILIB_MATCHES += $(foreach ARCH,+simd +crypto, \ march?armv7+fp=march?armv8-r$(ARCH) \ march?armv7+fp=march?armv8-r+crc$(ARCH)) - +MULTILIB_MATCHES += march?armv7-r+fp.sp=march?armv8-r+fp.sp +MULTILIB_MATCHES += march?armv7-r+fp.sp=march?armv8-r+crc+fp.sp ifeq (,$(HAS_APROFILE)) # Map all v7-a @@ -177,7 +190,7 @@ MULTILIB_MATCHES += $(foreach ARCH, $(v8_5_a_simd_variants), \ MULTILIB_REUSE += mthumb/march.armv7/mfloat-abi.soft=marm/march.armv7/mfloat-abi.soft MULTILIB_REUSE += $(foreach ABI, hard softfp, \ - $(foreach ARCH, armv7+fp, \ + $(foreach ARCH, armv7+fp armv7-r+fp\.sp, \ mthumb/march.$(ARCH)/mfloat-abi.$(ABI)=marm/march.$(ARCH)/mfloat-abi.$(ABI))) # Softfp but no FP, use the soft-float libraries. diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index a9f72b314c2..cb4b14ae379 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -3797,13 +3797,14 @@ avr_out_lpm (rtx_insn *insn, rtx *op, int *plen) gcc_unreachable(); case 1: - return avr_asm_len ("%4lpm %0,%a2", xop, plen, 1); + avr_asm_len ("%4lpm %0,%a2", xop, plen, 1); + break; case 2: if (REGNO (dest) == REG_Z) - return avr_asm_len ("%4lpm %5,%a2+" CR_TAB - "%4lpm %B0,%a2" CR_TAB - "mov %A0,%5", xop, plen, 3); + avr_asm_len ("%4lpm %5,%a2+" CR_TAB + "%4lpm %B0,%a2" CR_TAB + "mov %A0,%5", xop, plen, 3); else { avr_asm_len ("%4lpm %A0,%a2+" CR_TAB @@ -3832,9 +3833,9 @@ avr_out_lpm (rtx_insn *insn, rtx *op, int *plen) "%4lpm %B0,%a2+", xop, plen, 2); if (REGNO (dest) == REG_Z - 2) - return avr_asm_len ("%4lpm %5,%a2+" CR_TAB - "%4lpm %C0,%a2" CR_TAB - "mov %D0,%5", xop, plen, 3); + avr_asm_len ("%4lpm %5,%a2+" CR_TAB + "%4lpm %C0,%a2" CR_TAB + "mov %D0,%5", xop, plen, 3); else { avr_asm_len ("%4lpm %C0,%a2+" CR_TAB diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 3d85f29cb3d..b3577c416bc 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -210,6 +210,28 @@ darwin_default_min_version (void) return new_flag; } +/* See if we can find the sysroot from the SDKROOT environment variable. */ + +static const char * +maybe_get_sysroot_from_sdkroot () +{ + const char *maybe_sysroot = getenv ("SDKROOT"); + + /* We'll use the same rules as the clang driver, for compatibility. + 1) The path must be absolute + 2) Ignore "/", that is the default anyway and we do not want the + sysroot semantics to be applied to it. + 3) It must exist (actually, we'll check it's readable too). */ + + if (maybe_sysroot == NULL + || *maybe_sysroot != '/' + || strlen (maybe_sysroot) == 1 + || access (maybe_sysroot, R_OK) == -1) + return NULL; + + return xstrndup (maybe_sysroot, strlen (maybe_sysroot)); +} + /* Translate -filelist and -framework options in *DECODED_OPTIONS (size *DECODED_OPTIONS_COUNT) to use -Xlinker so that they are considered to be linker inputs in the case that no other inputs are @@ -234,6 +256,7 @@ darwin_driver_init (unsigned int *decoded_options_count, bool appendM64 = false; const char *vers_string = NULL; bool seen_version_min = false; + bool seen_sysroot_p = false; for (i = 1; i < *decoded_options_count; i++) { @@ -314,6 +337,11 @@ darwin_driver_init (unsigned int *decoded_options_count, --*decoded_options_count; break; + case OPT__sysroot_: + case OPT_isysroot: + seen_sysroot_p = true; + break; + default: break; } @@ -375,6 +403,22 @@ darwin_driver_init (unsigned int *decoded_options_count, &(*decoded_options)[*decoded_options_count - 1]); } + if (! seen_sysroot_p) + { + /* We will pick up an SDKROOT if we didn't specify a sysroot and treat + it as overriding any configure-time --with-sysroot. */ + const char *sdkroot = maybe_get_sysroot_from_sdkroot (); + if (sdkroot) + { + ++*decoded_options_count; + *decoded_options = XRESIZEVEC (struct cl_decoded_option, + *decoded_options, + *decoded_options_count); + generate_option (OPT__sysroot_, sdkroot, 1, CL_DRIVER, + &(*decoded_options)[*decoded_options_count - 1]); + } + } + /* We will need to know the OS X version we're trying to build for here so that we can figure out the mechanism and source for the sysroot to be used. */ diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index b9862353843..55759df79c8 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -844,7 +844,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) { if (reg == 0) { - gcc_assert (!reload_in_progress); + gcc_assert (!lra_in_progress); reg = gen_reg_rtx (Pmode); } @@ -928,7 +928,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) emit_use (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM)); #endif - if (reload_in_progress) + if (lra_in_progress) df_set_regs_ever_live (REGNO (pic), true); pic_ref = gen_rtx_PLUS (Pmode, pic, machopic_gen_offset (XEXP (orig, 0))); @@ -952,7 +952,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) if (reg == 0) { - gcc_assert (!reload_in_progress); + gcc_assert (!lra_in_progress); reg = gen_reg_rtx (Pmode); } @@ -998,7 +998,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) #if 0 emit_use (pic_offset_table_rtx); #endif - if (reload_in_progress) + if (lra_in_progress) df_set_regs_ever_live (REGNO (pic), true); pic_ref = gen_rtx_PLUS (Pmode, pic, @@ -1252,12 +1252,13 @@ darwin_mark_decl_preserved (const char *name) } static section * -darwin_rodata_section (int use_coal, bool zsize) +darwin_rodata_section (int use_coal, bool zsize, int reloc) { return (use_coal ? darwin_sections[const_coal_section] : (zsize ? darwin_sections[zobj_const_section] - : darwin_sections[const_section])); + : reloc ? darwin_sections[const_data_section] + : darwin_sections[const_section])); } static section * @@ -1550,7 +1551,7 @@ machopic_select_section (tree decl, case SECCAT_RODATA: case SECCAT_SRODATA: - base_section = darwin_rodata_section (use_coal, zsize); + base_section = darwin_rodata_section (use_coal, zsize, reloc); break; case SECCAT_RODATA_MERGE_STR: diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 0e253cb0dfa..e8fe90728e8 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -126,6 +126,24 @@ extern GTY(()) int darwin_ms_struct; "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} \ %<gsplit-dwarf" +#if LD64_HAS_EXPORT_DYNAMIC +#define DARWIN_RDYNAMIC "%{rdynamic:-export_dynamic}" +#else +#define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}" +#endif + +/* FIXME: we should check that the linker supports the -pie and -no_pie. + options. */ +#define DARWIN_PIE_SPEC \ +"%{pie|fpie|fPIE:\ + %{mdynamic-no-pic: \ + %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \ + :%:version-compare(>= 10.5 mmacosx-version-min= -pie) }} " + +#define DARWIN_NOPIE_SPEC \ +"%{no-pie|fno-pie|fno-PIE: \ + %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) }" + #define DARWIN_CC1_SPEC \ "%{findirect-virtual-calls: -fapple-kext} %<findirect-virtual-calls " \ "%{fterminated-vtables: -fapple-kext} %<fterminated-vtables " \ @@ -156,6 +174,16 @@ extern GTY(()) int darwin_ms_struct; #define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}" \ " %{pthread:-D_REENTRANT}" +/* This is a fix for PR41260 by passing -no_compact_unwind on darwin10 and + later until the assembler, linker and libunwind are able to deal with the + output from GCC. + + FIXME: we should check that the linker supports the option. +*/ + +#define DARWIN_NOCOMPACT_UNWIND \ +" %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) " + /* This is mostly a clone of the standard LINK_COMMAND_SPEC, plus precomp, libtool, and fat build additions. @@ -164,12 +192,6 @@ extern GTY(()) int darwin_ms_struct; specifying the handling of options understood by generic Unix linkers, and for positional arguments like libraries. */ -#if LD64_HAS_EXPORT_DYNAMIC -#define DARWIN_EXPORT_DYNAMIC " %{rdynamic:-export_dynamic}" -#else -#define DARWIN_EXPORT_DYNAMIC " %{rdynamic: %nrdynamic is not supported}" -#endif - #define LINK_COMMAND_SPEC_A \ "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ %(linker)" \ @@ -190,10 +212,14 @@ extern GTY(()) int darwin_ms_struct; %{%:sanitize(address): -lasan } \ %{%:sanitize(undefined): -lubsan } \ %(link_ssp) \ - " DARWIN_EXPORT_DYNAMIC " %<rdynamic \ %(link_gcc_c_sequence) \ }}}\ - %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{F*} }}}}}}}" + %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{F*} "\ + DARWIN_PIE_SPEC \ + DARWIN_NOPIE_SPEC \ + DARWIN_RDYNAMIC \ + DARWIN_NOCOMPACT_UNWIND \ + "}}}}}}} %<pie %<no-pie %<rdynamic " #define DSYMUTIL "\ndsymutil" @@ -230,8 +256,6 @@ extern GTY(()) int darwin_ms_struct; #define STANDARD_STARTFILE_PREFIX_1 "" #define STANDARD_STARTFILE_PREFIX_2 "" -#define DARWIN_PIE_SPEC "%{fpie|pie|fPIE:}" - /* Please keep the random linker options in alphabetical order (modulo 'Z' and 'no' prefixes). Note that options taking arguments may appear multiple times on a command line with different arguments each time, @@ -295,7 +319,6 @@ extern GTY(()) int darwin_ms_struct; %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \ %:version-compare(< 10.5 mmacosx-version-min= suppress)}} \ %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \ - " DARWIN_PIE_SPEC " \ %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \ %{read_only_relocs} \ %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \ diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h index 07a2b465a04..a6d1eba6ebd 100644 --- a/gcc/config/darwin10.h +++ b/gcc/config/darwin10.h @@ -18,17 +18,12 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ -/* Fix PR41260 by passing -no_compact_unwind on darwin10 and later until - unwinder in libSystem is fixed to digest new epilog unwinding notes. +/* Fix PR47558 by linking against libSystem ahead of libgcc_ext. */ - Fix PR47558 by linking against libSystem ahead of libgcc_ext. */ #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ -"%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ - %{!static:%{!static-libgcc: \ +"%{!static:%{!static-libgcc: \ %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ - %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ - %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } \ %{!nostdlib:%:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef.o)} \ %G %{!nolibc:%L}" diff --git a/gcc/config/darwin9.h b/gcc/config/darwin9.h index ca5c51718c8..1fd1604aed8 100644 --- a/gcc/config/darwin9.h +++ b/gcc/config/darwin9.h @@ -35,12 +35,6 @@ along with GCC; see the file COPYING3. If not see /* Tell collect2 to run dsymutil for us as necessary. */ #define COLLECT_RUN_DSYMUTIL 1 -#undef DARWIN_PIE_SPEC -#define DARWIN_PIE_SPEC \ - "%{fpie|pie|fPIE: \ - %{mdynamic-no-pic: %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \ - :-pie}}" - /* Only ask as for debug data if the debug style is stabs (since as doesn't yet generate dwarf.) */ diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 1e85658a0f7..5784fc076f5 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -8052,20 +8052,22 @@ pa_output_call (rtx_insn *insn, rtx call_dest, int sibcall) { output_asm_insn ("addil LT'%0,%%r19", xoperands); output_asm_insn ("ldw RT'%0(%%r1),%%r1", xoperands); - output_asm_insn ("ldw 0(%%r1),%%r1", xoperands); + output_asm_insn ("ldw 0(%%r1),%%r22", xoperands); } else { output_asm_insn ("addil LR'%0-$global$,%%r27", xoperands); - output_asm_insn ("ldw RR'%0-$global$(%%r1),%%r1", + output_asm_insn ("ldw RR'%0-$global$(%%r1),%%r22", xoperands); } - output_asm_insn ("bb,>=,n %%r1,30,.+16", xoperands); - output_asm_insn ("depi 0,31,2,%%r1", xoperands); - output_asm_insn ("ldw 4(%%sr0,%%r1),%%r19", xoperands); - output_asm_insn ("ldw 0(%%sr0,%%r1),%%r1", xoperands); + output_asm_insn ("bb,>=,n %%r22,30,.+16", xoperands); + output_asm_insn ("depi 0,31,2,%%r22", xoperands); + /* Should this be an ordered load to ensure the target + address is loaded before the global pointer? */ + output_asm_insn ("ldw 0(%%r22),%%r1", xoperands); + output_asm_insn ("ldw 4(%%r22),%%r19", xoperands); if (!sibcall && !TARGET_PA_20) { @@ -8158,10 +8160,6 @@ pa_attr_length_indirect_call (rtx_insn *insn) if (TARGET_PORTABLE_RUNTIME) return 16; - /* Inline version of $$dyncall. */ - if ((TARGET_NO_SPACE_REGS || TARGET_PA_20) && !optimize_size) - return 20; - if (!TARGET_LONG_CALLS && ((TARGET_PA_20 && !TARGET_SOM && distance < 7600000) || distance < MAX_PCREL17F_OFFSET)) @@ -8171,12 +8169,15 @@ pa_attr_length_indirect_call (rtx_insn *insn) if (!flag_pic) return 12; - /* Inline version of $$dyncall. */ - if (TARGET_NO_SPACE_REGS || TARGET_PA_20) - return 20; - + /* Inline versions of $$dyncall. */ if (!optimize_size) - return 36; + { + if (TARGET_NO_SPACE_REGS) + return 28; + + if (TARGET_PA_20) + return 32; + } /* Long PIC pc-relative call. */ return 20; @@ -8214,22 +8215,6 @@ pa_output_indirect_call (rtx_insn *insn, rtx call_dest) return "blr %%r0,%%r2\n\tbv,n %%r0(%%r31)"; } - /* Maybe emit a fast inline version of $$dyncall. */ - if ((TARGET_NO_SPACE_REGS || TARGET_PA_20) && !optimize_size) - { - output_asm_insn ("bb,>=,n %%r22,30,.+12\n\t" - "ldw 2(%%r22),%%r19\n\t" - "ldw -2(%%r22),%%r22", xoperands); - pa_output_arg_descriptor (insn); - if (TARGET_NO_SPACE_REGS) - { - if (TARGET_PA_20) - return "bve,l,n (%%r22),%%r2\n\tnop"; - return "ble 0(%%sr4,%%r22)\n\tcopy %%r31,%%r2"; - } - return "bve,l (%%r22),%%r2\n\tstw %%r2,-24(%%sp)"; - } - /* Now the normal case -- we can reach $$dyncall directly or we're sure that we can get there via a long-branch stub. @@ -8258,35 +8243,40 @@ pa_output_indirect_call (rtx_insn *insn, rtx call_dest) return "ble R'$$dyncall(%%sr4,%%r2)\n\tcopy %%r31,%%r2"; } - /* Maybe emit a fast inline version of $$dyncall. The long PIC - pc-relative call sequence is five instructions. The inline PA 2.0 - version of $$dyncall is also five instructions. The PA 1.X versions - are longer but still an overall win. */ - if (TARGET_NO_SPACE_REGS || TARGET_PA_20 || !optimize_size) + /* The long PIC pc-relative call sequence is five instructions. So, + let's use an inline version of $$dyncall when the calling sequence + has a roughly similar number of instructions and we are not optimizing + for size. We need two instructions to load the return pointer plus + the $$dyncall implementation. */ + if (!optimize_size) { - output_asm_insn ("bb,>=,n %%r22,30,.+12\n\t" - "ldw 2(%%r22),%%r19\n\t" - "ldw -2(%%r22),%%r22", xoperands); if (TARGET_NO_SPACE_REGS) { pa_output_arg_descriptor (insn); - if (TARGET_PA_20) - return "bve,l,n (%%r22),%%r2\n\tnop"; - return "ble 0(%%sr4,%%r22)\n\tcopy %%r31,%%r2"; + output_asm_insn ("bl .+8,%%r2\n\t" + "ldo 20(%%r2),%%r2\n\t" + "extru,<> %%r22,30,1,%%r0\n\t" + "bv,n %%r0(%%r22)\n\t" + "ldw -2(%%r22),%%r21\n\t" + "bv %%r0(%%r21)\n\t" + "ldw 2(%%r22),%%r19", xoperands); + return ""; } if (TARGET_PA_20) { pa_output_arg_descriptor (insn); - return "bve,l (%%r22),%%r2\n\tstw %%r2,-24(%%sp)"; + output_asm_insn ("bl .+8,%%r2\n\t" + "ldo 24(%%r2),%%r2\n\t" + "stw %%r2,-24(%%sp)\n\t" + "extru,<> %r22,30,1,%%r0\n\t" + "bve,n (%%r22)\n\t" + "ldw -2(%%r22),%%r21\n\t" + "bve (%%r21)\n\t" + "ldw 2(%%r22),%%r19", xoperands); + return ""; } - output_asm_insn ("bl .+8,%%r2\n\t" - "ldo 16(%%r2),%%r2\n\t" - "ldsid (%%r22),%%r1\n\t" - "mtsp %%r1,%%sr0", xoperands); - pa_output_arg_descriptor (insn); - return "be 0(%%sr0,%%r22)\n\tstw %%r2,-24(%%sp)"; } - + /* We need a long PIC call to $$dyncall. */ xoperands[0] = gen_rtx_SYMBOL_REF (Pmode, "$$dyncall"); xoperands[1] = gen_rtx_REG (Pmode, 2); @@ -10048,7 +10038,7 @@ pa_modes_tieable_p (machine_mode mode1, machine_mode mode2) /* Length in units of the trampoline instruction code. */ -#define TRAMPOLINE_CODE_SIZE (TARGET_64BIT ? 24 : (TARGET_PA_20 ? 32 : 40)) +#define TRAMPOLINE_CODE_SIZE (TARGET_64BIT ? 24 : (TARGET_PA_20 ? 36 : 48)) /* Output assembler code for a block containing the constant parts @@ -10069,27 +10059,46 @@ pa_asm_trampoline_template (FILE *f) { if (!TARGET_64BIT) { - fputs ("\tldw 36(%r22),%r21\n", f); - fputs ("\tbb,>=,n %r21,30,.+16\n", f); - if (ASSEMBLER_DIALECT == 0) - fputs ("\tdepi 0,31,2,%r21\n", f); - else - fputs ("\tdepwi 0,31,2,%r21\n", f); - fputs ("\tldw 4(%r21),%r19\n", f); - fputs ("\tldw 0(%r21),%r21\n", f); if (TARGET_PA_20) { - fputs ("\tbve (%r21)\n", f); - fputs ("\tldw 40(%r22),%r29\n", f); + fputs ("\tmfia %r20\n", f); + fputs ("\tldw 48(%r20),%r22\n", f); + fputs ("\tcopy %r22,%r21\n", f); + fputs ("\tbb,>=,n %r22,30,.+16\n", f); + fputs ("\tdepwi 0,31,2,%r22\n", f); + fputs ("\tldw 0(%r22),%r21\n", f); + fputs ("\tldw 4(%r22),%r19\n", f); + fputs ("\tbve (%r21)\n", f); + fputs ("\tldw 52(%r1),%r29\n", f); + fputs ("\t.word 0\n", f); fputs ("\t.word 0\n", f); fputs ("\t.word 0\n", f); } else { + if (ASSEMBLER_DIALECT == 0) + { + fputs ("\tbl .+8,%r20\n", f); + fputs ("\tdepi 0,31,2,%r20\n", f); + } + else + { + fputs ("\tb,l .+8,%r20\n", f); + fputs ("\tdepwi 0,31,2,%r20\n", f); + } + fputs ("\tldw 40(%r20),%r22\n", f); + fputs ("\tcopy %r22,%r21\n", f); + fputs ("\tbb,>=,n %r22,30,.+16\n", f); + if (ASSEMBLER_DIALECT == 0) + fputs ("\tdepi 0,31,2,%r22\n", f); + else + fputs ("\tdepwi 0,31,2,%r22\n", f); + fputs ("\tldw 0(%r22),%r21\n", f); + fputs ("\tldw 4(%r22),%r19\n", f); fputs ("\tldsid (%r21),%r1\n", f); fputs ("\tmtsp %r1,%sr0\n", f); - fputs ("\tbe 0(%sr0,%r21)\n", f); - fputs ("\tldw 40(%r22),%r29\n", f); + fputs ("\tbe 0(%sr0,%r21)\n", f); + fputs ("\tldw 44(%r20),%r29\n", f); } fputs ("\t.word 0\n", f); fputs ("\t.word 0\n", f); @@ -10103,11 +10112,11 @@ pa_asm_trampoline_template (FILE *f) fputs ("\t.dword 0\n", f); fputs ("\t.dword 0\n", f); fputs ("\tmfia %r31\n", f); - fputs ("\tldd 24(%r31),%r1\n", f); - fputs ("\tldd 24(%r1),%r27\n", f); - fputs ("\tldd 16(%r1),%r1\n", f); - fputs ("\tbve (%r1)\n", f); + fputs ("\tldd 24(%r31),%r27\n", f); fputs ("\tldd 32(%r31),%r31\n", f); + fputs ("\tldd 16(%r27),%r1\n", f); + fputs ("\tbve (%r1)\n", f); + fputs ("\tldd 24(%r27),%r27\n", f); fputs ("\t.dword 0 ; fptr\n", f); fputs ("\t.dword 0 ; static link\n", f); } @@ -10117,10 +10126,10 @@ pa_asm_trampoline_template (FILE *f) FNADDR is an RTX for the address of the function's pure code. CXT is an RTX for the static chain value for the function. - Move the function address to the trampoline template at offset 36. - Move the static chain value to trampoline template at offset 40. - Move the trampoline address to trampoline template at offset 44. - Move r19 to trampoline template at offset 48. The latter two + Move the function address to the trampoline template at offset 48. + Move the static chain value to trampoline template at offset 52. + Move the trampoline address to trampoline template at offset 56. + Move r19 to trampoline template at offset 60. The latter two words create a plabel for the indirect call to the trampoline. A similar sequence is used for the 64-bit port but the plabel is @@ -10146,15 +10155,15 @@ pa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) if (!TARGET_64BIT) { - tmp = adjust_address (m_tramp, Pmode, 36); + tmp = adjust_address (m_tramp, Pmode, 48); emit_move_insn (tmp, fnaddr); - tmp = adjust_address (m_tramp, Pmode, 40); + tmp = adjust_address (m_tramp, Pmode, 52); emit_move_insn (tmp, chain_value); /* Create a fat pointer for the trampoline. */ - tmp = adjust_address (m_tramp, Pmode, 44); + tmp = adjust_address (m_tramp, Pmode, 56); emit_move_insn (tmp, r_tramp); - tmp = adjust_address (m_tramp, Pmode, 48); + tmp = adjust_address (m_tramp, Pmode, 60); emit_move_insn (tmp, gen_rtx_REG (Pmode, 19)); /* fdc and fic only use registers for the address to flush, @@ -10213,13 +10222,13 @@ pa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) /* Perform any machine-specific adjustment in the address of the trampoline. ADDR contains the address that was passed to pa_trampoline_init. - Adjust the trampoline address to point to the plabel at offset 44. */ + Adjust the trampoline address to point to the plabel at offset 56. */ static rtx pa_trampoline_adjust_address (rtx addr) { if (!TARGET_64BIT) - addr = memory_address (Pmode, plus_constant (Pmode, addr, 46)); + addr = memory_address (Pmode, plus_constant (Pmode, addr, 58)); return addr; } diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 561efa51882..385feb27033 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -689,7 +689,7 @@ extern int may_call_alloca; /* Length in units of the trampoline for entering a nested function. */ -#define TRAMPOLINE_SIZE (TARGET_64BIT ? 72 : 52) +#define TRAMPOLINE_SIZE (TARGET_64BIT ? 72 : 64) /* Alignment required by the trampoline. */ diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 98ecf0ad2fe..6f750c69e0e 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -291,9 +291,9 @@ extern int darwin_emit_branch_islands; /* This is supported in cctools 465 and later. The macro test above prevents using it in earlier build environments. */ #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) \ + if ((LOG) > 0) \ { \ - if ((MAX_SKIP) == 0) \ + if ((MAX_SKIP) <= 0) \ fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ else \ fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 0a2bdb79e15..4d4f3b3e746 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -1177,26 +1177,26 @@ BU_ALTIVEC_X (MTVSCR, "mtvscr", MISC) BU_ALTIVEC_X (MFVSCR, "mfvscr", MISC) BU_ALTIVEC_X (DSSALL, "dssall", MISC) BU_ALTIVEC_X (DSS, "dss", MISC) -BU_ALTIVEC_X (LVSL, "lvsl", MEM) -BU_ALTIVEC_X (LVSR, "lvsr", MEM) -BU_ALTIVEC_X (LVEBX, "lvebx", MEM) -BU_ALTIVEC_X (LVEHX, "lvehx", MEM) -BU_ALTIVEC_X (LVEWX, "lvewx", MEM) -BU_ALTIVEC_X (LVXL, "lvxl", MEM) -BU_ALTIVEC_X (LVXL_V2DF, "lvxl_v2df", MEM) -BU_ALTIVEC_X (LVXL_V2DI, "lvxl_v2di", MEM) -BU_ALTIVEC_X (LVXL_V4SF, "lvxl_v4sf", MEM) -BU_ALTIVEC_X (LVXL_V4SI, "lvxl_v4si", MEM) -BU_ALTIVEC_X (LVXL_V8HI, "lvxl_v8hi", MEM) -BU_ALTIVEC_X (LVXL_V16QI, "lvxl_v16qi", MEM) -BU_ALTIVEC_X (LVX, "lvx", MEM) -BU_ALTIVEC_X (LVX_V1TI, "lvx_v1ti", MEM) -BU_ALTIVEC_X (LVX_V2DF, "lvx_v2df", MEM) -BU_ALTIVEC_X (LVX_V2DI, "lvx_v2di", MEM) -BU_ALTIVEC_X (LVX_V4SF, "lvx_v4sf", MEM) -BU_ALTIVEC_X (LVX_V4SI, "lvx_v4si", MEM) -BU_ALTIVEC_X (LVX_V8HI, "lvx_v8hi", MEM) -BU_ALTIVEC_X (LVX_V16QI, "lvx_v16qi", MEM) +BU_ALTIVEC_X (LVSL, "lvsl", PURE) +BU_ALTIVEC_X (LVSR, "lvsr", PURE) +BU_ALTIVEC_X (LVEBX, "lvebx", PURE) +BU_ALTIVEC_X (LVEHX, "lvehx", PURE) +BU_ALTIVEC_X (LVEWX, "lvewx", PURE) +BU_ALTIVEC_X (LVXL, "lvxl", PURE) +BU_ALTIVEC_X (LVXL_V2DF, "lvxl_v2df", PURE) +BU_ALTIVEC_X (LVXL_V2DI, "lvxl_v2di", PURE) +BU_ALTIVEC_X (LVXL_V4SF, "lvxl_v4sf", PURE) +BU_ALTIVEC_X (LVXL_V4SI, "lvxl_v4si", PURE) +BU_ALTIVEC_X (LVXL_V8HI, "lvxl_v8hi", PURE) +BU_ALTIVEC_X (LVXL_V16QI, "lvxl_v16qi", PURE) +BU_ALTIVEC_X (LVX, "lvx", PURE) +BU_ALTIVEC_X (LVX_V1TI, "lvx_v1ti", PURE) +BU_ALTIVEC_X (LVX_V2DF, "lvx_v2df", PURE) +BU_ALTIVEC_X (LVX_V2DI, "lvx_v2di", PURE) +BU_ALTIVEC_X (LVX_V4SF, "lvx_v4sf", PURE) +BU_ALTIVEC_X (LVX_V4SI, "lvx_v4si", PURE) +BU_ALTIVEC_X (LVX_V8HI, "lvx_v8hi", PURE) +BU_ALTIVEC_X (LVX_V16QI, "lvx_v16qi", PURE) BU_ALTIVEC_X (STVX, "stvx", MEM) BU_ALTIVEC_X (STVX_V2DF, "stvx_v2df", MEM) BU_ALTIVEC_X (STVX_V2DI, "stvx_v2di", MEM) @@ -1204,10 +1204,10 @@ BU_ALTIVEC_X (STVX_V4SF, "stvx_v4sf", MEM) BU_ALTIVEC_X (STVX_V4SI, "stvx_v4si", MEM) BU_ALTIVEC_X (STVX_V8HI, "stvx_v8hi", MEM) BU_ALTIVEC_X (STVX_V16QI, "stvx_v16qi", MEM) -BU_ALTIVEC_C (LVLX, "lvlx", MEM) -BU_ALTIVEC_C (LVLXL, "lvlxl", MEM) -BU_ALTIVEC_C (LVRX, "lvrx", MEM) -BU_ALTIVEC_C (LVRXL, "lvrxl", MEM) +BU_ALTIVEC_C (LVLX, "lvlx", PURE) +BU_ALTIVEC_C (LVLXL, "lvlxl", PURE) +BU_ALTIVEC_C (LVRX, "lvrx", PURE) +BU_ALTIVEC_C (LVRXL, "lvrxl", PURE) BU_ALTIVEC_X (STVEBX, "stvebx", MEM) BU_ALTIVEC_X (STVEHX, "stvehx", MEM) BU_ALTIVEC_X (STVEWX, "stvewx", MEM) @@ -1718,15 +1718,15 @@ BU_VSX_P (XVCMPGEDP_P, "xvcmpgedp_p", CONST, vector_ge_v2df_p) BU_VSX_P (XVCMPGTDP_P, "xvcmpgtdp_p", CONST, vector_gt_v2df_p) /* VSX builtins that are handled as special cases. */ -BU_VSX_X (LXSDX, "lxsdx", MEM) -BU_VSX_X (LXVD2X_V1TI, "lxvd2x_v1ti", MEM) -BU_VSX_X (LXVD2X_V2DF, "lxvd2x_v2df", MEM) -BU_VSX_X (LXVD2X_V2DI, "lxvd2x_v2di", MEM) -BU_VSX_X (LXVDSX, "lxvdsx", MEM) -BU_VSX_X (LXVW4X_V4SF, "lxvw4x_v4sf", MEM) -BU_VSX_X (LXVW4X_V4SI, "lxvw4x_v4si", MEM) -BU_VSX_X (LXVW4X_V8HI, "lxvw4x_v8hi", MEM) -BU_VSX_X (LXVW4X_V16QI, "lxvw4x_v16qi", MEM) +BU_VSX_X (LXSDX, "lxsdx", PURE) +BU_VSX_X (LXVD2X_V1TI, "lxvd2x_v1ti", PURE) +BU_VSX_X (LXVD2X_V2DF, "lxvd2x_v2df", PURE) +BU_VSX_X (LXVD2X_V2DI, "lxvd2x_v2di", PURE) +BU_VSX_X (LXVDSX, "lxvdsx", PURE) +BU_VSX_X (LXVW4X_V4SF, "lxvw4x_v4sf", PURE) +BU_VSX_X (LXVW4X_V4SI, "lxvw4x_v4si", PURE) +BU_VSX_X (LXVW4X_V8HI, "lxvw4x_v8hi", PURE) +BU_VSX_X (LXVW4X_V16QI, "lxvw4x_v16qi", PURE) BU_VSX_X (STXSDX, "stxsdx", MEM) BU_VSX_X (STXVD2X_V1TI, "stxvd2x_v1ti", MEM) BU_VSX_X (STXVD2X_V2DF, "stxvd2x_v2df", MEM) @@ -1735,13 +1735,13 @@ BU_VSX_X (STXVW4X_V4SF, "stxvw4x_v4sf", MEM) BU_VSX_X (STXVW4X_V4SI, "stxvw4x_v4si", MEM) BU_VSX_X (STXVW4X_V8HI, "stxvw4x_v8hi", MEM) BU_VSX_X (STXVW4X_V16QI, "stxvw4x_v16qi", MEM) -BU_VSX_X (LD_ELEMREV_V1TI, "ld_elemrev_v1ti", MEM) -BU_VSX_X (LD_ELEMREV_V2DF, "ld_elemrev_v2df", MEM) -BU_VSX_X (LD_ELEMREV_V2DI, "ld_elemrev_v2di", MEM) -BU_VSX_X (LD_ELEMREV_V4SF, "ld_elemrev_v4sf", MEM) -BU_VSX_X (LD_ELEMREV_V4SI, "ld_elemrev_v4si", MEM) -BU_VSX_X (LD_ELEMREV_V8HI, "ld_elemrev_v8hi", MEM) -BU_VSX_X (LD_ELEMREV_V16QI, "ld_elemrev_v16qi", MEM) +BU_VSX_X (LD_ELEMREV_V1TI, "ld_elemrev_v1ti", PURE) +BU_VSX_X (LD_ELEMREV_V2DF, "ld_elemrev_v2df", PURE) +BU_VSX_X (LD_ELEMREV_V2DI, "ld_elemrev_v2di", PURE) +BU_VSX_X (LD_ELEMREV_V4SF, "ld_elemrev_v4sf", PURE) +BU_VSX_X (LD_ELEMREV_V4SI, "ld_elemrev_v4si", PURE) +BU_VSX_X (LD_ELEMREV_V8HI, "ld_elemrev_v8hi", PURE) +BU_VSX_X (LD_ELEMREV_V16QI, "ld_elemrev_v16qi", PURE) BU_VSX_X (ST_ELEMREV_V1TI, "st_elemrev_v1ti", MEM) BU_VSX_X (ST_ELEMREV_V2DF, "st_elemrev_v2df", MEM) BU_VSX_X (ST_ELEMREV_V2DI, "st_elemrev_v2di", MEM) diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index bd7dff5f3e5..11440988f1a 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -961,11 +961,13 @@ sh_option_override (void) if (flag_unsafe_math_optimizations) { /* Enable fsca insn for SH4A if not otherwise specified by the user. */ - if (global_options_set.x_TARGET_FSCA == 0 && TARGET_SH4A_FP) + if (global_options_set.x_TARGET_FSCA == 0 + && (TARGET_SH4A_FP || TARGET_FPU_SH4_300)) TARGET_FSCA = 1; /* Enable fsrra insn for SH4A if not otherwise specified by the user. */ - if (global_options_set.x_TARGET_FSRRA == 0 && TARGET_SH4A_FP) + if (global_options_set.x_TARGET_FSRRA == 0 + && (TARGET_SH4A_FP || TARGET_FPU_SH4_300)) TARGET_FSRRA = 1; } @@ -12512,7 +12514,7 @@ static void sh_emit_mode_set (int entity ATTRIBUTE_UNUSED, int mode, int prev_mode, HARD_REG_SET regs_live ATTRIBUTE_UNUSED) { - if ((TARGET_SH4A_FP || TARGET_SH4_300) + if ((TARGET_SH4A_FP || TARGET_FPU_SH4_300) && prev_mode != FP_MODE_NONE && prev_mode != mode) { emit_insn (gen_toggle_pr ()); diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 0204872eae7..9372fcfa699 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -69,6 +69,8 @@ extern int code_for_indirect_jump_scratch; FPU is disabled (which makes it compatible with SH4al-dsp). */ #define TARGET_SH4A_FP (TARGET_SH4A && TARGET_FPU_ANY) +/* True if the FPU is a SH4-300 variant. */ +#define TARGET_FPU_SH4_300 (TARGET_FPU_ANY && TARGET_SH4_300) /* This is not used by the SH2E calling convention */ #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \ diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 83543778619..fdb80d5d9d6 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -9163,7 +9163,7 @@ (xor:SI (reg:SI FPSCR_REG) (const_int FPSCR_PR))) (set (reg:SI FPSCR_MODES_REG) (unspec_volatile:SI [(const_int 0)] UNSPECV_FPSCR_MODES))] - "TARGET_SH4A_FP" + "TARGET_SH4A_FP || TARGET_FPU_SH4_300" "fpchg" [(set_attr "type" "fpscr_toggle")]) @@ -9391,15 +9391,31 @@ (define_expand "negsf2" [(set (match_operand:SF 0 "fp_arith_reg_operand") (neg:SF (match_operand:SF 1 "fp_arith_reg_operand")))] - "TARGET_SH2E") + "TARGET_FPU_ANY" +{ + if (TARGET_FPU_SH4_300) + emit_insn (gen_negsf2_fpscr (operands[0], operands[1])); + else + emit_insn (gen_negsf2_no_fpscr (operands[0], operands[1])); + DONE; +}) -(define_insn "*negsf2_i" +(define_insn "negsf2_no_fpscr" [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f") (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))] - "TARGET_SH2E" + "TARGET_FPU_ANY && !TARGET_FPU_SH4_300" "fneg %0" [(set_attr "type" "fmove")]) +(define_insn "negsf2_fpscr" + [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f") + (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "0"))) + (use (reg:SI FPSCR_MODES_REG))] + "TARGET_FPU_SH4_300" + "fneg %0" + [(set_attr "type" "fmove") + (set_attr "fp_mode" "single")]) + (define_expand "sqrtsf2" [(set (match_operand:SF 0 "fp_arith_reg_operand" "") (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "")))] @@ -9489,15 +9505,31 @@ (define_expand "abssf2" [(set (match_operand:SF 0 "fp_arith_reg_operand") (abs:SF (match_operand:SF 1 "fp_arith_reg_operand")))] - "TARGET_SH2E") + "TARGET_FPU_ANY" +{ + if (TARGET_FPU_SH4_300) + emit_insn (gen_abssf2_fpscr (operands[0], operands[1])); + else + emit_insn (gen_abssf2_no_fpscr (operands[0], operands[1])); + DONE; +}) -(define_insn "*abssf2_i" +(define_insn "abssf2_no_fpscr" [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f") (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))] - "TARGET_SH2E" + "TARGET_FPU_ANY && !TARGET_FPU_SH4_300" "fabs %0" [(set_attr "type" "fmove")]) +(define_insn "abssf2_fpscr" + [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f") + (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "0"))) + (use (reg:SI FPSCR_MODES_REG))] + "TARGET_FPU_SH4_300" + "fabs %0" + [(set_attr "type" "fmove") + (set_attr "fp_mode" "single")]) + (define_expand "adddf3" [(set (match_operand:DF 0 "fp_arith_reg_operand" "") (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "") @@ -9673,12 +9705,28 @@ (define_expand "negdf2" [(set (match_operand:DF 0 "fp_arith_reg_operand") (neg:DF (match_operand:DF 1 "fp_arith_reg_operand")))] - "TARGET_FPU_DOUBLE") + "TARGET_FPU_DOUBLE" +{ + if (TARGET_FPU_SH4_300) + emit_insn (gen_negdf2_fpscr (operands[0], operands[1])); + else + emit_insn (gen_negdf2_no_fpscr (operands[0], operands[1])); + DONE; +}) -(define_insn "*negdf2_i" +(define_insn "negdf2_fpscr" + [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f") + (neg:DF (match_operand:DF 1 "fp_arith_reg_operand" "0"))) + (use (reg:SI FPSCR_MODES_REG))] + "TARGET_FPU_SH4_300" + "fneg %0" + [(set_attr "type" "fmove") + (set_attr "fp_mode" "double")]) + +(define_insn "negdf2_no_fpscr" [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f") (neg:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")))] - "TARGET_FPU_DOUBLE" + "TARGET_FPU_DOUBLE && !TARGET_FPU_SH4_300" "fneg %0" [(set_attr "type" "fmove")]) @@ -9704,15 +9752,31 @@ (define_expand "absdf2" [(set (match_operand:DF 0 "fp_arith_reg_operand") (abs:DF (match_operand:DF 1 "fp_arith_reg_operand")))] - "TARGET_FPU_DOUBLE") + "TARGET_FPU_DOUBLE" +{ + if (TARGET_FPU_SH4_300) + emit_insn (gen_absdf2_fpscr (operands[0], operands[1])); + else + emit_insn (gen_absdf2_no_fpscr (operands[0], operands[1])); + DONE; +}) -(define_insn "*absdf2_i" +(define_insn "absdf2_no_fpscr" [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f") (abs:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")))] - "TARGET_FPU_DOUBLE" + "TARGET_FPU_DOUBLE && !TARGET_FPU_SH4_300" "fabs %0" [(set_attr "type" "fmove")]) +(define_insn "absdf2_fpscr" + [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f") + (abs:DF (match_operand:DF 1 "fp_arith_reg_operand" "0"))) + (use (reg:SI FPSCR_MODES_REG))] + "TARGET_FPU_SH4_300" + "fabs %0" + [(set_attr "type" "fmove") + (set_attr "fp_mode" "double")]) + (define_expand "extendsfdf2" [(set (match_operand:DF 0 "fp_arith_reg_operand" "") (float_extend:DF (match_operand:SF 1 "fpul_operand" "")))] diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a9dc437231..8f801de7560 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,57 @@ +2019-10-24 Marek Polacek <polacek@redhat.com> + + * decl.c (reshape_init_r): Add missing space. + +2019-10-22 Marek Polacek <polacek@redhat.com> + + Backported from mainline + 2019-10-21 Marek Polacek <polacek@redhat.com> + + PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr. + * typeck.c (maybe_warn_about_returning_address_of_local): Avoid + recursing on null initializer and return false instead. + + PR c++/92062 - ODR-use ignored for static member of class template. + * pt.c (has_value_dependent_address): Strip location wrappers. + +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-10-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/91974 + * cp-gimplify.c (cp_gimplify_expr) <case CALL_EXPR>: For + -fstrong-eval-order ensure CALL_EXPR_FN side-effects are evaluated + before any arguments. Additionally, ensure CALL_EXPR_FN that isn't + invariant nor OBJ_TYPE_REF nor SSA_NAME is forced into a temporary. + + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/88203 + * parser.c (cp_parser_omp_var_list_no_open): Parse predefined + variables. + * semantics.c (finish_omp_clauses): Allow predefined variables in + shared and firstprivate clauses, even when they are predetermined + shared. + * cp-gimplify.c (cxx_omp_predetermined_sharing_1): Return + OMP_CLAUSE_DEFAULT_SHARED for predefined variables. + + 2019-08-09 Jakub Jelinek <jakub@redhat.com> + + PR c/91401 + * parser.c (cp_parser_omp_clause_dist_schedule): Comment out the + check_no_duplicate_clause call, instead emit a warning for duplicate + dist_schedule clauses. + +2019-10-16 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-02 Richard Biener <rguenther@suse.de> + + PR c++/91606 + * decl.c (build_ptrmemfunc_type): Mark pointer-to-member + fat pointer structure members as DECL_NONADDRESSABLE_P. + 2019-10-08 Marek Polacek <polacek@redhat.com> Backported from mainline diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 17d10456341..c3e37648c60 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -816,6 +816,21 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) case CALL_EXPR: ret = GS_OK; + if (flag_strong_eval_order == 2 + && CALL_EXPR_FN (*expr_p) + && cp_get_callee_fndecl_nofold (*expr_p) == NULL_TREE) + { + enum gimplify_status t + = gimplify_expr (&CALL_EXPR_FN (*expr_p), pre_p, NULL, + is_gimple_call_addr, fb_rvalue); + if (t == GS_ERROR) + ret = GS_ERROR; + else if (is_gimple_variable (CALL_EXPR_FN (*expr_p)) + && TREE_CODE (CALL_EXPR_FN (*expr_p)) != SSA_NAME) + CALL_EXPR_FN (*expr_p) + = get_initialized_tmp_var (CALL_EXPR_FN (*expr_p), pre_p, + NULL); + } if (!CALL_EXPR_FN (*expr_p)) /* Internal function call. */; else if (CALL_EXPR_REVERSE_ARGS (*expr_p)) @@ -2050,6 +2065,9 @@ cxx_omp_predetermined_sharing_1 (tree decl) tree ctx = CP_DECL_CONTEXT (decl); if (TYPE_P (ctx) && MAYBE_CLASS_TYPE_P (ctx)) return OMP_CLAUSE_DEFAULT_SHARED; + + if (c_omp_predefined_variable (decl)) + return OMP_CLAUSE_DEFAULT_SHARED; } /* this may not be specified in data-sharing clauses, still we need diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e860f26e55d..9769c1cb15d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6129,7 +6129,7 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, (CONSTRUCTOR_ELT (stripped_init,0)->value)))) { if (complain & tf_error) - error ("too many braces around scalar initializer" + error ("too many braces around scalar initializer " "for type %qT", type); init = error_mark_node; } @@ -9554,10 +9554,12 @@ build_ptrmemfunc_type (tree type) TYPE_PTRMEMFUNC_FLAG (t) = 1; field = build_decl (input_location, FIELD_DECL, pfn_identifier, type); + DECL_NONADDRESSABLE_P (field) = 1; fields = field; field = build_decl (input_location, FIELD_DECL, delta_identifier, delta_type_node); + DECL_NONADDRESSABLE_P (field) = 1; DECL_CHAIN (field) = fields; fields = field; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 09251bf2135..3fac495d293 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -32468,6 +32468,14 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind, decl = TREE_OPERAND (decl, 0); cp_lexer_consume_token (parser->lexer); } + else if (cp_parser_is_keyword (token, RID_FUNCTION_NAME) + || cp_parser_is_keyword (token, RID_PRETTY_FUNCTION_NAME) + || cp_parser_is_keyword (token, RID_C99_FUNCTION_NAME)) + { + cp_id_kind idk; + decl = cp_parser_primary_expression (parser, false, false, false, + &idk); + } else { name = cp_parser_id_expression (parser, /*template_p=*/false, @@ -34896,8 +34904,10 @@ cp_parser_omp_clause_dist_schedule (cp_parser *parser, tree list, else if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_COMMA_CLOSE_PAREN)) goto resync_fail; - check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, "dist_schedule", - location); + /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, + "dist_schedule", location); */ + if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE)) + warning_at (location, 0, "too many %qs clauses", "dist_schedule"); OMP_CLAUSE_CHAIN (c) = list; return c; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 442e01bfa11..48d8dbb6ad2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6353,6 +6353,8 @@ check_valid_ptrmem_cst_expr (tree type, tree expr, static bool has_value_dependent_address (tree op) { + STRIP_ANY_LOCATION_WRAPPER (op); + /* We could use get_inner_reference here, but there's no need; this is only relevant for template non-type arguments, which can only be expressed as &id-expression. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6d40b145fcb..ebfdf9a47b0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7790,6 +7790,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_DEFAULT_UNSPECIFIED: break; case OMP_CLAUSE_DEFAULT_SHARED: + if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) + && c_omp_predefined_variable (t)) + /* The __func__ variable and similar function-local predefined + variables may be listed in a shared or firstprivate + clause. */ + break; if (VAR_P (t) && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE && TREE_STATIC (t) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c815bf3368c..2169f8c4efd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -9292,8 +9292,10 @@ maybe_warn_about_returning_address_of_local (tree retval) tree base = DECL_DECOMP_BASE (whats_returned); if (TYPE_REF_P (TREE_TYPE (base))) { - tree init = DECL_INITIAL (base); - return maybe_warn_about_returning_address_of_local (init); + if (tree init = DECL_INITIAL (base)) + return maybe_warn_about_returning_address_of_local (init); + else + return false; } } bool w = false; diff --git a/gcc/doc/avr-mmcu.texi b/gcc/doc/avr-mmcu.texi index ea0161ecccb..99cd93cb23b 100644 --- a/gcc/doc/avr-mmcu.texi +++ b/gcc/doc/avr-mmcu.texi @@ -21,7 +21,7 @@ @*@var{mcu}@tie{}= @code{ata5272}, @code{ata6616c}, @code{attiny13}, @code{attiny13a}, @code{attiny2313}, @code{attiny2313a}, @code{attiny24}, @code{attiny24a}, @code{attiny25}, @code{attiny261}, @code{attiny261a}, @code{attiny43u}, @code{attiny4313}, @code{attiny44}, @code{attiny44a}, @code{attiny441}, @code{attiny45}, @code{attiny461}, @code{attiny461a}, @code{attiny48}, @code{attiny828}, @code{attiny84}, @code{attiny84a}, @code{attiny841}, @code{attiny85}, @code{attiny861}, @code{attiny861a}, @code{attiny87}, @code{attiny88}, @code{at86rf401}. @item avr3 -``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory. +``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory. @*@var{mcu}@tie{}= @code{at43usb355}, @code{at76c711}. @item avr31 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1cec00f2b85..55a73e12cc2 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -22284,19 +22284,18 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p, /* If the contexts differ, we may not be talking about the same thing. ??? When in LTO the DIE parent is the "abstract" copy and the - context_die is the specification "copy". But this whole block - should eventually be no longer needed. */ - if (parm_die && parm_die->die_parent != context_die && !in_lto_p) + context_die is the specification "copy". */ + if (parm_die + && parm_die->die_parent != context_die + && (parm_die->die_parent->die_tag != DW_TAG_GNU_formal_parameter_pack + || parm_die->die_parent->die_parent != context_die) + && !in_lto_p) { - if (!DECL_ABSTRACT_P (node)) - { - /* This can happen when creating an inlined instance, in - which case we need to create a new DIE that will get - annotated with DW_AT_abstract_origin. */ - parm_die = NULL; - } - else - gcc_unreachable (); + gcc_assert (!DECL_ABSTRACT_P (node)); + /* This can happen when creating a concrete instance, in + which case we need to create a new DIE that will get + annotated with DW_AT_abstract_origin. */ + parm_die = NULL; } if (parm_die && parm_die->die_parent == NULL) @@ -26647,16 +26646,12 @@ dwarf2out_late_global_decl (tree decl) { dw_die_ref die = lookup_decl_die (decl); - /* We may have to generate early debug late for LTO in case debug + /* We may have to generate full debug late for LTO in case debug was not enabled at compile-time or the target doesn't support the LTO early debug scheme. */ if (! die && in_lto_p) - { - dwarf2out_decl (decl); - die = lookup_decl_die (decl); - } - - if (die) + dwarf2out_decl (decl); + else if (die) { /* We get called via the symtab code invoking late_global_decl for symbols that are optimized out. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f0e43b5fda2..9feaea9fde5 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4935,10 +4935,9 @@ range_check_type (tree etype) /* First make sure that arithmetics in this type is valid, then make sure that it wraps around. */ if (TREE_CODE (etype) == ENUMERAL_TYPE || TREE_CODE (etype) == BOOLEAN_TYPE) - etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype), - TYPE_UNSIGNED (etype)); + etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype), 1); - if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_OVERFLOW_WRAPS (etype)) + if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_UNSIGNED (etype)) { tree utype, minv, maxv; @@ -4956,6 +4955,8 @@ range_check_type (tree etype) else return NULL_TREE; } + else if (POINTER_TYPE_P (etype)) + etype = unsigned_type_for (etype); return etype; } @@ -5046,9 +5047,6 @@ build_range_check (location_t loc, tree type, tree exp, int in_p, if (etype == NULL_TREE) return NULL_TREE; - if (POINTER_TYPE_P (etype)) - etype = unsigned_type_for (etype); - high = fold_convert_loc (loc, etype, high); low = fold_convert_loc (loc, etype, low); exp = fold_convert_loc (loc, etype, exp); diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 12c7221335a..4113fc89751 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,52 @@ +2019-10-22 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/92174 + * decl.c (attr_decl1): Move check for F2018:C822 from here ... + * array.c (gfc_set_array_spec): ... to here. + +2019-10-18 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/69455 + * trans-decl.c (generate_local_decl): Avoid misconstructed + intrinsic modules in a BLOCK construct. + +2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + Backport from mainline + 2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/91586 + * class.c (gfc_find_derived_vtab): Return NULL + instead of deref'ing NULL pointer. + +2019-10-17 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/83113 + PR fortran/89943 + decl.c (gfc_match_function_decl): Ignore duplicate BIND(C) for function + declaration in submodule. Implement at check for F2018 C1550. + (gfc_match_entry): Use temporary for locus, which allows removal of + one gfc_error_now(). + (gfc_match_subroutine): Ignore duplicate BIND(C) for subroutine + declaration in submodule. Implement at check for F2018 C1550. + +2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91715 + * decl.c (gfc_match_prefix): If matching a type-spec returns an error, + it's an error so re-act correctly. + +2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91649 + check.c (gfc_check_findloc): Additional checking for valid arguments + +2019-10-10 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91801 + * simplify.c (gfc_simplify_reshape): Convert a gcc_assert into a + gfc_error as a user can easily hit the condition. + 2019-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> Backport from trunk diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index c1342c7c844..6d20cbb9d36 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -843,6 +843,10 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) sym->as->cotype = as->cotype; sym->as->corank = as->corank; + /* Check F2018:C822. */ + if (sym->as->rank + sym->as->corank > GFC_MAX_DIMENSIONS) + goto too_many; + for (i = 0; i < as->corank; i++) { sym->as->lower[sym->as->rank + i] = as->lower[i]; @@ -861,6 +865,10 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) sym->as->cray_pointee = as->cray_pointee; sym->as->cp_was_assumed = as->cp_was_assumed; + /* Check F2018:C822. */ + if (sym->as->rank + sym->as->corank > GFC_MAX_DIMENSIONS) + goto too_many; + for (i = 0; i < sym->as->corank; i++) { sym->as->lower[as->rank + i] = sym->as->lower[i]; @@ -875,6 +883,12 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) free (as); return true; + +too_many: + + gfc_error ("rank + corank of %qs exceeds %d at %C", sym->name, + GFC_MAX_DIMENSIONS); + return false; } diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 27cb76dff71..4ef354f0a6e 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3363,26 +3363,27 @@ bool gfc_check_findloc (gfc_actual_arglist *ap) { gfc_expr *a, *v, *m, *d, *k, *b; + bool a1, v1; a = ap->expr; if (!intrinsic_type_check (a, 0) || !array_check (a, 0)) return false; v = ap->next->expr; - if (!scalar_check (v,1)) + if (!intrinsic_type_check (v, 1) || !scalar_check (v,1)) return false; - /* Check if the type is compatible. */ + /* Check if the type are both logical. */ + a1 = a->ts.type == BT_LOGICAL; + v1 = v->ts.type == BT_LOGICAL; + if ((a1 && !v1) || (!a1 && v1)) + goto incompat; - if ((a->ts.type == BT_LOGICAL && v->ts.type != BT_LOGICAL) - || (a->ts.type != BT_LOGICAL && v->ts.type == BT_LOGICAL)) - { - gfc_error ("Argument %qs of %qs intrinsic at %L must be in type " - "conformance to argument %qs at %L", - gfc_current_intrinsic_arg[0]->name, - gfc_current_intrinsic, &a->where, - gfc_current_intrinsic_arg[1]->name, &v->where); - } + /* Check if the type are both character. */ + a1 = a->ts.type == BT_CHARACTER; + v1 = v->ts.type == BT_CHARACTER; + if ((a1 && !v1) || (!a1 && v1)) + goto incompat; d = ap->next->next->expr; m = ap->next->next->next->expr; @@ -3430,6 +3431,14 @@ gfc_check_findloc (gfc_actual_arglist *ap) return false; return true; + +incompat: + gfc_error ("Argument %qs of %qs intrinsic at %L must be in type " + "conformance to argument %qs at %L", + gfc_current_intrinsic_arg[0]->name, + gfc_current_intrinsic, &a->where, + gfc_current_intrinsic_arg[1]->name, &v->where); + return false; } diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 8a1f43f116c..9117121e5fe 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -2241,6 +2241,9 @@ gfc_find_derived_vtab (gfc_symbol *derived) if (!derived->attr.unlimited_polymorphic && derived->attr.is_class) derived = gfc_get_derived_super_type (derived); + if (!derived) + return NULL; + /* Find the gsymbol for the module of use associated derived types. */ if ((derived->attr.use_assoc || derived->attr.used_in_submodule) && !derived->attr.vtype && !derived->attr.is_class) diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 9beb4eef455..52a98cd44ed 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6169,13 +6169,17 @@ gfc_match_prefix (gfc_typespec *ts) found_prefix = true; } - if (!seen_type && ts != NULL - && gfc_match_decl_type_spec (ts, 0) == MATCH_YES - && gfc_match_space () == MATCH_YES) + if (!seen_type && ts != NULL) { - - seen_type = true; - found_prefix = true; + match m; + m = gfc_match_decl_type_spec (ts, 0); + if (m == MATCH_ERROR) + goto error; + if (m == MATCH_YES && gfc_match_space () == MATCH_YES) + { + seen_type = true; + found_prefix = true; + } } if (gfc_match ("elemental% ") == MATCH_YES) @@ -7226,13 +7230,16 @@ gfc_match_function_decl (void) if (sym->attr.is_bind_c == 1) { sym->attr.is_bind_c = 0; - if (sym->old_symbol != NULL) - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", - &(sym->old_symbol->declared_at)); - else - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", &gfc_current_locus); + + if (gfc_state_stack->previous + && gfc_state_stack->previous->state != COMP_SUBMODULE) + { + locus loc; + loc = sym->old_symbol != NULL + ? sym->old_symbol->declared_at : gfc_current_locus; + gfc_error_now ("BIND(C) attribute at %L can only be used for " + "variables or common blocks", &loc); + } } if (found_match != MATCH_YES) @@ -7246,6 +7253,24 @@ gfc_match_function_decl (void) found_match = suffix_match; } + /* F2018 C1550 (R1526) If MODULE appears in the prefix of a module + subprogram and a binding label is specified, it shall be the + same as the binding label specified in the corresponding module + procedure interface body. */ + if (sym->attr.is_bind_c && sym->attr.module_procedure && sym->old_symbol + && strcmp (sym->name, sym->old_symbol->name) == 0 + && strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0) + { + const char *null = "NULL", *s1, *s2; + s1 = sym->binding_label; + if (!s1) s1 = null; + s2 = sym->old_symbol->binding_label; + if (!s2) s2 = null; + gfc_error ("Mismatch in BIND(C) names (%qs/%qs) at %C", s1, s2); + sym->refs++; /* Needed to avoid an ICE in gfc_release_symbol */ + return MATCH_ERROR; + } + if(found_match != MATCH_YES) m = MATCH_ERROR; else @@ -7484,15 +7509,15 @@ gfc_match_entry (void) not allowed for procedures. */ if (entry->attr.is_bind_c == 1) { + locus loc; + entry->attr.is_bind_c = 0; - if (entry->old_symbol != NULL) - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", - &(entry->old_symbol->declared_at)); - else - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", &gfc_current_locus); - } + + loc = entry->old_symbol != NULL + ? entry->old_symbol->declared_at : gfc_current_locus; + gfc_error_now ("BIND(C) attribute at %L can only be used for " + "variables or common blocks", &loc); + } /* Check what next non-whitespace character is so we can tell if there is the required parens if we have a BIND(C). */ @@ -7692,13 +7717,16 @@ gfc_match_subroutine (void) if (sym->attr.is_bind_c == 1) { sym->attr.is_bind_c = 0; - if (sym->old_symbol != NULL) - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", - &(sym->old_symbol->declared_at)); - else - gfc_error_now ("BIND(C) attribute at %L can only be used for " - "variables or common blocks", &gfc_current_locus); + + if (gfc_state_stack->previous + && gfc_state_stack->previous->state != COMP_SUBMODULE) + { + locus loc; + loc = sym->old_symbol != NULL + ? sym->old_symbol->declared_at : gfc_current_locus; + gfc_error_now ("BIND(C) attribute at %L can only be used for " + "variables or common blocks", &loc); + } } /* C binding names are not allowed for internal procedures. */ @@ -7740,6 +7768,24 @@ gfc_match_subroutine (void) return MATCH_ERROR; } + /* F2018 C1550 (R1526) If MODULE appears in the prefix of a module + subprogram and a binding label is specified, it shall be the + same as the binding label specified in the corresponding module + procedure interface body. */ + if (sym->attr.module_procedure && sym->old_symbol + && strcmp (sym->name, sym->old_symbol->name) == 0 + && strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0) + { + const char *null = "NULL", *s1, *s2; + s1 = sym->binding_label; + if (!s1) s1 = null; + s2 = sym->old_symbol->binding_label; + if (!s2) s2 = null; + gfc_error ("Mismatch in BIND(C) names (%qs/%qs) at %C", s1, s2); + sym->refs++; /* Needed to avoid an ICE in gfc_release_symbol */ + return MATCH_ERROR; + } + /* Scan the dummy arguments for an alternate return. */ for (arg = sym->formal; arg; arg = arg->next) if (!arg->sym) @@ -8444,14 +8490,6 @@ attr_decl1 (void) goto cleanup; } - /* Check F2018:C822. */ - if (sym->attr.dimension && sym->attr.codimension - && sym->as && sym->as->rank + sym->as->corank > 15) - { - gfc_error ("rank + corank of %qs exceeds 15 at %C", sym->name); - return MATCH_ERROR; - } - if (sym->attr.cray_pointee && sym->as != NULL) { /* Fix the array spec. */ diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index f8c9a42cdc7..58b4652b010 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6745,7 +6745,15 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, gfc_extract_int (e, &order[i]); - gcc_assert (order[i] >= 1 && order[i] <= rank); + if (order[i] < 1 || order[i] > rank) + { + gfc_error ("Element with a value of %d in ORDER at %L must be " + "in the range [1, ..., %d] for the RESHAPE intrinsic " + "near %L", order[i], &order_exp->where, rank, + &shape_exp->where); + return &gfc_bad_expr; + } + order[i]--; if (x[order[i]] != 0) { diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index eb92259f880..6ac7a9a7057 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5962,7 +5962,14 @@ generate_local_decl (gfc_symbol * sym) if (sym->ns && sym->ns->construct_entities) { - if (sym->attr.referenced) + /* Construction of the intrinsic modules within a BLOCK + construct, where ONLY and RENAMED entities are included, + seems to be bogus. This is a workaround that can be removed + if someone ever takes on the task to creating full-fledge + modules. See PR 69455. */ + if (sym->attr.referenced + && sym->from_intmod != INTMOD_ISO_C_BINDING + && sym->from_intmod != INTMOD_ISO_FORTRAN_ENV) gfc_get_symbol_decl (sym); sym->mark = 1; } diff --git a/gcc/function.c b/gcc/function.c index c6e862b3369..6c1d27f8a92 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -2449,8 +2449,7 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm, /* If the parm is to be passed as a transparent union or record, use the type of the first field for the tests below. We have already verified that the modes are the same. */ - if ((TREE_CODE (passed_type) == UNION_TYPE - || TREE_CODE (passed_type) == RECORD_TYPE) + if (RECORD_OR_UNION_TYPE_P (passed_type) && TYPE_TRANSPARENT_AGGR (passed_type)) passed_type = TREE_TYPE (first_field (passed_type)); diff --git a/gcc/generic-match-head.c b/gcc/generic-match-head.c index a46f375017b..3478cf59f91 100644 --- a/gcc/generic-match-head.c +++ b/gcc/generic-match-head.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "ssa.h" #include "cgraph.h" #include "fold-const.h" +#include "fold-const-call.h" #include "stor-layout.h" #include "tree-dfa.h" #include "builtins.h" diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 98408b981dc..28e13a71021 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -7058,6 +7058,8 @@ omp_default_clause (struct gimplify_omp_ctx *ctx, tree decl, kind = lang_hooks.decls.omp_predetermined_sharing (decl); if (kind != OMP_CLAUSE_DEFAULT_UNSPECIFIED) default_kind = kind; + else if (VAR_P (decl) && TREE_STATIC (decl) && DECL_IN_CONSTANT_POOL (decl)) + default_kind = OMP_CLAUSE_DEFAULT_SHARED; switch (default_kind) { diff --git a/gcc/match.pd b/gcc/match.pd index 039ddacfed1..bd3e3bf1ae9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1519,8 +1519,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) tree etype = range_check_type (TREE_TYPE (@0)); if (etype) { - if (! TYPE_UNSIGNED (etype)) - etype = unsigned_type_for (etype); hi = fold_convert (etype, hi); lo = fold_convert (etype, lo); hi = const_binop (MINUS_EXPR, etype, hi, lo); @@ -3381,8 +3379,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp { tem; } @1))))) /* Fold comparisons against built-in math functions. */ - (if (flag_unsafe_math_optimizations - && ! flag_errno_math) + (if (flag_unsafe_math_optimizations && ! flag_errno_math) (for sq (SQRT) (simplify (cmp (sq @0) REAL_CST@1) @@ -3417,56 +3414,108 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) if x is negative or NaN. Due to -funsafe-math-optimizations, the results for other x follow from natural arithmetic. */ (cmp @0 @1))) - (if (cmp == GT_EXPR || cmp == GE_EXPR) + (if ((cmp == LT_EXPR + || cmp == LE_EXPR + || cmp == GT_EXPR + || cmp == GE_EXPR) + && !REAL_VALUE_ISNAN (TREE_REAL_CST (@1)) + /* Give up for -frounding-math. */ + && !HONOR_SIGN_DEPENDENT_ROUNDING (TREE_TYPE (@0))) (with { - REAL_VALUE_TYPE c2; + REAL_VALUE_TYPE c2; + enum tree_code ncmp = cmp; + const real_format *fmt + = REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (@0))); real_arithmetic (&c2, MULT_EXPR, &TREE_REAL_CST (@1), &TREE_REAL_CST (@1)); - real_convert (&c2, TYPE_MODE (TREE_TYPE (@0)), &c2); - } - (if (REAL_VALUE_ISINF (c2)) - /* sqrt(x) > y is x == +Inf, when y is very large. */ - (if (HONOR_INFINITIES (@0)) - (eq @0 { build_real (TREE_TYPE (@0), c2); }) - { constant_boolean_node (false, type); }) - /* sqrt(x) > c is the same as x > c*c. */ - (cmp @0 { build_real (TREE_TYPE (@0), c2); })))) - (if (cmp == LT_EXPR || cmp == LE_EXPR) - (with - { - REAL_VALUE_TYPE c2; - real_arithmetic (&c2, MULT_EXPR, - &TREE_REAL_CST (@1), &TREE_REAL_CST (@1)); - real_convert (&c2, TYPE_MODE (TREE_TYPE (@0)), &c2); + real_convert (&c2, fmt, &c2); + /* See PR91734: if c2 is inexact and sqrt(c2) < c (or sqrt(c2) >= c), + then change LT_EXPR into LE_EXPR or GE_EXPR into GT_EXPR. */ + if (!REAL_VALUE_ISINF (c2)) + { + tree c3 = fold_const_call (CFN_SQRT, TREE_TYPE (@0), + build_real (TREE_TYPE (@0), c2)); + if (c3 == NULL_TREE || TREE_CODE (c3) != REAL_CST) + ncmp = ERROR_MARK; + else if ((cmp == LT_EXPR || cmp == GE_EXPR) + && real_less (&TREE_REAL_CST (c3), &TREE_REAL_CST (@1))) + ncmp = cmp == LT_EXPR ? LE_EXPR : GT_EXPR; + else if ((cmp == LE_EXPR || cmp == GT_EXPR) + && real_less (&TREE_REAL_CST (@1), &TREE_REAL_CST (c3))) + ncmp = cmp == LE_EXPR ? LT_EXPR : GE_EXPR; + else + { + /* With rounding to even, sqrt of up to 3 different values + gives the same normal result, so in some cases c2 needs + to be adjusted. */ + REAL_VALUE_TYPE c2alt, tow; + if (cmp == LT_EXPR || cmp == GE_EXPR) + tow = dconst0; + else + real_inf (&tow); + real_nextafter (&c2alt, fmt, &c2, &tow); + real_convert (&c2alt, fmt, &c2alt); + if (REAL_VALUE_ISINF (c2alt)) + ncmp = ERROR_MARK; + else + { + c3 = fold_const_call (CFN_SQRT, TREE_TYPE (@0), + build_real (TREE_TYPE (@0), c2alt)); + if (c3 == NULL_TREE || TREE_CODE (c3) != REAL_CST) + ncmp = ERROR_MARK; + else if (real_equal (&TREE_REAL_CST (c3), + &TREE_REAL_CST (@1))) + c2 = c2alt; + } + } + } } - (if (REAL_VALUE_ISINF (c2)) - (switch - /* sqrt(x) < y is always true, when y is a very large - value and we don't care about NaNs or Infinities. */ - (if (! HONOR_NANS (@0) && ! HONOR_INFINITIES (@0)) - { constant_boolean_node (true, type); }) - /* sqrt(x) < y is x != +Inf when y is very large and we - don't care about NaNs. */ - (if (! HONOR_NANS (@0)) - (ne @0 { build_real (TREE_TYPE (@0), c2); })) - /* sqrt(x) < y is x >= 0 when y is very large and we - don't care about Infinities. */ - (if (! HONOR_INFINITIES (@0)) - (ge @0 { build_real (TREE_TYPE (@0), dconst0); })) - /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */ - (if (GENERIC) - (truth_andif - (ge @0 { build_real (TREE_TYPE (@0), dconst0); }) - (ne @0 { build_real (TREE_TYPE (@0), c2); })))) - /* sqrt(x) < c is the same as x < c*c, if we ignore NaNs. */ - (if (! HONOR_NANS (@0)) - (cmp @0 { build_real (TREE_TYPE (@0), c2); }) - /* sqrt(x) < c is the same as x >= 0 && x < c*c. */ - (if (GENERIC) - (truth_andif - (ge @0 { build_real (TREE_TYPE (@0), dconst0); }) - (cmp @0 { build_real (TREE_TYPE (@0), c2); }))))))))) + (if (cmp == GT_EXPR || cmp == GE_EXPR) + (if (REAL_VALUE_ISINF (c2)) + /* sqrt(x) > y is x == +Inf, when y is very large. */ + (if (HONOR_INFINITIES (@0)) + (eq @0 { build_real (TREE_TYPE (@0), c2); }) + { constant_boolean_node (false, type); }) + /* sqrt(x) > c is the same as x > c*c. */ + (if (ncmp != ERROR_MARK) + (if (ncmp == GE_EXPR) + (ge @0 { build_real (TREE_TYPE (@0), c2); }) + (gt @0 { build_real (TREE_TYPE (@0), c2); })))) + /* else if (cmp == LT_EXPR || cmp == LE_EXPR) */ + (if (REAL_VALUE_ISINF (c2)) + (switch + /* sqrt(x) < y is always true, when y is a very large + value and we don't care about NaNs or Infinities. */ + (if (! HONOR_NANS (@0) && ! HONOR_INFINITIES (@0)) + { constant_boolean_node (true, type); }) + /* sqrt(x) < y is x != +Inf when y is very large and we + don't care about NaNs. */ + (if (! HONOR_NANS (@0)) + (ne @0 { build_real (TREE_TYPE (@0), c2); })) + /* sqrt(x) < y is x >= 0 when y is very large and we + don't care about Infinities. */ + (if (! HONOR_INFINITIES (@0)) + (ge @0 { build_real (TREE_TYPE (@0), dconst0); })) + /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */ + (if (GENERIC) + (truth_andif + (ge @0 { build_real (TREE_TYPE (@0), dconst0); }) + (ne @0 { build_real (TREE_TYPE (@0), c2); })))) + /* sqrt(x) < c is the same as x < c*c, if we ignore NaNs. */ + (if (ncmp != ERROR_MARK && ! HONOR_NANS (@0)) + (if (ncmp == LT_EXPR) + (lt @0 { build_real (TREE_TYPE (@0), c2); }) + (le @0 { build_real (TREE_TYPE (@0), c2); })) + /* sqrt(x) < c is the same as x >= 0 && x < c*c. */ + (if (ncmp != ERROR_MARK && GENERIC) + (if (ncmp == LT_EXPR) + (truth_andif + (ge @0 { build_real (TREE_TYPE (@0), dconst0); }) + (lt @0 { build_real (TREE_TYPE (@0), c2); })) + (truth_andif + (ge @0 { build_real (TREE_TYPE (@0), dconst0); }) + (le @0 { build_real (TREE_TYPE (@0), c2); }))))))))))) /* Transform sqrt(x) cmp sqrt(y) -> x cmp y. */ (simplify (cmp (sq @0) (sq @1)) diff --git a/gcc/optabs.c b/gcc/optabs.c index a0e361b8bfe..7d7efe0a4a2 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -5819,6 +5819,25 @@ expand_vec_cond_expr (tree vec_cond_type, tree op0, tree op1, tree op2, icode = get_vcond_icode (mode, cmp_op_mode, unsignedp); if (icode == CODE_FOR_nothing) { + if (tcode == LT_EXPR + && op0a == op0 + && TREE_CODE (op0) == VECTOR_CST) + { + /* A VEC_COND_EXPR condition could be folded from EQ_EXPR/NE_EXPR + into a constant when only get_vcond_eq_icode is supported. + Verify < 0 and != 0 behave the same and change it to NE_EXPR. */ + unsigned HOST_WIDE_INT nelts; + if (!VECTOR_CST_NELTS (op0).is_constant (&nelts)) + { + if (VECTOR_CST_STEPPED_P (op0)) + return 0; + nelts = vector_cst_encoded_nelts (op0); + } + for (unsigned int i = 0; i < nelts; ++i) + if (tree_int_cst_sgn (vector_cst_elt (op0, i)) == 1) + return 0; + tcode = NE_EXPR; + } if (tcode == EQ_EXPR || tcode == NE_EXPR) icode = get_vcond_eq_icode (mode, cmp_op_mode); if (icode == CODE_FOR_nothing) diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index 74096bc5462..cf1c3689eff 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -332,7 +332,7 @@ for (i = 0; i < n_opt_string; i++) { print " indent_to, \"\","; print " \"" name "\","; print " ptr1->x_" name " ? ptr1->x_" name " : \"(null)\","; - print " ptr2->x_" name " ? ptr1->x_" name " : \"(null)\");"; + print " ptr2->x_" name " ? ptr2->x_" name " : \"(null)\");"; print ""; } diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 1d73c5101f3..bf3dc9c10ef 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,7 @@ +2019-10-11 Joseph Myers <joseph@codesourcery.com> + + * fi.po: Update. + 2019-09-30 Joseph Myers <joseph@codesourcery.com> * es.po: Update. diff --git a/gcc/po/fi.po b/gcc/po/fi.po index c66de8afab4..b4b27c40017 100644 --- a/gcc/po/fi.po +++ b/gcc/po/fi.po @@ -33,7 +33,7 @@ msgstr "" "Project-Id-Version: gcc 9.1.0\n" "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n" "POT-Creation-Date: 2019-05-02 20:28+0000\n" -"PO-Revision-Date: 2019-05-29 18:58+0300\n" +"PO-Revision-Date: 2019-10-11 20:03+0300\n" "Last-Translator: Lauri Nurmi <lanurmi@iki.fi>\n" "Language-Team: Finnish <translation-team-fi@lists.sourceforge.net>\n" "Language: fi\n" @@ -67,9 +67,9 @@ msgid "[cannot find %s]" msgstr "lähdetiedostoa %s ei löydy" #: collect2.c:1632 -#, fuzzy, c-format +#, c-format msgid "collect2 version %s\n" -msgstr "gcc-versio %s %s\n" +msgstr "collect2-versio %s\n" #: collect2.c:1737 #, c-format @@ -118,9 +118,9 @@ msgid "const/copy propagation disabled" msgstr "const-/kopioinnin-eteneminen poistettu käytöstä" #: diagnostic.c:145 -#, fuzzy, c-format +#, c-format msgid "%s: all warnings being treated as errors" -msgstr "Käsittele kaikki varoitukset virheinä" +msgstr "%s: kaikki varoitukset käsitellään virheinä" #: diagnostic.c:150 #, c-format @@ -6142,9 +6142,8 @@ msgid "gfortran does not support -E without -cpp" msgstr "gfortran ei tue valitsinta -E ilman valitsinta -cpp" #: objc/lang-specs.h:30 objc/lang-specs.h:41 -#, fuzzy msgid "GNU Objective C no longer supports traditional compilation" -msgstr "GCC ei enää tue valitsinta -traditional ilman valitsinta -E" +msgstr "GNU Objective C ei enää tue perinteistä kääntämistä" #: objc/lang-specs.h:55 msgid "objc-cpp-output is deprecated; please use objective-c-cpp-output instead" @@ -6688,9 +6687,8 @@ msgid "Conform to the ISO Fortran 95 standard." msgstr "Noudata ISO Fortran 95 -standardia" #: fortran/lang.opt:827 -#, fuzzy msgid "Conform to nothing in particular." -msgstr "Älä noudata mitään erityisesti" +msgstr "Älä noudata mitään erityisesti." #: fortran/lang.opt:831 msgid "Accept extensions to support legacy code." @@ -6732,24 +6730,20 @@ msgid "-I <dir>\tAdd <dir> to the end of the main include path." msgstr "-isystem <hakemisto>\tLisää <hakemisto> järjestelmän include-polun alkuun" #: c-family/c.opt:217 -#, fuzzy msgid "Generate make dependencies." -msgstr "Luo make-riippuvuudet" +msgstr "Luo make-riippuvuudet." #: c-family/c.opt:221 -#, fuzzy msgid "Generate make dependencies and compile." -msgstr "Luo make-riippuvuudet ja käännä" +msgstr "Luo make-riippuvuudet ja käännä." #: c-family/c.opt:225 -#, fuzzy msgid "-MF <file>\tWrite dependency output to the given file." -msgstr "Kirjoita riippuvuustuloste annettuun tiedostoon" +msgstr "-MF <tiedosto>\tKirjoita riippuvuustuloste annettuun tiedostoon." #: c-family/c.opt:229 -#, fuzzy msgid "Treat missing header files as generated files." -msgstr "Käsittele puuttuvia otsikkotiedostoja luotavina tiedostoina" +msgstr "Käsittele puuttuvia otsikkotiedostoja luotavina tiedostoina." #: c-family/c.opt:233 msgid "Like -M but ignore system header files." @@ -6773,9 +6767,8 @@ msgid "-MT <target>\tAdd an unquoted target." msgstr "" #: c-family/c.opt:253 -#, fuzzy msgid "Do not generate #line directives." -msgstr "Älä luo #line-direktiivejä" +msgstr "Älä luo #line-direktiivejä." #: c-family/c.opt:257 #, fuzzy @@ -6817,11 +6810,9 @@ msgstr "" msgid "Enable most warning messages." msgstr "Subject: Fetchmailin varoitus liian suuresta viestistä" -# vähän fuzzy #: c-family/c.opt:308 -#, fuzzy msgid "Warn on any use of alloca." -msgstr "Varoita pragmain väärästä käytöstä." +msgstr "Varoita kaikesta allocan käytöstä." #: c-family/c.opt:312 #, fuzzy @@ -6931,9 +6922,8 @@ msgstr "Varoita ”char”-tyypillä indeksoinnista." #: c-family/c.opt:1369 c-family/c.opt:1373 c-family/c.opt:1377 #: c-family/c.opt:1381 c-family/c.opt:1385 c-family/c.opt:1389 #: config/i386/i386.opt:967 -#, fuzzy msgid "Deprecated in GCC 9. This switch has no effect." -msgstr "Vanhentunut. Tämä valitsin ei vaikuta mihinkään." +msgstr "Vanhentunut GCC 9:ssä. Tämä valitsin ei vaikuta mihinkään." #: c-family/c.opt:429 msgid "Warn about variables that might be changed by \"longjmp\" or \"vfork\"." @@ -6964,9 +6954,8 @@ msgid "Warn when all constructors and destructors are private." msgstr "Varoita kun kaikki muodostimet ja hajottimet ovat yksityisiä." #: c-family/c.opt:461 -#, fuzzy msgid "Warn about dangling else." -msgstr "Varoita implisiittisistä funktioesittelyistä." +msgstr "Varoita orvosta elsestä." #: c-family/c.opt:465 msgid "Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage." @@ -7119,9 +7108,8 @@ msgid "Warn whenever type qualifiers are ignored." msgstr "Varoita tyyppimääreiden huomiotta jättämisestä." #: c-family/c.opt:622 -#, fuzzy msgid "Warn whenever attributes are ignored." -msgstr "Varoita tyyppimääreiden huomiotta jättämisestä." +msgstr "Varoita attribuuttien huomiotta jättämisestä." #: c-family/c.opt:626 #, fuzzy @@ -7196,9 +7184,8 @@ msgid "Warn when a string or character literal is followed by a ud-suffix which msgstr "" #: c-family/c.opt:701 -#, fuzzy msgid "Warn when a logical operator is suspiciously always evaluating to true or false." -msgstr "Varoita vertailusta, joka on aina tosi tai aina epätosi." +msgstr "Varoita, kun looginen operaattori on aina tosi tai aina epätosi." #: c-family/c.opt:705 msgid "Warn when logical not is used on the left hand side operand of a comparison." @@ -7429,9 +7416,8 @@ msgid "Warn about packed bit-fields whose offset changed in GCC 4.4." msgstr "Varoita pakatuista bittikentistä, joiden siirrososoite vaihtui GCC 4.4:ssä" #: c-family/c.opt:955 -#, fuzzy msgid "Warn about possibly missing parentheses." -msgstr "Varoita mahdollisesti puuttuvista sulkeista" +msgstr "Varoita mahdollisesti puuttuvista sulkeista." #: c-family/c.opt:963 msgid "Warn about calling std::move on a local object in a return statement preventing copy elision." @@ -7975,9 +7961,8 @@ msgid "Enable OpenMP's SIMD directives." msgstr "Luokittelematon lause IF-lauseessa kohdassa %C" #: c-family/c.opt:1681 -#, fuzzy msgid "Recognize C++ keywords like \"compl\" and \"xor\"." -msgstr "Tunnista C++:n avainsanat kuten ”compl” ja ”xor”" +msgstr "Tunnista C++:n avainsanat kuten ”compl” ja ”xor”." #: c-family/c.opt:1692 msgid "Look for and use PCH files even when preprocessing." @@ -8732,9 +8717,8 @@ msgid "Set the maximum amount for a single stack increment operation." msgstr "" #: config/mcore/mcore.opt:75 -#, fuzzy msgid "Always treat bitfields as int-sized." -msgstr "Käsittele bittikenttiä aina int-kokoisina" +msgstr "Käsittele bittikenttiä aina int-kokoisina." #: config/linux-android.opt:23 msgid "Generate code for the Android platform." @@ -19730,7 +19714,7 @@ msgstr "%qs-attribuuttia ei huomioida %qs:lle" #: cgraphunit.c:976 c/c-decl.c:11507 #, fuzzy, gcc-internal-format msgid "%q+F used but never defined" -msgstr "nimike %q+D määritelty mutta käytettämättä" +msgstr "nimike %q+D määritelty mutta käyttämättä" #: cgraphunit.c:978 c/c-decl.c:11517 #, fuzzy, gcc-internal-format @@ -29294,7 +29278,7 @@ msgstr "%<X<=Y<=Z%> -tyylisillä vertailuilla on eri merkitys kuin matematiikass #: c-family/c-warn.c:2021 #, gcc-internal-format msgid "label %q+D defined but not used" -msgstr "nimike %q+D määritelty mutta käytettämättä" +msgstr "nimike %q+D määritelty mutta käyttämättä" #: c-family/c-warn.c:2023 #, gcc-internal-format @@ -68642,7 +68626,7 @@ msgstr "(%qs:n alustuksen lähistöllä)" #, fuzzy #~ msgid "variable %q+D set but not used" -#~ msgstr "nimike %q+D määritelty mutta käytettämättä" +#~ msgstr "nimike %q+D määritelty mutta käyttämättä" #~ msgid "jump to label %q+D" #~ msgstr "hyppy nimiöön %q+D" @@ -68659,7 +68643,7 @@ msgstr "(%qs:n alustuksen lähistöllä)" #, fuzzy #~ msgid "parameter %q+D set but not used" -#~ msgstr "nimike %q+D määritelty mutta käytettämättä" +#~ msgstr "nimike %q+D määritelty mutta käyttämättä" #~ msgid "%q+D declared here" #~ msgstr "%q+D esitelty täällä" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a308c86d5d6..84c4c6b9c06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,196 @@ +2019-10-24 Mihail Ionescu <mihail.ionescu@arm.com> + + Backport from mainline + 2019-10-18 Andre Vieira <andre.simoesdiasvieira@arm.com> + + * gcc.target/arm/multilib.exp: Add extra tests. + +2019-10-23 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91885 + * gcc.dg/pr91885.c (__int64_t): Change from long to long long. + (__uint64_t): Change from unsigned long to unsigned long long. + +2019-10-23 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-09-26 Martin Liska <mliska@suse.cz> + + PR tree-optimization/91885 + * gcc.dg/pr91885.c: New test. + +2019-10-23 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/execute/20191023-1.c: New test. + +2019-10-23 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-17 Richard Biener <rguenther@suse.de> + + PR debug/91887 + * g++.dg/debug/dwarf2/pr91887.C: New testcase. + +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-10-17 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/92056 + * gcc.c-torture/compile/pr92056.c: New test. + + PR fortran/87752 + * gfortran.dg/gomp/pr87752.f90: New test. + + 2019-10-05 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91734 + * gcc.dg/pr91734.c: New test. + + 2019-10-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/91974 + * g++.dg/cpp1z/eval-order5.C: New test. + + 2019-10-01 Jakub Jelinek <jakub@redhat.com> + + PR c++/91925 + * g++.dg/conversion/packed2.C: New test. + + 2019-09-27 Jakub Jelinek <jakub@redhat.com> + + PR c++/88203 + * c-c++-common/gomp/pr88203-1.c: New test. + * c-c++-common/gomp/pr88203-2.c: New test. + * c-c++-common/gomp/pr88203-3.c: New test. + + PR middle-end/91920 + * c-c++-common/gomp/pr91920.c: New test. + + 2019-09-11 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/89435 + PR rtl-optimization/89795 + PR rtl-optimization/91720 + * gcc.dg/pr89435.c: New test. + * gcc.dg/pr89795.c: New test. + * gcc.dg/pr91720.c: New test. + + PR tree-optimization/91723 + * gcc.dg/vect/vect-fma-3.c: New test. + + 2019-09-07 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91665 + * gcc.dg/vect/pr91665.c: New test. + + 2019-09-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91001 + PR middle-end/91105 + PR middle-end/91106 + * gcc.c-torture/compile/pr91001.c: New test. + + 2019-09-02 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91632 + * gcc.c-torture/execute/pr91632.c: New test. + + 2019-09-01 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91623 + * gcc.target/i386/pr91623.c: New test. + + PR lto/91572 + * g++.dg/lto/pr91572_0.C: New test. + + 2019-08-29 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91351 + * g++.dg/opt/pr91351.C: New test. + + 2019-08-09 Jakub Jelinek <jakub@redhat.com> + + PR c/91401 + * c-c++-common/gomp/pr91401-1.c: New test. + * c-c++-common/gomp/pr91401-2.c: New test. + +2019-10-18 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/69455 + * gfortran.dg/pr69455_1.f90: New test. + * gfortran.dg/pr69455_2.f90: Ditto. + +2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + Backport from mainline + 2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/91586 + * gfortran.dg/class_71.f90: New. + +2019-10-17 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/83113 + PR fortran/89943 + * gfortran.dg/pr89943_1.f90: New test. + * gfortran.dg/pr89943_2.f90: Ditto. + * gfortran.dg/pr89943_3.f90: Ditto. + * gfortran.dg/pr89943_4.f90: Ditto. + +2019-10-17 Bill Schmidt <wschmidt@linux.ibm.com> + + Backport from mainline + 2019-10-15 Bill Schmidt <wschmidt@linux.ibm.com> + + PR target/92093 + * gcc.target/powerpc/pr91275.c: Fix type and endian issues. + +2019-10-16 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-02 Richard Biener <rguenther@suse.de> + + PR c++/91606 + * g++.dg/torture/pr91606.C: New testcase. + + 2019-09-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91812 + * gcc.dg/torture/pr91812.c: New testcase. + +2019-10-14 Will Schmidt <will_schmidt@vnet.ibm.com> + + Backport from trunk. + 2019-09-26 Will Schmidt <will_schmidt@vnet.ibm.com> + + * gcc.target/powerpc/pure-builtin-redundant-load.c: New. + +2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91715 + * gfortran.dg/function_kinds_5.f90: Prune run-on error. + * gfortran.dg/pr85543.f90: Ditto. + * gfortran.dg/pr91715.f90: New test. + +2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91649 + * gfortran.dg/pr91649.f90: New test. + +2019-10-10 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91801 + * gfortran.dg/pr91801.f90: New test. + +2019-10-10 Uroš Bizjak <ubizjak@gmail.com> + + PR target/92022 + * g++.dg/pr92022.C: New test. + 2019-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> Backport from trunk diff --git a/gcc/testsuite/c-c++-common/gomp/pr88203-1.c b/gcc/testsuite/c-c++-common/gomp/pr88203-1.c new file mode 100644 index 00000000000..54a686487c9 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr88203-1.c @@ -0,0 +1,61 @@ +/* PR c++/88203 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c99" { target c } } */ +/* { dg-additional-options "-std=c++11" { target c++ } } */ + +void foo (const char *); +#pragma omp declare target to (foo) + +void +f1 (void) +{ + #pragma omp parallel default(none) + foo (__func__); +} + +void +f2 (void) +{ + #pragma omp parallel default(none) shared(__func__) + foo (__func__); +} + +void +f3 (void) +{ + #pragma omp parallel default(none) firstprivate(__func__) + foo (__func__); +} + +void +f4 (void) +{ + foo (__func__); + #pragma omp parallel default(none) + foo (__func__); +} + +void +f5 (void) +{ + foo (__func__); + #pragma omp parallel default(none) shared(__func__) + foo (__func__); +} + +void +f6 (void) +{ + foo (__func__); + #pragma omp parallel default(none) firstprivate(__func__) + foo (__func__); +} + +void +f7 (void) +{ + #pragma omp target map(to: __func__) + foo (__func__); + #pragma omp task depend(inout:__func__) + foo (__func__); +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr88203-2.c b/gcc/testsuite/c-c++-common/gomp/pr88203-2.c new file mode 100644 index 00000000000..90c4a720774 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr88203-2.c @@ -0,0 +1,65 @@ +/* PR c++/88203 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=gnu99" { target c } } */ +/* { dg-additional-options "-std=gnu++11" { target c++ } } */ + +void foo (const char *, const char *); +#pragma omp declare target to (foo) + +void +f1 (void) +{ + #pragma omp parallel default(none) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f2 (void) +{ + #pragma omp parallel default(none) shared(__FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp parallel default(none) shared(__FUNCTION__) firstprivate(__PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f3 (void) +{ + #pragma omp parallel default(none) firstprivate(__FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp parallel default(none) firstprivate(__FUNCTION__), shared(__PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f4 (void) +{ + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp parallel default(none) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f5 (void) +{ + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp parallel default(none) shared(__FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f6 (void) +{ + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp parallel default(none) firstprivate(__FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} + +void +f7 (void) +{ + #pragma omp target map(to: __FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); + #pragma omp task depend(inout:__FUNCTION__, __PRETTY_FUNCTION__) + foo (__FUNCTION__, __PRETTY_FUNCTION__); +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr88203-3.c b/gcc/testsuite/c-c++-common/gomp/pr88203-3.c new file mode 100644 index 00000000000..6a9585d3281 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr88203-3.c @@ -0,0 +1,28 @@ +/* PR c++/88203 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c99" { target c } } */ +/* { dg-additional-options "-std=c++11" { target c++ } } */ + +void foo (const char *); +#pragma omp declare target to (foo) + +void +f1 (void) +{ + #pragma omp parallel for lastprivate (__func__) /* { dg-error "'__func__' is predetermined 'shared' for 'lastprivate'" } */ + for (int i = 0; i < 2; i++) + foo (__func__); + #pragma omp parallel private (__func__) /* { dg-error "'__func__' is predetermined 'shared' for 'private'" } */ + foo (__func__); +} + +void +f2 (void) +{ + foo (__func__); + #pragma omp parallel default(none) private (__func__) /* { dg-error "'__func__' is predetermined 'shared' for 'private'" } */ + foo (__func__); + #pragma omp parallel for default(none) lastprivate (__func__) /* { dg-error "'__func__' is predetermined 'shared' for 'lastprivate'" } */ + for (int i = 0; i < 2; i++) + foo (__func__); +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr91401-1.c b/gcc/testsuite/c-c++-common/gomp/pr91401-1.c new file mode 100644 index 00000000000..f588bf6f16c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr91401-1.c @@ -0,0 +1,10 @@ +/* PR c/91401 */ + +void +foo (void) +{ + int i; + #pragma omp distribute parallel for schedule (static) dist_schedule (static) + for (i = 0; i < 64; i++) + ; +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr91401-2.c b/gcc/testsuite/c-c++-common/gomp/pr91401-2.c new file mode 100644 index 00000000000..f537e66e27c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr91401-2.c @@ -0,0 +1,15 @@ +#pragma omp declare target +void f0 (void); + +void +f1 (void) +{ + int i; + #pragma omp distribute dist_schedule(static) dist_schedule(static) /* { dg-warning "too many 'dist_schedule' clauses" } */ + for (i = 0; i < 8; ++i) + f0 (); + #pragma omp distribute dist_schedule(static,2) dist_schedule(static,4) /* { dg-warning "too many 'dist_schedule' clauses" } */ + for (i = 0; i < 8; ++i) + f0 (); +} +#pragma omp end declare target diff --git a/gcc/testsuite/c-c++-common/gomp/pr91920.c b/gcc/testsuite/c-c++-common/gomp/pr91920.c new file mode 100644 index 00000000000..604fd5986f8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr91920.c @@ -0,0 +1,19 @@ +/* PR middle-end/91920 */ + +void bar (float *); + +void +foo (void) +{ + int i; + float f[3] = { 0.0f, 0.0f, 0.0f }; +#pragma omp parallel for default(none) reduction(+:f[:3]) + for (i = 0; i < 1000; i++) + { + int j; + float k[3] = { 0.25f, 0.5f, 0.75f }; + for (j = 0; j < 3; j++) + f[j] += k[j]; + } + bar (f); +} diff --git a/gcc/testsuite/g++.dg/conversion/packed2.C b/gcc/testsuite/g++.dg/conversion/packed2.C new file mode 100644 index 00000000000..7df74dc110b --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/packed2.C @@ -0,0 +1,15 @@ +// PR c++/91925 +// { dg-do compile { target c++11 } } +// { dg-options "-fpack-struct" } + +struct A {}; +int foo (A); +struct B { + A a; + decltype (foo (a)) p; +}; +template <typename T> T bar (T); +class C { + A a; + decltype (bar (a)) p; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C new file mode 100644 index 00000000000..cf3f95f0565 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C @@ -0,0 +1,19 @@ +// PR c++/92062 - ODR-use ignored for static member of class template. +// { dg-do run { target c++11 } } + +template<int> struct A { + static const bool x; + static_assert(&x, ""); // odr-uses A<...>::x +}; + +int g; + +template<int I> +const bool A<I>::x = (g = 42, false); + +void f(A<0>) {} // A<0> must be complete, so is instantiated +int main() +{ + if (g != 42) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C new file mode 100644 index 00000000000..0927488e569 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C @@ -0,0 +1,19 @@ +// PR c++/92062 - ODR-use ignored for static member of class template. +// { dg-do run { target c++11 } } + +template<int> struct A { + static const bool x; + enum { force_instantiation =! &x}; // odr-uses A<...>::x +}; + +int g; + +template<int I> +const bool A<I>::x = (g = 42, false); + +void f(A<0>) {} // A<0> must be complete, so is instantiated +int main() +{ + if (g != 42) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp50.C b/gcc/testsuite/g++.dg/cpp1z/decomp50.C new file mode 100644 index 00000000000..5400a826948 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp50.C @@ -0,0 +1,51 @@ +// PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr. +// { dg-do compile { target c++17 } } + +template <typename> struct B; +template <typename _Tp> struct B<_Tp *> { typedef _Tp& reference; }; +struct C { + template <typename _Up> using rebind = _Up *; +}; +template <typename _Iterator, typename> class D { +public: + typename B<_Iterator>::reference operator*(); + void operator++(); +}; + +template <typename _Iterator, typename _Container> +bool operator!=(D<_Iterator, _Container>, D<_Iterator, _Container>); +template <typename _Tp> class F { +public: + typedef _Tp value_type; +}; + +template <typename _Alloc> struct G { + template <typename _Tp> struct H { using type = C::rebind<_Tp>; }; + using const_pointer = typename H<typename _Alloc::value_type>::type; +}; +template <typename _Tp, typename _Alloc = F<_Tp>> class I { + typedef D<typename G<_Alloc>::const_pointer, int> const_iterator; + +public: + const_iterator begin(); + const_iterator end(); +}; + +struct A { + struct J { + int name; + int value; + }; + I<J> members; + template <typename Key> const int *find(Key) { + for (const auto &[name, value] : members) + // See <https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01107.html> + // for why we don't warn here. + return &value; // { dg-bogus "address of local variable" } + return nullptr; + } +}; +int main() { + A a; + a.find(""); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/eval-order5.C b/gcc/testsuite/g++.dg/cpp1z/eval-order5.C new file mode 100644 index 00000000000..a8f06ed421a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/eval-order5.C @@ -0,0 +1,31 @@ +// PR c++/91974 +// { dg-do run } +// { dg-options "-fstrong-eval-order" } + +extern "C" void abort (); + +bool ok = false; + +void +foo (int x) +{ + if (x != 0) + abort (); + ok = true; +} + +void +bar (int) +{ + abort (); +} + +int +main () +{ + typedef void (*T) (int); + T fn = foo; + fn ((fn = bar, 0)); + if (fn != bar || !ok) + abort (); +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C new file mode 100644 index 00000000000..6cd99cc9bb8 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-require-effective-target c++11 } +// { dg-options "-g -fdebug-types-section" } +class A { +public: + A(); + template <typename U> A(U); +}; +template <class> struct B { typedef A type; }; +template <class R, typename... Args> +int Bind(R(Args...), typename B<Args>::type...) { return 0; } +void KeepBufferRefs(A, A) { A a, b(Bind(KeepBufferRefs, a, b)); } diff --git a/gcc/testsuite/g++.dg/lto/pr91572_0.C b/gcc/testsuite/g++.dg/lto/pr91572_0.C new file mode 100644 index 00000000000..95a7e9fabf5 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr91572_0.C @@ -0,0 +1,12 @@ +// PR lto/91572 +// { dg-lto-do link } +// { dg-lto-options { { -O -fPIC -flto } } } +// { dg-require-effective-target shared } +// { dg-require-effective-target fpic } +// { dg-extra-ld-options "-shared" } + +void foo (char); +namespace N { + class A { A (); }; + A::A () { asm ("" : : "g" (0)); } +} diff --git a/gcc/testsuite/g++.dg/opt/pr91351.C b/gcc/testsuite/g++.dg/opt/pr91351.C new file mode 100644 index 00000000000..f793a2f1b11 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr91351.C @@ -0,0 +1,38 @@ +// PR tree-optimization/91351 +// { dg-do run } +// { dg-options "-O2 -fstrict-enums" } + +enum E { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, + e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25 }; + +__attribute__((noipa)) void +foo () +{ + __builtin_abort (); +} + +__attribute__((noipa)) void +bar () +{ +} + +__attribute__((noipa)) void +baz (E e) +{ + switch (e) + { + case e11: + case e12: + case e13: foo (); break; + case e24: break; + case e14: + case e15: break; + default: bar (); break; + } +} + +int +main () +{ + baz (e3); +} diff --git a/gcc/testsuite/g++.dg/pr92022.C b/gcc/testsuite/g++.dg/pr92022.C new file mode 100644 index 00000000000..066d984ffc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr92022.C @@ -0,0 +1,13 @@ +// { dg-do compile { target alpha*-*-* } } +// { dg-options "-O1 -g -fno-var-tracking -mcpu=ev4 -mieee" } + +struct a { + a(long); +}; +long b; +void c() { + a d(1); + double e = b; + for (; b;) + d = e; +} diff --git a/gcc/testsuite/g++.dg/torture/pr91606.C b/gcc/testsuite/g++.dg/torture/pr91606.C new file mode 100644 index 00000000000..37a05a5e3a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr91606.C @@ -0,0 +1,109 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fstrict-aliasing" } */ + +#include <cstdlib> +#include <array> +#include <type_traits> + +template <typename T1, typename T2> +struct variant +{ + constexpr variant(T1 arg) + : f1(arg), + index(0) + {} + + constexpr variant(T2 arg) + : f2(arg), + index(1) + {} + + union + { + T1 f1; + T2 f2; + }; + std::size_t index = 0; +}; + +template <typename T1, typename T2> +constexpr const T1* get_if(const variant<T1, T2>* v) +{ + if (v->index != 0) + { + return nullptr; + } + return &v->f1; +} + +template <typename T2, typename T1> +constexpr const T2* get_if(const variant<T1, T2>* v) +{ + if (v->index != 1) + { + return nullptr; + } + return &v->f2; +} + +template <typename T, size_t N> +struct my_array +{ + constexpr const T* begin() const + { + return data; + } + + constexpr const T* end() const + { + return data + N; + } + + T data[N]; +}; + +template <typename ...Ts> +constexpr auto get_array_of_variants(Ts ...ptrs) +{ + return std::array<variant<std::decay_t<Ts>...>, sizeof...(Ts)>{ ptrs... }; +} + +template <typename T> +constexpr auto get_member_functions(); + +template <typename Member, typename Class> +constexpr int getFuncId(Member (Class::*memFuncPtr)) +{ + int idx = 0u; + for (auto &anyFunc : get_member_functions<Class>()) + { + if (auto *specificFunc = get_if<Member (Class::*)>(&anyFunc)) + { + if (*specificFunc == memFuncPtr) + { + return idx; + } + } + ++idx; + } + std::abort(); +} + +struct MyStruct +{ + void fun1(int /*a*/) {} + + int fun2(char /*b*/, short /*c*/, bool /*d*/) { return 0; } + +}; + +template <> +constexpr auto get_member_functions<MyStruct>() +{ + return get_array_of_variants(&MyStruct::fun1, &MyStruct::fun2); +} + +int main() +{ + return getFuncId(&MyStruct::fun1); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr91001.c b/gcc/testsuite/gcc.c-torture/compile/pr91001.c new file mode 100644 index 00000000000..4b6a017c860 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr91001.c @@ -0,0 +1,31 @@ +/* PR middle-end/91001 */ +/* PR middle-end/91105 */ +/* PR middle-end/91106 */ + +struct __attribute__((packed)) S { short b; char c; }; +struct T { short b, c, d; }; +struct __attribute__((packed)) R { int b; char c; }; +union __attribute__((aligned(128), transparent_union)) U { struct S c; } u; +union __attribute__((aligned(32), transparent_union)) V { struct T c; } v; +union __attribute__((aligned(32), transparent_union)) W { struct R c; } w; +void foo (union U); +void bar (union V); +void baz (union W); + +void +qux (void) +{ + foo (u); +} + +void +quux (void) +{ + bar (v); +} + +void +corge (void) +{ + baz (w); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr92056.c b/gcc/testsuite/gcc.c-torture/compile/pr92056.c new file mode 100644 index 00000000000..d04da763e15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr92056.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/92056 */ + +const char *d; + +void +foo (int c, char *e, const char *a, const char *b) +{ + switch (c) + { + case 33: + for (;; d++) + if (__builtin_strcmp (b ? : "", d)) + return; + break; + case 4: + __builtin_sprintf (e, a); + } +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20191023-1.c b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c new file mode 100644 index 00000000000..3811ebca151 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c @@ -0,0 +1,73 @@ +/* PR tree-optimization/92131 */ +/* Testcase by Armin Rigo <arigo@tunes.org> */ + +long b, c, d, e, f, i; +char g, h, j, k; +int *aa; + +static void error (void) __attribute__((noipa)); +static void error (void) { __builtin_abort(); } + +static void see_me_here (void) __attribute__((noipa)); +static void see_me_here (void) {} + +static void aaa (void) __attribute__((noipa)); +static void aaa (void) {} + +static void a (void) __attribute__((noipa)); +static void a (void) { + long am, ao; + if (aa == 0) { + aaa(); + if (j) + goto ay; + } + return; +ay: + aaa(); + if (k) { + aaa(); + goto az; + } + return; +az: + if (i) + if (g) + if (h) + if (e) + goto bd; + return; +bd: + am = 0; + while (am < e) { + switch (c) { + case 8: + goto bh; + case 4: + return; + } + bh: + if (am >= 0) + b = -am; + ao = am + b; + f = ao & 7; + if (f == 0) + see_me_here(); + if (ao >= 0) + am++; + else + error(); + } +} + +int main (void) +{ + j++; + k++; + i++; + g++; + h++; + e = 1; + a(); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr91632.c b/gcc/testsuite/gcc.c-torture/execute/pr91632.c new file mode 100644 index 00000000000..c16c3da4efd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr91632.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/91632 */ +/* { dg-additional-options "-fwrapv" } */ + +static int +__attribute__((noipa)) +foo (char x) +{ + switch (x) + { + case '"': + case '<': + case '>': + case '\\': + case '^': + case '`': + case '{': + case '|': + case '}': + return 0; + } + return 1; +} + +int +main () +{ + if (foo ('h') == 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr89435.c b/gcc/testsuite/gcc.dg/pr89435.c new file mode 100644 index 00000000000..d72d087f5ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89435.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/89435 */ +/* { dg-do run } */ +/* { dg-options "-O1 -fno-forward-propagate -fno-tree-forwprop -fno-tree-ccp" } */ + +unsigned short a; +unsigned int b, c, d, e, f; + +int +main () +{ +#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 + unsigned char g = e = __builtin_mul_overflow_p (5, 542624702, 0); + d = __builtin_bswap64 (a); + b = __builtin_sub_overflow ((unsigned char) -e, (unsigned int) d, &g); + e = __builtin_mul_overflow (b, c, &a); + f = g + e; + if (f != 0xff) + __builtin_abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr89795.c b/gcc/testsuite/gcc.dg/pr89795.c new file mode 100644 index 00000000000..4ceaa433f3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89795.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/89795 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-dce -fno-forward-propagate -fno-sched-pressure" } */ + +unsigned char a; +unsigned b, c, d; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned x; + int e, f; + unsigned char g; + e = __builtin_bswap32 (a); + f = __builtin_ffs (~(unsigned short) e); + a = __builtin_mul_overflow ((unsigned char) 0xf7, f, &g); + a |= __builtin_sub_overflow_p (c, 0, (unsigned char) 0); + d = g + b; + x = d; + if (x != 0xf7) + __builtin_abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr91720.c b/gcc/testsuite/gcc.dg/pr91720.c new file mode 100644 index 00000000000..4abdace94da --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91720.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/91720 */ +/* { dg-do run } */ +/* { dg-options "-Og -fno-forward-propagate -frerun-cse-after-loop -fno-tree-fre" } */ + +unsigned a, b; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned c = 1; + unsigned long long d = 0; + unsigned char e = 0; + e = __builtin_sub_overflow (d, e, &a) ? 0 : 0x80; + e = e << 7 | e >> c; + __builtin_memmove (&d, &a, 2); + b = e; + if (b != 0x40) + __builtin_abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr91734.c b/gcc/testsuite/gcc.dg/pr91734.c new file mode 100644 index 00000000000..1cc3e40ccbc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91734.c @@ -0,0 +1,97 @@ +/* PR tree-optimization/91734 */ +/* { dg-do run } */ +/* { dg-add-options ieee } */ +/* { dg-additional-options "-O2 -std=gnu99" } */ + +__attribute__((noipa, optimize ("Ofast"))) int +f1 (float x) +{ + return __builtin_sqrtf (x) < __FLT_MIN__; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f2 (float x) +{ + return __builtin_sqrtf (x) < 0x1.2dd3d0p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f3 (float x) +{ + return __builtin_sqrtf (x) >= 0x1.2dd3d0p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f4 (float x) +{ + return __builtin_sqrtf (x) >= 0x1.5642e6p+54f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f5 (float x) +{ + return __builtin_sqrtf (x) > 0x1.5642e6p+54f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f6 (float x) +{ + return __builtin_sqrtf (x) < 0x1.4da1cp-19f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f7 (float x) +{ + return __builtin_sqrtf (x) <= 0x1.4da1cp-19f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f8 (float x) +{ + return __builtin_sqrtf (x) < 0x1.50cb62p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f9 (float x) +{ + return __builtin_sqrtf (x) <= 0x1.4fc00cp-73f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f10 (float x) +{ + return __builtin_sqrtf (x) < 0x1.001002p+0f; +} + +int +main () +{ + if (__FLT_RADIX__ != 2 + || __FLT_MANT_DIG__ != 24 + || __FLT_MIN_EXP__ != -125 + || __FLT_MAX_EXP__ != 128 + || __FLT_HAS_DENORM__ != 1 + || __FLT_HAS_INFINITY__ != 1) + return 0; + if (!f1 (0.0f) || f1 (0x1.0p-149f)) + __builtin_abort (); + if (!f2 (0x1.63dbc0p-130f)) + __builtin_abort (); + if (f3 (0x1.63dbc0p-130f)) + __builtin_abort (); + if (!f4 (0x1.c996d0p+108f) || !f4 (0x1.c996cep+108f) || f4 (0x1.c996ccp+108f)) + __builtin_abort (); + if (f5 (0x1.c996d0p+108f) || f5 (0x1.c996d2p+108f) || !f5 (0x1.c996d4p+108f)) + __builtin_abort (); + if (!f6 (0x1.b2ce3p-38f) || f6 (0x1.b2ce32p-38f) || f6 (0x1.b2ce34p-38f)) + __builtin_abort (); + if (!f7 (0x1.b2ce3p-38f) || !f7 (0x1.b2ce34p-38f) || !f7 (0x1.b2ce36p-38f) || f7 (0x1.b2ce38p-38f)) + __builtin_abort (); + if (!f8 (0x1.bb166p-130f) || !f8 (0x1.bb168p-130f) || f8 (0x1.bb16ap-130f) || f8 (0x1.bb16cp-130f)) + __builtin_abort (); + if (!f9 (0x1.8p-146f) || !f9 (0x1.ap-146f) || f9 (0x1.cp-146f) || f9 (0x1.ep-146f)) + __builtin_abort (); + if (f10 (0x1.002004p+0f)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr91885.c b/gcc/testsuite/gcc.dg/pr91885.c new file mode 100644 index 00000000000..35be32be559 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91885.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +typedef signed long long int __int64_t; +typedef unsigned long long int __uint64_t; +typedef __int64_t int64_t; +typedef __uint64_t uint64_t; +inline void +BLI_endian_switch_int64 (int64_t *val) +{ + uint64_t tval = *val; + *val = ((tval >> 56)) | ((tval << 40) & 0x00ff000000000000ll) + | ((tval << 24) & 0x0000ff0000000000ll) + | ((tval << 8) & 0x000000ff00000000ll) + | ((tval >> 8) & 0x00000000ff000000ll) + | ((tval >> 24) & 0x0000000000ff0000ll) + | ((tval >> 40) & 0x000000000000ff00ll) | ((tval << 56)); +} +typedef struct anim_index_entry +{ + unsigned long long seek_pos_dts; + unsigned long long pts; +} anim_index_entry; +extern struct anim_index_entry * +MEM_callocN (int); +struct anim_index +{ + int num_entries; + struct anim_index_entry *entries; +}; +struct anim_index * +IMB_indexer_open (const char *name) +{ + char header[13]; + struct anim_index *idx; + int i; + idx->entries = MEM_callocN (8); + if (((1 == 0) != (header[8] == 'V'))) + { + for (i = 0; i < idx->num_entries; i++) + { + BLI_endian_switch_int64 ((int64_t *) &idx->entries[i].seek_pos_dts); + BLI_endian_switch_int64 ((int64_t *) &idx->entries[i].pts); + } + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91812.c b/gcc/testsuite/gcc.dg/torture/pr91812.c new file mode 100644 index 00000000000..ebc67a01e33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91812.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ +/* { dg-options "-fdump-tree-optimized-blocks" } */ + +unsigned register1; +unsigned register2; + +void busy_wait_for_register (int x) +{ + volatile unsigned* ptr; + switch(x) { + case 0x1111: + ptr = ®ister1; + break; + + case 0x2222: + ptr = ®ister2; + break; + + default: + return; + } + while (*ptr) {} +} + +/* { dg-final { scan-tree-dump "loop depth 1" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr91665.c b/gcc/testsuite/gcc.dg/vect/pr91665.c new file mode 100644 index 00000000000..6b69ea030b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91665.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/91665 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +short int v; + +void +foo (short int x, short int y) +{ + short int *p = &v; + + x = 1; + while (x != 0) + x += ++y || (*p = x); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-fma-3.c b/gcc/testsuite/gcc.dg/vect/vect-fma-3.c new file mode 100644 index 00000000000..b231a328fa5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-fma-3.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/91723 */ +/* { dg-do compile { target { scalar_all_fma || { i?86-*-* x86_64-*-* } } } } */ +/* { dg-additional-options "-mfma" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (double *restrict r, const double *restrict a, + const double *restrict b, const double *restrict c) +{ + for (int i = 0; i < 1024; i++) + { + double x = __builtin_fma (a[i], b[i], c[i]); + x = __builtin_fma (a[i], b[i], x); + r[i] = x; + } +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_double } } } */ diff --git a/gcc/testsuite/gcc.target/arm/multilib.exp b/gcc/testsuite/gcc.target/arm/multilib.exp index d82306ed630..dcea829965e 100644 --- a/gcc/testsuite/gcc.target/arm/multilib.exp +++ b/gcc/testsuite/gcc.target/arm/multilib.exp @@ -753,6 +753,28 @@ if {[multilib_config "rmprofile"] } { {-march=armv8-m.main+fp.dp -mfpu=fpv5-d16 -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp" {-march=armv8-m.main+fp+dsp -mfpu=fpv5-d16 -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp" {-march=armv8-m.main+fp.dp+dsp -mfpu=fpv5-d16 -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp" + {-march=armv7-r+fp -mfpu=auto -mfloat-abi=softfp} "thumb/v7+fp/softfp" + {-march=armv7-r+fp -mfpu=auto -mfloat-abi=hard} "thumb/v7+fp/hard" + {-march=armv7-r+fp+idiv -mfpu=auto -mfloat-abi=softfp} "thumb/v7+fp/softfp" + {-march=armv7-r+fp+idiv -mfpu=auto -mfloat-abi=hard} "thumb/v7+fp/hard" + {-march=armv7-r+vfpv3-d16-fp16 -mfpu=auto -mfloat-abi=softfp} "thumb/v7+fp/softfp" + {-march=armv7-r+vfpv3-d16-fp16 -mfpu=auto -mfloat-abi=hard} "thumb/v7+fp/hard" + {-march=armv7-r+vfpv3-d16-fp16+idiv -mfpu=auto -mfloat-abi=softfp} "thumb/v7+fp/softfp" + {-march=armv7-r+vfpv3-d16-fp16+idiv -mfpu=auto -mfloat-abi=hard} "thumb/v7+fp/hard" + {-march=armv7-r+fp.sp -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv7-r+fp.sp -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv7-r+fp.sp+idiv -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv7-r+fp.sp+idiv -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv7-r+vfpv3xd -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv7-r+vfpv3xd -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv7-r+vfpv3xd+idiv -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv7-r+vfpv3xd+idiv -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv7-r+vfpv3xd-fp16+idiv -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv7-r+vfpv3xd-fp16+idiv -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv8-r+fp.sp -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv8-r+fp.sp -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" + {-march=armv8-r+crc+fp.sp -mfpu=auto -mfloat-abi=softfp} "thumb/v7-r+fp.sp/softfp" + {-march=armv8-r+crc+fp.sp -mfpu=auto -mfloat-abi=hard} "thumb/v7-r+fp.sp/hard" } { check_multi_dir $opts $dir } diff --git a/gcc/testsuite/gcc.target/i386/pr91623.c b/gcc/testsuite/gcc.target/i386/pr91623.c new file mode 100644 index 00000000000..94de4f91c6d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91623.c @@ -0,0 +1,32 @@ +/* PR middle-end/91623 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse4.1 -mno-sse4.2" } */ + +typedef long long V __attribute__((__vector_size__(16))); +V e, h; +int d; +const int i; + +void foo (void); + +void +bar (int k, int l) +{ + if (d && 0 <= k - 1 && l) + foo (); +} + +void +baz (void) +{ + V n = (V) { 1 }; + V g = (V) {}; + V o = g; + for (int f = 0; f < i; ++f) + { + V a = o == n; + h = a; + bar (f, i); + o = e; + } +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr91275.c b/gcc/testsuite/gcc.target/powerpc/pr91275.c index b23d75be29b..cd461158af7 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr91275.c +++ b/gcc/testsuite/gcc.target/powerpc/pr91275.c @@ -10,12 +10,17 @@ int main() { const unsigned long long r0l = 0x8e7dfceac070e3a0; vector unsigned long long r0 = (vector unsigned long long) {r0l, 0}, v; const vector unsigned long long pd - = (vector unsigned long) {0xc2LLU << 56, 0}; + = (vector unsigned long long) {0xc2LLU << 56, 0}; v = __builtin_crypto_vpmsumd ((vector unsigned long long) {r0[0], 0}, pd); +#if __LITTLE_ENDIAN__ if (v[0] != 0x4000000000000000 || v[1] != 0x65bd7ab605a4a8ff) __builtin_abort (); +#else + if (v[1] != 0x4000000000000000 || v[0] != 0x65bd7ab605a4a8ff) + __builtin_abort (); +#endif return 0; } diff --git a/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c b/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c new file mode 100644 index 00000000000..16ab6abfc3b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -fdump-tree-fre-all -mvsx" } */ + +/* Verify we remove a redundant load that occurs both before and after +we call a vector load builtin. +This testcase is introduced as we updated a number of our vector load +built-ins with the attribute of PURE instead of MEM, to indicate that +those builtins only read from memory, versus reading from and writing +to the same. +This means we can identify the redundant load instructions in an earlier +pass, and optimize them away. */ + +#include <altivec.h> + +vector signed short load_data; + +vector signed short foo() +{ + vector signed short r11,r12,r13; + r11 = load_data; + r12 = vec_xl (0, &load_data[0]); + r13 = load_data; + return (r11 + r12 + r13); +} + +vector signed short biz() +{ + vector signed short r21,r22,r23; + r21 = load_data; + r22 = vec_lvehx (0, &load_data[0]); + r23 = load_data; + return (r21 + r22 + r23); +} + +vector signed short bar() +{ + vector signed short r31,r32,r33; + r31 = load_data; + r32 = vec_lvx (0, &load_data[0]); + r33 = load_data; + return (r31 + r32 + r33); +} + +/* { dg-final { scan-tree-dump-times "Removing dead stmt r13_. = load_data;" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "Removing dead stmt r23_. = load_data;" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "Removing dead stmt r33_. = load_data;" 1 "fre1" } } */ diff --git a/gcc/testsuite/gfortran.dg/class_71.f90 b/gcc/testsuite/gfortran.dg/class_71.f90 new file mode 100644 index 00000000000..bc0ffcd2305 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_71.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! +! PR fortran/91586 +! +! Contributed by G. Steinmetz +! +program p + type t + class(*), allocatable :: a + end type + class(t) :: x, y ! { dg-error "must be dummy, allocatable or pointer" } + y = x ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" } +end diff --git a/gcc/testsuite/gfortran.dg/function_kinds_5.f90 b/gcc/testsuite/gfortran.dg/function_kinds_5.f90 index e48484ec30d..106431fe206 100644 --- a/gcc/testsuite/gfortran.dg/function_kinds_5.f90 +++ b/gcc/testsuite/gfortran.dg/function_kinds_5.f90 @@ -8,3 +8,4 @@ real (bad_kind(0d0)) function foo () ! { dg-error "must be an intrinsic function" } foo = real (kind (foo)) end function +! { dg-prune-output "Bad kind expression for function" } diff --git a/gcc/testsuite/gfortran.dg/gomp/pr87752.f90 b/gcc/testsuite/gfortran.dg/gomp/pr87752.f90 new file mode 100644 index 00000000000..072de218253 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr87752.f90 @@ -0,0 +1,12 @@ +! PR fortran/87752 +! { dg-do compile } +! { dg-additional-options "-Ofast" } + +subroutine foo (n, u, v) + integer :: n + real, pointer :: u(:), v(:) + !$omp parallel do simd + do i = 1, n + u(:) = v(:) + end do +end diff --git a/gcc/testsuite/gfortran.dg/pr69455_1.f90 b/gcc/testsuite/gfortran.dg/pr69455_1.f90 new file mode 100644 index 00000000000..fe62e5c1b0b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69455_1.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +program foo + block + use, intrinsic :: iso_c_binding, only: wp => c_float, ik => c_int + if (ik /= 4) stop 1 + if (wp /= 4) stop 2 + end block + block + use, intrinsic :: iso_c_binding, only: wp => c_double, ik => c_int64_t + if (ik /= 8) stop 3 + if (wp /= 8) stop 4 + end block +end program foo + diff --git a/gcc/testsuite/gfortran.dg/pr69455_2.f90 b/gcc/testsuite/gfortran.dg/pr69455_2.f90 new file mode 100644 index 00000000000..8f9fb35021f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69455_2.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +program foo + block + use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL32, ik => INT32 + if (ik /= 4) stop 1 + if (wp /= 4) stop 2 + end block + block + use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL64, ik => INT64 + if (ik /= 8) stop 3 + if (wp /= 8) stop 4 + end block +end program foo diff --git a/gcc/testsuite/gfortran.dg/pr85543.f90 b/gcc/testsuite/gfortran.dg/pr85543.f90 index d3f83276a7f..b0faa8d5927 100644 --- a/gcc/testsuite/gfortran.dg/pr85543.f90 +++ b/gcc/testsuite/gfortran.dg/pr85543.f90 @@ -6,3 +6,4 @@ contains real(z()) function f() ! { dg-error "in initialization expression at" } end end +! { dg-prune-output "Bad kind expression for function" } diff --git a/gcc/testsuite/gfortran.dg/pr89943_1.f90 b/gcc/testsuite/gfortran.dg/pr89943_1.f90 new file mode 100644 index 00000000000..3aa9c36d628 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89943_1.f90 @@ -0,0 +1,31 @@ +! { dg-do compile } +! PR fortran/89943 +! Code contributed by Alberto Luaces <aluaces at udc dot se> +module Foo_mod + + implicit none + + interface + module subroutine runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer(c_int32_t) , intent(in) :: ndim + end subroutine runFoo4C + end interface + + contains + +end module Foo_mod + +submodule(Foo_mod) Foo_smod + + contains + + module subroutine runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer(c_int32_t) , intent(in) :: ndim + end subroutine runFoo4C + +end submodule Foo_smod + diff --git a/gcc/testsuite/gfortran.dg/pr89943_2.f90 b/gcc/testsuite/gfortran.dg/pr89943_2.f90 new file mode 100644 index 00000000000..ac69ec3af56 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89943_2.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! PR fortran/89943 +! Code contributed by Alberto Luaces <aluaces at udc dot se> +module Foo_mod + + implicit none + + interface + module function runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer runFoo4c + integer(c_int32_t) , intent(in) :: ndim + end function runFoo4C + end interface + + contains + +end module Foo_mod + +submodule(Foo_mod) Foo_smod + + contains + + module function runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer runFoo4c + integer(c_int32_t) , intent(in) :: ndim + end function runFoo4C + +end submodule Foo_smod + diff --git a/gcc/testsuite/gfortran.dg/pr89943_3.f90 b/gcc/testsuite/gfortran.dg/pr89943_3.f90 new file mode 100644 index 00000000000..38b723e2458 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89943_3.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +module Foo_mod + + implicit none + + interface + module subroutine runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer(c_int32_t) , intent(in) :: ndim + end subroutine runFoo4C + end interface + + contains + +end module Foo_mod + +submodule(Foo_mod) Foo_smod + + contains + + module subroutine runFoo4C(ndim) bind(C, name="runFu") ! { dg-error "Mismatch in BIND" } + use, intrinsic :: iso_c_binding ! { dg-error "Unexpected USE statement" } + implicit none ! { dg-error "Unexpected IMPLICIT NONE statement" } + integer(c_int32_t) , intent(in) :: ndim ! { dg-error "Unexpected data declaration" } + end subroutine runFoo4C ! { dg-error " Expecting END SUBMODULE" } + +end submodule Foo_smod diff --git a/gcc/testsuite/gfortran.dg/pr89943_4.f90 b/gcc/testsuite/gfortran.dg/pr89943_4.f90 new file mode 100644 index 00000000000..8eba2eda171 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89943_4.f90 @@ -0,0 +1,29 @@ +! { dg-do compile } +module Foo_mod + + implicit none + + interface + module function runFoo4C(ndim) bind(C, name="runFoo") + use, intrinsic :: iso_c_binding + implicit none + integer runFoo4c + integer(c_int32_t) , intent(in) :: ndim + end function runFoo4C + end interface + + contains + +end module Foo_mod + +submodule(Foo_mod) Foo_smod + + contains + + module function runFoo4C(ndim) bind(C, name="runFu") ! { dg-error "Mismatch in BIND" } + use, intrinsic :: iso_c_binding ! { dg-error "Unexpected USE statement in" } + implicit none ! { dg-error "Unexpected IMPLICIT NONE statement" } + integer(c_int32_t) , intent(in) :: ndim ! { dg-error "Unexpected data declaration" } + end function runFoo4C ! { dg-error "Expecting END SUBMODULE" } + +end submodule Foo_smod diff --git a/gcc/testsuite/gfortran.dg/pr91649.f90 b/gcc/testsuite/gfortran.dg/pr91649.f90 new file mode 100644 index 00000000000..0e6acb9ac8d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91649.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! PR fortran/91649 +! Code originally contributed by Gerhard Steinmetz +subroutine p + logical :: back = .true. + integer :: x(1) = findloc([1, 2, 1], '1', back=back) ! { dg-error "must be in type conformance" } + print *, x +end + +subroutine q + type t + end type + logical :: back = .false. + integer :: x(1) = findloc([1, 2, 1], t(), back=back) ! { dg-error "must be of intrinsic type" } + print *, x +end + +subroutine s + character(4) :: c = '1234' + integer :: x(1) = findloc([1, 2, 1], c, back=.true.) ! { dg-error "must be in type conformance" } + print *, x +end + diff --git a/gcc/testsuite/gfortran.dg/pr91715.f90 b/gcc/testsuite/gfortran.dg/pr91715.f90 new file mode 100644 index 00000000000..a3d9b8d1d9a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91715.f90 @@ -0,0 +1,5 @@ +! { dg-do compile } +! PR fortran/91715 +! Code contributed Gerhard Steinmetz +character(1function f() ! { dg-error "Syntax error in CHARACTER" } +end diff --git a/gcc/testsuite/gfortran.dg/pr91801.f90 b/gcc/testsuite/gfortran.dg/pr91801.f90 new file mode 100644 index 00000000000..d2d82b88464 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91801.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/91801 +! Code contributed by Gerhard Steinmetz +program p + integer, parameter :: a(2) = [2,0] ! { dg-error "Element with a value of" } + print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "for the RESHAPE intrinsic near" } +end diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 32be59acfb0..d27cc65f883 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9151,7 +9151,7 @@ generate_range_test (basic_block bb, tree index, tree low, tree high, tree *lhs, tree *rhs) { tree type = TREE_TYPE (index); - tree utype = unsigned_type_for (type); + tree utype = range_check_type (type); low = fold_convert (utype, low); high = fold_convert (utype, high); diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 183b491ab1d..4bac38ab00c 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -101,6 +101,8 @@ convert_single_case_switch (gswitch *swtch, gimple_stmt_iterator &gsi) if (high) { tree lhs, rhs; + if (range_check_type (TREE_TYPE (index)) == NULL_TREE) + return false; generate_range_test (bb, index, low, high, &lhs, &rhs); cond = gimple_build_cond (LE_EXPR, lhs, rhs, NULL_TREE, NULL_TREE); } diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index f9ad7e83943..25c5ced57b7 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -890,6 +890,9 @@ cond_expr_object_size (struct object_size_info *osi, tree var, gimple *stmt) else expr_object_size (osi, var, then_); + if (object_sizes[object_size_type][varno] == unknown[object_size_type]) + return reexamine; + if (TREE_CODE (else_) == SSA_NAME) reexamine |= merge_object_sizes (osi, var, else_, 0); else diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index d710582a915..e90ae6a89cb 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -338,8 +338,15 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, && (!type || types_compatible_p (TREE_TYPE (gimple_assign_lhs (use_stmt)), type)) - /* We cannot replace a load that may throw or is volatile. */ - && !stmt_can_throw_internal (cfun, use_stmt))) + /* We cannot replace a load that may throw or is volatile. + For volatiles the transform can change the number of + executions if the load is inside a loop but the address + computations outside (PR91812). We could relax this + if we guard against that appropriately. For loads that can + throw we could relax things if the moved loads all are + known to not throw. */ + && !stmt_can_throw_internal (cfun, use_stmt) + && !gimple_has_volatile_ops (use_stmt))) continue; /* Check if we can move the loads. The def stmt of the virtual use diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index c3f2baf39d7..dd6dd8064de 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -605,7 +605,9 @@ switch_conversion::build_one_array (int num, tree arr_index_type, vec<constructor_elt, va_gc> *constructor = m_constructors[num]; wide_int coeff_a, coeff_b; bool linear_p = contains_linear_function_p (constructor, &coeff_a, &coeff_b); - if (linear_p) + tree type; + if (linear_p + && (type = range_check_type (TREE_TYPE ((*constructor)[0].value)))) { if (dump_file && coeff_a.to_uhwi () > 0) fprintf (dump_file, "Linear transformation with A = %" PRId64 @@ -613,13 +615,12 @@ switch_conversion::build_one_array (int num, tree arr_index_type, coeff_b.to_shwi ()); /* We must use type of constructor values. */ - tree t = unsigned_type_for (TREE_TYPE ((*constructor)[0].value)); gimple_seq seq = NULL; - tree tmp = gimple_convert (&seq, t, m_index_expr); - tree tmp2 = gimple_build (&seq, MULT_EXPR, t, - wide_int_to_tree (t, coeff_a), tmp); - tree tmp3 = gimple_build (&seq, PLUS_EXPR, t, tmp2, - wide_int_to_tree (t, coeff_b)); + tree tmp = gimple_convert (&seq, type, m_index_expr); + tree tmp2 = gimple_build (&seq, MULT_EXPR, type, + wide_int_to_tree (type, coeff_a), tmp); + tree tmp3 = gimple_build (&seq, PLUS_EXPR, type, tmp2, + wide_int_to_tree (type, coeff_b)); tree tmp4 = gimple_convert (&seq, TREE_TYPE (name), tmp3); gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); load = gimple_build_assign (name, tmp4); @@ -1350,7 +1351,7 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters) entire)); } else - for (int i = end - 1; i >= start; i--) + for (int i = end - 1; i >= start; i--) output.safe_push (clusters[i]); end = start; @@ -1483,7 +1484,7 @@ bit_test_cluster::emit (tree index_expr, tree index_type, unsigned int i, j, k; unsigned int count; - tree unsigned_index_type = unsigned_type_for (index_type); + tree unsigned_index_type = range_check_type (index_type); gimple_stmt_iterator gsi; gassign *shift_stmt; @@ -1793,7 +1794,8 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> &clusters) tree index_type = TREE_TYPE (index_expr); basic_block bb = gimple_bb (m_switch); - if (gimple_switch_num_labels (m_switch) == 1) + if (gimple_switch_num_labels (m_switch) == 1 + || range_check_type (index_type) == NULL_TREE) return false; /* Find the default case target label. */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 337e078df00..0308b26b808 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6445,10 +6445,13 @@ vectorizable_reduction (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, gcc_assert (TREE_CODE (base) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST); cond_reduc_val = NULL_TREE; + tree res = PHI_RESULT (STMT_VINFO_STMT (cond_stmt_vinfo)); + if (!types_compatible_p (TREE_TYPE (res), TREE_TYPE (base))) + ; /* Find a suitable value, for MAX_EXPR below base, for MIN_EXPR above base; punt if base is the minimum value of the type for MAX_EXPR or maximum value of the type for MIN_EXPR for now. */ - if (tree_int_cst_sgn (step) == -1) + else if (tree_int_cst_sgn (step) == -1) { cond_reduc_op_code = MIN_EXPR; if (tree_int_cst_sgn (base) == -1) diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 17769c88b6a..8263889cbe4 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3279,7 +3279,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, if (!vectype_in) vectype_in = vectypes[i]; else if (vectypes[i] - && vectypes[i] != vectype_in) + && !types_compatible_p (vectypes[i], vectype_in)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -8276,7 +8276,9 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, || alignment_support_scheme == dr_explicit_realign) && !compute_in_loop) { - msq = vect_setup_realignment (first_stmt_info, gsi, &realignment_token, + msq = vect_setup_realignment (first_stmt_info_for_drptr + ? first_stmt_info_for_drptr + : first_stmt_info, gsi, &realignment_token, alignment_support_scheme, NULL_TREE, &at_loop); if (alignment_support_scheme == dr_explicit_realign_optimized) diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index d27104933a9..d89ec3b7c76 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -941,7 +941,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab, fold_loop_internal_call (loop_vectorized_call, boolean_true_node); loop_vectorized_call = NULL; - ret |= TODO_cleanup_cfg; + ret |= TODO_cleanup_cfg | TODO_update_ssa_only_virtuals; } } /* If outer loop vectorization fails for LOOP_VECTORIZED guarded diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 4c9f8853fac..2140101d7d2 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1770,18 +1770,19 @@ extract_range_from_binary_expr (value_range_base *vr, combine_bound (code, wmin, min_ovf, expr_type, min_op0, min_op1); combine_bound (code, wmax, max_ovf, expr_type, max_op0, max_op1); - /* If we have overflow for the constant part and the resulting - range will be symbolic, drop to VR_VARYING. */ - if (((bool)min_ovf && sym_min_op0 != sym_min_op1) - || ((bool)max_ovf && sym_max_op0 != sym_max_op1)) + /* If the resulting range will be symbolic, we need to eliminate any + explicit or implicit overflow introduced in the above computation + because compare_values could make an incorrect use of it. That's + why we require one of the ranges to be a singleton. */ + if ((sym_min_op0 != sym_min_op1 || sym_max_op0 != sym_max_op1) + && ((bool)min_ovf || (bool)max_ovf + || (min_op0 != max_op0 && min_op1 != max_op1))) { vr->set_varying (); return; } /* Adjust the range for possible overflow. */ - min = NULL_TREE; - max = NULL_TREE; set_value_range_with_overflow (type, min, max, expr_type, wmin, wmax, min_ovf, max_ovf); if (type == VR_VARYING) diff --git a/gcc/tree.c b/gcc/tree.c index 337b95a85e2..b20781ce00b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -5936,8 +5936,9 @@ find_decls_types_r (tree *tp, int *ws, void *data) { for (tree *tem = &BLOCK_VARS (t); *tem; ) { - if (TREE_CODE (*tem) != VAR_DECL - || !auto_var_in_fn_p (*tem, DECL_CONTEXT (*tem))) + if (TREE_CODE (*tem) != LABEL_DECL + && (TREE_CODE (*tem) != VAR_DECL + || !auto_var_in_fn_p (*tem, DECL_CONTEXT (*tem)))) { gcc_assert (TREE_CODE (*tem) != RESULT_DECL && TREE_CODE (*tem) != PARM_DECL); @@ -6106,6 +6107,13 @@ find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) { tree arg = gimple_op (stmt, i); find_decls_types (arg, fld); + /* find_decls_types doesn't walk TREE_PURPOSE of TREE_LISTs, + which we need for asm stmts. */ + if (arg + && TREE_CODE (arg) == TREE_LIST + && TREE_PURPOSE (arg) + && gimple_code (stmt) == GIMPLE_ASM) + find_decls_types (TREE_PURPOSE (arg), fld); } } } diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 348c54c0b3e..bbf9b59926b 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,20 @@ +2019-10-15 John David Anglin <danglin@gcc.gnu.org> + + * config/pa/fptr.c (_dl_read_access_allowed): Change argument to + unsigned int. Adjust callers. + (__canonicalize_funcptr_for_compare): Change plabel type to volatile + unsigned int *. Load relocation offset before function pointer. + Add barrier to ensure ordering. + +2019-10-12 John David Anglin <danglin@gcc.gnu.org> + + * config/pa/lib2funcs.S (__gcc_plt_call): Load branch target to %r21. + Load PIC register after branch target. Fix white space. + * config/pa/milli64.S ($$dyncall): Separate LINUX and non LINUX + implementations. Load PIC register after branch target. Don't + clobber function pointer when it points to function descriptor. + Use nullification instead of branch in LINUX implementation. + 2019-08-12 Release Manager * GCC 9.2.0 released. diff --git a/libgcc/config/pa/fptr.c b/libgcc/config/pa/fptr.c index 53440051730..5beb0b832e2 100644 --- a/libgcc/config/pa/fptr.c +++ b/libgcc/config/pa/fptr.c @@ -53,7 +53,7 @@ typedef int (*fixup_t) (struct link_map *, unsigned int); extern unsigned int _GLOBAL_OFFSET_TABLE_; static inline int -_dl_read_access_allowed (unsigned int *addr) +_dl_read_access_allowed (unsigned int addr) { int result; @@ -76,7 +76,8 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) { static unsigned int fixup_plabel[2] __attribute__((used)); fixup_t fixup; - unsigned int *got, *iptr, *plabel; + volatile unsigned int *plabel; + unsigned int *got, *iptr, reloc_offset; int i; /* -1 and page 0 are special. -1 is used in crtend to mark the end of @@ -91,17 +92,20 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) to the entry of the PLT stub just before the global offset table. The second word in the plabel contains the relocation offset for the function. */ - plabel = (unsigned int *) ((unsigned int) fptr & ~3); - if (!_dl_read_access_allowed (plabel)) + plabel = (volatile unsigned int *) ((unsigned int) fptr & ~3); + if (!_dl_read_access_allowed ((unsigned int)plabel)) return (unsigned int) fptr; /* Load first word of candidate descriptor. It should be a pointer with word alignment and point to memory that can be read. */ got = (unsigned int *) plabel[0]; if (((unsigned int) got & 3) != 0 - || !_dl_read_access_allowed (got)) + || !_dl_read_access_allowed ((unsigned int)got)) return (unsigned int) fptr; + /* We need to load the relocation offset before the function address. */ + reloc_offset = plabel[1]; + __sync_synchronize(); got = (unsigned int *) (plabel[0] + GOT_FROM_PLT_STUB); /* Return the address of the function if the plabel has been resolved. */ @@ -137,7 +141,7 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) /* Call fixup to resolve the function address. got[1] contains the link_map pointer and plabel[1] the relocation offset. */ - fixup ((struct link_map *) got[1], plabel[1]); + fixup ((struct link_map *) got[1], reloc_offset); return plabel[0]; } diff --git a/libgcc/config/pa/lib2funcs.S b/libgcc/config/pa/lib2funcs.S index b401b6157da..a2db5b3d3ac 100644 --- a/libgcc/config/pa/lib2funcs.S +++ b/libgcc/config/pa/lib2funcs.S @@ -55,13 +55,13 @@ __gcc_plt_call ; An inline version of dyncall so we don't have to worry ; about long calls to millicode, PIC and other complexities. bb,>=,n %r22,30,L$foo - depi 0,31,2,%r22 - ldw 4(%r22),%r19 - ldw 0(%r22),%r22 + depi 0,31,2,%r22 + ldw 0(%r22),%r21 + ldw 4(%r22),%r19 L$foo - ldsid (%r22),%r1 - mtsp %r1,%sr0 - ble 0(%sr0,%r22) + ldsid (%r21),%r1 + mtsp %r1,%sr0 + ble 0(%sr0,%r21) copy %r31,%r2 ldw -8(%r30),%r2 diff --git a/libgcc/config/pa/milli64.S b/libgcc/config/pa/milli64.S index 1e46f5018b9..36040e9e78d 100644 --- a/libgcc/config/pa/milli64.S +++ b/libgcc/config/pa/milli64.S @@ -222,19 +222,26 @@ GSYM($$dyncall) .proc .callinfo millicode .entry - bb,>=,n %r22,30,LREF(1) ; branch if not plabel address - depi 0,31,2,%r22 ; clear the two least significant bits - ldw 4(%r22),%r19 ; load new LTP value - ldw 0(%r22),%r22 ; load address of target -LSYM(1) #ifdef LINUX - bv %r0(%r22) ; branch to the real target + extru,<> %r22,30,1,%r0 ; nullify if plabel bit set + bv,n %r0(%r22) ; branch to target + ldw -2(%r22),%r21 ; load address of target + bv %r0(%r21) ; branch to the real target + ldw 2(%r22),%r19 ; load new LTP value #else + bb,>=,n %r22,30,LREF(1) ; branch if not plabel address + ldw -2(%r22),%r21 ; load address of target to r21 + ldsid (%sr0,%r21),%r1 ; get the "space ident" selected by r21 + ldw 2(%r22),%r19 ; load new LTP value + mtsp %r1,%sr0 ; move that space identifier into sr0 + be 0(%sr0,%r21) ; branch to the real target + stw %r2,-24(%r30) ; save return address into frame marker +LSYM(1) ldsid (%sr0,%r22),%r1 ; get the "space ident" selected by r22 mtsp %r1,%sr0 ; move that space identifier into sr0 - be 0(%sr0,%r22) ; branch to the real target -#endif + be 0(%sr0,%r22) ; branch to the target stw %r2,-24(%r30) ; save return address into frame marker +#endif .exit .procend #endif diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog index 15f371b36f0..b8f71d6520b 100644 --- a/libquadmath/ChangeLog +++ b/libquadmath/ChangeLog @@ -1,3 +1,12 @@ +2019-10-21 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-08-02 Jakub Jelinek <jakub@redhat.com> + + * quadmath.h (M_Eq, M_LOG2Eq, M_LOG10Eq, M_LN2q, M_LN10q, M_PIq, + M_PI_2q, M_PI_4q, M_1_PIq, M_2_PIq, M_2_SQRTPIq, M_SQRT2q, + M_SQRT1_2q): Use two more decimal places. + 2019-08-12 Release Manager * GCC 9.2.0 released. diff --git a/libquadmath/quadmath.h b/libquadmath/quadmath.h index 76275b51b62..81eb957d2fa 100644 --- a/libquadmath/quadmath.h +++ b/libquadmath/quadmath.h @@ -1,5 +1,5 @@ /* GCC Quad-Precision Math Library - Copyright (C) 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2010-2019 Free Software Foundation, Inc. Written by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> This file is part of the libquadmath library. @@ -165,19 +165,19 @@ extern int quadmath_snprintf (char *str, size_t size, (floating constant exceeds range of ‘__float128’) */ /* #define HUGE_VALQ (__extension__ 0x1.0p32767Q) */ -#define M_Eq 2.7182818284590452353602874713526625Q /* e */ -#define M_LOG2Eq 1.4426950408889634073599246810018921Q /* log_2 e */ -#define M_LOG10Eq 0.4342944819032518276511289189166051Q /* log_10 e */ -#define M_LN2q 0.6931471805599453094172321214581766Q /* log_e 2 */ -#define M_LN10q 2.3025850929940456840179914546843642Q /* log_e 10 */ -#define M_PIq 3.1415926535897932384626433832795029Q /* pi */ -#define M_PI_2q 1.5707963267948966192313216916397514Q /* pi/2 */ -#define M_PI_4q 0.7853981633974483096156608458198757Q /* pi/4 */ -#define M_1_PIq 0.3183098861837906715377675267450287Q /* 1/pi */ -#define M_2_PIq 0.6366197723675813430755350534900574Q /* 2/pi */ -#define M_2_SQRTPIq 1.1283791670955125738961589031215452Q /* 2/sqrt(pi) */ -#define M_SQRT2q 1.4142135623730950488016887242096981Q /* sqrt(2) */ -#define M_SQRT1_2q 0.7071067811865475244008443621048490Q /* 1/sqrt(2) */ +#define M_Eq 2.718281828459045235360287471352662498Q /* e */ +#define M_LOG2Eq 1.442695040888963407359924681001892137Q /* log_2 e */ +#define M_LOG10Eq 0.434294481903251827651128918916605082Q /* log_10 e */ +#define M_LN2q 0.693147180559945309417232121458176568Q /* log_e 2 */ +#define M_LN10q 2.302585092994045684017991454684364208Q /* log_e 10 */ +#define M_PIq 3.141592653589793238462643383279502884Q /* pi */ +#define M_PI_2q 1.570796326794896619231321691639751442Q /* pi/2 */ +#define M_PI_4q 0.785398163397448309615660845819875721Q /* pi/4 */ +#define M_1_PIq 0.318309886183790671537767526745028724Q /* 1/pi */ +#define M_2_PIq 0.636619772367581343075535053490057448Q /* 2/pi */ +#define M_2_SQRTPIq 1.128379167095512573896158903121545172Q /* 2/sqrt(pi) */ +#define M_SQRT2q 1.414213562373095048801688724209698079Q /* sqrt(2) */ +#define M_SQRT1_2q 0.707106781186547524400844362104849039Q /* 1/sqrt(2) */ #define __quadmath_extern_inline \ extern inline __attribute__ ((__gnu_inline__)) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 33e56ea9c8f..2cc882f2da3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,217 @@ +2019-10-24 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2019-05-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/90682 + * libsupc++/eh_term_handler.cc: Include eh_term_handler.h to get + definition of _GLIBCXX_DEFAULT_TERM_HANDLER. + * libsupc++/eh_term_handler.h: New header defining + _GLIBCXX_DEFAULT_TERM_HANDLER. + * libsupc++/eh_terminate.cc: Include eh_term_handler.h. + (set_terminate): Restore default handler when argument is null. + (set_unexpected): Likewise. + * testsuite/18_support/set_terminate.cc: New test. + * testsuite/18_support/set_unexpected.cc: New test. + + Backport from mainline + 2019-05-01 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/61761 + * include/std/complex (__complex_proj): Return parameter unchanged. + [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for + floating-point types to take std::complex arguments. + [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for + floating-point types. + * testsuite/26_numerics/complex/proj.cc: New test. + + Backport from mainline + 2019-06-06 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Add + dg-prune-output for different C++98 diagnostic. + * testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc: + Likewise. + * testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc: + Likewise. + * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: + Likewise. + * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: + Likewise. + * testsuite/23_containers/vector/requirements/dr438/ + constructor_1_neg.cc: Likewise. + * testsuite/23_containers/vector/requirements/dr438/ + constructor_2_neg.cc: Likewise. + * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: + Likewise. + * testsuite/libstdc++-prettyprinters/compat.cc: Do not run for C++98. + + Backport from mainline + 2019-06-06 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/20_util/is_nothrow_invocable/value.cc: Test converting to + void. + * testsuite/experimental/names.cc: Do not run for C++98 mode. Do not + include Library Fundamentals or Networking headers in C++11 mode. + * testsuite/ext/char8_t/atomic-1.cc: Do not run for C++98 mode. + + Backport from mainline + 2019-05-14 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/util/testsuite_allocator.h (memory_resource) + (default_resource_mgr): Fix indentation. + + Backport from mainline + 2019-08-30 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/89164 + * include/bits/stl_algobase.h (__copy_move): Give descriptive names + to template parameters. + * include/bits/stl_uninitialized.h (uninitialized_copy) + (uninitialized_fill, uninitialized_fill_n): Add static assertions to + diagnose invalid uses. + * testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc: + Adjust expected error. + * testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc: + New test. + * testsuite/20_util/specialized_algorithms/uninitialized_copy_n/ + 89164.cc: New test. + * testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc: + New test. + * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/ + 89164.cc: New test. + * testsuite/23_containers/vector/cons/89164.cc: New test. + * testsuite/23_containers/vector/cons/89164_c++17.cc: New test. + + Backport from mainline + 2019-10-22 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/memoryfwd.h (uses_allocator): Do not declare for C++98. + * testsuite/17_intro/names.cc: Check uses_allocator in C++98. + + Backport from mainline + 2019-10-18 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/92143 + * libsupc++/new_opa.cc (operator new) [__APPLE__]: Increase alignment + to at least sizeof(void*). + + Backport from mainline + 2019-06-06 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/23_containers/unordered_map/requirements/debug_container.cc: + Do not test allocator rebinding extension for C++2a. + * testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Change + dg-do directive for C++17 and C++2a. + + Backport from mainline + 2019-05-23 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/20_util/function_objects/invoke/1.cc: Add more tests. + Move C++17-specific tests to ... + * testsuite/20_util/function_objects/invoke/3.cc: New test. + * testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Change + "compile" test to "run". + + Backport from mainline + 2019-10-08 Jonathan Wakely <jwakely@redhat.com> + + * doc/Makefile.am (doc-html-docbook-regenerate): New target. + (${docbook_outdir}/html): Do not create unused 'html/ext' directory. + * doc/Makefile.in: Regenerate. + * doc/xml/manual/documentation_hacking.xml: Document new target. + * doc/html/*: Regenerate. + + * doc/xml/manual/allocator.xml: Use archived copy of CUJ article. + + Backport from mainline + 2019-05-31 Gerald Pfeifer <gerald@pfeifer.com> + + * doc/xml/manual/allocator.xml: Move hoard.org back to http. + + Backport from mainline + 2019-08-15 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/91456 + * include/bits/std_function.h (__check_func_return_type): Remove. + (function::_Callable): Use std::__is_invocable_impl instead of + __check_func_return_type. + * include/std/type_traits (__is_invocable_impl): Add another defaulted + template parameter. Define a separate partial specialization for + INVOKE and INVOKE<void>. For INVOKE<R> replace is_convertible check + with a check that models delayed temporary materialization. + * testsuite/20_util/function/91456.cc: New test. + * testsuite/20_util/is_invocable/91456.cc: New test. + + Backport from mainline + 2019-09-30 Andreas Tobler <andreast@gcc.gnu.org> + + * include/experimental/internet: Include netinet/in.h if we have + _GLIBCXX_HAVE_NETINET_IN_H defined. + + Backport from mainline + 2019-09-26 Jonathan Wakely <jwakely@redhat.com> + + * include/experimental/internet (operator==, operator<): Fix loop + condition to avoid reading past the end of the array. + + Backport from mainline + 2019-08-06 Jonathan Wakely <jwakely@redhat.com> + + P1651R0 bind_front should not unwrap reference_wrapper + * include/std/functional (bind_front): Don't unwrap reference_wrapper. + * include/std/version (__cpp_lib_bind_front): Update value. + * testsuite/20_util/function_objects/bind_front/1.cc: Fix test for + feature test macro. + * testsuite/20_util/function_objects/bind_front/2.cc: New test. + + Backport from mainline + 2019-10-11 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/92059 + * include/tr2/dynamic_bitset (__dynamic_bitset_base): Define all + special member functions as defaulted. Add noexcept to most members. + (__dynamic_bitset_base(size_t, unsigned long long, const _Alloc&)): + Mask off unwanted bits in the __val parameter. Avoid undefined left + shifts. + (__dynamic_bitset_base::_M_assign): Remove. + (__dynamic_bitset_base::_M_do_reset): Use std::fill. + (__dynamic_bitset_base::_M_are_all_aux): Avoid integer promotion when + block_type has lower rank than int. + (dynamic_bitset): Add noexcept to most members. Use injected-class-name + in return types and parameter types. + (dynamic_bitset::_M_Nb): Add default member initializer. + (dynamic_bitset(), dynamic_bitset(const dynamic_bitset&)): Define as + defaulted. + (dynamic_bitset(dynamic_bitset&&)): Clear source object after move. + (dynamic_bitset::operator=(const dynamic_bitset&)): Define as + defaulted. + (dynamic_bitset::operator=(dynamic_bitset&&)): Add noexcept-specifier. + Define without using swap, to propagate allocator correctly. + (dynamic_bitset(const char*, const _Alloc&)): Use strlen. + (dynamic_bitset::_M_do_sanitize, dynamic_bitset::_M_do_fill): Use + casts to avoid unwanted integer promotions. + (dynamic_bitset::_M_copy_from_ptr): Rearrange template parameters and + add default template arguments and default argument to simplify usage. + (dynamic_bitset::_M_copy_from_string): Adjust call to _M_copy_from_ptr. + (operator==(const dynamic_bitset&, const dynamic_bitset&)) + (operator<(const dynamic_bitset&, const dynamic_bitset&)): Use _M_Nb. + * include/tr2/dynamic_bitset.tcc (dynamic_bitset::_M_copy_from_ptr): + Adjust template parameters to match declaration. + * testsuite/tr2/dynamic_bitset/cmp.cc: New test. + * testsuite/tr2/dynamic_bitset/cons.cc: New test. + * testsuite/tr2/dynamic_bitset/copy.cc: New test. + * testsuite/tr2/dynamic_bitset/move.cc: New test. + * testsuite/tr2/dynamic_bitset/pr92059.cc: New test. + 2019-09-12 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/91748 diff --git a/libstdc++-v3/doc/Makefile.am b/libstdc++-v3/doc/Makefile.am index eb8251d10e3..4427e5da6ad 100644 --- a/libstdc++-v3/doc/Makefile.am +++ b/libstdc++-v3/doc/Makefile.am @@ -477,7 +477,6 @@ ${docbook_outdir}/fo: ${docbook_outdir}/html: mkdir -p ${docbook_outdir}/html - mkdir -p ${docbook_outdir}/html/ext mkdir -p ${docbook_outdir}/html/images mkdir -p ${docbook_outdir}/html/manual @@ -546,6 +545,12 @@ stamp-html-docbook: $(xml_sources) ${docbook_outdir}/html doc-html-docbook: stamp-html-docbook-data +# Generate the HTML pages and copy them back to the source tree. +doc-html-docbook-regenerate: doc-html-docbook + $(INSTALL_DATA) ${docbook_outdir}/html/*.html ${top_srcdir}/doc/html + $(INSTALL_DATA) ${docbook_outdir}/html/images/* ${top_srcdir}/doc/html/images + $(INSTALL_DATA) ${docbook_outdir}/html/manual/*.html ${top_srcdir}/doc/html/manual + # HTML, all one page # NB: Have to generate customization XSL for UTF-8 output. manual_html = ${docbook_outdir}/html/libstdc++-manual-single.html diff --git a/libstdc++-v3/doc/Makefile.in b/libstdc++-v3/doc/Makefile.in index 12be1f7e254..1058d5c3cc8 100644 --- a/libstdc++-v3/doc/Makefile.in +++ b/libstdc++-v3/doc/Makefile.in @@ -978,7 +978,6 @@ ${docbook_outdir}/fo: ${docbook_outdir}/html: mkdir -p ${docbook_outdir}/html - mkdir -p ${docbook_outdir}/html/ext mkdir -p ${docbook_outdir}/html/images mkdir -p ${docbook_outdir}/html/manual @@ -1030,6 +1029,12 @@ stamp-html-docbook: $(xml_sources) ${docbook_outdir}/html $(STAMP) stamp-html-docbook doc-html-docbook: stamp-html-docbook-data + +# Generate the HTML pages and copy them back to the source tree. +doc-html-docbook-regenerate: doc-html-docbook + $(INSTALL_DATA) ${docbook_outdir}/html/*.html ${top_srcdir}/doc/html + $(INSTALL_DATA) ${docbook_outdir}/html/images/* ${top_srcdir}/doc/html/images + $(INSTALL_DATA) ${docbook_outdir}/html/manual/*.html ${top_srcdir}/doc/html/manual stamp-html-single-docbook: $(xml_sources) ${docbook_outdir}/html @echo "Generating html single file..." $(XSLTPROC) $(XSLT_PARAM) $(XSLT_FLAGS) -o ${manual_html} \ diff --git a/libstdc++-v3/doc/html/manual/documentation_hacking.html b/libstdc++-v3/doc/html/manual/documentation_hacking.html index fcd7f1e60c5..045556a337b 100644 --- a/libstdc++-v3/doc/html/manual/documentation_hacking.html +++ b/libstdc++-v3/doc/html/manual/documentation_hacking.html @@ -381,11 +381,16 @@ </p><p> </p><pre class="screen"><strong class="userinput"><code>make doc-xml-single-docbook</code></strong></pre><p> </p><p> - Generated files are output into separate sub directores of + Generated files are output into separate sub-directores of <code class="filename">doc/docbook/</code> in the build directory, based on the output format. For instance, the HTML docs will be in <code class="filename">doc/docbook/html</code>. </p><p> + The </p><pre class="screen">doc-html-docbook-regenerate</pre><p> target will generate + the HTML files and copy them back to the libstdc++ source tree. + This can be used to update the HTML files that are checked in to + version control. + </p><p> If the Docbook stylesheets are installed in a custom location, one can use the variable <code class="literal">XSL_STYLE_DIR</code> to override the Makefile defaults. For example: diff --git a/libstdc++-v3/doc/html/manual/memory.html b/libstdc++-v3/doc/html/manual/memory.html index 0330df1dfaf..8a150af50ce 100644 --- a/libstdc++-v3/doc/html/manual/memory.html +++ b/libstdc++-v3/doc/html/manual/memory.html @@ -314,13 +314,13 @@ </em>. </span> isoc++_1998 <span class="pagenums">20.4 Memory. </span></p></div><div class="biblioentry"><a id="id-1.3.4.4.4.3.9.3"></a><p><span class="title"><em> - <a class="link" href="http://www.drdobbs.com/the-standard-librarian-what-are-allocato/184403759" target="_top"> + <a class="link" href="https://web.archive.org/web/20190622154249/http://www.drdobbs.com/the-standard-librarian-what-are-allocato/184403759" target="_top"> The Standard Librarian: What Are Allocators Good For? - </a> - </em>. </span><span class="author"><span class="firstname">Matt</span> <span class="surname">Austern</span>. </span><span class="publisher"><span class="publishername"> + </a> + </em>. </span><span class="author"><span class="firstname">Matt</span> <span class="surname">Austern</span>. </span><span class="publisher"><span class="publishername"> C/C++ Users Journal - . </span></span></p></div><div class="biblioentry"><a id="id-1.3.4.4.4.3.9.4"></a><p><span class="title"><em> - <a class="link" href="https://www.hoard.org" target="_top"> + . </span></span><span class="pubdate">2000-12. </span></p></div><div class="biblioentry"><a id="id-1.3.4.4.4.3.9.4"></a><p><span class="title"><em> + <a class="link" href="http://hoard.org" target="_top"> The Hoard Memory Allocator </a> </em>. </span><span class="author"><span class="firstname">Emery</span> <span class="surname">Berger</span>. </span></p></div><div class="biblioentry"><a id="id-1.3.4.4.4.3.9.5"></a><p><span class="title"><em> diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html index ebae5e34da5..36ec08f34e9 100644 --- a/libstdc++-v3/doc/html/manual/status.html +++ b/libstdc++-v3/doc/html/manual/status.html @@ -1110,11 +1110,12 @@ Feature-testing recommendations for C++</a>. <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0809r0.pdf" target="_top"> P0809R0 </a> - </td><td align="center"> </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Constexpr iterator requirements </td><td align="left"> + </td><td align="center"> </td><td align="left"> </td></tr><tr><td align="left"> Constexpr iterator requirements </td><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0858r0.html" target="_top"> P0858R0 </a> - </td><td align="center"> </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Symmetry for spaceship </td><td align="left"> + </td><td align="center"> 9.1 </td><td align="left"> <code class="code">__cpp_lib_string_view >= 201803L</code> + and <code class="code">__cpp_lib_array_constexpr >= 201803L</code> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> Symmetry for spaceship </td><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0905r1.html" target="_top"> P0905R1 </a> diff --git a/libstdc++-v3/doc/xml/manual/allocator.xml b/libstdc++-v3/doc/xml/manual/allocator.xml index 8d49b919ff6..633d33c5ff1 100644 --- a/libstdc++-v3/doc/xml/manual/allocator.xml +++ b/libstdc++-v3/doc/xml/manual/allocator.xml @@ -499,12 +499,12 @@ </biblioentry> <biblioentry> - <title> - <link xmlns:xlink="http://www.w3.org/1999/xlink" - xlink:href="http://www.drdobbs.com/the-standard-librarian-what-are-allocato/184403759"> + <title> + <link xmlns:xlink="http://www.w3.org/1999/xlink" + xlink:href="https://web.archive.org/web/20190622154249/http://www.drdobbs.com/the-standard-librarian-what-are-allocato/184403759"> The Standard Librarian: What Are Allocators Good For? - </link> - </title> + </link> + </title> <author><personname><firstname>Matt</firstname><surname>Austern</surname></personname></author> <publisher> @@ -512,12 +512,13 @@ C/C++ Users Journal </publishername> </publisher> + <pubdate>2000-12</pubdate> </biblioentry> <biblioentry> <title> <link xmlns:xlink="http://www.w3.org/1999/xlink" - xlink:href="https://www.hoard.org"> + xlink:href="http://hoard.org"> The Hoard Memory Allocator </link> </title> diff --git a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml index fffa1fc775a..043f2fa44dc 100644 --- a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml +++ b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml @@ -805,7 +805,7 @@ </para> <para> - Generated files are output into separate sub directores of + Generated files are output into separate sub-directores of <filename class="directory">doc/docbook/</filename> in the build directory, based on the output format. For instance, the HTML docs will be in <filename @@ -813,6 +813,13 @@ </para> <para> + The <screen>doc-html-docbook-regenerate</screen> target will generate + the HTML files and copy them back to the libstdc++ source tree. + This can be used to update the HTML files that are checked in to + version control. + </para> + + <para> If the Docbook stylesheets are installed in a custom location, one can use the variable <literal>XSL_STYLE_DIR</literal> to override the Makefile defaults. For example: diff --git a/libstdc++-v3/include/bits/memoryfwd.h b/libstdc++-v3/include/bits/memoryfwd.h index 8b1664a398d..732ac805322 100644 --- a/libstdc++-v3/include/bits/memoryfwd.h +++ b/libstdc++-v3/include/bits/memoryfwd.h @@ -66,9 +66,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> class allocator<void>; +#if __cplusplus >= 201103L /// Declare uses_allocator so it can be specialized in \<queue\> etc. template<typename, typename> struct uses_allocator; +#endif /// @} group memory diff --git a/libstdc++-v3/include/bits/std_function.h b/libstdc++-v3/include/bits/std_function.h index b70ed564d11..b59f6978971 100644 --- a/libstdc++-v3/include/bits/std_function.h +++ b/libstdc++-v3/include/bits/std_function.h @@ -359,10 +359,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; - template<typename _From, typename _To> - using __check_func_return_type - = __or_<is_void<_To>, is_same<_From, _To>, is_convertible<_From, _To>>; - /** * @brief Primary class template for std::function. * @ingroup functors @@ -375,8 +371,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION private _Function_base { template<typename _Func, - typename _Res2 = typename result_of<_Func&(_ArgTypes...)>::type> - struct _Callable : __check_func_return_type<_Res2, _Res> { }; + typename _Res2 = __invoke_result<_Func&, _ArgTypes...>> + struct _Callable + : __is_invocable_impl<_Res2, _Res>::type + { }; // Used so the return type convertibility checks aren't done when // performing overload resolution for copy construction/assignment. diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 3b1139401ee..6e9316a24cd 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -301,7 +301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // (2) If we're using random access iterators, then write the loop as // a for loop with an explicit count. - template<bool, bool, typename> + template<bool _IsMove, bool _IsSimple, typename _Category> struct __copy_move { template<typename _II, typename _OI> diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 0d42b253df1..f5ca74329e2 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -122,9 +122,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus < 201103L const bool __assignable = true; #else - // trivial types can have deleted assignment + // Trivial types can have deleted copy constructor, but the std::copy + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType2, decltype(*__first)>::value, + "result type must be constructible from value type of input range"); + typedef typename iterator_traits<_InputIterator>::reference _RefType1; typedef typename iterator_traits<_ForwardIterator>::reference _RefType2; + // Trivial types can have deleted assignment, so using std::copy + // would be ill-formed. Require assignability before using std::copy: const bool __assignable = is_assignable<_RefType2, _RefType1>::value; #endif @@ -186,7 +192,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus < 201103L const bool __assignable = true; #else - // trivial types can have deleted assignment + // Trivial types can have deleted copy constructor, but the std::fill + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill + // would be ill-formed. Require assignability before using std::fill: const bool __assignable = is_copy_assignable<_ValueType>::value; #endif @@ -248,7 +260,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus < 201103L const bool __assignable = true; #else - // trivial types can have deleted assignment + // Trivial types can have deleted copy constructor, but the std::fill + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill + // would be ill-formed. Require assignability before using std::fill: const bool __assignable = is_copy_assignable<_ValueType>::value; #endif return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>:: diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet index 467bdfda3ed..3b397737bb6 100644 --- a/libstdc++-v3/include/experimental/internet +++ b/libstdc++-v3/include/experimental/internet @@ -50,6 +50,9 @@ #ifdef _GLIBCXX_HAVE_ARPA_INET_H # include <arpa/inet.h> // inet_ntop #endif +#ifdef _GLIBCXX_HAVE_NETINET_IN_H +# include <netinet/in.h> // IPPROTO_IP +#endif #ifdef _GLIBCXX_HAVE_NETINET_TCP_H # include <netinet/tcp.h> // TCP_NODELAY #endif @@ -539,7 +542,7 @@ namespace ip const auto& __aa = __a._M_bytes; const auto& __bb = __b._M_bytes; int __i = 0; - for (; __aa[__i] == __bb[__i] && __i < 16; ++__i) + for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i) ; return __i == 16 ? __a.scope_id() == __b.scope_id() : false; } @@ -554,7 +557,7 @@ namespace ip const auto& __aa = __a._M_bytes; const auto& __bb = __b._M_bytes; int __i = 0; - for (; __aa[__i] == __bb[__i] && __i < 16; ++__i) + for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i) ; return __i == 16 ? __a.scope_id() < __b.scope_id() : __aa[__i] < __bb[__i]; } diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 0a4f68bc438..45450e8ca01 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1898,41 +1898,59 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&); + // Generic implementation of std::proj, does not work for infinities. template<typename _Tp> - std::complex<_Tp> + inline std::complex<_Tp> __complex_proj(const std::complex<_Tp>& __z) - { - const _Tp __den = (__z.real() * __z.real() - + __z.imag() * __z.imag() + _Tp(1.0)); - - return std::complex<_Tp>((_Tp(2.0) * __z.real()) / __den, - (_Tp(2.0) * __z.imag()) / __den); - } + { return __z; } #if _GLIBCXX_USE_C99_COMPLEX - inline __complex__ float - __complex_proj(__complex__ float __z) - { return __builtin_cprojf(__z); } - - inline __complex__ double - __complex_proj(__complex__ double __z) - { return __builtin_cproj(__z); } - - inline __complex__ long double - __complex_proj(const __complex__ long double& __z) - { return __builtin_cprojl(__z); } + inline complex<float> + __complex_proj(const complex<float>& __z) + { return __builtin_cprojf(__z.__rep()); } + + inline complex<double> + __complex_proj(const complex<double>& __z) + { return __builtin_cproj(__z.__rep()); } + + inline complex<long double> + __complex_proj(const complex<long double>& __z) + { return __builtin_cprojl(__z.__rep()); } +#elif defined _GLIBCXX_USE_C99_MATH_TR1 + inline complex<float> + __complex_proj(const complex<float>& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex<float>(__builtin_inff(), + __builtin_copysignf(0.0f, __z.imag())); + return __z; + } + + inline complex<double> + __complex_proj(const complex<double>& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex<double>(__builtin_inf(), + __builtin_copysign(0.0, __z.imag())); + return __z; + } + + inline complex<long double> + __complex_proj(const complex<long double>& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex<long double>(__builtin_infl(), + __builtin_copysignl(0.0l, __z.imag())); + return __z; + } +#endif template<typename _Tp> inline std::complex<_Tp> proj(const std::complex<_Tp>& __z) - { return __complex_proj(__z.__rep()); } -#else - template<typename _Tp> - inline std::complex<_Tp> - proj(const std::complex<_Tp>& __z) { return __complex_proj(__z); } -#endif + // Overload for scalars template<typename _Tp> inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type> proj(_Tp __x) diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 8cf2c670648..528452fed40 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -837,7 +837,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #if __cplusplus > 201703L -#define __cpp_lib_bind_front 201902L +#define __cpp_lib_bind_front 201907L template<typename _Fd, typename... _BoundArgs> struct _Bind_front @@ -923,7 +923,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Fn, typename... _Args> using _Bind_front_t - = _Bind_front<decay_t<_Fn>, unwrap_ref_decay_t<_Args>...>; + = _Bind_front<decay_t<_Fn>, decay_t<_Args>...>; template<typename _Fn, typename... _Args> _Bind_front_t<_Fn, _Args...> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 440813dcf76..9bad55829ce 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -2662,14 +2662,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __is_invocable (std::is_invocable for C++11) - template<typename _Result, typename _Ret, typename = void> + // The primary template is used for invalid INVOKE expressions. + template<typename _Result, typename _Ret, + bool = is_void<_Ret>::value, typename = void> struct __is_invocable_impl : false_type { }; + // Used for valid INVOKE and INVOKE<void> expressions. template<typename _Result, typename _Ret> - struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> - : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type + struct __is_invocable_impl<_Result, _Ret, + /* is_void<_Ret> = */ true, + __void_t<typename _Result::type>> + : true_type { }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" + // Used for INVOKE<R> expressions to check the implicit conversion to R. + template<typename _Result, typename _Ret> + struct __is_invocable_impl<_Result, _Ret, + /* is_void<_Ret> = */ false, + __void_t<typename _Result::type>> + { + private: + // The type of the INVOKE expression. + // Unlike declval, this doesn't add_rvalue_reference. + static typename _Result::type _S_get(); + + template<typename _Tp> + static void _S_conv(_Tp); + + // This overload is viable if INVOKE(f, args...) can convert to _Tp. + template<typename _Tp, typename = decltype(_S_conv<_Tp>(_S_get()))> + static true_type + _S_test(int); + + template<typename _Tp> + static false_type + _S_test(...); + + public: + using type = decltype(_S_test<_Ret>(1)); + }; +#pragma GCC diagnostic pop + template<typename _Fn, typename... _ArgTypes> struct __is_invocable : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index a513e09eb2f..3c288301952 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -149,7 +149,7 @@ #if __cplusplus > 201703L // c++2a -#define __cpp_lib_bind_front 201902L +#define __cpp_lib_bind_front 201907L #define __cpp_lib_bounded_array_traits 201902L #if __cpp_impl_destroying_delete # define __cpp_lib_destroying_delete 201806L diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset index 434a4cc87ec..28c877c0484 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset +++ b/libstdc++-v3/include/tr2/dynamic_bitset @@ -34,10 +34,9 @@ #include <limits> #include <vector> #include <string> -#include <memory> // For std::allocator -#include <bits/functexcept.h> // For invalid_argument, out_of_range, - // overflow_error -#include <iosfwd> +#include <istream> +#include <bits/functexcept.h> +#include <bits/stl_algo.h> // For fill #include <bits/cxxabi_forced.h> namespace std _GLIBCXX_VISIBILITY(default) @@ -76,41 +75,48 @@ namespace tr2 std::vector<block_type, allocator_type> _M_w; explicit - __dynamic_bitset_base(const allocator_type& __alloc = allocator_type()) + __dynamic_bitset_base(const allocator_type& __alloc) : _M_w(__alloc) { } - explicit - __dynamic_bitset_base(__dynamic_bitset_base&& __b) - { this->_M_w.swap(__b._M_w); } + __dynamic_bitset_base() = default; + __dynamic_bitset_base(const __dynamic_bitset_base&) = default; + __dynamic_bitset_base(__dynamic_bitset_base&& __b) = default; + __dynamic_bitset_base& operator=(const __dynamic_bitset_base&) = default; + __dynamic_bitset_base& operator=(__dynamic_bitset_base&&) = default; + ~__dynamic_bitset_base() = default; explicit __dynamic_bitset_base(size_type __nbits, unsigned long long __val = 0ULL, const allocator_type& __alloc = allocator_type()) - : _M_w(__nbits / _S_bits_per_block - + (__nbits % _S_bits_per_block > 0), - __val, __alloc) + : _M_w(__nbits / _S_bits_per_block + (__nbits % _S_bits_per_block > 0), + block_type(0), __alloc) { - unsigned long long __mask = ~static_cast<block_type>(0); - size_t __n = std::min(this->_M_w.size(), - sizeof(unsigned long long) / sizeof(block_type)); - for (size_t __i = 0; __i < __n; ++__i) + if (__nbits < std::numeric_limits<decltype(__val)>::digits) + __val &= ~(-1ULL << __nbits); + if (__val == 0) + return; + + if _GLIBCXX17_CONSTEXPR (sizeof(__val) == sizeof(block_type)) + _M_w[0] = __val; + else { - this->_M_w[__i] = (__val & __mask) >> (__i * _S_bits_per_block); - __mask <<= _S_bits_per_block; + const size_t __n + = std::min(_M_w.size(), sizeof(__val) / sizeof(block_type)); + for (size_t __i = 0; __val && __i < __n; ++__i) + { + _M_w[__i] = static_cast<block_type>(__val); + __val >>= _S_bits_per_block; + } } } void - _M_assign(const __dynamic_bitset_base& __b) - { this->_M_w = __b._M_w; } - - void - _M_swap(__dynamic_bitset_base& __b) + _M_swap(__dynamic_bitset_base& __b) noexcept { this->_M_w.swap(__b._M_w); } void - _M_clear() + _M_clear() noexcept { this->_M_w.clear(); } void @@ -129,7 +135,7 @@ namespace tr2 } allocator_type - _M_get_allocator() const + _M_get_allocator() const noexcept { return this->_M_w.get_allocator(); } static size_type @@ -149,23 +155,23 @@ namespace tr2 { return (static_cast<block_type>(1)) << _S_whichbit(__pos); } block_type& - _M_getword(size_type __pos) + _M_getword(size_type __pos) noexcept { return this->_M_w[_S_whichword(__pos)]; } block_type - _M_getword(size_type __pos) const + _M_getword(size_type __pos) const noexcept { return this->_M_w[_S_whichword(__pos)]; } block_type& - _M_hiword() + _M_hiword() noexcept { return this->_M_w[_M_w.size() - 1]; } block_type - _M_hiword() const + _M_hiword() const noexcept { return this->_M_w[_M_w.size() - 1]; } void - _M_do_and(const __dynamic_bitset_base& __x) + _M_do_and(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -175,7 +181,7 @@ namespace tr2 } void - _M_do_or(const __dynamic_bitset_base& __x) + _M_do_or(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -185,7 +191,7 @@ namespace tr2 } void - _M_do_xor(const __dynamic_bitset_base& __x) + _M_do_xor(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -195,7 +201,7 @@ namespace tr2 } void - _M_do_dif(const __dynamic_bitset_base& __x) + _M_do_dif(const __dynamic_bitset_base& __x) noexcept { if (__x._M_w.size() == this->_M_w.size()) for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -211,28 +217,27 @@ namespace tr2 _M_do_right_shift(size_t __shift); void - _M_do_flip() + _M_do_flip() noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) this->_M_w[__i] = ~this->_M_w[__i]; } void - _M_do_set() + _M_do_set() noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) - this->_M_w[__i] = ~static_cast<block_type>(0); + this->_M_w[__i] = static_cast<block_type>(-1); } void - _M_do_reset() + _M_do_reset() noexcept { - for (size_t __i = 0; __i < this->_M_w.size(); ++__i) - this->_M_w[__i] = static_cast<block_type>(0); + std::fill(_M_w.begin(), _M_w.end(), static_cast<block_type>(0)); } bool - _M_is_equal(const __dynamic_bitset_base& __x) const + _M_is_equal(const __dynamic_bitset_base& __x) const noexcept { if (__x._M_w.size() == this->_M_w.size()) { @@ -246,7 +251,7 @@ namespace tr2 } bool - _M_is_less(const __dynamic_bitset_base& __x) const + _M_is_less(const __dynamic_bitset_base& __x) const noexcept { if (__x._M_w.size() == this->_M_w.size()) { @@ -264,17 +269,17 @@ namespace tr2 } size_t - _M_are_all_aux() const + _M_are_all_aux() const noexcept { for (size_t __i = 0; __i < this->_M_w.size() - 1; ++__i) - if (_M_w[__i] != ~static_cast<block_type>(0)) + if (_M_w[__i] != static_cast<block_type>(-1)) return 0; return ((this->_M_w.size() - 1) * _S_bits_per_block + __builtin_popcountll(this->_M_hiword())); } bool - _M_is_any() const + _M_is_any() const noexcept { for (size_t __i = 0; __i < this->_M_w.size(); ++__i) if (this->_M_w[__i] != static_cast<block_type>(0)) @@ -283,7 +288,7 @@ namespace tr2 } bool - _M_is_subset_of(const __dynamic_bitset_base& __b) + _M_is_subset_of(const __dynamic_bitset_base& __b) noexcept { if (__b._M_w.size() == this->_M_w.size()) { @@ -297,7 +302,7 @@ namespace tr2 } bool - _M_is_proper_subset_of(const __dynamic_bitset_base& __b) const + _M_is_proper_subset_of(const __dynamic_bitset_base& __b) const noexcept { if (this->is_subset_of(__b)) { @@ -311,7 +316,7 @@ namespace tr2 } size_t - _M_do_count() const + _M_do_count() const noexcept { size_t __result = 0; for (size_t __i = 0; __i < this->_M_w.size(); ++__i) @@ -357,6 +362,7 @@ namespace tr2 * * See N2050, * Proposal to Add a Dynamically Sizeable Bitset to the Standard Library. + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2050.pdf * * In the general unoptimized case, storage is allocated in * word-sized blocks. Let B be the number of bits in a word, then @@ -435,7 +441,7 @@ namespace tr2 { size_type __shift = this->_M_Nb % bits_per_block; if (__shift > 0) - this->_M_hiword() &= ~((~static_cast<block_type>(0)) << __shift); + this->_M_hiword() &= block_type(~(block_type(-1) << __shift)); } // Set the unused bits in the uppermost word. @@ -444,22 +450,22 @@ namespace tr2 { size_type __shift = this->_M_Nb % bits_per_block; if (__shift > 0) - this->_M_hiword() |= ((~static_cast<block_type>(0)) << __shift); + this->_M_hiword() |= block_type(block_type(-1) << __shift); } /** * These versions of single-bit set, reset, flip, and test * do no range checking. */ - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_set(size_type __pos) + dynamic_bitset& + _M_unchecked_set(size_type __pos) noexcept { this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_set(size_type __pos, int __val) + dynamic_bitset& + _M_unchecked_set(size_type __pos, int __val) noexcept { if (__val) this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); @@ -468,26 +474,26 @@ namespace tr2 return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_reset(size_type __pos) + dynamic_bitset& + _M_unchecked_reset(size_type __pos) noexcept { this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); return *this; } - dynamic_bitset<_WordT, _Alloc>& - _M_unchecked_flip(size_type __pos) + dynamic_bitset& + _M_unchecked_flip(size_type __pos) noexcept { this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); return *this; } bool - _M_unchecked_test(size_type __pos) const + _M_unchecked_test(size_type __pos) const noexcept { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) != static_cast<_WordT>(0)); } - size_type _M_Nb; + size_type _M_Nb = 0; public: /** @@ -511,22 +517,16 @@ namespace tr2 block_type *_M_wp; size_type _M_bpos; - // left undefined - reference(); - public: - reference(dynamic_bitset& __b, size_type __pos) + reference(dynamic_bitset& __b, size_type __pos) noexcept { this->_M_wp = &__b._M_getword(__pos); this->_M_bpos = _Base::_S_whichbit(__pos); } - ~reference() - { } - // For b[i] = __x; reference& - operator=(bool __x) + operator=(bool __x) noexcept { if (__x) *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos); @@ -537,7 +537,7 @@ namespace tr2 // For b[i] = b[__j]; reference& - operator=(const reference& __j) + operator=(const reference& __j) noexcept { if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos))) *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos); @@ -548,16 +548,16 @@ namespace tr2 // Flips the bit bool - operator~() const + operator~() const noexcept { return (*(_M_wp) & _Base::_S_maskbit(this->_M_bpos)) == 0; } // For __x = b[i]; - operator bool() const + operator bool() const noexcept { return (*(this->_M_wp) & _Base::_S_maskbit(this->_M_bpos)) != 0; } // For b[i].flip(); reference& - flip() + flip() noexcept { *this->_M_wp ^= _Base::_S_maskbit(this->_M_bpos); return *this; @@ -569,10 +569,14 @@ namespace tr2 typedef bool const_reference; // 23.3.5.1 constructors: + + /// All bits set to zero. + dynamic_bitset() = default; + /// All bits set to zero. explicit - dynamic_bitset(const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), _M_Nb(0) + dynamic_bitset(const allocator_type& __alloc) + : _Base(__alloc) { } /// Initial bits bitwise-copied from a single word (others set to zero). @@ -585,7 +589,7 @@ namespace tr2 dynamic_bitset(initializer_list<block_type> __il, const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), _M_Nb(0) + : _Base(__alloc) { this->append(__il); } /** @@ -609,8 +613,7 @@ namespace tr2 __n = std::basic_string<_CharT, _Traits, _Alloc1>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'), const allocator_type& __alloc = allocator_type()) - : _Base(__alloc), - _M_Nb(0) // Watch for npos. + : _Base(__alloc) { if (__pos > __str.size()) __throw_out_of_range(__N("dynamic_bitset::bitset initial position " @@ -619,8 +622,7 @@ namespace tr2 // Watch for npos. this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n); this->resize(this->_M_Nb); - this->_M_copy_from_string(__str, __pos, __n, - _CharT('0'), _CharT('1')); + this->_M_copy_from_string(__str, __pos, __n); } /** @@ -633,61 +635,42 @@ namespace tr2 explicit dynamic_bitset(const char* __str, const allocator_type& __alloc = allocator_type()) - : _Base(__alloc) + : _Base(__builtin_strlen(__str), 0ULL, __alloc), + _M_Nb(__builtin_strlen(__str)) { - size_t __len = 0; - if (__str) - while (__str[__len] != '\0') - ++__len; - this->resize(__len); - this->_M_copy_from_ptr<char,std::char_traits<char>> - (__str, __len, 0, __len, '0', '1'); + this->_M_copy_from_ptr(__str, _M_Nb, 0, _M_Nb); } - /** - * @brief Copy constructor. - */ - dynamic_bitset(const dynamic_bitset& __b) - : _Base(__b), _M_Nb(__b.size()) - { } + /// Copy constructor. + dynamic_bitset(const dynamic_bitset&) = default; - /** - * @brief Move constructor. - */ - dynamic_bitset(dynamic_bitset&& __b) - : _Base(std::forward<_Base>(__b)), _M_Nb(__b.size()) - { } + /// Move constructor. + dynamic_bitset(dynamic_bitset&& __b) noexcept + : _Base(std::move(__b)), _M_Nb(__b._M_Nb) + { __b.clear(); } - /** - * @brief Swap with another bitset. - */ + /// Swap with another bitset. void - swap(dynamic_bitset& __b) + swap(dynamic_bitset& __b) noexcept { this->_M_swap(__b); std::swap(this->_M_Nb, __b._M_Nb); } - /** - * @brief Assignment. - */ - dynamic_bitset& - operator=(const dynamic_bitset& __b) - { - if (&__b != this) - { - this->_M_assign(__b); - this->_M_Nb = __b._M_Nb; - } - } + /// Copy assignment operator. + dynamic_bitset& operator=(const dynamic_bitset&) = default; - /** - * @brief Move assignment. - */ + /// Move assignment operator. dynamic_bitset& operator=(dynamic_bitset&& __b) + noexcept(std::is_nothrow_move_assignable<_Base>::value) { - this->swap(__b); + static_cast<_Base&>(*this) = static_cast<_Base&&>(__b); + _M_Nb = __b._M_Nb; + if _GLIBCXX17_CONSTEXPR (std::is_nothrow_move_assignable<_Base>::value) + __b._M_Nb = 0; + else if (get_allocator() == __b.get_allocator()) + __b._M_Nb = 0; return *this; } @@ -695,7 +678,7 @@ namespace tr2 * @brief Return the allocator for the bitset. */ allocator_type - get_allocator() const + get_allocator() const noexcept { return this->_M_get_allocator(); } /** @@ -734,6 +717,8 @@ namespace tr2 ++this->_M_Nb; } + // XXX why is there no pop_back() member in the proposal? + /** * @brief Append a block. */ @@ -770,36 +755,36 @@ namespace tr2 * * These should be self-explanatory. */ - dynamic_bitset<_WordT, _Alloc>& - operator&=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator&=(const dynamic_bitset& __rhs) { this->_M_do_and(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator&=(dynamic_bitset<_WordT, _Alloc>&& __rhs) + dynamic_bitset& + operator&=(dynamic_bitset&& __rhs) { this->_M_do_and(std::move(__rhs)); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator|=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator|=(const dynamic_bitset& __rhs) { this->_M_do_or(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator^=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator^=(const dynamic_bitset& __rhs) { this->_M_do_xor(__rhs); return *this; } - dynamic_bitset<_WordT, _Alloc>& - operator-=(const dynamic_bitset<_WordT, _Alloc>& __rhs) + dynamic_bitset& + operator-=(const dynamic_bitset& __rhs) { this->_M_do_dif(__rhs); return *this; @@ -813,7 +798,7 @@ namespace tr2 * * These should be self-explanatory. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& operator<<=(size_type __pos) { if (__builtin_expect(__pos < this->_M_Nb, 1)) @@ -826,7 +811,7 @@ namespace tr2 return *this; } - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& operator>>=(size_type __pos) { if (__builtin_expect(__pos < this->_M_Nb, 1)) @@ -844,7 +829,7 @@ namespace tr2 /** * @brief Sets every bit to true. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& set() { this->_M_do_set(); @@ -858,7 +843,7 @@ namespace tr2 * @param __val Either true or false, defaults to true. * @throw std::out_of_range If @a __pos is bigger the size of the %set. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& set(size_type __pos, bool __val = true) { if (__pos >= _M_Nb) @@ -869,7 +854,7 @@ namespace tr2 /** * @brief Sets every bit to false. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& reset() { this->_M_do_reset(); @@ -883,7 +868,7 @@ namespace tr2 * * Same as writing @c set(__pos, false). */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& reset(size_type __pos) { if (__pos >= _M_Nb) @@ -894,7 +879,7 @@ namespace tr2 /** * @brief Toggles every bit to its opposite value. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& flip() { this->_M_do_flip(); @@ -907,7 +892,7 @@ namespace tr2 * @param __pos The index of the bit. * @throw std::out_of_range If @a __pos is bigger the size of the %set. */ - dynamic_bitset<_WordT, _Alloc>& + dynamic_bitset& flip(size_type __pos) { if (__pos >= _M_Nb) @@ -916,7 +901,7 @@ namespace tr2 } /// See the no-argument flip(). - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator~() const { return dynamic_bitset<_WordT, _Alloc>(*this).flip(); } @@ -978,19 +963,23 @@ namespace tr2 } // Helper functions for string operations. - template<typename _CharT, typename _Traits> + template<typename _Traits = std::char_traits<char>, + typename _CharT = typename _Traits::char_type> void _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, - _CharT, _CharT); + _CharT __zero = _CharT('0'), + _CharT __one = _CharT('1')); template<typename _CharT, typename _Traits, typename _Alloc1> void - _M_copy_from_string(const std::basic_string<_CharT, - _Traits, _Alloc1>& __str, size_t __pos, size_t __n, + _M_copy_from_string(const basic_string<_CharT, _Traits, _Alloc1>& __str, + size_t __pos, size_t __n, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) - { _M_copy_from_ptr<_CharT, _Traits>(__str.data(), __str.size(), - __pos, __n, __zero, __one); } + { + _M_copy_from_ptr<_Traits>(__str.data(), __str.size(), __pos, __n, + __zero, __one); + } template<typename _CharT, typename _Traits, typename _Alloc1> void @@ -1065,13 +1054,13 @@ namespace tr2 //@{ /// Self-explanatory. - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator<<(size_type __pos) const - { return dynamic_bitset<_WordT, _Alloc>(*this) <<= __pos; } + { return dynamic_bitset(*this) <<= __pos; } - dynamic_bitset<_WordT, _Alloc> + dynamic_bitset operator>>(size_type __pos) const - { return dynamic_bitset<_WordT, _Alloc>(*this) >>= __pos; } + { return dynamic_bitset(*this) >>= __pos; } //@} /** @@ -1102,14 +1091,14 @@ namespace tr2 { return this->_M_is_proper_subset_of(__b); } friend bool - operator==(const dynamic_bitset<_WordT, _Alloc>& __lhs, - const dynamic_bitset<_WordT, _Alloc>& __rhs) - { return __lhs._M_is_equal(__rhs); } + operator==(const dynamic_bitset& __lhs, + const dynamic_bitset& __rhs) noexcept + { return __lhs._M_Nb == __rhs._M_Nb && __lhs._M_is_equal(__rhs); } friend bool - operator<(const dynamic_bitset<_WordT, _Alloc>& __lhs, - const dynamic_bitset<_WordT, _Alloc>& __rhs) - { return __lhs._M_is_less(__rhs); } + operator<(const dynamic_bitset& __lhs, + const dynamic_bitset& __rhs) noexcept + { return __lhs._M_is_less(__rhs) || __lhs._M_Nb < __rhs._M_Nb; } }; template<typename _WordT, typename _Alloc> diff --git a/libstdc++-v3/include/tr2/dynamic_bitset.tcc b/libstdc++-v3/include/tr2/dynamic_bitset.tcc index 8228d7bc472..bbd2cb3bb04 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset.tcc +++ b/libstdc++-v3/include/tr2/dynamic_bitset.tcc @@ -174,7 +174,7 @@ namespace tr2 // Definitions of non-inline member functions. template<typename _WordT, typename _Alloc> - template<typename _CharT, typename _Traits> + template<typename _Traits, typename _CharT> void dynamic_bitset<_WordT, _Alloc>:: _M_copy_from_ptr(const _CharT* __str, size_t __len, diff --git a/libstdc++-v3/libsupc++/eh_term_handler.cc b/libstdc++-v3/libsupc++/eh_term_handler.cc index 6a368c0699e..4b330bc9177 100644 --- a/libstdc++-v3/libsupc++/eh_term_handler.cc +++ b/libstdc++-v3/libsupc++/eh_term_handler.cc @@ -24,21 +24,8 @@ #include <bits/c++config.h> #include "unwind-cxx.h" +#include "eh_term_handler.h" -/* We default to the talkative, informative handler in a normal hosted - library. This pulls in the demangler, the dyn-string utilities, and - elements of the I/O library. For a low-memory environment, you can return - to the earlier "silent death" handler by configuring GCC with - --disable-libstdcxx-verbose and rebuilding the library. - In a freestanding environment, we default to this latter approach. */ - -#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE && __cpp_exceptions /* The current installed user handler. */ std::terminate_handler __cxxabiv1::__terminate_handler = - __gnu_cxx::__verbose_terminate_handler; -#else -# include <cstdlib> -/* The current installed user handler. */ -std::terminate_handler __cxxabiv1::__terminate_handler = std::abort; -#endif - + _GLIBCXX_DEFAULT_TERM_HANDLER; diff --git a/libstdc++-v3/libsupc++/eh_term_handler.h b/libstdc++-v3/libsupc++/eh_term_handler.h new file mode 100644 index 00000000000..e4774bdf9c5 --- /dev/null +++ b/libstdc++-v3/libsupc++/eh_term_handler.h @@ -0,0 +1,39 @@ +// -*- C++ -*- default std::terminate handler +// Copyright (C) 2002-2019 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> + +/* We default to the talkative, informative handler in a normal hosted + library. This pulls in the demangler, the dyn-string utilities, and + elements of the I/O library. For a low-memory environment, you can return + to the earlier "silent death" handler by configuring GCC with + --disable-libstdcxx-verbose and rebuilding the library. + In a freestanding environment, we default to this latter approach. */ + +#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE && __cpp_exceptions +# define _GLIBCXX_DEFAULT_TERM_HANDLER __gnu_cxx::__verbose_terminate_handler +#else +# include <cstdlib> +# define _GLIBCXX_DEFAULT_TERM_HANDLER std::abort +#endif diff --git a/libstdc++-v3/libsupc++/eh_terminate.cc b/libstdc++-v3/libsupc++/eh_terminate.cc index 6acae0593ac..d5f24ea1000 100644 --- a/libstdc++-v3/libsupc++/eh_terminate.cc +++ b/libstdc++-v3/libsupc++/eh_terminate.cc @@ -26,6 +26,7 @@ #include "exception" #include <cstdlib> #include "unwind-cxx.h" +#include "eh_term_handler.h" #include <bits/exception_defines.h> #include <bits/atomic_lockfree_defines.h> @@ -73,6 +74,9 @@ std::unexpected () std::terminate_handler std::set_terminate (std::terminate_handler func) throw() { + if (!func) + func = _GLIBCXX_DEFAULT_TERM_HANDLER; + std::terminate_handler old; #if ATOMIC_POINTER_LOCK_FREE > 1 __atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL); @@ -100,6 +104,9 @@ std::get_terminate () noexcept std::unexpected_handler std::set_unexpected (std::unexpected_handler func) throw() { + if (!func) + func = std::terminate; + std::unexpected_handler old; #if ATOMIC_POINTER_LOCK_FREE > 1 __atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL); diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc index 0303ecde6bd..8143c129bc6 100644 --- a/libstdc++-v3/libsupc++/new_opa.cc +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -114,9 +114,10 @@ operator new (std::size_t sz, std::align_val_t al) sz = 1; #if _GLIBCXX_HAVE_ALIGNED_ALLOC -# ifdef _AIX +# if defined _AIX || defined __APPLE__ /* AIX 7.2.0.0 aligned_alloc incorrectly has posix_memalign's requirement - * that alignment is a multiple of sizeof(void*). */ + * that alignment is a multiple of sizeof(void*). + * OS X 10.15 has the same requirement. */ if (align < sizeof(void*)) align = sizeof(void*); # endif diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 66c639ff3a3..a47d53503e3 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -100,6 +100,10 @@ #define tmp ( +#if __cplusplus < 201103L +#define uses_allocator ( +#endif + #if __cplusplus < 201703L // <charconv> defines to_chars_result::ptr and to_chars_result::ec #define ec ( diff --git a/libstdc++-v3/testsuite/18_support/set_terminate.cc b/libstdc++-v3/testsuite/18_support/set_terminate.cc new file mode 100644 index 00000000000..81f182a7a76 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/set_terminate.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2019 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-options "-std=gnu++11" } +// { dg-do run } + +#include <exception> +#include <testsuite_hooks.h> + +void term_handler() { __builtin_abort(); } + +void +test01() +{ + const std::terminate_handler orig = std::get_terminate(); + VERIFY( orig != 0 ); // GNU-specific behaviour + + std::terminate_handler prev = std::set_terminate(term_handler); + VERIFY( std::get_terminate() == term_handler ); + VERIFY( prev == orig ); + + prev = std::set_terminate(orig); + VERIFY( std::get_terminate() == orig ); + VERIFY( prev == term_handler ); +} + +void +test02() +{ + // PR libstdc++/90682 + std::set_terminate(0); // Undefined in C++98, unspecified in C++11 and later + const std::terminate_handler dfault = std::get_terminate(); + VERIFY( dfault != 0 ); // GNU-specific behaviour + const std::terminate_handler prev = std::set_terminate(0); + VERIFY( prev == dfault ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/18_support/set_unexpected.cc b/libstdc++-v3/testsuite/18_support/set_unexpected.cc new file mode 100644 index 00000000000..7c3f3d44790 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/set_unexpected.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2019 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-options "-std=gnu++11" } +// { dg-do run { target { c++11_only || c++14_only } } } + +#include <exception> +#include <testsuite_hooks.h> + +void unex_handler() { __builtin_abort(); } + +void +test01() +{ + const std::unexpected_handler orig = std::get_unexpected(); + VERIFY( orig == std::terminate ); // GNU-specific behaviour + + std::unexpected_handler prev = std::set_unexpected(unex_handler); + VERIFY( std::get_unexpected() == unex_handler ); + VERIFY( prev == orig ); + + prev = std::set_unexpected(orig); + VERIFY( std::get_unexpected() == orig ); + VERIFY( prev == unex_handler ); +} + +void +test02() +{ + // PR libstdc++/90682 + std::set_unexpected(0); // Undefined in C++98, unspecified in C++11 and C++14 + const std::unexpected_handler dfault = std::get_unexpected(); + VERIFY( dfault == std::terminate ); // GNU-specific behaviour + const std::unexpected_handler prev = std::set_unexpected(0); + VERIFY( prev == dfault ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/20_util/function/91456.cc b/libstdc++-v3/testsuite/20_util/function/91456.cc new file mode 100644 index 00000000000..a2d412d7bec --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/91456.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <functional> + +struct Immovable { + Immovable() = default; + Immovable(const Immovable&) = delete; + Immovable& operator=(const Immovable&) = delete; +}; + +Immovable get() { return {}; } +const Immovable i = get(); // OK +std::function<const Immovable()> f{&get}; // fails +const Immovable i2 = f(); + +const Immovable cget() { return {}; } +Immovable ci = cget(); // OK +std::function<Immovable()> cf{&cget}; // fails +Immovable ci2 = cf(); diff --git a/libstdc++-v3/testsuite/20_util/function_objects/bind_front/1.cc b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/1.cc index 8ebc2bab41a..c6cf5cf2baf 100644 --- a/libstdc++-v3/testsuite/20_util/function_objects/bind_front/1.cc +++ b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/1.cc @@ -23,7 +23,7 @@ #ifndef __cpp_lib_bind_front # error "Feature test macro for bind_front is missing" -#elif __cpp_lib_bind_front < 201811L +#elif __cpp_lib_bind_front < 201902L # error "Feature test macro for bind_front has wrong value" #endif diff --git a/libstdc++-v3/testsuite/20_util/function_objects/bind_front/2.cc b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/2.cc new file mode 100644 index 00000000000..b68cc65f719 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/2.cc @@ -0,0 +1,91 @@ +// Copyright (C) 2019 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-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include <functional> +#include <memory> +#include <string> +#include <testsuite_hooks.h> + +// P1651R0 bind_front should not unwrap reference_wrapper + +#ifndef __cpp_lib_bind_front +# error "Feature test macro for bind_front is missing" +#elif __cpp_lib_bind_front < 201907L +# error "Feature test macro for bind_front has wrong value" +#endif + +void functionAcceptingStringView(std::string_view) { } + +void +test01() +{ + std::string s; + auto fs = std::bind_front(&functionAcceptingStringView, std::string_view(s)); + fs(); +} + +template <typename F> +struct PartialApply { + PartialApply(F f) : f(f) {} + F f; + + template <typename... A> decltype(auto) operator()(A const&... a) const { + if constexpr (std::is_invocable<F const&, A const&...>::value) { + return f(a...); + } else { + return bind_front(*this, a...); + } + } +}; + +void +test02() +{ + struct Thingy { }; + std::unique_ptr<Thingy> thingy; + auto func = [](const std::unique_ptr<Thingy>&, int) {}; + PartialApply{func}(std::ref(thingy))(10); +} + +void +test03() +{ + std::string str; + auto func = [](const std::string& s, int) -> const std::string& { return s; }; + + // sref refers to copy of str stored in bind_front result: + const std::string& sref = PartialApply{func}(std::ref(str))(10); + + // pre-P1651R0 this is a use of a dangling reference: + const char& c = sref[0]; + + // post-P1651R0 the bind_front result stores a reference_wrapper by value, + // and so sref is bound to str instead of dangling: + VERIFY( &c == str.data() ); + VERIFY( &sref == &str ); +} + +int +main() +{ + test01(); + test02(); + test03(); +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc b/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc index e6a4a2ac560..fe8d681e87b 100644 --- a/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc +++ b/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc @@ -24,7 +24,18 @@ struct abstract { void operator()() noexcept; }; -static_assert( noexcept(std::__invoke(std::declval<abstract>())), "" ); -#if __cpp_lib_invoke -static_assert( noexcept(std::invoke(std::declval<abstract>())), "" ); -#endif +static_assert( noexcept(std::__invoke(std::declval<abstract>())), + "It should be possible to use abstract types with INVOKE" ); + +struct F { + void operator()() &; + void operator()() && noexcept; + int operator()(int); + double* operator()(int, int) noexcept; +}; +struct D { D(void*); }; + +static_assert( !noexcept(std::__invoke(std::declval<F&>())), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>())), "" ); +static_assert( !noexcept(std::__invoke(std::declval<F>(), 1)), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>(), 1, 2)), "" ); diff --git a/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc b/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc new file mode 100644 index 00000000000..74999eca0c3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2016-2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <functional> + +struct abstract { + virtual ~abstract() = 0; + void operator()() noexcept; +}; + +static_assert( noexcept(std::__invoke(std::declval<abstract>())), + "It should be possible to use abstract types with INVOKE" ); +static_assert( noexcept(std::invoke(std::declval<abstract>())), + "It should be possible to use abstract types with INVOKE" ); + +struct F { + void operator()() &; + void operator()() && noexcept; + int operator()(int); + double* operator()(int, int) noexcept; +}; +struct D { D(void*); }; + +static_assert( !noexcept(std::__invoke(std::declval<F&>())), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>())), "" ); +static_assert( !noexcept(std::__invoke(std::declval<F>(), 1)), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>(), 1, 2)), "" ); + +static_assert( !noexcept(std::invoke(std::declval<F&>())), "" ); +static_assert( noexcept(std::invoke(std::declval<F>())), "" ); +static_assert( !noexcept(std::invoke(std::declval<F>(), 1)), "" ); +static_assert( noexcept(std::invoke(std::declval<F>(), 1, 2)), "" ); diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc b/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc new file mode 100644 index 00000000000..d510d221a7d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <type_traits> + +#include <functional> + +struct Immovable { + Immovable() = default; + Immovable(const Immovable&) = delete; + Immovable& operator=(const Immovable&) = delete; +}; + +Immovable get() { return {}; } +const Immovable i = get(); // OK +std::function<const Immovable()> f{&get}; // fails +const Immovable i2 = f(); diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value.cc index 0a365a910fc..24ab3d786ec 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value.cc @@ -119,9 +119,11 @@ void test01() static_assert( ! is_nt_invocable_r< T, F >(), "call throws"); static_assert( ! is_nt_invocable_r< NT, F >(), "call throws"); static_assert( ! is_nt_invocable_r< Ex, F >(), "call throws"); + static_assert( ! is_nt_invocable_r< void, F >(), "call throws"); static_assert( ! is_nt_invocable_r< T, CF >(), "conversion throws"); static_assert( is_nt_invocable_r< NT, CF >(), "" ); static_assert( ! is_nt_invocable_r< Ex, CF >(), "conversion fails"); + static_assert( is_nt_invocable_r< void, CF >(), ""); static_assert( ! is_nt_invocable< F, int >(), "call throws"); static_assert( is_nt_invocable< F&, int >(), ""); @@ -140,12 +142,14 @@ void test01() static_assert( is_nt_invocable_r< char&, CF, int >(), ""); static_assert( is_nt_invocable_r< char&, CF&, int >(), ""); + static_assert( is_nt_invocable_r< void, CF&, int >(), ""); static_assert( ! is_nt_invocable_r< T, CF&, int >(), "conversion throws"); static_assert( is_nt_invocable_r< NT, CF&, int >(), ""); static_assert( ! is_nt_invocable_r< Ex, CF&, int >(), "conversion fails, would use explicit constructor"); + static_assert( is_nt_invocable_r< void, CF&, int >(), ""); static_assert( ! is_nt_invocable< F, int, int >(), "would call private member"); diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc index d3b82107217..22b9805612f 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc @@ -34,4 +34,4 @@ test01(T* result) T t[1]; std::uninitialized_copy(t, t+1, result); // { dg-error "here" } } -// { dg-prune-output "use of deleted function" } +// { dg-error "constructible from value" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc new file mode 100644 index 00000000000..fa1ae59e664 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2019 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 <vector> + +// PR libstdc++/89164 + +struct X +{ + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x[1]; + alignas(X) unsigned char buf[sizeof(X)]; + X* p = (X*)buf; + + std::uninitialized_copy(x, x+1, p); // { dg-error "here" } +} +// { dg-error "must be constructible" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/89164.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/89164.cc new file mode 100644 index 00000000000..361a7989bbf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/89164.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2019 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 <vector> + +struct X { + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x[1]; + alignas(X) unsigned char buf[sizeof(X)]; + X* p = (X*)buf; + + std::uninitialized_copy_n(x, 1, p); // { dg-error "here" } +} +// { dg-error "must be constructible" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc new file mode 100644 index 00000000000..8634c8044aa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2019 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 <vector> + +struct X { + X() = default; + X(const X&) = delete; +}; + +void f() +{ + X x; + alignas(X) unsigned char buf[sizeof(X)]; + X* p = (X*)buf; + + std::uninitialized_fill(p, p+1, x); // { dg-error "here" } +} +// { dg-error "must be constructible" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/89164.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/89164.cc new file mode 100644 index 00000000000..a2d7dc7a338 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/89164.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2019 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 <vector> + +struct X { + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x; + alignas(X) unsigned char buf[sizeof(X)]; + X* p = (X*)buf; + + std::uninitialized_fill_n(p, 1, x); // { dg-error "here" } +} +// { dg-error "must be constructible" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index 0be1e965103..fdb03865e3d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_assign" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index d99bd63abb5..1cb8cf1a7ec 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index 9962bbfa225..4d3c9b31434 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index 8051196011b..83ee4492ff3 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_insert" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index a3da00b03e9..a4dd34d8a6d 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_assign" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index fc8d48fb934..4cb886c3006 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index 0fccc43192f..b186b067cc3 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index 86a1b3c53a0..e617e67d5df 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc index d6afae9c2e9..903802878d7 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc @@ -30,7 +30,7 @@ template class __gnu_debug::unordered_map<string, float>; template class __gnu_debug::unordered_map<string, int, hash<string>, equal_to<string>, allocator<pair<const string, int>>>; -#ifndef __STRICT_ANSI__ +#if !defined __STRICT_ANSI__ && __cplusplus <= 201703L template class __gnu_debug::unordered_map<string, float, hash<string>, equal_to<string>, allocator<char>>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc index 707e6d27d00..b7a63c5e393 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc @@ -15,7 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do compile { target c++11 } } +// { dg-do run { target { c++11_only || c++14_only } } } +// { dg-do compile { target c++17 } } #include <unordered_set> #include <memory> diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/89164.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/89164.cc new file mode 100644 index 00000000000..e280731403b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/89164.cc @@ -0,0 +1,40 @@ +// Copyright (C) 2019 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 <vector> + +// PR libstdc++/89164 + +struct X +{ + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x[1]; + // Should not be able to create vector using uninitialized_copy: + std::vector<X> v1{x, x+1}; // { dg-error "here" } + + // Should not be able to create vector using uninitialized_fill_n: + std::vector<X> v2{2u, X{}}; // { dg-error "here" } +} +// { dg-error "constructible from value" "" { target *-*-* } 0 } +// { dg-error "constructible from input" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc new file mode 100644 index 00000000000..db7d8d5c850 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <vector> + +// PR libstdc++/89164 + +struct X +{ + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x[1]; + // Should not be able to create vector using uninitialized_copy: + std::vector<X> v1{x, x+1}; // { dg-error "here" } + + // Should not be able to create vector using uninitialized_fill_n: + std::vector<X> v2{2u, X{}}; // { dg-error "here" } +} + +void test02() +{ +#if __cplusplus >= 201703L + // Can create initializer_list<X> with C++17 guaranteed copy elision, + // but shouldn't be able to copy from it with uninitialized_copy: + std::vector<X> v3{X{}, X{}, X{}}; // { dg-error "here" } +#endif +} +// { dg-error "constructible from value" "" { target *-*-* } 0 } +// { dg-error "constructible from input" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc index ae825128c58..397445612c5 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_assign" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc index 2794cae0935..f78f750cf5a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc index f8fe1d6618e..4d1b774d75c 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_initialize" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc index 55fcc00bc51..fee6d70c3c1 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -18,6 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } +// { dg-prune-output "cannot convert" } // { dg-prune-output "no matching function .*_M_fill_insert" } #include <vector> diff --git a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc new file mode 100644 index 00000000000..64e0dec7129 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc @@ -0,0 +1,403 @@ +// Copyright (C) 2019 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 <complex> +#include <limits> +#include <testsuite_hooks.h> + +namespace test +{ +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + using std::copysign; +#else + bool copysign(float x, float y) + { return __builtin_copysignf(x, y); } + + bool copysign(double x, double y) + { return __builtin_copysign(x, y); } + + bool copysign(long double x, long double y) + { return __builtin_copysignl(x, y); } +#endif +} + +template<typename T> +bool eq(const std::complex<T>& x, const std::complex<T>& y) +{ + bool nan_reals = std::isnan(x.real()) && std::isnan(y.real()); + bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag()); + + bool sign_reals + = test::copysign(T(1), x.real()) == test::copysign(T(1), y.real()); + bool sign_imags + = test::copysign(T(1), x.imag()) == test::copysign(T(1), y.imag()); + + return ((x.real() == y.real() && sign_reals) || nan_reals) + && ((x.imag() == y.imag() && sign_imags) || nan_imags); +} + +void +test01() +{ + const double qnan = std::numeric_limits<double>::quiet_NaN(); + const double pinf = std::numeric_limits<double>::infinity(); + const double ninf = -pinf; + + std::complex<double> c00(0, 0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + + const std::complex<double> c01(0, 1); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + + const std::complex<double> c10(1, 0); + VERIFY( eq( std::proj(c10) , c10 ) ); + VERIFY( eq( std::proj(-c10) , -c10 ) ); + + const std::complex<double> c12(1, 2); + VERIFY( eq( std::proj(c12) , c12 ) ); + VERIFY( eq( std::proj(-c12) , -c12 ) ); + + const std::complex<double> c0q(0, qnan); + VERIFY( eq( std::proj(c0q) , c0q ) ); + VERIFY( eq( std::proj(-c0q) , -c0q ) ); + + const std::complex<double> c1q(1, qnan); + VERIFY( eq( std::proj(c1q) , c1q ) ); + VERIFY( eq( std::proj(-c1q) , -c1q ) ); + + const std::complex<double> cq0(qnan, 0); + VERIFY( eq( std::proj(cq0) , cq0 ) ); + VERIFY( eq( std::proj(-cq0) , -cq0 ) ); + + const std::complex<double> cq1(qnan, 1); + VERIFY( eq( std::proj(cq1) , cq1 ) ); + VERIFY( eq( std::proj(-cq1) , -cq1 ) ); + + const std::complex<double> cqq(qnan, qnan); + VERIFY( eq( std::proj(cqq) , cqq ) ); + VERIFY( eq( std::proj(-cqq) , -cqq ) ); + + const std::complex<double> c0p(0, pinf); + VERIFY( eq( std::proj(c0p) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c0p) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> c1p(1, pinf); + VERIFY( eq( std::proj(c1p) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c1p) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cqp(qnan, pinf); + VERIFY( eq( std::proj(cqp) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cqp) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cpp(pinf, pinf); + VERIFY( eq( std::proj(cpp) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpp) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> c0n(0, ninf); + VERIFY( eq( std::proj(c0n) , std::complex<double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c0n) , std::complex<double>(pinf, +0.0) ) ); + + const std::complex<double> c1n(1, ninf); + VERIFY( eq( std::proj(c1n) , std::complex<double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c1n) , std::complex<double>(pinf, +0.0) ) ); + + const std::complex<double> cqn(qnan, ninf); + VERIFY( eq( std::proj(cqn) , std::complex<double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cqn) , std::complex<double>(pinf, +0.0) ) ); + + const std::complex<double> cpn(pinf, ninf); + VERIFY( eq( std::proj(cpn) , std::complex<double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cpn) , std::complex<double>(pinf, +0.0) ) ); + + const std::complex<double> cnn(ninf, ninf); + VERIFY( eq( std::proj(cnn) , std::complex<double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cnn) , std::complex<double>(pinf, +0.0) ) ); + + const std::complex<double> cp0(pinf, 0); + VERIFY( eq( std::proj(cp0) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp0) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cp1(pinf, 1); + VERIFY( eq( std::proj(cp1) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp1) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cpq(pinf, qnan); + VERIFY( eq( std::proj(cpq) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpq) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cn0(ninf, 0); + VERIFY( eq( std::proj(cn0) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn0) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cn1(ninf, 1); + VERIFY( eq( std::proj(cn1) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn1) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cnq(ninf, qnan); + VERIFY( eq( std::proj(cnq) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnq) , std::complex<double>(pinf, -0.0) ) ); + + const std::complex<double> cnp(ninf, pinf); + VERIFY( eq( std::proj(cnp) , std::complex<double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnp) , std::complex<double>(pinf, -0.0) ) ); +} + +void +test02() +{ + const float qnan = std::numeric_limits<float>::quiet_NaN(); + const float pinf = std::numeric_limits<float>::infinity(); + const float ninf = -pinf; + + std::complex<float> c00(0, 0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + + const std::complex<float> c01(0, 1); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + + const std::complex<float> c10(1, 0); + VERIFY( eq( std::proj(c10) , c10 ) ); + VERIFY( eq( std::proj(-c10) , -c10 ) ); + + const std::complex<float> c12(1, 2); + VERIFY( eq( std::proj(c12) , c12 ) ); + VERIFY( eq( std::proj(-c12) , -c12 ) ); + + const std::complex<float> c0q(0, qnan); + VERIFY( eq( std::proj(c0q) , c0q ) ); + VERIFY( eq( std::proj(-c0q) , -c0q ) ); + + const std::complex<float> c1q(1, qnan); + VERIFY( eq( std::proj(c1q) , c1q ) ); + VERIFY( eq( std::proj(-c1q) , -c1q ) ); + + const std::complex<float> cq0(qnan, 0); + VERIFY( eq( std::proj(cq0) , cq0 ) ); + VERIFY( eq( std::proj(-cq0) , -cq0 ) ); + + const std::complex<float> cq1(qnan, 1); + VERIFY( eq( std::proj(cq1) , cq1 ) ); + VERIFY( eq( std::proj(-cq1) , -cq1 ) ); + + const std::complex<float> cqq(qnan, qnan); + VERIFY( eq( std::proj(cqq) , cqq ) ); + VERIFY( eq( std::proj(-cqq) , -cqq ) ); + + const std::complex<float> c0p(0, pinf); + VERIFY( eq( std::proj(c0p) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c0p) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> c1p(1, pinf); + VERIFY( eq( std::proj(c1p) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c1p) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cqp(qnan, pinf); + VERIFY( eq( std::proj(cqp) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cqp) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cpp(pinf, pinf); + VERIFY( eq( std::proj(cpp) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpp) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> c0n(0, ninf); + VERIFY( eq( std::proj(c0n) , std::complex<float>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c0n) , std::complex<float>(pinf, +0.0) ) ); + + const std::complex<float> c1n(1, ninf); + VERIFY( eq( std::proj(c1n) , std::complex<float>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c1n) , std::complex<float>(pinf, +0.0) ) ); + + const std::complex<float> cqn(qnan, ninf); + VERIFY( eq( std::proj(cqn) , std::complex<float>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cqn) , std::complex<float>(pinf, +0.0) ) ); + + const std::complex<float> cpn(pinf, ninf); + VERIFY( eq( std::proj(cpn) , std::complex<float>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cpn) , std::complex<float>(pinf, +0.0) ) ); + + const std::complex<float> cnn(ninf, ninf); + VERIFY( eq( std::proj(cnn) , std::complex<float>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cnn) , std::complex<float>(pinf, +0.0) ) ); + + const std::complex<float> cp0(pinf, 0); + VERIFY( eq( std::proj(cp0) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp0) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cp1(pinf, 1); + VERIFY( eq( std::proj(cp1) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp1) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cpq(pinf, qnan); + VERIFY( eq( std::proj(cpq) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpq) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cn0(ninf, 0); + VERIFY( eq( std::proj(cn0) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn0) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cn1(ninf, 1); + VERIFY( eq( std::proj(cn1) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn1) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cnq(ninf, qnan); + VERIFY( eq( std::proj(cnq) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnq) , std::complex<float>(pinf, -0.0) ) ); + + const std::complex<float> cnp(ninf, pinf); + VERIFY( eq( std::proj(cnp) , std::complex<float>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnp) , std::complex<float>(pinf, -0.0) ) ); +} + +void +test03() +{ + const long double qnan = std::numeric_limits<long double>::quiet_NaN(); + const long double pinf = std::numeric_limits<long double>::infinity(); + const long double ninf = -pinf; + + std::complex<long double> c00(0, 0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c00) , c00 ) ); + VERIFY( eq( std::proj(-c00) , -c00 ) ); + + const std::complex<long double> c01(0, 1); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + c00.real(-0.0); + VERIFY( eq( std::proj(c01) , c01 ) ); + VERIFY( eq( std::proj(-c01) , -c01 ) ); + + const std::complex<long double> c10(1, 0); + VERIFY( eq( std::proj(c10) , c10 ) ); + VERIFY( eq( std::proj(-c10) , -c10 ) ); + + const std::complex<long double> c12(1, 2); + VERIFY( eq( std::proj(c12) , c12 ) ); + VERIFY( eq( std::proj(-c12) , -c12 ) ); + + const std::complex<long double> c0q(0, qnan); + VERIFY( eq( std::proj(c0q) , c0q ) ); + VERIFY( eq( std::proj(-c0q) , -c0q ) ); + + const std::complex<long double> c1q(1, qnan); + VERIFY( eq( std::proj(c1q) , c1q ) ); + VERIFY( eq( std::proj(-c1q) , -c1q ) ); + + const std::complex<long double> cq0(qnan, 0); + VERIFY( eq( std::proj(cq0) , cq0 ) ); + VERIFY( eq( std::proj(-cq0) , -cq0 ) ); + + const std::complex<long double> cq1(qnan, 1); + VERIFY( eq( std::proj(cq1) , cq1 ) ); + VERIFY( eq( std::proj(-cq1) , -cq1 ) ); + + const std::complex<long double> cqq(qnan, qnan); + VERIFY( eq( std::proj(cqq) , cqq ) ); + VERIFY( eq( std::proj(-cqq) , -cqq ) ); + + const std::complex<long double> c0p(0, pinf); + VERIFY( eq( std::proj(c0p) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c0p) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> c1p(1, pinf); + VERIFY( eq( std::proj(c1p) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-c1p) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cqp(qnan, pinf); + VERIFY( eq( std::proj(cqp) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cqp) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cpp(pinf, pinf); + VERIFY( eq( std::proj(cpp) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpp) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> c0n(0, ninf); + VERIFY( eq( std::proj(c0n) , std::complex<long double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c0n) , std::complex<long double>(pinf, +0.0) ) ); + + const std::complex<long double> c1n(1, ninf); + VERIFY( eq( std::proj(c1n) , std::complex<long double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-c1n) , std::complex<long double>(pinf, +0.0) ) ); + + const std::complex<long double> cqn(qnan, ninf); + VERIFY( eq( std::proj(cqn) , std::complex<long double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cqn) , std::complex<long double>(pinf, +0.0) ) ); + + const std::complex<long double> cpn(pinf, ninf); + VERIFY( eq( std::proj(cpn) , std::complex<long double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cpn) , std::complex<long double>(pinf, +0.0) ) ); + + const std::complex<long double> cnn(ninf, ninf); + VERIFY( eq( std::proj(cnn) , std::complex<long double>(pinf, -0.0) ) ); + VERIFY( eq( std::proj(-cnn) , std::complex<long double>(pinf, +0.0) ) ); + + const std::complex<long double> cp0(pinf, 0); + VERIFY( eq( std::proj(cp0) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp0) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cp1(pinf, 1); + VERIFY( eq( std::proj(cp1) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cp1) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cpq(pinf, qnan); + VERIFY( eq( std::proj(cpq) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cpq) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cn0(ninf, 0); + VERIFY( eq( std::proj(cn0) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn0) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cn1(ninf, 1); + VERIFY( eq( std::proj(cn1) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cn1) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cnq(ninf, qnan); + VERIFY( eq( std::proj(cnq) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnq) , std::complex<long double>(pinf, -0.0) ) ); + + const std::complex<long double> cnp(ninf, pinf); + VERIFY( eq( std::proj(cnp) , std::complex<long double>(pinf, +0.0) ) ); + VERIFY( eq( std::proj(-cnp) , std::complex<long double>(pinf, -0.0) ) ); +} + +int +main() +{ + test01(); + test02(); + test03(); +} diff --git a/libstdc++-v3/testsuite/experimental/names.cc b/libstdc++-v3/testsuite/experimental/names.cc index 233b3487981..cfda34948af 100644 --- a/libstdc++-v3/testsuite/experimental/names.cc +++ b/libstdc++-v3/testsuite/experimental/names.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do compile } +// { dg-do compile { target c++11 } } // Define macros for some common variables names that we must not use for // naming variables, parameters etc. in the library. @@ -25,6 +25,9 @@ #if __has_include(<experimental/filesystem>) # include <experimental/filesystem> #endif + +#if __cplusplus >= 201402L + // Library Fundamentals #include <experimental/algorithm> #include <experimental/any> @@ -66,3 +69,5 @@ # include <experimental/timer> # include <experimental/executor> #endif + +#endif // C++14 diff --git a/libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc b/libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc index cecd05df937..0841aa3bb06 100644 --- a/libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc +++ b/libstdc++-v3/testsuite/ext/char8_t/atomic-1.cc @@ -1,6 +1,6 @@ // Test that char8_t related atomic types and macros are not present when // -fchar8_t is not enabled. -// { dg-do compile } +// { dg-do compile { target c++11 } } // { dg-options "-fno-char8_t" } #include <atomic> diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc index a538b854038..255d3e7cff1 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc @@ -1,5 +1,5 @@ // { dg-options "-g -O0" } -// { dg-do run } +// { dg-do run { target c++11 } } // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } } // Copyright (C) 2014-2019 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/cmp.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/cmp.cc new file mode 100644 index 00000000000..a811307c73a --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/cmp.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2019 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 <tr2/dynamic_bitset> +#include <testsuite_hooks.h> + +void +test01() +{ + std::tr2::dynamic_bitset<> a(100); + std::tr2::dynamic_bitset<> b = a; + VERIFY( a == b ); + b.resize(99); + VERIFY( a != b ); +} + +void +test02() +{ + std::tr2::dynamic_bitset<> a(100); + std::tr2::dynamic_bitset<> b = a; + VERIFY( !(a < b) ); + VERIFY( !(b < a) ); + b.resize(99); + VERIFY( !(a < b) ); + VERIFY( b < a ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/cons.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/cons.cc new file mode 100644 index 00000000000..9e21a91ff52 --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/cons.cc @@ -0,0 +1,105 @@ +// Copyright (C) 2019 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 <tr2/dynamic_bitset> +#include <testsuite_hooks.h> + +void +test01() +{ + std::tr2::dynamic_bitset<> a; + VERIFY( a.size() == 0 ); + VERIFY( a.empty() ); + std::tr2::dynamic_bitset<> b(1); + VERIFY( b.size() == 1 ); + VERIFY( !b.empty() ); + VERIFY( a != b ); +} + +void +test02() +{ + std::tr2::dynamic_bitset<> a(1, 0); // { 0 } + std::tr2::dynamic_bitset<> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test03() +{ + std::tr2::dynamic_bitset<> a; + a.resize(1); // { 0 } + std::tr2::dynamic_bitset<> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test04() +{ + std::tr2::dynamic_bitset<> a(3, 2); // { 0, 1, 0 } + std::tr2::dynamic_bitset<> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test05() +{ + std::tr2::dynamic_bitset<unsigned short> a(1, 0); // { 0 } + std::tr2::dynamic_bitset<unsigned short> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test06() +{ + std::tr2::dynamic_bitset<unsigned short> a; + a.resize(1); // { 0 } + std::tr2::dynamic_bitset<unsigned short> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test07() +{ + std::tr2::dynamic_bitset<unsigned short> a(3, 2); // { 0, 1, 0 } + std::tr2::dynamic_bitset<unsigned short> b(2, 2); // { 0, 1 } + VERIFY( a != b ); +} + +void +test08() +{ + std::tr2::dynamic_bitset<> a(65, -1ULL); + std::tr2::dynamic_bitset<> b(64, -1ULL); + b.push_back(0); + VERIFY( a == b ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + test06(); + test07(); + test08(); +} diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/copy.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/copy.cc new file mode 100644 index 00000000000..06bc1158a82 --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/copy.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2019 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 <tr2/dynamic_bitset> +#include <testsuite_hooks.h> + +void +test01() +{ + std::tr2::dynamic_bitset<> a(100); + const auto n = a.num_blocks(); + std::tr2::dynamic_bitset<> b = a; + VERIFY(b.num_blocks() == n); + VERIFY(b.size() == 100); + VERIFY(a.num_blocks() == n); + VERIFY(a.size() == 100); + VERIFY(b == a); +} + +void +test02() +{ + std::tr2::dynamic_bitset<> a(100); + const auto n = a.num_blocks(); + std::tr2::dynamic_bitset<> b; + b = a; + VERIFY(b.num_blocks() == n); + VERIFY(b.size() == 100); + VERIFY(a.num_blocks() == n); + VERIFY(a.size() == 100); + VERIFY(b == a); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/move.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/move.cc new file mode 100644 index 00000000000..ed320db300d --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/move.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2019 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 <tr2/dynamic_bitset> +#include <testsuite_hooks.h> + +void +test01() +{ + std::tr2::dynamic_bitset<> a(100); + const auto n = a.num_blocks(); + std::tr2::dynamic_bitset<> b = std::move(a); + VERIFY(b.num_blocks() == n); + VERIFY(b.size() == 100); + VERIFY(a.num_blocks() == 0); + VERIFY(a.size() == 0); +} + +void +test02() +{ + std::tr2::dynamic_bitset<> a(100); + const auto n = a.num_blocks(); + std::tr2::dynamic_bitset<> b; + b = std::move(a); + VERIFY(b.num_blocks() == n); + VERIFY(b.size() == 100); + VERIFY(a.num_blocks() == 0); + VERIFY(a.size() == 0); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr92059.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr92059.cc new file mode 100644 index 00000000000..0aec1adf65b --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr92059.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2019 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 <tr2/dynamic_bitset> +#include <testsuite_hooks.h> + +void +test01() +{ + // PR libstdc++/92059 + std::tr2::dynamic_bitset<> b1(10000), b2(10000); + b2 = b1; // crashed on missing return + VERIFY( b2 == b1); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h index 0392421ca04..b02cbcaa55e 100644 --- a/libstdc++-v3/testsuite/util/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h @@ -699,162 +699,162 @@ namespace __gnu_test #if __cplusplus >= 201703L #if __cpp_aligned_new && __cpp_rtti - // A concrete memory_resource, with error checking. - class memory_resource : public std::pmr::memory_resource - { - public: - memory_resource() - : lists(new allocation_lists) - { } + // A concrete memory_resource, with error checking. + class memory_resource : public std::pmr::memory_resource + { + public: + memory_resource() + : lists(new allocation_lists) + { } - memory_resource(const memory_resource& r) noexcept - : lists(r.lists) - { lists->refcount++; } + memory_resource(const memory_resource& r) noexcept + : lists(r.lists) + { lists->refcount++; } - memory_resource& operator=(const memory_resource&) = delete; + memory_resource& operator=(const memory_resource&) = delete; - ~memory_resource() - { - if (lists->refcount-- == 1) - delete lists; // last one out turns out the lights - } + ~memory_resource() + { + if (lists->refcount-- == 1) + delete lists; // last one out turns out the lights + } - struct bad_size { }; - struct bad_alignment { }; - struct bad_address { }; + struct bad_size { }; + struct bad_alignment { }; + struct bad_address { }; - // Deallocate everything (moving the tracking info to the freed list) - void - deallocate_everything() - { - while (lists->active) - { - auto a = lists->active; - // Intentionally virtual dispatch, to inform derived classes: - this->do_deallocate(a->p, a->bytes, a->alignment); - } - } + // Deallocate everything (moving the tracking info to the freed list) + void + deallocate_everything() + { + while (lists->active) + { + auto a = lists->active; + // Intentionally virtual dispatch, to inform derived classes: + this->do_deallocate(a->p, a->bytes, a->alignment); + } + } - // Clear the freed list - void - forget_freed_allocations() - { lists->forget_allocations(lists->freed); } + // Clear the freed list + void + forget_freed_allocations() + { lists->forget_allocations(lists->freed); } - // Count how many allocations have been done and not freed. - std::size_t - number_of_active_allocations() const noexcept - { - std::size_t n = 0; - for (auto a = lists->active; a != nullptr; a = a->next) - ++n; - return n; - } + // Count how many allocations have been done and not freed. + std::size_t + number_of_active_allocations() const noexcept + { + std::size_t n = 0; + for (auto a = lists->active; a != nullptr; a = a->next) + ++n; + return n; + } - protected: - void* - do_allocate(std::size_t bytes, std::size_t alignment) override - { - // TODO perform a single allocation and put the allocation struct - // in the buffer using placement new? It means deallocation won't - // actually return memory to the OS, as it will stay in lists->freed. - // - // TODO adjust the returned pointer to be minimally aligned? - // e.g. if alignment==1 don't return something aligned to 2 bytes. - // Maybe not worth it, at least monotonic_buffer_resource will - // never ask upstream for anything with small alignment. - void* p = ::operator new(bytes, std::align_val_t(alignment)); - lists->active = new allocation{p, bytes, alignment, lists->active}; - return p; - } + protected: + void* + do_allocate(std::size_t bytes, std::size_t alignment) override + { + // TODO perform a single allocation and put the allocation struct + // in the buffer using placement new? It means deallocation won't + // actually return memory to the OS, as it will stay in lists->freed. + // + // TODO adjust the returned pointer to be minimally aligned? + // e.g. if alignment==1 don't return something aligned to 2 bytes. + // Maybe not worth it, at least monotonic_buffer_resource will + // never ask upstream for anything with small alignment. + void* p = ::operator new(bytes, std::align_val_t(alignment)); + lists->active = new allocation{p, bytes, alignment, lists->active}; + return p; + } - void - do_deallocate(void* p, std::size_t bytes, std::size_t alignment) override - { - allocation** aptr = &lists->active; - while (*aptr) - { - allocation* a = *aptr; - if (p == a->p) - { - if (bytes != a->bytes) - throw bad_size(); - if (alignment != a->alignment) - throw bad_alignment(); + void + do_deallocate(void* p, std::size_t bytes, std::size_t alignment) override + { + allocation** aptr = &lists->active; + while (*aptr) + { + allocation* a = *aptr; + if (p == a->p) + { + if (bytes != a->bytes) + throw bad_size(); + if (alignment != a->alignment) + throw bad_alignment(); #if __cpp_sized_deallocation - ::operator delete(p, bytes, std::align_val_t(alignment)); + ::operator delete(p, bytes, std::align_val_t(alignment)); #else - ::operator delete(p, std::align_val_t(alignment)); + ::operator delete(p, std::align_val_t(alignment)); #endif - *aptr = a->next; - a->next = lists->freed; - lists->freed = a; - return; - } - aptr = &a->next; - } - throw bad_address(); - } - - bool - do_is_equal(const std::pmr::memory_resource& r) const noexcept override - { - // Equality is determined by sharing the same allocation_lists object. - if (auto p = dynamic_cast<const memory_resource*>(&r)) - return p->lists == lists; - return false; - } - - private: - struct allocation - { - void* p; - std::size_t bytes; - std::size_t alignment; - allocation* next; - }; - - // Maintain list of allocated blocks and list of freed blocks. - // Copies of this memory_resource share the same ref-counted lists. - struct allocation_lists - { - unsigned refcount = 1; - allocation* active = nullptr; - allocation* freed = nullptr; - - void forget_allocations(allocation*& list) - { - while (list) - { - auto p = list; - list = list->next; - delete p; + *aptr = a->next; + a->next = lists->freed; + lists->freed = a; + return; } + aptr = &a->next; } + throw bad_address(); + } - ~allocation_lists() - { - forget_allocations(active); // Anything in this list is a leak! - forget_allocations(freed); - } - }; + bool + do_is_equal(const std::pmr::memory_resource& r) const noexcept override + { + // Equality is determined by sharing the same allocation_lists object. + if (auto p = dynamic_cast<const memory_resource*>(&r)) + return p->lists == lists; + return false; + } - allocation_lists* lists; + private: + struct allocation + { + void* p; + std::size_t bytes; + std::size_t alignment; + allocation* next; }; -#endif // aligned-new && rtti - // Set the default resource, and restore the previous one on destruction. - struct default_resource_mgr + // Maintain list of allocated blocks and list of freed blocks. + // Copies of this memory_resource share the same ref-counted lists. + struct allocation_lists { - explicit default_resource_mgr(std::pmr::memory_resource* r) - : prev(std::pmr::set_default_resource(r)) - { } + unsigned refcount = 1; + allocation* active = nullptr; + allocation* freed = nullptr; - ~default_resource_mgr() - { std::pmr::set_default_resource(prev); } + void forget_allocations(allocation*& list) + { + while (list) + { + auto p = list; + list = list->next; + delete p; + } + } - std::pmr::memory_resource* prev; + ~allocation_lists() + { + forget_allocations(active); // Anything in this list is a leak! + forget_allocations(freed); + } }; + allocation_lists* lists; + }; +#endif // aligned-new && rtti + + // Set the default resource, and restore the previous one on destruction. + struct default_resource_mgr + { + explicit default_resource_mgr(std::pmr::memory_resource* r) + : prev(std::pmr::set_default_resource(r)) + { } + + ~default_resource_mgr() + { std::pmr::set_default_resource(prev); } + + std::pmr::memory_resource* prev; + }; + #endif // C++17 } // namespace __gnu_test |