From 9f59cb7cac009f3c6eba81eb09714699b9ac9f8d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 20 Mar 2021 17:02:06 +0100 Subject: c-family: Fix PR94272 -fcompare-debug issue even for C [PR99230] The following testcase results in -fcompare-debug failure. The problem is the similar like in PR94272 https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542562.html When genericizing, with -g0 we have just a TREE_SIDE_EFFECTS DO_STMT in a branch of if, while with -g we have that wrapped into TREE_SIDE_EFFECTS STATEMENT_LIST containing DEBUG_BEGIN_STMT and that DO_STMT. The do loop is empty with 0 condition, so c_genericize_control_stmt turns it into an empty statement (without TREE_SIDE_EFFECTS). For -g0 that means that suddenly the if branch doesn't have side effects and is expanded differently. But with -g we still have TREE_SIDE_EFFECTS STATEMENT_LIST containing DEBUG_BEGIN_STMT and non-TREE_SIDE_EFFECTS stmt. The following patch fixes that by detecting this case and removing TREE_SIDE_EFFECTS. And, so that we don't duplicate the same code, changes the C++ FE to just call the c_genericize_control_stmt function that can now handle it. 2021-03-20 Jakub Jelinek PR debug/99230 * c-gimplify.c (c_genericize_control_stmt): Handle STATEMENT_LIST. * cp-gimplify.c (cp_genericize_r) : Remove special code, instead call c_genericize_control_stmt. * gcc.dg/pr99230.c: New test. --- gcc/c-family/c-gimplify.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index e1dfca2..39c969d 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -497,6 +497,35 @@ c_genericize_control_stmt (tree *stmt_p, int *walk_subtrees, void *data, genericize_omp_for_stmt (stmt_p, walk_subtrees, data, func, lh); break; + case STATEMENT_LIST: + if (TREE_SIDE_EFFECTS (stmt)) + { + tree_stmt_iterator i; + int nondebug_stmts = 0; + bool clear_side_effects = true; + /* Genericization can clear TREE_SIDE_EFFECTS, e.g. when + transforming an IF_STMT into COND_EXPR. If such stmt + appears in a STATEMENT_LIST that contains only that + stmt and some DEBUG_BEGIN_STMTs, without -g where the + STATEMENT_LIST wouldn't be present at all the resulting + expression wouldn't have TREE_SIDE_EFFECTS set, so make sure + to clear it even on the STATEMENT_LIST in such cases. */ + for (i = tsi_start (stmt); !tsi_end_p (i); tsi_next (&i)) + { + tree t = tsi_stmt (i); + if (TREE_CODE (t) != DEBUG_BEGIN_STMT && nondebug_stmts < 2) + nondebug_stmts++; + walk_tree_1 (tsi_stmt_ptr (i), func, data, NULL, lh); + if (TREE_CODE (t) != DEBUG_BEGIN_STMT + && (nondebug_stmts > 1 || TREE_SIDE_EFFECTS (tsi_stmt (i)))) + clear_side_effects = false; + } + if (clear_side_effects) + TREE_SIDE_EFFECTS (stmt) = 0; + *walk_subtrees = 0; + } + break; + default: break; } -- cgit v1.1 From 6af7b307f659a4f1845a9efd36ca37899515e234 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 21 Mar 2021 00:16:22 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d1ce4b4..0a97851 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-03-20 Jakub Jelinek + + PR debug/99230 + * c-gimplify.c (c_genericize_control_stmt): Handle STATEMENT_LIST. + 2021-03-05 Eric Botcazou * c-ada-spec.c (dump_ada_declaration) : Dump nested types -- cgit v1.1 From 660eb7e9dee46ef1c986d5a4fa5cbd182b435518 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 25 Mar 2021 11:33:35 +0100 Subject: c-family: Fix up -Wduplicated-branches for union members [PR99565] Honza has fairly recently changed operand_equal_p to compare DECL_FIELD_OFFSET for COMPONENT_REFs when comparing addresses. As the first testcase in this patch shows, while that is very nice for optimizations, for the -Wduplicated-branches warning it causes regressions. Pedantically a union in both C and C++ has only one active member at a time, so using some other union member even if it has the same type is UB, so I think the warning shouldn't warn when it sees access to different fields that happen to have the same offset and should consider them different. In my first attempt to fix this I've keyed the old behavior on OEP_LEXICOGRAPHIC, but unfortunately that has various problems, the warning has a quick non-lexicographic compare in build_conditional_expr* and another lexicographic more expensive one later during genericization and turning the first one into lexicographic would mean wasting compile time on large conditionals. So, this patch instead introduces a new OEP_ flag and makes sure to pass it to operand_equal_p in all -Wduplicated-branches cases. The cvt.c changes are because on the other testcase we were warning with UNKNOWN_LOCATION, so the user wouldn't really know where the questionable code is. 2021-03-25 Jakub Jelinek PR c++/99565 * tree-core.h (enum operand_equal_flag): Add OEP_ADDRESS_OF_SAME_FIELD. * fold-const.c (operand_compare::operand_equal_p): Don't compare field offsets if OEP_ADDRESS_OF_SAME_FIELD. * c-warn.c (do_warn_duplicated_branches): Pass also OEP_ADDRESS_OF_SAME_FIELD to operand_equal_p. * c-typeck.c (build_conditional_expr): Pass OEP_ADDRESS_OF_SAME_FIELD to operand_equal_p. * call.c (build_conditional_expr_1): Pass OEP_ADDRESS_OF_SAME_FIELD to operand_equal_p. * cvt.c (convert_to_void): Preserve location_t on COND_EXPR or or COMPOUND_EXPR. * g++.dg/warn/Wduplicated-branches6.C: New test. * g++.dg/warn/Wduplicated-branches7.C: New test. --- gcc/c-family/c-warn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 2347e0b..534e4f3 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -2779,7 +2779,8 @@ do_warn_duplicated_branches (tree expr) /* Compare the hashes. */ if (h0 == h1 - && operand_equal_p (thenb, elseb, OEP_LEXICOGRAPHIC) + && operand_equal_p (thenb, elseb, OEP_LEXICOGRAPHIC + | OEP_ADDRESS_OF_SAME_FIELD) /* Don't warn if any of the branches or their subexpressions comes from a macro. */ && !walk_tree_without_duplicates (&thenb, expr_from_macro_expansion_r, -- cgit v1.1 From 4493b1c1ad7e2b2a60ad70563b81f51173115471 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 26 Mar 2021 00:16:25 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0a97851..7d6dab2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-03-25 Jakub Jelinek + + PR c++/99565 + * c-warn.c (do_warn_duplicated_branches): Pass also + OEP_ADDRESS_OF_SAME_FIELD to operand_equal_p. + 2021-03-20 Jakub Jelinek PR debug/99230 -- cgit v1.1 From 5f00df5925082c7b66da91270f2ed29bf4818c93 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 31 Mar 2021 17:48:50 -0400 Subject: c++: Add ABI version for PR98481 fix The PR98481 fix corrects an ABI regression in GCC 10, but we don't want to introduce an ABI change in the middle of the GCC 10 cycle. This patch introduces ABI v15 for the fix, which will be available but not default in GCC 10.3; the broken behavior remains in ABI v14. Compatibility aliases will not be generated for this change. gcc/ChangeLog: PR c++/98481 * common.opt: Document v15 and v16. gcc/c-family/ChangeLog: PR c++/98481 * c-opts.c (c_common_post_options): Bump latest_abi_version. gcc/cp/ChangeLog: PR c++/98481 * mangle.c (write_expression): Adjust. * class.c (find_abi_tags_r): Disable PR98481 fix for ABI v14. (mark_abi_tags_r): Likewise. gcc/testsuite/ChangeLog: PR c++/98481 * g++.dg/abi/abi-tag24a.C: New test. * g++.dg/abi/macro0.C: Adjust expected value. --- gcc/c-family/c-opts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index bd15b9c..89e05a4 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -965,7 +965,7 @@ c_common_post_options (const char **pfilename) /* Change flag_abi_version to be the actual current ABI level, for the benefit of c_cpp_builtins, and to make comparison simpler. */ - const int latest_abi_version = 15; + const int latest_abi_version = 16; /* Generate compatibility aliases for ABI v11 (7.1) by default. */ const int abi_compat_default = 11; -- cgit v1.1 From f1607029aea3043f7bd4f86c005e0997795f5ffd Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 2 Apr 2021 00:16:26 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7d6dab2..6c727e3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-04-01 Jason Merrill + + PR c++/98481 + * c-opts.c (c_common_post_options): Bump latest_abi_version. + 2021-03-25 Jakub Jelinek PR c++/99565 -- cgit v1.1 From 7ebdef2076fda56cb4cffb941f6c2576f980f3b3 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 5 Apr 2021 19:49:56 +0200 Subject: Fix small regression with -fdump-ada-spec When the enumeration constants of an enumeration type are defined by explicit values, the binding generated by -fdump-ada-spec does not use an enumeration type on the Ada side, because the set of allowed values in C/C++ is larger than the set of allowed values in Ada, but instead use an integer subtype and defines a set of explicit constants, which used to be of this subtype but were changed to the base type at some point. This reinstates the subtype for them. gcc/c-family/ * c-ada-spec.c (is_simple_enum): Minor tweaks. (dump_ada_enum_type): Add TYPE and PARENT parameters. For non-simple enumeral types use again the type name for the enumeration constants. (dump_ada_node): Adjust call to dump_ada_enum_type. (dump_nested_type): Likewise. --- gcc/c-family/c-ada-spec.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index dd8e8bb..9fef5f0 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -1932,8 +1932,8 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc) return num_inst > 0; } -/* Return true if NODE is a simple enum types, that can be mapped to an - Ada enum type directly. */ +/* Return true if NODE is a simple enumeral type that can be mapped to an + Ada enumeration type directly. */ static bool is_simple_enum (tree node) @@ -1947,9 +1947,7 @@ is_simple_enum (tree node) if (TREE_CODE (int_val) != INTEGER_CST) int_val = DECL_INITIAL (int_val); - if (!tree_fits_shwi_p (int_val)) - return false; - else if (tree_to_shwi (int_val) != count) + if (!tree_fits_shwi_p (int_val) || tree_to_shwi (int_val) != count) return false; count++; @@ -1958,11 +1956,12 @@ is_simple_enum (tree node) return true; } -/* Dump in BUFFER an enumeral type NODE in Ada syntax. SPC is the indentation - level. */ +/* Dump in BUFFER the declaration of enumeral NODE of type TYPE in Ada syntax. + PARENT is the parent node of NODE. SPC is the indentation level. */ static void -dump_ada_enum_type (pretty_printer *buffer, tree node, int spc) +dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, tree parent, + int spc) { if (is_simple_enum (node)) { @@ -1993,25 +1992,29 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, int spc) pp_string (buffer, "unsigned"); else pp_string (buffer, "int"); + for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value)) { + tree int_val = TREE_VALUE (value); + + if (TREE_CODE (int_val) != INTEGER_CST) + int_val = DECL_INITIAL (int_val); + pp_semicolon (buffer); newline_and_indent (buffer, spc); pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false); pp_string (buffer, " : constant "); - if (TYPE_UNSIGNED (node)) - pp_string (buffer, "unsigned"); + if (TYPE_NAME (node)) + dump_ada_node (buffer, node, NULL_TREE, spc, false, true); + else if (type) + dump_ada_node (buffer, type, NULL_TREE, spc, false, true); else - pp_string (buffer, "int"); + dump_anonymous_type_name (buffer, node, parent); pp_string (buffer, " := "); - dump_ada_node (buffer, - TREE_CODE (TREE_VALUE (value)) == INTEGER_CST - ? TREE_VALUE (value) - : DECL_INITIAL (TREE_VALUE (value)), - node, spc, false, true); + dump_ada_node (buffer, int_val, node, spc, false, true); } } } @@ -2098,7 +2101,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (name_only) dump_ada_node (buffer, TYPE_NAME (node), node, spc, false, true); else - dump_ada_enum_type (buffer, node, spc); + dump_ada_enum_type (buffer, node, type, NULL_TREE, spc); break; case REAL_TYPE: @@ -2577,7 +2580,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, else dump_anonymous_type_name (buffer, field_type, parent); pp_string (buffer, " is "); - dump_ada_enum_type (buffer, field_type, spc); + dump_ada_enum_type (buffer, field_type, NULL_TREE, parent, spc); pp_semicolon (buffer); newline_and_indent (buffer, spc); break; -- cgit v1.1 From b1da991623341a2ecd97bf9034b93b0d63516517 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 6 Apr 2021 00:16:43 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 6c727e3..85e2489 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2021-04-05 Eric Botcazou + + * c-ada-spec.c (is_simple_enum): Minor tweaks. + (dump_ada_enum_type): Add TYPE and PARENT parameters. For non-simple + enumeral types use again the type name for the enumeration constants. + (dump_ada_node): Adjust call to dump_ada_enum_type. + (dump_nested_type): Likewise. + 2021-04-01 Jason Merrill PR c++/98481 -- cgit v1.1 From d6cc745cb87aa62f9e17699aedf5aa2d9831fbd8 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 8 Apr 2021 09:08:39 -0600 Subject: PR middle-end/99883 - A couple of minor misspellings gcc/c-family/ChangeLog: PR middle-end/99883 * c.opt (Wmismatched-new-delete): Correct spelling. gcc/lto/ChangeLog: PR middle-end/99883 * lto-lang.c (lto_post_options): Correct spelling. --- gcc/c-family/c.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 64e46e7..ed9a825 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -800,7 +800,7 @@ functions. Wmismatched-new-delete C++ ObjC++ Var(warn_mismatched_new_delete) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) -Warn for mismatches between calls to operator new or delete and the corrsponding +Warn for mismatches between calls to operator new or delete and the corresponding call to the allocation or deallocation function. Wmismatched-tags -- cgit v1.1 From 0567998287649833744ad728b1dfb785fe17c545 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 8 Apr 2021 19:05:08 +0200 Subject: c-family: Fix various comment typos in c-warn.c When looking into PR99420, I have noticed several comment typos. 2021-04-08 Jakub Jelinek * c-warn.c (do_warn_double_promotion): Fix comment typo, occured -> occurred. (check_alignment_of_packed_member): Fix a comment typo, memeber -> member. (warn_parm_ptrarray_mismatch): Fix comment typos, os -> of and onless -> unless. (warn_parm_array_mismatch): Fix comment typos, declaratation -> declaration and woud -> would. Fix up comment indentation. --- gcc/c-family/c-warn.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 534e4f3..c48dc2e 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -2394,7 +2394,7 @@ do_warn_double_promotion (tree result_type, tree type1, tree type2, warn about it. */ if (c_inhibit_evaluation_warnings) return; - /* If an invalid conversion has occured, don't warn. */ + /* If an invalid conversion has occurred, don't warn. */ if (result_type == error_mark_node) return; if (TYPE_MAIN_VARIANT (result_type) != double_type_node @@ -2900,7 +2900,7 @@ warn_for_multistatement_macros (location_t body_loc, location_t next_loc, "this %qs clause", guard_tinfo_to_string (keyword)); } -/* Return struct or union type if the alignment of data memeber, FIELD, +/* Return struct or union type if the alignment of data member, FIELD, is less than the alignment of TYPE. Otherwise, return NULL_TREE. If RVALUE is true, only arrays evaluate to pointers. */ @@ -3151,7 +3151,7 @@ vla_bound_parm_decl (tree expr) } /* Diagnose mismatches in VLA bounds between function parameters NEWPARMS - of pointer types on a redeclaration os a function previously declared + of pointer types on a redeclaration of a function previously declared with CURPARMS at ORIGLOC. */ static void @@ -3220,7 +3220,7 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms) if (origloc == UNKNOWN_LOCATION) origloc = newloc; - /* Issue -Warray-parameter onless one or more mismatches involves + /* Issue -Warray-parameter unless one or more mismatches involves a VLA bound; then issue -Wvla-parameter. */ int opt = OPT_Warray_parameter_; /* Traverse the two array types looking for variable bounds and @@ -3335,15 +3335,15 @@ expr_to_str (pretty_printer &pp, tree expr, const char *dflt) /* Detect and diagnose a mismatch between an attribute access specification on the original declaration of FNDECL and that on the parameters NEWPARMS - from its refeclaration. ORIGLOC is the location of the first declaration + from its redeclaration. ORIGLOC is the location of the first declaration (FNDECL's is set to the location of the redeclaration). */ void warn_parm_array_mismatch (location_t origloc, tree fndecl, tree newparms) { - /* The original parameter list (copied from the original declaration - into the current [re]declaration, FNDECL)). The two are equal if - and only if FNDECL is the first declaratation. */ + /* The original parameter list (copied from the original declaration + into the current [re]declaration, FNDECL)). The two are equal if + and only if FNDECL is the first declaration. */ tree curparms = DECL_ARGUMENTS (fndecl); if (!curparms || !newparms || curparms == newparms) return; @@ -3375,7 +3375,7 @@ warn_parm_array_mismatch (location_t origloc, tree fndecl, tree newparms) return; } /* ...otherwise, if at least one spec isn't empty there may be mismatches, - such as between f(T*) and f(T[1]), where the former mapping woud be + such as between f(T*) and f(T[1]), where the former mapping would be empty. */ /* Create an empty access specification and use it for pointers with -- cgit v1.1 From 019a922063f26784d5a070d9198a1f937b8a8343 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 9 Apr 2021 00:16:56 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 85e2489..032a0ff 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,19 @@ +2021-04-08 Jakub Jelinek + + * c-warn.c (do_warn_double_promotion): Fix comment typo, + occured -> occurred. + (check_alignment_of_packed_member): Fix a comment typo, + memeber -> member. + (warn_parm_ptrarray_mismatch): Fix comment typos, os -> of + and onless -> unless. + (warn_parm_array_mismatch): Fix comment typos, declaratation + -> declaration and woud -> would. Fix up comment indentation. + +2021-04-08 Martin Sebor + + PR middle-end/99883 + * c.opt (Wmismatched-new-delete): Correct spelling. + 2021-04-05 Eric Botcazou * c-ada-spec.c (is_simple_enum): Minor tweaks. -- cgit v1.1 From 3395dfc4da8ad1fccd346c62dfc9bd44b2b48c62 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 19 Apr 2021 10:24:49 +0200 Subject: [OpenACC 'kernels'] '-fopenacc-kernels=[...]' -> '--param=openacc-kernels=[...]' This configuration knob is temporary, and isn't really meant to be exposed to users. gcc/ * params.opt (-param=openacc-kernels=): Add. * omp-oacc-kernels-decompose.cc (pass_omp_oacc_kernels_decompose::gate): Use it. * doc/invoke.texi (-fopenacc-kernels=@var{mode}): Move... (--param): ... here, 'openacc-kernels'. gcc/c-family/ * c.opt (fopenacc-kernels=): Remove. gcc/fortran/ * lang.opt (fopenacc-kernels=): Remove. gcc/testsuite/ * c-c++-common/goacc/if-clause-2.c: '-fopenacc-kernels=[...]' -> '--param=openacc-kernels=[...]'. * c-c++-common/goacc/kernels-decompose-1.c: Likewise. * c-c++-common/goacc/kernels-decompose-2.c: Likewise. * c-c++-common/goacc/kernels-decompose-ice-1.c: Likewise. * c-c++-common/goacc/kernels-decompose-ice-2.c: Likewise. * gfortran.dg/goacc/kernels-decompose-1.f95: Likewise. * gfortran.dg/goacc/kernels-decompose-2.f95: Likewise. * gfortran.dg/goacc/kernels-tree.f95: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c: '-fopenacc-kernels=[...]' -> '--param=openacc-kernels=[...]'. * testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c: Likewise. * testsuite/libgomp.oacc-fortran/pr94358-1.f90: Likewise. --- gcc/c-family/c.opt | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index ed9a825..3f8b72c 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1873,19 +1873,6 @@ fopenacc-dim= C ObjC C++ ObjC++ LTO Joined Var(flag_openacc_dims) Specify default OpenACC compute dimensions. -fopenacc-kernels= -C ObjC C++ ObjC++ RejectNegative Joined Enum(openacc_kernels) Var(flag_openacc_kernels) Init(OPENACC_KERNELS_PARLOOPS) --fopenacc-kernels=[decompose|parloops] Specify mode of OpenACC 'kernels' constructs handling. - -Enum -Name(openacc_kernels) Type(enum openacc_kernels) - -EnumValue -Enum(openacc_kernels) String(decompose) Value(OPENACC_KERNELS_DECOMPOSE) - -EnumValue -Enum(openacc_kernels) String(parloops) Value(OPENACC_KERNELS_PARLOOPS) - fopenmp C ObjC C++ ObjC++ LTO Var(flag_openmp) Enable OpenMP (implies -frecursive in Fortran). -- cgit v1.1 From 6e81e015d91568fc3df3939623ae999e0681a0fc Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 20 Apr 2021 00:16:27 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 032a0ff..fb2c4b0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-04-19 Thomas Schwinge + + * c.opt (fopenacc-kernels=): Remove. + 2021-04-08 Jakub Jelinek * c-warn.c (do_warn_double_promotion): Fix comment typo, -- cgit v1.1 From 22cff118f7526bec195ed6e41452980820fdf3a8 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 23 Apr 2021 12:23:51 +0200 Subject: Add '-Wopenacc-parallelism' ... to diagnose potentially suboptimal choices regarding OpenACC parallelism. Not enabled by default: too noisy ("*potentially* suboptimal choices"); see XFAILed 'dg-bogus'es. gcc/c-family/ * c.opt (Wopenacc-parallelism): New. gcc/fortran/ * lang.opt (Wopenacc-parallelism): New. gcc/ * omp-offload.c (oacc_validate_dims): Implement '-Wopenacc-parallelism'. * doc/invoke.texi (-Wopenacc-parallelism): Document. gcc/testsuite/ * c-c++-common/goacc/diag-parallelism-1.c: New. * c-c++-common/goacc/acc-icf.c: Specify '-Wopenacc-parallelism', and match diagnostics, as appropriate. * c-c++-common/goacc/classify-kernels-unparallelized.c: Likewise. * c-c++-common/goacc/classify-kernels.c: Likewise. * c-c++-common/goacc/classify-parallel.c: Likewise. * c-c++-common/goacc/classify-routine.c: Likewise. * c-c++-common/goacc/classify-serial.c: Likewise. * c-c++-common/goacc/kernels-decompose-1.c: Likewise. * c-c++-common/goacc/kernels-decompose-2.c: Likewise. * c-c++-common/goacc/parallel-dims-1.c: Likewise. * c-c++-common/goacc/parallel-reduction.c: Likewise. * c-c++-common/goacc/pr70688.c: Likewise. * c-c++-common/goacc/routine-1.c: Likewise. * c-c++-common/goacc/routine-level-of-parallelism-2.c: Likewise. * c-c++-common/goacc/uninit-dim-clause.c: Likewise. * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise. * gfortran.dg/goacc/classify-kernels.f95: Likewise. * gfortran.dg/goacc/classify-parallel.f95: Likewise. * gfortran.dg/goacc/classify-routine.f95: Likewise. * gfortran.dg/goacc/classify-serial.f95: Likewise. * gfortran.dg/goacc/kernels-decompose-1.f95: Likewise. * gfortran.dg/goacc/kernels-decompose-2.f95: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. * gfortran.dg/goacc/routine-4.f90: Likewise. * gfortran.dg/goacc/routine-level-of-parallelism-1.f90: Likewise. * gfortran.dg/goacc/routine-module-mod-1.f90: Likewise. * gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise. * gfortran.dg/goacc/uninit-dim-clause.f95: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/firstprivate-1.c: Specify '-Wopenacc-parallelism', and match diagnostics, as appropriate. * testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/mode-transitions.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-reduction.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr85381-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/private-variables.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/reduction-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/static-variable-1.c: Likewise. * testsuite/libgomp.oacc-fortran/optional-private.f90: Likewise. * testsuite/libgomp.oacc-fortran/par-reduction-2-1.f: Likewise. * testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise. * testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise. * testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise. * testsuite/libgomp.oacc-fortran/pr84028.f90: Likewise. * testsuite/libgomp.oacc-fortran/private-variables.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-6.f90: Likewise. * testsuite/libgomp.oacc-fortran/routine-7.f90: Likewise. Co-Authored-By: Nathan Sidwell Co-Authored-By: Tom de Vries Co-Authored-By: Julian Brown Co-Authored-By: Kwok Cheung Yeung --- gcc/c-family/c.opt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 3f8b72c..f1b4c3f 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1037,6 +1037,10 @@ Wold-style-definition C ObjC Var(warn_old_style_definition) Init(-1) Warning Warn if an old-style parameter definition is used. +Wopenacc-parallelism +C C++ Var(warn_openacc_parallelism) Warning +Warn about potentially suboptimal choices related to OpenACC parallelism. + Wopenmp-simd C C++ Var(warn_openmp_simd) Warning LangEnabledBy(C C++,Wall) Warn if a simd directive is overridden by the vectorizer cost model. -- cgit v1.1 From c0fa3f2fb365144b3a059920aeaf6ff37db1177d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 27 Apr 2021 00:16:30 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index fb2c4b0..38855e1 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2021-04-26 Thomas Schwinge + Nathan Sidwell + Tom de Vries + Julian Brown + Kwok Cheung Yeung + + * c.opt (Wopenacc-parallelism): New. + 2021-04-19 Thomas Schwinge * c.opt (fopenacc-kernels=): Remove. -- cgit v1.1 From 54f0224d55a1b56dde092460ddf76913670e6efc Mon Sep 17 00:00:00 2001 From: Patrick McGehearty Date: Wed, 28 Apr 2021 19:14:48 +0000 Subject: Practical improvement to libgcc complex divide Correctness and performance test programs used during development of this project may be found in the attachment to: https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg254210.html Summary of Purpose This patch to libgcc/libgcc2.c __divdc3 provides an opportunity to gain important improvements to the quality of answers for the default complex divide routine (half, float, double, extended, long double precisions) when dealing with very large or very small exponents. The current code correctly implements Smith's method (1962) [2] further modified by c99's requirements for dealing with NaN (not a number) results. When working with input values where the exponents are greater than *_MAX_EXP/2 or less than -(*_MAX_EXP)/2, results are substantially different from the answers provided by quad precision more than 1% of the time. This error rate may be unacceptable for many applications that cannot a priori restrict their computations to the safe range. The proposed method reduces the frequency of "substantially different" answers by more than 99% for double precision at a modest cost of performance. Differences between current gcc methods and the new method will be described. Then accuracy and performance differences will be discussed. Background This project started with an investigation related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59714. Study of Beebe[1] provided an overview of past and recent practice for computing complex divide. The current glibc implementation is based on Robert Smith's algorithm [2] from 1962. A google search found the paper by Baudin and Smith [3] (same Robert Smith) published in 2012. Elen Kalda's proposed patch [4] is based on that paper. I developed two sets of test data by randomly distributing values over a restricted range and the full range of input values. The current complex divide handled the restricted range well enough, but failed on the full range more than 1% of the time. Baudin and Smith's primary test for "ratio" equals zero reduced the cases with 16 or more error bits by a factor of 5, but still left too many flawed answers. Adding debug print out to cases with substantial errors allowed me to see the intermediate calculations for test values that failed. I noted that for many of the failures, "ratio" was a subnormal. Changing the "ratio" test from check for zero to check for subnormal reduced the 16 bit error rate by another factor of 12. This single modified test provides the greatest benefit for the least cost, but the percentage of cases with greater than 16 bit errors (double precision data) is still greater than 0.027% (2.7 in 10,000). Continued examination of remaining errors and their intermediate computations led to the various tests of input value tests and scaling to avoid under/overflow. The current patch does not handle some of the rare and most extreme combinations of input values, but the random test data is only showing 1 case in 10 million that has an error of greater than 12 bits. That case has 18 bits of error and is due to subtraction cancellation. These results are significantly better than the results reported by Baudin and Smith. Support for half, float, double, extended, and long double precision is included as all are handled with suitable preprocessor symbols in a single source routine. Since half precision is computed with float precision as per current libgcc practice, the enhanced algorithm provides no benefit for half precision and would cost performance. Further investigation showed changing the half precision algorithm to use the simple formula (real=a*c+b*d imag=b*c-a*d) caused no loss of precision and modest improvement in performance. The existing constants for each precision: float: FLT_MAX, FLT_MIN; double: DBL_MAX, DBL_MIN; extended and/or long double: LDBL_MAX, LDBL_MIN are used for avoiding the more common overflow/underflow cases. This use is made generic by defining appropriate __LIBGCC2_* macros in c-cppbuiltin.c. Tests are added for when both parts of the denominator have exponents small enough to allow shifting any subnormal values to normal values all input values could be scaled up without risking overflow. That gained a clear improvement in accuracy. Similarly, when either numerator was subnormal and the other numerator and both denominator values were not too large, scaling could be used to reduce risk of computing with subnormals. The test and scaling values used all fit within the allowed exponent range for each precision required by the C standard. Float precision has more difficulty with getting correct answers than double precision. When hardware for double precision floating point operations is available, float precision is now handled in double precision intermediate calculations with the simple algorithm the same as the half-precision method of using float precision for intermediate calculations. Using the higher precision yields exact results for all tested input values (64-bit double, 32-bit float) with the only performance cost being the requirement to convert the four input values from float to double. If double precision hardware is not available, then float complex divide will use the same improved algorithm as the other precisions with similar change in performance. Further Improvement The most common remaining substantial errors are due to accuracy loss when subtracting nearly equal values. This patch makes no attempt to improve that situation. NOTATION For all of the following, the notation is: Input complex values: a+bi (a= real part, b= imaginary part) c+di Output complex value: e+fi = (a+bi)/(c+di) For the result tables: current = current method (SMITH) b1div = method proposed by Elen Kalda b2div = alternate method considered by Elen Kalda new = new method proposed by this patch DESCRIPTIONS of different complex divide methods: NAIVE COMPUTATION (-fcx-limited-range): e = (a*c + b*d)/(c*c + d*d) f = (b*c - a*d)/(c*c + d*d) Note that c*c and d*d will overflow or underflow if either c or d is outside the range 2^-538 to 2^512. This method is available in gcc when the switch -fcx-limited-range is used. That switch is also enabled by -ffast-math. Only one who has a clear understanding of the maximum range of all intermediate values generated by an application should consider using this switch. SMITH's METHOD (current libgcc): if(fabs(c) RBIG) || (FABS (a) > RBIG) || (FABS (b) > RBIG) ) { a = a * 0.5; b = b * 0.5; c = c * 0.5; d = d * 0.5; } /* minimize overflow/underflow issues when c and d are small */ else if (FABS (d) < RMIN2) { a = a * RMINSCAL; b = b * RMINSCAL; c = c * RMINSCAL; d = d * RMINSCAL; } else { if(((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (d) < RMAX2)) || ((FABS (b) < RMIN) && (FABS (a) < RMAX2) && (FABS (d) < RMAX2))) { a = a * RMINSCAL; b = b * RMINSCAL; c = c * RMINSCAL; d = d * RMINSCAL; } } r = c/d; denom = (c*r) + d; if( r > RMIN ) { e = (a*r + b) / denom ; f = (b*r - a) / denom } else { e = (c * (a/d) + b) / denom; f = (c * (b/d) - a) / denom; } } [ only presenting the fabs(c) < fabs(d) case here, full code in patch. ] Before any computation of the answer, the code checks for any input values near maximum to allow down scaling to avoid overflow. These scalings almost never harm the accuracy since they are by 2. Values that are over RBIG are relatively rare but it is easy to test for them and allow aviodance of overflows. Testing for RMIN2 reveals when both c and d are less than [FLT|DBL]_EPSILON. By scaling all values by 1/EPSILON, the code converts subnormals to normals, avoids loss of accuracy and underflows in intermediate computations that otherwise might occur. If scaling a and b by 1/EPSILON causes either to overflow, then the computation will overflow whatever method is used. Finally, we test for either a or b being subnormal (RMIN) and if so, for the other three values being small enough to allow scaling. We only need to test a single denominator value since we have already determined which of c and d is larger. Next, r (the ratio of c to d) is checked for being near zero. Baudin and Smith checked r for zero. This code improves that approach by checking for values less than DBL_MIN (subnormal) covers roughly 12 times as many cases and substantially improves overall accuracy. If r is too small, then when it is used in a multiplication, there is a high chance that the result will underflow to zero, losing significant accuracy. That underflow is avoided by reordering the computation. When r is subnormal, the code replaces a*r (= a*(c/d)) with ((a/d)*c) which is mathematically the same but avoids the unnecessary underflow. TEST Data Two sets of data are presented to test these methods. Both sets contain 10 million pairs of complex values. The exponents and mantissas are generated using multiple calls to random() and then combining the results. Only values which give results to complex divide that are representable in the appropriate precision after being computed in quad precision are used. The first data set is labeled "moderate exponents". The exponent range is limited to -DBL_MAX_EXP/2 to DBL_MAX_EXP/2 for Double Precision (use FLT_MAX_EXP or LDBL_MAX_EXP for the appropriate precisions. The second data set is labeled "full exponents". The exponent range for these cases is the full exponent range including subnormals for a given precision. ACCURACY Test results: Note: The following accuracy tests are based on IEEE-754 arithmetic. Note: All results reporteed are based on use of fused multiply-add. If fused multiply-add is not used, the error rate increases, giving more 1 and 2 bit errors for both current and new complex divide. Differences between using fused multiply and not using it that are greater than 2 bits are less than 1 in a million. The complex divide methods are evaluated by determining the percentage of values that exceed differences in low order bits. If a "2 bit" test results show 1%, that would mean that 1% of 10,000,000 values (100,000) have either a real or imaginary part that differs from the quad precision result by more than the last 2 bits. Results are reported for differences greater than or equal to 1 bit, 2 bits, 8 bits, 16 bits, 24 bits, and 52 bits for double precision. Even when the patch avoids overflows and underflows, some input values are expected to have errors due to the potential for catastrophic roundoff from floating point subtraction. For example, when b*c and a*d are nearly equal, the result of subtraction may lose several places of accuracy. This patch does not attempt to detect or minimize this type of error, but neither does it increase them. I only show the results for Elen Kalda's method (with both 1 and 2 divides) and the new method for only 1 divide in the double precision table. In the following charts, lower values are better. current - current complex divide in libgcc b1div - Elen Kalda's method from Baudin & Smith with one divide b2div - Elen Kalda's method from Baudin & Smith with two divides new - This patch which uses 2 divides =================================================== Errors Moderate Dataset gtr eq current b1div b2div new ====== ======== ======== ======== ======== 1 bit 0.24707% 0.92986% 0.24707% 0.24707% 2 bits 0.01762% 0.01770% 0.01762% 0.01762% 8 bits 0.00026% 0.00026% 0.00026% 0.00026% 16 bits 0.00000% 0.00000% 0.00000% 0.00000% 24 bits 0% 0% 0% 0% 52 bits 0% 0% 0% 0% =================================================== Table 1: Errors with Moderate Dataset (Double Precision) Note in Table 1 that both the old and new methods give identical error rates for data with moderate exponents. Errors exceeding 16 bits are exceedingly rare. There are substantial increases in the 1 bit error rates for b1div (the 1 divide/2 multiplys method) as compared to b2div (the 2 divides method). These differences are minimal for 2 bits and larger error measurements. =================================================== Errors Full Dataset gtr eq current b1div b2div new ====== ======== ======== ======== ======== 1 bit 2.05% 1.23842% 0.67130% 0.16664% 2 bits 1.88% 0.51615% 0.50354% 0.00900% 8 bits 1.77% 0.42856% 0.42168% 0.00011% 16 bits 1.63% 0.33840% 0.32879% 0.00001% 24 bits 1.51% 0.25583% 0.24405% 0.00000% 52 bits 1.13% 0.01886% 0.00350% 0.00000% =================================================== Table 2: Errors with Full Dataset (Double Precision) Table 2 shows significant differences in error rates. First, the difference between b1div and b2div show a significantly higher error rate for the b1div method both for single bit errros and well beyond. Even for 52 bits, we see the b1div method gets completely wrong answers more than 5 times as often as b2div. To retain comparable accuracy with current complex divide results for small exponents and due to the increase in errors for large exponents, I choose to use the more accurate method of two divides. The current method has more 1.6% of cases where it is getting results where the low 24 bits of the mantissa differ from the correct answer. More than 1.1% of cases where the answer is completely wrong. The new method shows less than one case in 10,000 with greater than two bits of error and only one case in 10 million with greater than 16 bits of errors. The new patch reduces 8 bit errors by a factor of 16,000 and virtually eliminates completely wrong answers. As noted above, for architectures with double precision hardware, the new method uses that hardware for the intermediate calculations before returning the result in float precision. Testing of the new patch has shown zero errors found as seen in Tables 3 and 4. Correctness for float ============================= Errors Moderate Dataset gtr eq current new ====== ======== ======== 1 bit 28.68070% 0% 2 bits 0.64386% 0% 8 bits 0.00401% 0% 16 bits 0.00001% 0% 24 bits 0% 0% ============================= Table 3: Errors with Moderate Dataset (float) ============================= Errors Full Dataset gtr eq current new ====== ======== ======== 1 bit 19.98% 0% 2 bits 3.20% 0% 8 bits 1.97% 0% 16 bits 1.08% 0% 24 bits 0.55% 0% ============================= Table 4: Errors with Full Dataset (float) As before, the current method shows an troubling rate of extreme errors. There very minor changes in accuracy for half-precision since the code changes from Smith's method to the simple method. 5 out of 1 million test cases show correct answers instead of 1 or 2 bit errors. libgcc computes half-precision functions in float precision allowing the existing methods to avoid overflow/underflow issues for the allowed range of exponents for half-precision. Extended precision (using x87 80-bit format on x86) and Long double (using IEEE-754 128-bit on x86 and aarch64) both have 15-bit exponents as compared to 11-bit exponents in double precision. We note that the C standard also allows Long Double to be implemented in the equivalent range of Double. The RMIN2 and RMINSCAL constants are selected to work within the Double range as well as with extended and 128-bit ranges. We will limit our performance and accurancy discussions to the 80-bit and 128-bit formats as seen on x86 here. The extended and long double precision investigations were more limited. Aarch64 does not support extended precision but does support the software implementation of 128-bit long double precision. For x86, long double defaults to the 80-bit precision but using the -mlong-double-128 flag switches to using the software implementation of 128-bit precision. Both 80-bit and 128-bit precisions have the same exponent range, with the 128-bit precision has extended mantissas. Since this change is only aimed at avoiding underflow/overflow for extreme exponents, I studied the extended precision results on x86 for 100,000 values. The limited exponent dataset showed no differences. For the dataset with full exponent range, the current and new values showed major differences (greater than 32 bits) in 567 cases out of 100,000 (0.56%). In every one of these cases, the ratio of c/d or d/c (as appropriate) was zero or subnormal, indicating the advantage of the new method and its continued correctness where needed. PERFORMANCE Test results In order for a library change to be practical, it is necessary to show the slowdown is tolerable. The slowdowns observed are much less than would be seen by (for example) switching from hardware double precison to a software quad precision, which on the tested machines causes a slowdown of around 100x). The actual slowdown depends on the machine architecture. It also depends on the nature of the input data. If underflow/overflow is rare, then implementations that have strong branch prediction will only slowdown by a few cycles. If underflow/overflow is common, then the branch predictors will be less accurate and the cost will be higher. Results from two machines are presented as examples of the overhead for the new method. The one labeled x86 is a 5 year old Intel x86 processor and the one labeled aarch64 is a 3 year old arm64 processor. In the following chart, the times are averaged over a one million value data set. All values are scaled to set the time of the current method to be 1.0. Lower values are better. A value of less than 1.0 would be faster than the current method and a value greater than 1.0 would be slower than the current method. ================================================ Moderate set full set x86 aarch64 x86 aarch64 ======== =============== =============== float 0.59 0.79 0.45 0.81 double 1.04 1.24 1.38 1.56 long double 1.13 1.24 1.29 1.25 ================================================ Table 5: Performance Comparisons (ratio new/current) The above tables omit the timing for the 1 divide and 2 multiply comparison with the 2 divide approach. The float results show clear performance improvement due to using the simple method with double precision for intermediate calculations. The double results with the newer method show less overhead for the moderate dataset than for the full dataset. That's because the moderate dataset does not ever take the new branches which protect from under/overflow. The better the branch predictor, the lower the cost for these untaken branches. Both platforms are somewhat dated, with the x86 having a better branch predictor which reduces the cost of the additional branches in the new code. Of course, the relative slowdown may be greater for some architectures, especially those with limited branch prediction combined with a high cost of misprediction. The long double results are fairly consistent in showing the moderate additional cost of the extra branches and calculations for all cases. The observed cost for all precisions is claimed to be tolerable on the grounds that: (a) the cost is worthwhile considering the accuracy improvement shown. (b) most applications will only spend a small fraction of their time calculating complex divide. (c) it is much less than the cost of extended precision (d) users are not forced to use it (as described below) Those users who find this degree of slowdown unsatisfactory may use the gcc switch -fcx-fortran-rules which does not use the library routine, instead inlining Smith's method without the C99 requirement for dealing with NaN results. The proposed patch for libgcc complex divide does not affect the code generated by -fcx-fortran-rules. SUMMARY When input data to complex divide has exponents whose absolute value is less than half of *_MAX_EXP, this patch makes no changes in accuracy and has only a modest effect on performance. When input data contains values outside those ranges, the patch eliminates more than 99.9% of major errors with a tolerable cost in performance. In comparison to Elen Kalda's method, this patch introduces more performance overhead but reduces major errors by a factor of greater than 4000. REFERENCES [1] Nelson H.F. Beebe, "The Mathematical-Function Computation Handbook. Springer International Publishing AG, 2017. [2] Robert L. Smith. Algorithm 116: Complex division. Commun. ACM, 5(8):435, 1962. [3] Michael Baudin and Robert L. Smith. "A robust complex division in Scilab," October 2012, available at http://arxiv.org/abs/1210.4539. [4] Elen Kalda: Complex division improvements in libgcc https://gcc.gnu.org/legacy-ml/gcc-patches/2019-08/msg01629.html 2020-12-08 Patrick McGehearty gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Add supporting macros for new complex divide libgcc/ * libgcc2.c (XMTYPE, XCTYPE, RBIG, RMIN, RMIN2, RMINSCAL, RMAX2): Define. (__divsc3, __divdc3, __divxc3, __divtc3): Improve complex divide. * config/rs6000/_divkc3.c (RBIG, RMIN, RMIN2, RMINSCAL, RMAX2): Define. (__divkc3): Improve complex divide. gcc/testsuite/ * gcc.c-torture/execute/ieee/cdivchkd.c: New test. * gcc.c-torture/execute/ieee/cdivchkf.c: Likewise. * gcc.c-torture/execute/ieee/cdivchkld.c: Likewise. --- gcc/c-family/c-cppbuiltin.c | 58 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 9f993c4..42b7604 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1277,29 +1277,39 @@ c_cpp_builtins (cpp_reader *pfile) { scalar_float_mode mode = mode_iter.require (); const char *name = GET_MODE_NAME (mode); + const size_t name_len = strlen (name); + char float_h_prefix[16] = ""; char *macro_name - = (char *) alloca (strlen (name) - + sizeof ("__LIBGCC__MANT_DIG__")); + = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MANT_DIG__")); sprintf (macro_name, "__LIBGCC_%s_MANT_DIG__", name); builtin_define_with_int_value (macro_name, REAL_MODE_FORMAT (mode)->p); if (!targetm.scalar_mode_supported_p (mode) || !targetm.libgcc_floating_mode_supported_p (mode)) continue; - macro_name = (char *) alloca (strlen (name) - + sizeof ("__LIBGCC_HAS__MODE__")); + macro_name = XALLOCAVEC (char, name_len + + sizeof ("__LIBGCC_HAS__MODE__")); sprintf (macro_name, "__LIBGCC_HAS_%s_MODE__", name); cpp_define (pfile, macro_name); - macro_name = (char *) alloca (strlen (name) - + sizeof ("__LIBGCC__FUNC_EXT__")); + macro_name = XALLOCAVEC (char, name_len + + sizeof ("__LIBGCC__FUNC_EXT__")); sprintf (macro_name, "__LIBGCC_%s_FUNC_EXT__", name); char suffix[20] = ""; if (mode == TYPE_MODE (double_type_node)) - ; /* Empty suffix correct. */ + { + /* Empty suffix correct. */ + memcpy (float_h_prefix, "DBL", 4); + } else if (mode == TYPE_MODE (float_type_node)) - suffix[0] = 'f'; + { + suffix[0] = 'f'; + memcpy (float_h_prefix, "FLT", 4); + } else if (mode == TYPE_MODE (long_double_type_node)) - suffix[0] = 'l'; + { + suffix[0] = 'l'; + memcpy (float_h_prefix, "LDBL", 5); + } else { bool found_suffix = false; @@ -1310,6 +1320,8 @@ c_cpp_builtins (cpp_reader *pfile) sprintf (suffix, "f%d%s", floatn_nx_types[i].n, floatn_nx_types[i].extended ? "x" : ""); found_suffix = true; + sprintf (float_h_prefix, "FLT%d%s", floatn_nx_types[i].n, + floatn_nx_types[i].extended ? "X" : ""); break; } gcc_assert (found_suffix); @@ -1347,11 +1359,33 @@ c_cpp_builtins (cpp_reader *pfile) default: gcc_unreachable (); } - macro_name = (char *) alloca (strlen (name) - + sizeof ("__LIBGCC__EXCESS_" - "PRECISION__")); + macro_name = XALLOCAVEC (char, name_len + + sizeof ("__LIBGCC__EXCESS_PRECISION__")); sprintf (macro_name, "__LIBGCC_%s_EXCESS_PRECISION__", name); builtin_define_with_int_value (macro_name, excess_precision); + + char val_name[64]; + + macro_name = XALLOCAVEC (char, name_len + + sizeof ("__LIBGCC__EPSILON__")); + sprintf (macro_name, "__LIBGCC_%s_EPSILON__", name); + sprintf (val_name, "__%s_EPSILON__", float_h_prefix); + builtin_define_with_value (macro_name, val_name, 0); + + macro_name = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MAX__")); + sprintf (macro_name, "__LIBGCC_%s_MAX__", name); + sprintf (val_name, "__%s_MAX__", float_h_prefix); + builtin_define_with_value (macro_name, val_name, 0); + + macro_name = XALLOCAVEC (char, name_len + sizeof ("__LIBGCC__MIN__")); + sprintf (macro_name, "__LIBGCC_%s_MIN__", name); + sprintf (val_name, "__%s_MIN__", float_h_prefix); + builtin_define_with_value (macro_name, val_name, 0); + +#ifdef HAVE_adddf3 + builtin_define_with_int_value ("__LIBGCC_HAVE_HWDBL__", + HAVE_adddf3); +#endif } /* For libgcc crtstuff.c and libgcc2.c. */ -- cgit v1.1 From e4ff4ffb43d3d8520f1c106e04421f2e6a021c39 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 29 Apr 2021 00:17:01 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 38855e1..b31a7ba 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-04-28 Patrick McGehearty + + * c-cppbuiltin.c (c_cpp_builtins): Add supporting macros for new + complex divide + 2021-04-26 Thomas Schwinge Nathan Sidwell Tom de Vries -- cgit v1.1 From 6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 17 Mar 2021 16:36:44 +0100 Subject: Come up with startswith function. gcc/ada/ChangeLog: * gcc-interface/utils.c (def_builtin_1): Use startswith function instead of strncmp. gcc/analyzer/ChangeLog: * sm-file.cc (is_file_using_fn_p): Use startswith function instead of strncmp. gcc/ChangeLog: * builtins.c (is_builtin_name): Use startswith function instead of strncmp. * collect2.c (main): Likewise. (has_lto_section): Likewise. (scan_libraries): Likewise. * coverage.c (coverage_checksum_string): Likewise. (coverage_init): Likewise. * dwarf2out.c (is_cxx): Likewise. (gen_compile_unit_die): Likewise. * gcc-ar.c (main): Likewise. * gcc.c (init_spec): Likewise. (read_specs): Likewise. (execute): Likewise. (check_live_switch): Likewise. * genattrtab.c (write_attr_case): Likewise. (IS_ATTR_GROUP): Likewise. * gencfn-macros.c (main): Likewise. * gengtype.c (type_for_name): Likewise. (gen_rtx_next): Likewise. (get_file_langdir): Likewise. (write_local): Likewise. * genmatch.c (get_operator): Likewise. (get_operand_type): Likewise. (expr::gen_transform): Likewise. * genoutput.c (validate_optab_operands): Likewise. * incpath.c (add_sysroot_to_chain): Likewise. * langhooks.c (lang_GNU_C): Likewise. (lang_GNU_CXX): Likewise. (lang_GNU_Fortran): Likewise. (lang_GNU_OBJC): Likewise. * lto-wrapper.c (run_gcc): Likewise. * omp-general.c (omp_max_simt_vf): Likewise. * omp-low.c (omp_runtime_api_call): Likewise. * opts-common.c (parse_options_from_collect_gcc_options): Likewise. * read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise. * real.c (real_from_string): Likewise. * selftest.c (assert_str_startswith): Likewise. * timevar.c (timer::validate_phases): Likewise. * tree.c (get_file_function_name): Likewise. * ubsan.c (ubsan_use_new_style_p): Likewise. * varasm.c (default_function_rodata_section): Likewise. (incorporeal_function_p): Likewise. (default_section_type_flags): Likewise. * system.h (startswith): Define startswith. gcc/c-family/ChangeLog: * c-ada-spec.c (print_destructor): Use startswith function instead of strncmp. (dump_ada_declaration): Likewise. * c-common.c (disable_builtin_function): Likewise. (def_builtin_1): Likewise. * c-format.c (check_tokens): Likewise. (check_plain): Likewise. (convert_format_name_to_system_name): Likewise. gcc/c/ChangeLog: * c-aux-info.c (affix_data_type): Use startswith function instead of strncmp. * c-typeck.c (build_function_call_vec): Likewise. * gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Use startswith function instead of strncmp. (cxx_builtin_function): Likewise. (omp_declare_variant_finalize_one): Likewise. (grokfndecl): Likewise. * error.c (dump_decl_name): Likewise. * mangle.c (find_decomp_unqualified_name): Likewise. (write_guarded_var_name): Likewise. (decl_tls_wrapper_p): Likewise. * parser.c (cp_parser_simple_type_specifier): Likewise. (cp_parser_tx_qualifier_opt): Likewise. * pt.c (template_parm_object_p): Likewise. (dguide_name_p): Likewise. gcc/d/ChangeLog: * d-builtins.cc (do_build_builtin_fn): Use startswith function instead of strncmp. * dmd/dinterpret.c (evaluateIfBuiltin): Likewise. * dmd/dmangle.c: Likewise. * dmd/hdrgen.c: Likewise. * dmd/identifier.c (Identifier::toHChars2): Likewise. gcc/fortran/ChangeLog: * decl.c (variable_decl): Use startswith function instead of strncmp. (gfc_match_end): Likewise. * gfortran.h (gfc_str_startswith): Likewise. * module.c (load_omp_udrs): Likewise. (read_module): Likewise. * options.c (gfc_handle_runtime_check_option): Likewise. * primary.c (match_arg_list_function): Likewise. * trans-decl.c (gfc_get_symbol_decl): Likewise. * trans-expr.c (gfc_conv_procedure_call): Likewise. * trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise. gcc/go/ChangeLog: * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith function instead of strncmp. gcc/objc/ChangeLog: * objc-act.c (objc_string_ref_type_p): Use startswith function instead of strncmp. * objc-encoding.c (encode_type): Likewise. * objc-next-runtime-abi-02.c (has_load_impl): Likewise. --- gcc/c-family/c-ada-spec.c | 8 ++++---- gcc/c-family/c-common.c | 5 ++--- gcc/c-family/c-format.c | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 17 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 9fef5f0..29eb0b0 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -2696,7 +2696,7 @@ print_destructor (pretty_printer *buffer, tree t, tree type) tree decl_name = DECL_NAME (TYPE_NAME (type)); pp_string (buffer, "Delete_"); - if (strncmp (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del", 8) == 0) + if (startswith (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del")) pp_string (buffer, "And_Free_"); pp_ada_tree_identifier (buffer, decl_name, t, false); } @@ -2980,9 +2980,9 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) return 0; /* Only consider complete constructors and deleting destructors. */ - if (strncmp (IDENTIFIER_POINTER (decl_name), "__ct_comp", 9) != 0 - && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_comp", 9) != 0 - && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_del", 8) != 0) + if (!startswith (IDENTIFIER_POINTER (decl_name), "__ct_comp") + && !startswith (IDENTIFIER_POINTER (decl_name), "__dt_comp") + && !startswith (IDENTIFIER_POINTER (decl_name), "__dt_del")) return 0; } diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index d227686..7bd799d 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4670,7 +4670,7 @@ static bool builtin_function_disabled_p (const char *); void disable_builtin_function (const char *name) { - if (strncmp (name, "__builtin_", strlen ("__builtin_")) == 0) + if (startswith (name, "__builtin_")) error ("cannot disable built-in function %qs", name); else { @@ -4718,8 +4718,7 @@ def_builtin_1 (enum built_in_function fncode, return; gcc_assert ((!both_p && !fallback_p) - || !strncmp (name, "__builtin_", - strlen ("__builtin_"))); + || startswith (name, "__builtin_")); libname = name + strlen ("__builtin_"); decl = add_builtin_function (name, fntype, fncode, fnclass, diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 0a63cac..bda3b18 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -3097,7 +3097,7 @@ check_tokens (const token_t *tokens, unsigned ntoks, /* Allow this ugly warning for the time being. */ if (toklen == 2 && format_chars - orig_format_chars > 6 - && !strncmp (format_chars - 7, " count >= width of ", 19)) + && startswith (format_chars - 7, " count >= width of ")) return format_chars + 10; /* The token is a type if it ends in an alphabetic character. */ @@ -3127,7 +3127,7 @@ check_tokens (const token_t *tokens, unsigned ntoks, /* Diagnose unquoted __attribute__. Consider any parenthesized argument to the attribute to avoid redundant warnings for the double parentheses that might follow. */ - if (!strncmp (format_chars, "__attribute", sizeof "__attribute" - 1)) + if (startswith (format_chars, "__attribute")) { unsigned nchars = sizeof "__attribute" - 1; while ('_' == format_chars[nchars]) @@ -3178,9 +3178,9 @@ check_tokens (const token_t *tokens, unsigned ntoks, /* Diagnose unquoted built-ins. */ if (format_chars[0] == '_' && format_chars[1] == '_' - && (!strncmp (format_chars + 2, "atomic", sizeof "atomic" - 1) - || !strncmp (format_chars + 2, "builtin", sizeof "builtin" - 1) - || !strncmp (format_chars + 2, "sync", sizeof "sync" - 1))) + && (startswith (format_chars + 2, "atomic") + || startswith (format_chars + 2, "builtin") + || startswith (format_chars + 2, "sync"))) { format_warning_substr (format_string_loc, format_string_cst, fmtchrpos, fmtchrpos + wlen, opt, @@ -3267,7 +3267,7 @@ check_plain (location_t format_string_loc, tree format_string_cst, if (*format_chars == '%') { /* Diagnose %<%s%> and suggest using %qs instead. */ - if (!strncmp (format_chars, "%<%s%>", 6)) + if (startswith (format_chars, "%<%s%>")) format_warning_substr (format_string_loc, format_string_cst, fmtchrpos, fmtchrpos + 6, opt, "quoted %qs directive in format; " @@ -3593,7 +3593,7 @@ check_plain (location_t format_string_loc, tree format_string_cst, if (nchars == 1) { - if (!strncmp (format_chars, "\"%s\"", 4)) + if (startswith (format_chars, "\"%s\"")) { if (format_warning_substr (format_string_loc, format_string_cst, fmtchrpos, fmtchrpos + 4, opt, @@ -3621,7 +3621,7 @@ check_plain (location_t format_string_loc, tree format_string_cst, && format_chars[0] == '(') ; /* Text beginning in an open parenthesis. */ else if (nchars == 3 - && !strncmp (format_chars, "...", 3) + && startswith (format_chars, "...") && format_chars[3]) ; /* Text beginning in an ellipsis. */ else @@ -3663,7 +3663,7 @@ check_plain (location_t format_string_loc, tree format_string_cst, a period at the end of a capitalized sentence. */ else if (nchars == 3 && format_chars - orig_format_chars > 0 - && !strncmp (format_chars, "...", 3)) + && startswith (format_chars, "...")) ; /* Text ending in the ellipsis. */ else format_warning_substr (format_string_loc, format_string_cst, @@ -5104,7 +5104,7 @@ convert_format_name_to_system_name (const char *attr_name) int i; if (attr_name == NULL || *attr_name == 0 - || strncmp (attr_name, "gcc_", 4) == 0) + || startswith (attr_name, "gcc_")) return attr_name; #ifdef TARGET_OVERRIDES_FORMAT_INIT TARGET_OVERRIDES_FORMAT_INIT (); -- cgit v1.1 From aa891c56f25baac94db004e309d1b6e40b770a95 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 11 May 2021 00:16:36 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b31a7ba..e73c3ee 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2021-05-10 Martin Liska + + * c-ada-spec.c (print_destructor): Use startswith + function instead of strncmp. + (dump_ada_declaration): Likewise. + * c-common.c (disable_builtin_function): Likewise. + (def_builtin_1): Likewise. + * c-format.c (check_tokens): Likewise. + (check_plain): Likewise. + (convert_format_name_to_system_name): Likewise. + 2021-04-28 Patrick McGehearty * c-cppbuiltin.c (c_cpp_builtins): Add supporting macros for new -- cgit v1.1 From 5ea40269a77a3754dd0f610f7c09b1a372e3c7f7 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 11 May 2021 14:25:55 +0000 Subject: preprocessor: Enable digit separators for C2X C2X adds digit separators, as in C++. Enable them accordingly in libcpp and c-lex.c. Some basic tests are added that digit separators behave as expected for C2X and are properly disabled for C11; further test coverage is included in the existing g++.dg/cpp1y/digit-sep*.C tests. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c-family/ * c-lex.c (interpret_float): Handle digit separators for C2X. libcpp/ * init.c (lang_defaults): Enable digit separators for GNUC2X and STDC2X. gcc/testsuite/ * gcc.dg/c11-digit-separators-1.c, gcc.dg/c2x-digit-separators-1.c, gcc.dg/c2x-digit-separators-2.c: New tests. --- gcc/c-family/c-lex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 6374b72..1c66ecd 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -1001,7 +1001,7 @@ interpret_float (const cpp_token *token, unsigned int flags, } copy = (char *) alloca (copylen + 1); - if (cxx_dialect > cxx11) + if (c_dialect_cxx () ? cxx_dialect > cxx11 : flag_isoc2x) { size_t maxlen = 0; for (size_t i = 0; i < copylen; ++i) -- cgit v1.1 From 037e36611108283a729d94a8ae15962995742886 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 12 May 2021 08:51:03 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e73c3ee..3860677 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-05-11 Joseph Myers + + * c-lex.c (interpret_float): Handle digit separators for C2X. + 2021-05-10 Martin Liska * c-ada-spec.c (print_destructor): Use startswith -- cgit v1.1 From 9feb5822b713c6a12cb290ba0406ba2362d4c09c Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 13 May 2021 13:59:59 +0200 Subject: attributes: target_clone expects a string argument PR middle-end/100504 gcc/c-family/ChangeLog: * c-attribs.c (handle_target_clones_attribute): Expect a string argument to target_clone argument. gcc/testsuite/ChangeLog: * gcc.target/i386/pr100504.c: New test. --- gcc/c-family/c-attribs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index c1f652d..f54388e 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -5288,7 +5288,12 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args), /* Ensure we have a function type. */ if (TREE_CODE (*node) == FUNCTION_DECL) { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) + if (TREE_CODE (TREE_VALUE (args)) != STRING_CST) + { + error ("%qE attribute argument not a string constant", name); + *no_add_attrs = true; + } + else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) { warning (OPT_Wattributes, "%qE attribute ignored due to conflict " "with %qs attribute", name, "always_inline"); -- cgit v1.1 From f9af11c7f156bede9aa28410073acbab7b0fa0fe Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 14 May 2021 00:16:30 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3860677..d33ad4a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-05-13 Martin Liska + + PR middle-end/100504 + * c-attribs.c (handle_target_clones_attribute): Expect a string + argument to target_clone argument. + 2021-05-11 Joseph Myers * c-lex.c (interpret_float): Handle digit separators for C2X. -- cgit v1.1 From 40a2f88838e5119799649a74692cbf38d774b706 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 14 May 2021 11:40:58 +0200 Subject: opts: add Warning keyword for 2 options gcc/c-family/ChangeLog: * c.opt: Add Warning keyword for 2 options. --- gcc/c-family/c.opt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index f1b4c3f..5fcf961 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -592,7 +592,7 @@ C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration) This switch is deprecated; use -Werror=implicit-function-declaration instead. Wexceptions -C++ ObjC++ Var(warn_exceptions) Init(1) +C++ ObjC++ Var(warn_exceptions) Init(1) Warning Warn when an exception handler is shadowed by another handler. Wextra @@ -1741,7 +1741,7 @@ C++ ObjC Var(flag_module_version_ignore) Integer ; undocumented, Very dangerous, but occasionally useful Winvalid-imported-macros -C++ ObjC++ Var(warn_imported_macros) +C++ ObjC++ Var(warn_imported_macros) Warning Warn about macros that have conflicting header units definitions. flang-info-include-translate -- cgit v1.1 From 87a7d10c2e9ec34a276e6acb5d2282a35b9cfafb Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 15 May 2021 00:16:27 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d33ad4a..7fc64a5 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-05-14 Martin Liska + + * c.opt: Add Warning keyword for 2 options. + 2021-05-13 Martin Liska PR middle-end/100504 -- cgit v1.1 From a8e19fa4198ea2504c89d01741d11766e0e9e91b Mon Sep 17 00:00:00 2001 From: Joern Rennecke Date: Mon, 17 May 2021 10:57:23 +0100 Subject: Avoid outputting corrupt string constructor when host/target chars mismatch. * c-common.c (braced_list_to_string): Return CTOR unchanged if host and target character sizes don't match. --- gcc/c-family/c-common.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7bd799d..b7daa2e 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -9059,6 +9059,12 @@ braced_list_to_string (tree type, tree ctor, bool member) if (!member && !tree_fits_uhwi_p (typesize)) return ctor; + /* If the target char size differes from the host char size, we'd risk + loosing data and getting object sizes wrong by converting to + host chars. */ + if (TYPE_PRECISION (char_type_node) != CHAR_BIT) + return ctor; + /* If the array has an explicit bound, use it to constrain the size of the string. If it doesn't, be sure to create a string that's as long as implied by the index of the last zero specified via -- cgit v1.1 From a7ffc1ef6e38c01037c8894a6bc1889d6f875444 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 18 May 2021 00:16:40 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7fc64a5..cc1019c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-05-17 Joern Rennecke + + * c-common.c (braced_list_to_string): Return CTOR unchanged + if host and target character sizes don't match. + 2021-05-14 Martin Liska * c.opt: Add Warning keyword for 2 options. -- cgit v1.1 From 4054472b3fa15e11ccd48190f5e3ecfc89d65af9 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 12 May 2021 09:20:17 +0200 Subject: c/100547 - reject overly large vector_size attributes This rejects a number of vector components that does not fit an 'int' which is an internal limitation of RTVEC. This requires adjusting gcc.dg/attr-vector_size.c which checks for much larger supported vectors. Note that the RTVEC limitation is a host specific limitation (unless we change this 'int' to int32_t), but should be 32bits in practice everywhere. 2021-05-12 Richard Biener PR c/100547 gcc/c-family/ * c-attribs.c (type_valid_for_vector_size): Reject too large nunits. Reword existing nunit diagnostic. gcc/testsuite/ * gcc.dg/pr100547.c: New testcase. * gcc.dg/attr-vector_size.c: Adjust. --- gcc/c-family/c-attribs.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index f54388e..ecb32c7 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -4245,10 +4245,22 @@ type_valid_for_vector_size (tree type, tree atname, tree args, if (nunits & (nunits - 1)) { if (error_p) - error ("number of components of the vector not a power of two"); + error ("number of vector components %wu not a power of two", nunits); else warning (OPT_Wattributes, - "number of components of the vector not a power of two"); + "number of vector components %wu not a power of two", nunits); + return NULL_TREE; + } + + if (nunits >= (unsigned HOST_WIDE_INT)INT_MAX) + { + if (error_p) + error ("number of vector components %wu exceeds %d", + nunits, INT_MAX - 1); + else + warning (OPT_Wattributes, + "number of vector components %wu exceeds %d", + nunits, INT_MAX - 1); return NULL_TREE; } -- cgit v1.1 From a8daf9a19a5eae6b98acede14bb6c27b2e0038e0 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 19 May 2021 00:16:45 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index cc1019c..ed45d29 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-05-18 Richard Biener + + PR c/100547 + * c-attribs.c (type_valid_for_vector_size): Reject too large nunits. + Reword existing nunit diagnostic. + 2021-05-17 Joern Rennecke * c-common.c (braced_list_to_string): Return CTOR unchanged -- cgit v1.1 From eb2a917fa0779b689f09ac8d8c41b0456facbe62 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 19 May 2021 16:13:13 -0600 Subject: PR c/100619 - ICE on a VLA parameter with too many dimensions gcc/c-family/ChangeLog: PR c/100619 * c-attribs.c (build_attr_access_from_parms): Handle arbitrarily many bounds. gcc/testsuite/ChangeLog: PR c/100619 * gcc.dg/pr100619.c: New test. --- gcc/c-family/c-attribs.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index ecb32c7..ccf9e4c 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -5043,16 +5043,25 @@ build_attr_access_from_parms (tree parms, bool skip_voidptr) /* Create the attribute access string from the arg spec string, optionally followed by position of the VLA bound argument if it is one. */ - char specbuf[80]; - int len = snprintf (specbuf, sizeof specbuf, "%c%u%s", - attr_access::mode_chars[access_deferred], - argpos, s); - gcc_assert ((size_t) len < sizeof specbuf); - - if (!spec.length ()) - spec += '+'; + { + size_t specend = spec.length (); + if (!specend) + { + spec = '+'; + specend = 1; + } - spec += specbuf; + /* Format the access string in place. */ + int len = snprintf (NULL, 0, "%c%u%s", + attr_access::mode_chars[access_deferred], + argpos, s); + spec.resize (specend + len + 1); + sprintf (&spec[specend], "%c%u%s", + attr_access::mode_chars[access_deferred], + argpos, s); + /* Trim the trailing NUL. */ + spec.resize (specend + len); + } /* The (optional) list of expressions denoting the VLA bounds N in ARGTYPE [Ni]...[Nj]...[Nk]. */ @@ -5077,8 +5086,13 @@ build_attr_access_from_parms (tree parms, bool skip_voidptr) { /* BOUND previously seen in the parameter list. */ TREE_PURPOSE (vb) = size_int (*psizpos); - sprintf (specbuf, "$%u", *psizpos); - spec += specbuf; + /* Format the position string in place. */ + int len = snprintf (NULL, 0, "$%u", *psizpos); + size_t specend = spec.length (); + spec.resize (specend + len + 1); + sprintf (&spec[specend], "$%u", *psizpos); + /* Trim the trailing NUL. */ + spec.resize (specend + len); } else { -- cgit v1.1 From 65f32e5d6bbeb93a7d8d121fd56af6555e16d747 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 20 May 2021 00:16:40 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ed45d29..6fd6790 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-05-19 Martin Sebor + + PR c/100619 + * c-attribs.c (build_attr_access_from_parms): Handle arbitrarily many + bounds. + 2021-05-18 Richard Biener PR c/100547 -- cgit v1.1 From 459d84e9b6e925922246b6aff76a5202b1d4d4ba Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Fri, 30 Apr 2021 07:52:40 -0700 Subject: opts: change write_symbols to support bitmasks To support multiple debug formats, we need to move away from explicit enumeration of each individual combination of debug formats. gcc/c-family/ChangeLog: * c-opts.c (c_common_post_options): Adjust access to debug_type_names. * c-pch.c (struct c_pch_validity): Use type uint32_t. (pch_init): Renamed member. (c_common_valid_pch): Adjust access to debug_type_names. gcc/ChangeLog: * common.opt: Change type to support bitmasks. * flag-types.h (enum debug_info_type): Rename enumerator constants. (NO_DEBUG): New bitmask. (DBX_DEBUG): Likewise. (DWARF2_DEBUG): Likewise. (XCOFF_DEBUG): Likewise. (VMS_DEBUG): Likewise. (VMS_AND_DWARF2_DEBUG): Likewise. * flags.h (debug_set_to_format): New function declaration. (debug_set_count): Likewise. (debug_set_names): Likewise. * opts.c (debug_type_masks): Array of bitmasks for debug formats. (debug_set_to_format): New function definition. (debug_set_count): Likewise. (debug_set_names): Likewise. (set_debug_level): Update access to debug_type_names. * toplev.c: Likewise. gcc/objc/ChangeLog: * objc-act.c (synth_module_prologue): Use uint32_t instead of enum debug_info_type. gcc/testsuite/ChangeLog: * gcc.dg/pch/valid-1.c: Adjust diagnostic message in testcase. * lib/dg-pch.exp: Adjust diagnostic message. --- gcc/c-family/c-opts.c | 7 ++++--- gcc/c-family/c-pch.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 89e05a4..60b5802 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1112,9 +1112,10 @@ c_common_post_options (const char **pfilename) /* Only -g0 and -gdwarf* are supported with PCH, for other debug formats we warn here and refuse to load any PCH files. */ if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG) - warning (OPT_Wdeprecated, - "the %qs debug format cannot be used with " - "pre-compiled headers", debug_type_names[write_symbols]); + warning (OPT_Wdeprecated, + "the %qs debug info cannot be used with " + "pre-compiled headers", + debug_set_names (write_symbols & ~DWARF2_DEBUG)); } else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG) c_common_no_more_pch (); diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index fd94c37..8f0f760 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -52,7 +52,7 @@ enum { struct c_pch_validity { - unsigned char debug_info_type; + uint32_t pch_write_symbols; signed char match[MATCH_SIZE]; void (*pch_init) (void); size_t target_data_length; @@ -108,7 +108,7 @@ pch_init (void) pch_outfile = f; memset (&v, '\0', sizeof (v)); - v.debug_info_type = write_symbols; + v.pch_write_symbols = write_symbols; { size_t i; for (i = 0; i < MATCH_SIZE; i++) @@ -252,13 +252,13 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) /* The allowable debug info combinations are that either the PCH file was built with the same as is being used now, or the PCH file was built for some kind of debug info but now none is in use. */ - if (v.debug_info_type != write_symbols + if (v.pch_write_symbols != write_symbols && write_symbols != NO_DEBUG) { cpp_warning (pfile, CPP_W_INVALID_PCH, - "%s: created with -g%s, but used with -g%s", name, - debug_type_names[v.debug_info_type], - debug_type_names[write_symbols]); + "%s: created with '%s' debug info, but used with '%s'", name, + debug_set_names (v.pch_write_symbols), + debug_set_names (write_symbols)); return 2; } -- cgit v1.1 From 66168f96f07b12bbe0beb6e0e988818f624d56bd Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Fri, 30 Apr 2021 08:03:52 -0700 Subject: dwarf: new dwarf_debuginfo_p predicate This patch introduces a dwarf_debuginfo_p predicate that abstracts and replaces complex checks on write_symbols. gcc/c-family/ChangeLog: * c-lex.c (init_c_lex): Use dwarf_debuginfo_p. gcc/ChangeLog: * config/c6x/c6x.c (c6x_output_file_unwind): Use dwarf_debuginfo_p. * config/darwin.c (darwin_override_options): Likewise. * config/i386/cygming.h (DBX_REGISTER_NUMBER): Likewise. * config/i386/darwin.h (DBX_REGISTER_NUMBER): Likewise. (DWARF2_FRAME_REG_OUT): Likewise. * config/mips/mips.c (mips_output_filename): Likewise. * config/rs6000/rs6000.c (rs6000_xcoff_declare_function_name): Likewise. (rs6000_dbx_register_number): Likewise. * dbxout.c: Include flags.h. * dwarf2cfi.c (cfi_label_required_p): Likewise. (dwarf2out_do_frame): Likewise. * except.c: Include flags.h. * final.c (dwarf2_debug_info_emitted_p): Likewise. (final_scan_insn_1): Likewise. * flags.h (dwarf_debuginfo_p): New function declaration. * opts.c (dwarf_debuginfo_p): New function definition. * targhooks.c (default_debug_unwind_info): Use dwarf_debuginfo_p. * toplev.c (process_options): Likewise. --- gcc/c-family/c-lex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 1c66ecd..c44e7a1 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "stor-layout.h" #include "c-pragma.h" #include "debug.h" +#include "flags.h" #include "file-prefix-map.h" /* remap_macro_filename() */ #include "langhooks.h" #include "attribs.h" @@ -87,8 +88,7 @@ init_c_lex (void) /* Set the debug callbacks if we can use them. */ if ((debug_info_level == DINFO_LEVEL_VERBOSE - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG)) + && dwarf_debuginfo_p ()) || flag_dump_go_spec != NULL) { cb->define = cb_define; -- cgit v1.1 From ee336ecb2a7161bc28f6c5343d97870a8d15e177 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 19 May 2021 21:35:58 +0100 Subject: c++: Add new warning options for C++ language mismatches This adds new warning flags, enabled by default: -Wc++11-extensions, -Wc++14-extensions, -Wc++17-extensions, -Wc++20-extensions, and -Wc++23-extensions. The names of the flags are copied from Clang, which already has similar options. No new diagnostics are added, but the new OPT_Wxxx variables are used to control existing pedwarns about occurences of new C++ constructs in code using an old C++ standard dialect. This allows several existing warnings that cannot currently be disabled to be controlled by the appropriate -Wno-xxx flag. For example, it will now be possible to disable warnings about using variadic templates in C++98 code, by using the new -Wno-c++11-extensions option. This will allow libstdc++ headers to disable those warnings unconditionally by using diagnostic pragmas, so that they are not emitted even if -Wsystem-headers is used. Some of the affected diagnostics are currently only given when -Wpedantic is used. Now that we have a more specific warning flag, we could consider making them not depend on -Wpedantic, and only on the new flag. This patch does not do that, as it intends to make no changes to what is accepted/rejected by default. The only effect should be that the new option is shown when -fdiagnostics-show-option is active, and that some warnings can be disabled by using the new flags (and for the warnings that previously only dependend on -Wpedantic, it will now be possible to disable just those warnings while still using -Wpedantic for its other benefits). gcc/c-family/ChangeLog: * c.opt (Wc++11-extensions, Wc++14-extensions) (Wc++17-extensions, Wc++20-extensions, Wc++23-extensions): New options. gcc/cp/ChangeLog: * call.c (maybe_warn_array_conv): Use new warning option. * decl.c (mark_inline_variable, grokdeclarator): Likewise. * error.c (maybe_warn_cpp0x): Likewise. * parser.c (cp_parser_primary_expression) (cp_parser_unqualified_id) (cp_parser_pseudo_destructor_name) (cp_parser_lambda_introducer) (cp_parser_lambda_declarator_opt) (cp_parser_selection_statement) (cp_parser_init_statement) (cp_parser_decomposition_declaration) (cp_parser_function_specifier_opt) (cp_parser_static_assert) (cp_parser_namespace_definition) (cp_parser_using_declaration) (cp_parser_asm_definition) (cp_parser_ctor_initializer_opt_and_function_body) (cp_parser_initializer_list) (cp_parser_type_parameter_key) (cp_parser_member_declaration) (cp_parser_try_block) (cp_parser_std_attribute_spec): Likewise. * pt.c (check_template_variable): Likewise. gcc/ChangeLog: * doc/invoke.texi (-Wno-c++11-extensions) (-Wno-c++14-extensions, -Wno-c++17-extensions) (-Wno-c++20-extensions, -Wno-c++23-extensions): Document new options. --- gcc/c-family/c.opt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 5fcf961..9192970 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -431,6 +431,26 @@ Wc++20-compat C++ ObjC++ Var(warn_cxx20_compat) Warning LangEnabledBy(C++ ObjC++,Wall) Warn about C++ constructs whose meaning differs between ISO C++ 2017 and ISO C++ 2020. +Wc++11-extensions +C++ ObjC++ Var(warn_cxx11_extensions) Warning LangEnabledBy(C++ ObjC++) Init(1) +Warn about C++11 constructs in code compiled with an older standard. + +Wc++14-extensions +C++ ObjC++ Var(warn_cxx14_extensions) Warning LangEnabledBy(C++ ObjC++) Init(1) +Warn about C++14 constructs in code compiled with an older standard. + +Wc++17-extensions +C++ ObjC++ Var(warn_cxx17_extensions) Warning LangEnabledBy(C++ ObjC++) Init(1) +Warn about C++17 constructs in code compiled with an older standard. + +Wc++20-extensions +C++ ObjC++ Var(warn_cxx20_extensions) Warning LangEnabledBy(C++ ObjC++) Init(1) +Warn about C++20 constructs in code compiled with an older standard. + +Wc++23-extensions +C++ ObjC++ Var(warn_cxx23_extensions) Warning LangEnabledBy(C++ ObjC++) Init(1) +Warn about C++23 constructs in code compiled with an older standard. + Wcast-function-type C ObjC C++ ObjC++ Var(warn_cast_function_type) Warning EnabledBy(Wextra) Warn about casts between incompatible function types. -- cgit v1.1 From ea34e2edd3d7ab245d1f57a1487c10587f324ec6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 21 May 2021 00:16:57 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 6fd6790..6dc0400 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,20 @@ +2021-05-20 Jonathan Wakely + + * c.opt (Wc++11-extensions, Wc++14-extensions) + (Wc++17-extensions, Wc++20-extensions, Wc++23-extensions): New + options. + +2021-05-20 Indu Bhagat + + * c-lex.c (init_c_lex): Use dwarf_debuginfo_p. + +2021-05-20 Indu Bhagat + + * c-opts.c (c_common_post_options): Adjust access to debug_type_names. + * c-pch.c (struct c_pch_validity): Use type uint32_t. + (pch_init): Renamed member. + (c_common_valid_pch): Adjust access to debug_type_names. + 2021-05-19 Martin Sebor PR c/100619 -- cgit v1.1 From b5c1c7a96bc8d7062d2c35675f48131667498182 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 21 May 2021 21:16:21 +0200 Subject: openmp: Fix up firstprivate+lastprivate clause handling [PR99928] The C/C++ clause splitting happens very early during construct parsing, but only the FEs later on handle possible instantiations, non-static member handling and array section lowering. In the OpenMP 5.0/5.1 rules, whether firstprivate is added to combined target depends on whether it isn't also mentioned in lastprivate or map clauses, but unfortunately I think such checks are much better done only when the FEs perform all the above mentioned changes. So, this patch arranges for the firstprivate clause to be copied or moved to combined target construct (as before), but sets flags on that clause, which tell the FE *finish_omp_clauses and the gimplifier it has been added only conditionally and let the FEs and gimplifier DTRT for these. 2021-05-21 Jakub Jelinek PR middle-end/99928 gcc/ * tree.h (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET): Define. * gimplify.c (enum gimplify_omp_var_data): Fix up GOVD_MAP_HAS_ATTACHMENTS value, add GOVD_FIRSTPRIVATE_IMPLICIT. (omp_lastprivate_for_combined_outer_constructs): If combined target has GOVD_FIRSTPRIVATE_IMPLICIT set for the decl, change it to GOVD_MAP | GOVD_SEEN. (gimplify_scan_omp_clauses): Set GOVD_FIRSTPRIVATE_IMPLICIT for firstprivate clauses with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT. (gimplify_adjust_omp_clauses): For firstprivate clauses with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT either clear that bit and OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET too, or remove it and let it be replaced by implicit map clause. gcc/c-family/ * c-omp.c (c_omp_split_clauses): Set OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT on firstprivate clause copy going to target construct, and for target simd set also OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET bit. gcc/c/ * c-typeck.c (c_finish_omp_clauses): Move firstprivate clauses with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT to the end of the chain. Don't error if a decl is mentioned both in map clause and in such firstprivate clause unless OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET is also set. gcc/cp/ * semantics.c (finish_omp_clauses): Move firstprivate clauses with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT to the end of the chain. Don't error if a decl is mentioned both in map clause and in such firstprivate clause unless OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET is also set. gcc/testsuite/ * c-c++-common/gomp/pr99928-3.c: Remove all xfails. * c-c++-common/gomp/pr99928-15.c: New test. --- gcc/c-family/c-omp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index fb1a0d6..0945a1e 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -1733,10 +1733,21 @@ c_omp_split_clauses (location_t loc, enum tree_code code, { /* This must be #pragma omp target simd. */ s = C_OMP_CLAUSE_SPLIT_TARGET; + OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (clauses) = 1; + OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (clauses) = 1; break; } c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), OMP_CLAUSE_FIRSTPRIVATE); + /* firstprivate should not be applied to target if it is + also lastprivate or on the combined/composite construct, + or if it is mentioned in map clause. OMP_CLAUSE_DECLs + may need to go through FE handling though (instantiation, + C++ non-static data members, array section lowering), so + add the clause with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT and + let *finish_omp_clauses and the gimplifier handle it + right. */ + OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) = 1; OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = c; -- cgit v1.1 From 2832d51b383392e961373fb7067a73c6dfdc7cb1 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 22 May 2021 00:16:29 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 6dc0400..43d4c5e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2021-05-21 Jakub Jelinek + + PR middle-end/99928 + * c-omp.c (c_omp_split_clauses): Set OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT + on firstprivate clause copy going to target construct, and for + target simd set also OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET bit. + 2021-05-20 Jonathan Wakely * c.opt (Wc++11-extensions, Wc++14-extensions) -- cgit v1.1 From 3a81735c1c8cea4323dcb912b7a8879b54aa3bc0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 25 May 2021 11:07:01 +0200 Subject: openmp: Fix reduction clause handling on teams distribute simd [PR99928] When a directive isn't combined with worksharing-loop, it takes much simpler clause splitting path for reduction, and that one was missing handling of teams when combined with simd. 2021-05-25 Jakub Jelinek PR middle-end/99928 gcc/c-family/ * c-omp.c (c_omp_split_clauses): Copy reduction to teams when teams is combined with simd and not with taskloop or for. gcc/testsuite/ * c-c++-common/gomp/pr99928-8.c: Remove xfails from omp teams r21 and r28 checks. * c-c++-common/gomp/pr99928-9.c: Likewise. * c-c++-common/gomp/pr99928-10.c: Likewise. libgomp/ * testsuite/libgomp.c-c++-common/reduction-17.c: New test. --- gcc/c-family/c-omp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 0945a1e..1b4a112 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2059,6 +2059,23 @@ c_omp_split_clauses (location_t loc, enum tree_code code, OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_TASKLOOP]; cclauses[C_OMP_CLAUSE_SPLIT_TASKLOOP] = c; } + else if ((mask & (OMP_CLAUSE_MASK_1 + << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) != 0) + { + c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), + OMP_CLAUSE_REDUCTION); + OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); + OMP_CLAUSE_REDUCTION_CODE (c) + = OMP_CLAUSE_REDUCTION_CODE (clauses); + OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) + = OMP_CLAUSE_REDUCTION_PLACEHOLDER (clauses); + OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) + = OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clauses); + OMP_CLAUSE_REDUCTION_INSCAN (c) + = OMP_CLAUSE_REDUCTION_INSCAN (clauses); + OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS]; + cclauses[C_OMP_CLAUSE_SPLIT_TEAMS] = c; + } s = C_OMP_CLAUSE_SPLIT_SIMD; } else -- cgit v1.1 From cec4d4a6782c9bd8d071839c50a239c49caca689 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 20 May 2021 09:32:29 +0200 Subject: Add no_sanitize_coverage attribute. gcc/ChangeLog: * asan.h (sanitize_coverage_p): New function. * doc/extend.texi: Document it. * fold-const.c (fold_range_test): Use sanitize_flags_p instead of flag_sanitize_coverage. (fold_truth_andor): Likewise. * sancov.c: Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * ipa-inline.c (sanitize_attrs_match_for_inline_p): Handle -fsanitize-coverage when inlining. gcc/c-family/ChangeLog: * c-attribs.c (handle_no_sanitize_coverage_attribute): New. gcc/testsuite/ChangeLog: * gcc.dg/sancov/attribute.c: New test. --- gcc/c-family/c-attribs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index ccf9e4c..671b27c 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -62,6 +62,8 @@ static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree, int, bool *); static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int, bool *); +static tree handle_no_sanitize_coverage_attribute (tree *, tree, tree, int, + bool *); static tree handle_asan_odr_indicator_attribute (tree *, tree, tree, int, bool *); static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *); @@ -449,6 +451,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_no_sanitize_thread_attribute, NULL }, { "no_sanitize_undefined", 0, 0, true, false, false, false, handle_no_sanitize_undefined_attribute, NULL }, + { "no_sanitize_coverage", 0, 0, true, false, false, false, + handle_no_sanitize_coverage_attribute, NULL }, { "asan odr indicator", 0, 0, true, false, false, false, handle_asan_odr_indicator_attribute, NULL }, { "warning", 1, 1, true, false, false, false, @@ -1211,6 +1215,22 @@ handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int, return NULL_TREE; } +/* Handle a "no_sanitize_coverage" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_no_sanitize_coverage_attribute (tree *node, tree name, tree, int, + bool *no_add_attrs) +{ + if (TREE_CODE (*node) != FUNCTION_DECL) + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Handle an "asan odr indicator" attribute; arguments as in struct attribute_spec.handler. */ -- cgit v1.1 From ebd5e86c0f41dc1d692f9b2b68a510b1f6835a3e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 10 Mar 2021 15:12:31 +0100 Subject: Improve global state for options. gcc/c-family/ChangeLog: PR tree-optimization/92860 PR target/99592 * c-attribs.c (handle_optimize_attribute): Save target node before calling parse_optimize_options and save it in case it changes. * c-pragma.c (handle_pragma_target): Similarly for pragma. (handle_pragma_pop_options): Likewise here. gcc/ChangeLog: PR tree-optimization/92860 PR target/99592 * optc-save-gen.awk: Remove exceptions. --- gcc/c-family/c-attribs.c | 9 +++++++++ gcc/c-family/c-pragma.c | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 671b27c..804374d 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -5383,6 +5383,8 @@ handle_optimize_attribute (tree *node, tree name, tree args, /* Save current options. */ cl_optimization_save (&cur_opts, &global_options, &global_options_set); + tree prev_target_node = build_target_option_node (&global_options, + &global_options_set); /* If we previously had some optimization options, use them as the default. */ @@ -5401,10 +5403,17 @@ handle_optimize_attribute (tree *node, tree name, tree args, parse_optimize_options (args, true); DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = build_optimization_node (&global_options, &global_options_set); + tree target_node = build_target_option_node (&global_options, + &global_options_set); + if (prev_target_node != target_node) + DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node; /* Restore current options. */ cl_optimization_restore (&global_options, &global_options_set, &cur_opts); + cl_target_option_restore (&global_options, &global_options_set, + TREE_TARGET_OPTION (prev_target_node)); + if (saved_global_options != NULL) { cl_optimization_compare (saved_global_options, &global_options); diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 4f8e8e0..7f658ea 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -918,6 +918,12 @@ handle_pragma_target(cpp_reader *ARG_UNUSED(dummy)) if (targetm.target_option.pragma_parse (args, NULL_TREE)) current_target_pragma = chainon (current_target_pragma, args); + + /* A target pragma can also influence optimization options. */ + tree current_optimize + = build_optimization_node (&global_options, &global_options_set); + if (current_optimize != optimization_current_node) + optimization_current_node = current_optimize; } } @@ -1078,12 +1084,14 @@ handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy)) target_option_current_node = p->target_binary; } + /* Always restore optimization options as optimization_current_node is + * overwritten by invoke_set_current_function_hook. */ + cl_optimization_restore (&global_options, &global_options_set, + TREE_OPTIMIZATION (p->optimize_binary)); + if (p->optimize_binary != optimization_current_node) { - tree old_optimize = optimization_current_node; - cl_optimization_restore (&global_options, &global_options_set, - TREE_OPTIMIZATION (p->optimize_binary)); - c_cpp_builtins_optimize_pragma (parse_in, old_optimize, + c_cpp_builtins_optimize_pragma (parse_in, optimization_current_node, p->optimize_binary); optimization_current_node = p->optimize_binary; } -- cgit v1.1 From 2bc6dacecb2ba60f1f06f310c6887a26b09cdba8 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 26 May 2021 00:16:41 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 43d4c5e..28544c7 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,23 @@ +2021-05-25 Martin Liska + + PR tree-optimization/92860 + PR target/99592 + * c-attribs.c (handle_optimize_attribute): Save target node + before calling parse_optimize_options and save it in case + it changes. + * c-pragma.c (handle_pragma_target): Similarly for pragma. + (handle_pragma_pop_options): Likewise here. + +2021-05-25 Martin Liska + + * c-attribs.c (handle_no_sanitize_coverage_attribute): New. + +2021-05-25 Jakub Jelinek + + PR middle-end/99928 + * c-omp.c (c_omp_split_clauses): Copy reduction to teams when teams is + combined with simd and not with taskloop or for. + 2021-05-21 Jakub Jelinek PR middle-end/99928 -- cgit v1.1 From 9a5de4d5af1c10a8c097de30ee4c71457216e975 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 28 May 2021 10:01:19 +0200 Subject: OpenMP: Add iterator support to Fortran's depend; add affinity clause gcc/c-family/ChangeLog: * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_AFFINITY. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_clause_affinity): New. (c_parser_omp_clause_name, c_parser_omp_variable_list, c_parser_omp_all_clauses, OMP_TASK_CLAUSE_MASK): Handle affinity clause. * c-typeck.c (handle_omp_array_sections_1, handle_omp_array_sections, c_finish_omp_clauses): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_clause_affinity): New. (cp_parser_omp_clause_name, cp_parser_omp_var_list_no_open, cp_parser_omp_all_clauses, OMP_TASK_CLAUSE_MASK): Handle affinity clause. * semantics.c (handle_omp_array_sections_1, handle_omp_array_sections, finish_omp_clauses): Likewise. gcc/fortran/ChangeLog: * dump-parse-tree.c (show_iterator): New. (show_omp_namelist): Handle iterators. (show_omp_clauses): Handle affinity. * gfortran.h (gfc_free_omp_namelist): New union with 'udr' and new 'ns'. * match.c (gfc_free_omp_namelist): Add are to choose union element. * openmp.c (gfc_free_omp_clauses, gfc_match_omp_detach, gfc_match_omp_clause_reduction, gfc_match_omp_flush): Update call to gfc_free_omp_namelist. (gfc_match_omp_variable_list): Likewise; permit preceeding whitespace. (enum omp_mask1): Add OMP_CLAUSE_AFFINITY. (gfc_match_iterator): New. (gfc_match_omp_clauses): Use it; update call to gfc_free_omp_namelist. (OMP_TASK_CLAUSES): Add OMP_CLAUSE_AFFINITY. (gfc_match_omp_taskwait): Match depend clause. (resolve_omp_clauses): Handle affinity; update for udr/union change. (gfc_resolve_omp_directive): Resolve clauses of taskwait. * st.c (gfc_free_statement): Update gfc_free_omp_namelist call. * trans-openmp.c (gfc_trans_omp_array_reduction_or_udr): Likewise (handle_iterator): New. (gfc_trans_omp_clauses): Handle iterators for depend/affinity clause. (gfc_trans_omp_taskwait): Handle depend clause. (gfc_trans_omp_directive): Update call. gcc/ChangeLog: * gimplify.c (gimplify_omp_affinity): New. (gimplify_scan_omp_clauses): Call it; remove affinity clause afterwards. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_AFFINITY. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_AFFINITY. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add clause. (walk_tree_1): Handle OMP_CLAUSE_AFFINITY. libgomp/ChangeLog: * testsuite/libgomp.fortran/depend-iterator-2.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/affinity-1.c: New test. * c-c++-common/gomp/affinity-2.c: New test. * c-c++-common/gomp/affinity-3.c: New test. * c-c++-common/gomp/affinity-4.c: New test. * c-c++-common/gomp/affinity-5.c: New test. * c-c++-common/gomp/affinity-6.c: New test. * c-c++-common/gomp/affinity-7.c: New test. * gfortran.dg/gomp/affinity-clause-1.f90: New test. * gfortran.dg/gomp/affinity-clause-2.f90: New test. * gfortran.dg/gomp/affinity-clause-3.f90: New test. * gfortran.dg/gomp/affinity-clause-4.f90: New test. * gfortran.dg/gomp/affinity-clause-5.f90: New test. * gfortran.dg/gomp/affinity-clause-6.f90: New test. * gfortran.dg/gomp/depend-iterator-1.f90: New test. * gfortran.dg/gomp/depend-iterator-2.f90: New test. * gfortran.dg/gomp/depend-iterator-3.f90: New test. * gfortran.dg/gomp/taskwait.f90: New test. --- gcc/c-family/c-pragma.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index 6c34ffa..e4fd3c9 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -86,6 +86,7 @@ enum pragma_kind { enum pragma_omp_clause { PRAGMA_OMP_CLAUSE_NONE = 0, + PRAGMA_OMP_CLAUSE_AFFINITY, PRAGMA_OMP_CLAUSE_ALIGNED, PRAGMA_OMP_CLAUSE_ALLOCATE, PRAGMA_OMP_CLAUSE_BIND, -- cgit v1.1 From c94424b0ed786ec92b6904da69af8b5243b34fdc Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 28 May 2021 11:26:48 +0200 Subject: openmp: Fix up handling of reduction clause on constructs combined with target [PR99928] The reduction clause should be copied as map (tofrom: ) to combined target if present, but as we need different handling of array sections between map and reduction, doing that during gimplification would be harder. So, this patch adds them during splitting, and similarly to firstprivate adds them with a new flag that they should be just ignored/removed if an explicit map clause of the same list item is present. The exact rules are to be decided in https://github.com/OpenMP/spec/issues/2766 so this patch just implements something that is IMHO reasonable and exact detailed testcases for the cornercases will follow once it is clarified. 2021-05-28 Jakub Jelinek PR middle-end/99928 gcc/ * tree.h (OMP_CLAUSE_MAP_IMPLICIT): Define. gcc/c-family/ * c-omp.c (c_omp_split_clauses): For reduction clause if combined with target add a map tofrom clause with OMP_CLAUSE_MAP_IMPLICIT. gcc/c/ * c-typeck.c (handle_omp_array_sections): Copy OMP_CLAUSE_MAP_IMPLICIT. (c_finish_omp_clauses): Move not just OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT marked clauses last, but also OMP_CLAUSE_MAP_IMPLICIT. Add map_firstprivate_head bitmap, set it for GOMP_MAP_FIRSTPRIVATE_POINTER maps and silently remove OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT if it is present too. For OMP_CLAUSE_MAP_IMPLICIT silently remove the clause if present in map_head, map_field_head or map_firstprivate_head bitmaps. gcc/cp/ * semantics.c (handle_omp_array_sections): Copy OMP_CLAUSE_MAP_IMPLICIT. (finish_omp_clauses): Move not just OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT marked clauses last, but also OMP_CLAUSE_MAP_IMPLICIT. Add map_firstprivate_head bitmap, set it for GOMP_MAP_FIRSTPRIVATE_POINTER maps and silently remove OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT if it is present too. For OMP_CLAUSE_MAP_IMPLICIT silently remove the clause if present in map_head, map_field_head or map_firstprivate_head bitmaps. gcc/testsuite/ * c-c++-common/gomp/pr99928-8.c: Remove all xfails. * c-c++-common/gomp/pr99928-9.c: Likewise. * c-c++-common/gomp/pr99928-10.c: Likewise. * c-c++-common/gomp/pr99928-16.c: New test. --- gcc/c-family/c-omp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 1b4a112..28fbb1d 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -1989,6 +1989,16 @@ c_omp_split_clauses (location_t loc, enum tree_code code, "%, %"); OMP_CLAUSE_REDUCTION_INSCAN (clauses) = 0; } + if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) != 0) + { + c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), + OMP_CLAUSE_MAP); + OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); + OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM); + OMP_CLAUSE_MAP_IMPLICIT (c) = 1; + OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; + cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = c; + } if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) != 0) { if (code == OMP_SIMD) -- cgit v1.1 From 48166757dcf46d92cf1795dd7333dda7030179c8 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 29 May 2021 00:16:29 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 28544c7..2905179 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,13 @@ +2021-05-28 Jakub Jelinek + + PR middle-end/99928 + * c-omp.c (c_omp_split_clauses): For reduction clause if combined with + target add a map tofrom clause with OMP_CLAUSE_MAP_IMPLICIT. + +2021-05-28 Tobias Burnus + + * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_AFFINITY. + 2021-05-25 Martin Liska PR tree-optimization/92860 -- cgit v1.1 From ef8176e0fac935c095cc39f4ecdfd43cdb8cb3f3 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 21 May 2021 11:33:30 +0200 Subject: c++/88601 - [C/C++] __builtin_shufflevector support This adds support for the clang __builtin_shufflevector extension to the C and C++ frontends. The builtin is lowered to VEC_PERM_EXPR. Because VEC_PERM_EXPR does not support different sized vector inputs or result or the special permute index of -1 (don't-care) c_build_shufflevector applies lowering by widening inputs and output to the widest vector, replacing -1 by a defined index and subsetting the final vector if we produced a wider result than desired. Code generation thus can be sub-optimal, followup patches will aim to fix that by recovering from part of the missing features during RTL expansion and by relaxing the constraints of the GIMPLE IL with regard to VEC_PERM_EXPR. 2021-05-21 Richard Biener PR c++/88601 gcc/c-family/ * c-common.c: Include tree-vector-builder.h and vec-perm-indices.h. (c_common_reswords): Add __builtin_shufflevector. (c_build_shufflevector): New funtion. * c-common.h (enum rid): Add RID_BUILTIN_SHUFFLEVECTOR. (c_build_shufflevector): Declare. gcc/c/ * c-decl.c (names_builtin_p): Handle RID_BUILTIN_SHUFFLEVECTOR. * c-parser.c (c_parser_postfix_expression): Likewise. gcc/cp/ * cp-objcp-common.c (names_builtin_p): Handle RID_BUILTIN_SHUFFLEVECTOR. * cp-tree.h (build_x_shufflevector): Declare. * parser.c (cp_parser_postfix_expression): Handle RID_BUILTIN_SHUFFLEVECTOR. * pt.c (tsubst_copy_and_build): Handle IFN_SHUFFLEVECTOR. * typeck.c (build_x_shufflevector): Build either a lowered VEC_PERM_EXPR or an unlowered shufflevector via a temporary internal function IFN_SHUFFLEVECTOR. gcc/ * internal-fn.c (expand_SHUFFLEVECTOR): Define. * internal-fn.def (SHUFFLEVECTOR): New. * internal-fn.h (expand_SHUFFLEVECTOR): Declare. * doc/extend.texi: Document __builtin_shufflevector. gcc/testsuite/ * c-c++-common/builtin-shufflevector-2.c: New testcase. * c-c++-common/torture/builtin-shufflevector-1.c: Likewise. * g++.dg/ext/builtin-shufflevector-1.C: Likewise. * g++.dg/ext/builtin-shufflevector-2.C: Likewise. --- gcc/c-family/c-common.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/c-family/c-common.h | 4 +- 2 files changed, 142 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b7daa2e..c4eb2b1 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -51,6 +51,8 @@ along with GCC; see the file COPYING3. If not see #include "c-spellcheck.h" #include "selftest.h" #include "debug.h" +#include "tree-vector-builder.h" +#include "vec-perm-indices.h" cpp_reader *parse_in; /* Declared in c-pragma.h. */ @@ -383,6 +385,7 @@ const struct c_common_resword c_common_reswords[] = { "__builtin_has_attribute", RID_BUILTIN_HAS_ATTRIBUTE, 0 }, { "__builtin_launder", RID_BUILTIN_LAUNDER, D_CXXONLY }, { "__builtin_shuffle", RID_BUILTIN_SHUFFLE, 0 }, + { "__builtin_shufflevector", RID_BUILTIN_SHUFFLEVECTOR, 0 }, { "__builtin_tgmath", RID_BUILTIN_TGMATH, D_CONLY }, { "__builtin_offsetof", RID_OFFSETOF, 0 }, { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, D_CONLY }, @@ -1108,6 +1111,142 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, return ret; } +/* Build a VEC_PERM_EXPR if V0, V1 are not error_mark_nodes + and have vector types, V0 has the same element type as V1, and the + number of elements the result is that of MASK. */ +tree +c_build_shufflevector (location_t loc, tree v0, tree v1, vec mask, + bool complain) +{ + tree ret; + bool wrap = true; + bool maybe_const = false; + + if (v0 == error_mark_node || v1 == error_mark_node) + return error_mark_node; + + if (!gnu_vector_type_p (TREE_TYPE (v0)) + || !gnu_vector_type_p (TREE_TYPE (v1))) + { + if (complain) + error_at (loc, "%<__builtin_shufflevector%> arguments must be vectors"); + return error_mark_node; + } + + /* ??? In principle one could select a constant part of a variable size + vector but things get a bit awkward with trying to support this here. */ + unsigned HOST_WIDE_INT v0n, v1n; + if (!TYPE_VECTOR_SUBPARTS (TREE_TYPE (v0)).is_constant (&v0n) + || !TYPE_VECTOR_SUBPARTS (TREE_TYPE (v1)).is_constant (&v1n)) + { + if (complain) + error_at (loc, "%<__builtin_shufflevector%> arguments must be constant" + " size vectors"); + return error_mark_node; + } + + if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (v0))) + != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (v1)))) + { + if (complain) + error_at (loc, "%<__builtin_shufflevector%> argument vectors must " + "have the same element type"); + return error_mark_node; + } + + if (!pow2p_hwi (mask.length ())) + { + if (complain) + error_at (loc, "%<__builtin_shufflevector%> must specify a result " + "with a power of two number of elements"); + return error_mark_node; + } + + if (!c_dialect_cxx ()) + { + /* Avoid C_MAYBE_CONST_EXPRs inside VEC_PERM_EXPR. */ + v0 = c_fully_fold (v0, false, &maybe_const); + wrap &= maybe_const; + + v1 = c_fully_fold (v1, false, &maybe_const); + wrap &= maybe_const; + } + + unsigned HOST_WIDE_INT maskl = MAX (mask.length (), MAX (v0n, v1n)); + unsigned HOST_WIDE_INT pad = (v0n < maskl ? maskl - v0n : 0); + vec_perm_builder sel (maskl, maskl, 1); + unsigned i; + for (i = 0; i < mask.length (); ++i) + { + tree idx = mask[i]; + if (!tree_fits_shwi_p (idx)) + { + if (complain) + error_at (loc, "invalid element index %qE to " + "%<__builtin_shufflevector%>", idx); + return error_mark_node; + } + HOST_WIDE_INT iidx = tree_to_shwi (idx); + if (iidx < -1 + || (iidx != -1 + && (unsigned HOST_WIDE_INT) iidx >= v0n + v1n)) + { + if (complain) + error_at (loc, "invalid element index %qE to " + "%<__builtin_shufflevector%>", idx); + return error_mark_node; + } + /* ??? Our VEC_PERM_EXPR does not allow for -1 yet. */ + if (iidx == -1) + iidx = i; + /* ??? Our VEC_PERM_EXPR does not allow different sized inputs, + so pad out a smaller v0. */ + else if ((unsigned HOST_WIDE_INT) iidx >= v0n) + iidx += pad; + sel.quick_push (iidx); + } + /* ??? VEC_PERM_EXPR does not support a result that is smaller than + the inputs, so we have to pad id out. */ + for (; i < maskl; ++i) + sel.quick_push (i); + + vec_perm_indices indices (sel, 2, maskl); + + tree ret_type = build_vector_type (TREE_TYPE (TREE_TYPE (v0)), maskl); + tree mask_type = build_vector_type (build_nonstandard_integer_type + (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (ret_type))), 1), + maskl); + /* Pad out arguments to the common vector size. */ + if (v0n < maskl) + { + constructor_elt elt = { NULL_TREE, build_zero_cst (TREE_TYPE (v0)) }; + v0 = build_constructor_single (ret_type, NULL_TREE, v0); + for (i = 1; i < maskl / v0n; ++i) + vec_safe_push (CONSTRUCTOR_ELTS (v0), elt); + } + if (v1n < maskl) + { + constructor_elt elt = { NULL_TREE, build_zero_cst (TREE_TYPE (v1)) }; + v1 = build_constructor_single (ret_type, NULL_TREE, v1); + for (i = 1; i < maskl / v1n; ++i) + vec_safe_push (CONSTRUCTOR_ELTS (v1), elt); + } + ret = build3_loc (loc, VEC_PERM_EXPR, ret_type, v0, v1, + vec_perm_indices_to_tree (mask_type, indices)); + /* Get the lowpart we are interested in. */ + if (mask.length () < maskl) + { + tree lpartt = build_vector_type (TREE_TYPE (ret_type), mask.length ()); + ret = build3_loc (loc, BIT_FIELD_REF, + lpartt, ret, TYPE_SIZE (lpartt), bitsize_zero_node); + } + + if (!c_dialect_cxx () && !wrap) + ret = c_wrap_maybe_const (ret, true); + + return ret; +} + /* Build a VEC_CONVERT ifn for __builtin_convertvector builtin. */ tree diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index f30b6c6..be4b29a 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -107,7 +107,7 @@ enum rid RID_ASM, RID_TYPEOF, RID_ALIGNOF, RID_ATTRIBUTE, RID_VA_ARG, RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL, RID_CHOOSE_EXPR, RID_TYPES_COMPATIBLE_P, RID_BUILTIN_COMPLEX, RID_BUILTIN_SHUFFLE, - RID_BUILTIN_CONVERTVECTOR, RID_BUILTIN_TGMATH, + RID_BUILTIN_SHUFFLEVECTOR, RID_BUILTIN_CONVERTVECTOR, RID_BUILTIN_TGMATH, RID_BUILTIN_HAS_ATTRIBUTE, RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, @@ -1048,6 +1048,8 @@ extern bool lvalue_p (const_tree); extern bool vector_targets_convertible_p (const_tree t1, const_tree t2); extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note); extern tree c_build_vec_perm_expr (location_t, tree, tree, tree, bool = true); +extern tree c_build_shufflevector (location_t, tree, tree, + vec, bool = true); extern tree c_build_vec_convert (location_t, tree, location_t, tree, bool = true); extern void init_c_lex (void); -- cgit v1.1 From a87efd32384ee78ee33d20703deaa65fba81cb2d Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Mon, 31 May 2021 09:19:38 -0700 Subject: PR testsuite/100749 - gcc.dg/pch/valid-1.c fails after r12-949 Fix failing pch testcases. Use xstrdup to retain a reliable copy of the debug format str containing the names (df_set_names is a static string var). 2021-05-31 Indu Bhagat gcc/c-family/ PR testsuite/100749 * c-pch.c (c_common_valid_pch): Use xstrdup for debug format set names. --- gcc/c-family/c-pch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index 8f0f760..5da6042 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -255,10 +255,13 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) if (v.pch_write_symbols != write_symbols && write_symbols != NO_DEBUG) { + char *created_str = xstrdup (debug_set_names (v.pch_write_symbols)); + char *used_str = xstrdup (debug_set_names (write_symbols)); cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: created with '%s' debug info, but used with '%s'", name, - debug_set_names (v.pch_write_symbols), - debug_set_names (write_symbols)); + created_str, used_str); + free (created_str); + free (used_str); return 2; } -- cgit v1.1 From ee682192755bb88af0ee10852e7c873b844d449f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 1 Jun 2021 00:16:37 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2905179..e85a6bf 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,18 @@ +2021-05-31 Indu Bhagat + + PR testsuite/100749 + * c-pch.c (c_common_valid_pch): Use xstrdup for debug format set names. + +2021-05-31 Richard Biener + + PR c++/88601 + * c-common.c: Include tree-vector-builder.h and + vec-perm-indices.h. + (c_common_reswords): Add __builtin_shufflevector. + (c_build_shufflevector): New funtion. + * c-common.h (enum rid): Add RID_BUILTIN_SHUFFLEVECTOR. + (c_build_shufflevector): Declare. + 2021-05-28 Jakub Jelinek PR middle-end/99928 -- cgit v1.1 From b195d84561a5c31108c7bbbd7c5b63fe3cebe35f Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 1 Jun 2021 10:41:04 +0200 Subject: Fix sanity checking of global_options. gcc/c-family/ChangeLog: PR other/100759 * c-attribs.c (handle_optimize_attribute): Limit sanity check to a situation where we are not in processing of an optimize pragma. * c-pragma.c (handle_pragma_pop_options): Restore target options. --- gcc/c-family/c-attribs.c | 6 +++++- gcc/c-family/c-pragma.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 804374d..156f7b3 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -5389,7 +5389,11 @@ handle_optimize_attribute (tree *node, tree name, tree args, /* If we previously had some optimization options, use them as the default. */ gcc_options *saved_global_options = NULL; - if (flag_checking) + + /* When #pragma GCC optimize pragma is used, it modifies global_options + without calling targetm.override_options_after_change. That can leave + target flags inconsistent for comparison. */ + if (flag_checking && optimization_current_node == optimization_default_node) { saved_global_options = XNEW (gcc_options); *saved_global_options = global_options; diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 7f658ea..f46b5b9 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1088,6 +1088,8 @@ handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy)) * overwritten by invoke_set_current_function_hook. */ cl_optimization_restore (&global_options, &global_options_set, TREE_OPTIMIZATION (p->optimize_binary)); + cl_target_option_restore (&global_options, &global_options_set, + TREE_TARGET_OPTION (p->target_binary)); if (p->optimize_binary != optimization_current_node) { -- cgit v1.1 From b75978d14fc35981ffd8bf060ee52300db4dae50 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 2 Jun 2021 00:16:43 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e85a6bf..cb2757c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2021-06-01 Martin Liska + + PR other/100759 + * c-attribs.c (handle_optimize_attribute): Limit sanity check + to a situation where we are not in processing of an optimize + pragma. + * c-pragma.c (handle_pragma_pop_options): Restore target + options. + 2021-05-31 Indu Bhagat PR testsuite/100749 -- cgit v1.1 From 5f2ef25b08f782a9f72adb8e6389ce66d302594b Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 3 Jun 2021 17:46:15 +0200 Subject: Fix duplicate name issues in output of -fdump-ada-spec The namespace rules are different in the C family of languages and in Ada, and a few adjustments are further needed in -fdump-ada-spec because of them. gcc/c-family/ * c-ada-spec.c (dump_ada_enum_type): Dump a prefix for constants. (htable_t): New typedef. (overloaded_names): Use it. (add_name): New function. (init_overloaded_names): Use add_name to populate the table and add special cases for sigaction and stat. (overloaded_name_p): Rename into... (overloading_index): ...this. Do not initialize overloaded_names table here. Return the index or zero. (dump_ada_declaration): Minor tweaks. Do not skip overloaded functions but add an overloading suffix instead. (dump_ada_specs): Initialize overloaded_names tables here. --- gcc/c-family/c-ada-spec.c | 106 ++++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 42 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 29eb0b0..ef0c74c 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -2003,7 +2003,15 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, tree parent, pp_semicolon (buffer); newline_and_indent (buffer, spc); + if (TYPE_NAME (node)) + dump_ada_node (buffer, node, NULL_TREE, spc, false, true); + else if (type) + dump_ada_node (buffer, type, NULL_TREE, spc, false, true); + else + dump_anonymous_type_name (buffer, node, parent); + pp_underscore (buffer); pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false); + pp_string (buffer, " : constant "); if (TYPE_NAME (node)) @@ -2628,11 +2636,31 @@ struct overloaded_name_hasher : delete_ptr_hash { return a->name == b->name; } }; -static hash_table *overloaded_names; +typedef hash_table htable_t; + +static htable_t *overloaded_names; + +/* Add an overloaded NAME with N occurrences to TABLE. */ + +static void +add_name (const char *name, unsigned int n, htable_t *table) +{ + struct overloaded_name_hash in, *h, **slot; + tree id = get_identifier (name); + hashval_t hash = htab_hash_pointer (id); + in.hash = hash; + in.name = id; + slot = table->find_slot_with_hash (&in, hash, INSERT); + h = new overloaded_name_hash; + h->hash = hash; + h->name = id; + h->n = n; + *slot = h; +} /* Initialize the table with the problematic overloaded names. */ -static hash_table * +static htable_t * init_overloaded_names (void) { static const char *names[] = @@ -2640,41 +2668,31 @@ init_overloaded_names (void) { "memchr", "rawmemchr", "memrchr", "strchr", "strrchr", "strchrnul", "strpbrk", "strstr", "strcasestr", "index", "rindex", "basename" }; - hash_table *table - = new hash_table (64); + htable_t *table = new htable_t (64); for (unsigned int i = 0; i < ARRAY_SIZE (names); i++) - { - struct overloaded_name_hash in, *h, **slot; - tree id = get_identifier (names[i]); - hashval_t hash = htab_hash_pointer (id); - in.hash = hash; - in.name = id; - slot = table->find_slot_with_hash (&in, hash, INSERT); - h = new overloaded_name_hash; - h->hash = hash; - h->name = id; - h->n = 0; - *slot = h; - } + add_name (names[i], 0, table); + + /* Consider that sigaction() is overloaded by struct sigaction for QNX. */ + add_name ("sigaction", 1, table); + + /* Consider that stat() is overloaded by struct stat for QNX. */ + add_name ("stat", 1, table); return table; } -/* Return whether NAME cannot be supported as overloaded name. */ +/* Return the overloading index of NAME or 0 if NAME is not overloaded. */ -static bool -overloaded_name_p (tree name) +static unsigned int +overloading_index (tree name) { - if (!overloaded_names) - overloaded_names = init_overloaded_names (); - struct overloaded_name_hash in, *h; hashval_t hash = htab_hash_pointer (name); in.hash = hash; in.name = name; h = overloaded_names->find_with_hash (&in, hash); - return h && ++h->n > 1; + return h ? ++h->n : 0; } /* Dump in BUFFER constructor spec corresponding to T for TYPE. */ @@ -2798,14 +2816,17 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) } /* Skip unnamed or anonymous structs/unions/enum types. */ - if (!orig && !decl_name && !name + if (!orig && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)) - || TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE)) + || TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE) + && !decl_name + && !name) return 0; - /* Skip anonymous enum types (duplicates of real types). */ + /* Skip duplicates of structs/unions/enum types built in C++. */ if (!orig - && TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE + && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)) + || TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE) && decl_name && (*IDENTIFIER_POINTER (decl_name) == '.' || *IDENTIFIER_POINTER (decl_name) == '$')) @@ -2826,16 +2847,6 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) return 1; } - if (decl_name - && (*IDENTIFIER_POINTER (decl_name) == '.' - || *IDENTIFIER_POINTER (decl_name) == '$')) - { - pp_string (buffer, "-- skipped anonymous struct "); - dump_ada_node (buffer, t, type, spc, false, true); - TREE_VISITED (t) = 1; - return 1; - } - /* ??? Packed record layout is not supported. */ if (TYPE_PACKED (TREE_TYPE (t))) { @@ -2869,7 +2880,11 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) case POINTER_TYPE: case REFERENCE_TYPE: dump_forward_type (buffer, TREE_TYPE (TREE_TYPE (t)), t, spc); - /* fallthrough */ + if (orig && TYPE_NAME (orig)) + pp_string (buffer, "subtype "); + else + pp_string (buffer, "type "); + break; case ARRAY_TYPE: if ((orig && TYPE_NAME (orig)) || is_char_array (TREE_TYPE (t))) @@ -2945,9 +2960,9 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) } else if (TREE_CODE (t) == FUNCTION_DECL) { + tree decl_name = DECL_NAME (t); bool is_abstract_class = false; bool is_method = TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE; - tree decl_name = DECL_NAME (t); bool is_abstract = false; bool is_assignment_operator = false; bool is_constructor = false; @@ -2955,7 +2970,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) bool is_copy_constructor = false; bool is_move_constructor = false; - if (!decl_name || overloaded_name_p (decl_name)) + if (!decl_name) return 0; if (cpp_check) @@ -3018,7 +3033,12 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) else if (is_assignment_operator) print_assignment_operator (buffer, t, type); else - dump_ada_decl_name (buffer, t, false); + { + const unsigned int suffix = overloading_index (decl_name); + pp_ada_tree_identifier (buffer, decl_name, t, false); + if (suffix > 1) + pp_decimal_int (buffer, suffix); + } dump_ada_function_declaration (buffer, t, is_method, is_constructor, is_destructor, spc); @@ -3477,6 +3497,8 @@ dump_ada_specs (void (*collect_all_refs)(const char *), { bitmap_obstack_initialize (NULL); + overloaded_names = init_overloaded_names (); + /* Iterate over the list of files to dump specs for. */ for (int i = 0; i < source_refs_used; i++) dump_ads (source_refs[i], collect_all_refs, check); -- cgit v1.1 From 517155ceb971d33881cfeecd767406f0801c6512 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 3 Jun 2021 17:50:44 +0200 Subject: Fix issue for external subtypes with -fdump-ada-spec This works around an irregularity of the language whereby subtypes, unlike types, are not visible through a limited_with clause. gcc/c-family/ * c-ada-spec.c (pp_ada_tree_identifier): Tidy up. (dump_ada_node) : Deal specially with external subtypes. --- gcc/c-family/c-ada-spec.c | 91 +++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 38 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index ef0c74c..751cc0e 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -1341,49 +1341,46 @@ pp_ada_tree_identifier (pretty_printer *buffer, tree node, tree type, char *s = to_ada_name (name, &space_found); tree decl = get_underlying_decl (type); - /* If the entity comes from another file, generate a package prefix. */ if (decl) { - expanded_location xloc = expand_location (decl_sloc (decl, false)); + /* If the entity comes from another file, generate a package prefix. */ + const expanded_location xloc = expand_location (decl_sloc (decl, false)); - if (xloc.file && xloc.line) + if (xloc.line && xloc.file && xloc.file != current_source_file) { - if (xloc.file != current_source_file) + switch (TREE_CODE (type)) { - switch (TREE_CODE (type)) - { - case ENUMERAL_TYPE: - case INTEGER_TYPE: - case REAL_TYPE: - case FIXED_POINT_TYPE: - case BOOLEAN_TYPE: - case REFERENCE_TYPE: - case POINTER_TYPE: - case ARRAY_TYPE: - case RECORD_TYPE: - case UNION_TYPE: - case TYPE_DECL: - if (package_prefix) - { - char *s1 = get_ada_package (xloc.file); - append_withs (s1, limited_access); - pp_string (buffer, s1); - pp_dot (buffer); - free (s1); - } - break; - default: - break; - } + case ENUMERAL_TYPE: + case INTEGER_TYPE: + case REAL_TYPE: + case FIXED_POINT_TYPE: + case BOOLEAN_TYPE: + case REFERENCE_TYPE: + case POINTER_TYPE: + case ARRAY_TYPE: + case RECORD_TYPE: + case UNION_TYPE: + case TYPE_DECL: + if (package_prefix) + { + char *s1 = get_ada_package (xloc.file); + append_withs (s1, limited_access); + pp_string (buffer, s1); + pp_dot (buffer); + free (s1); + } + break; + default: + break; + } - /* Generate the additional package prefix for C++ classes. */ - if (separate_class_package (decl)) - { - pp_string (buffer, "Class_"); - pp_string (buffer, s); - pp_dot (buffer); - } - } + /* Generate the additional package prefix for C++ classes. */ + if (separate_class_package (decl)) + { + pp_string (buffer, "Class_"); + pp_string (buffer, s); + pp_dot (buffer); + } } } @@ -2220,6 +2217,24 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, { tree type_name = TYPE_NAME (TREE_TYPE (node)); + /* Generate "access " instead of "access " + if the subtype comes from another file, because subtype + declarations do not contribute to the limited view of a + package and thus subtypes cannot be referenced through + a limited_with clause. */ + if (type_name + && TREE_CODE (type_name) == TYPE_DECL + && DECL_ORIGINAL_TYPE (type_name) + && TYPE_NAME (DECL_ORIGINAL_TYPE (type_name))) + { + const expanded_location xloc + = expand_location (decl_sloc (type_name, false)); + if (xloc.line + && xloc.file + && xloc.file != current_source_file) + type_name = DECL_ORIGINAL_TYPE (type_name); + } + /* For now, handle access-to-access as System.Address. */ if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE) { @@ -2241,8 +2256,8 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, { if (!type || TREE_CODE (type) != FUNCTION_DECL) { - pp_string (buffer, "access "); is_access = true; + pp_string (buffer, "access "); if (quals & TYPE_QUAL_CONST) pp_string (buffer, "constant "); -- cgit v1.1 From cd4dd47265f2bff89fbbfb6a12a98a7101fb5280 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 3 Jun 2021 17:54:45 +0200 Subject: Fix issue for nested record types with -fdump-ada-spec Ada does not support anonymous record declarations nested in other record declarations so -fdump-ada-spec needs to unnest them, and this contains a few fixes for this machinery. gcc/c-family/ * c-ada-spec.c (dump_ada_macros): Minor tweaks. (dump_ada_decl_name): Likewise. (dump_anonymous_type_name): Remove parent parameter and adjust. (dump_sloc): Minor tweak. (dump_ada_array_type): Remove type parameter and adjust. (dump_ada_enum_type): Remove parent parameter and adjust. (dump_ada_node): Adjust calls to above functions. (dumped_anonymous_types): New global variable. (dump_nested_types_1): Rename into... (dump_nested_types): ...this. (dump_nested_type): Remove parent and dumped_types parameters. : Replace dumped_types with dumped_anonymous_types. Adjust calls to dump_anonymous_type_name and dump_ada_array_type. (dump_ada_specs): Initialize and free dumped_anonymous_types. --- gcc/c-family/c-ada-spec.c | 116 +++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 64 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 751cc0e..a2669c6 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -408,8 +408,8 @@ dump_ada_macros (pretty_printer *pp, const char* file) } else { - chars_seen = sprintf - ((char *) buffer, "Character'Val (%d)", (int) c); + chars_seen = sprintf ((char *) buffer, + "Character'Val (%d)", (int) c); buffer += chars_seen; } } @@ -611,7 +611,7 @@ dump_ada_macros (pretty_printer *pp, const char* file) pp_string (pp, "; -- "); pp_string (pp, sloc.file); pp_colon (pp); - pp_scalar (pp, "%d", sloc.line); + pp_decimal_int (pp, sloc.line); pp_newline (pp); } else @@ -1464,28 +1464,21 @@ dump_ada_decl_name (pretty_printer *buffer, tree decl, bool limited_access) { pp_string (buffer, "anon"); if (TREE_CODE (decl) == FIELD_DECL) - pp_scalar (buffer, "%d", DECL_UID (decl)); + pp_decimal_int (buffer, DECL_UID (decl)); else - pp_scalar (buffer, "%d", TYPE_UID (TREE_TYPE (decl))); + pp_decimal_int (buffer, TYPE_UID (TREE_TYPE (decl))); } else if (TREE_CODE (type_name) == IDENTIFIER_NODE) pp_ada_tree_identifier (buffer, type_name, decl, limited_access); } } -/* Dump in BUFFER a name for the type T, which is a _TYPE without TYPE_NAME. - PARENT is the parent node of T. */ +/* Dump in BUFFER a name for the type T, which is a TYPE without TYPE_NAME. */ static void -dump_anonymous_type_name (pretty_printer *buffer, tree t, tree parent) +dump_anonymous_type_name (pretty_printer *buffer, tree t) { - if (DECL_NAME (parent)) - pp_ada_tree_identifier (buffer, DECL_NAME (parent), parent, false); - else - { - pp_string (buffer, "anon"); - pp_scalar (buffer, "%d", TYPE_UID (TREE_TYPE (parent))); - } + pp_string (buffer, "anon"); switch (TREE_CODE (t)) { @@ -1506,7 +1499,7 @@ dump_anonymous_type_name (pretty_printer *buffer, tree t, tree parent) break; } - pp_scalar (buffer, "%d", TYPE_UID (t)); + pp_decimal_int (buffer, TYPE_UID (t)); } /* Dump in BUFFER aspect Import on a given node T. SPC is the current @@ -1757,12 +1750,12 @@ dump_sloc (pretty_printer *buffer, tree node) { expanded_location xloc; - xloc.file = NULL; - if (DECL_P (node)) xloc = expand_location (DECL_SOURCE_LOCATION (node)); else if (EXPR_HAS_LOCATION (node)) xloc = expand_location (EXPR_LOCATION (node)); + else + xloc.file = NULL; if (xloc.file) { @@ -1790,11 +1783,11 @@ is_char_array (tree t) && id_equal (DECL_NAME (TYPE_NAME (t)), "char"); } -/* Dump in BUFFER an array type NODE of type TYPE in Ada syntax. SPC is the - indentation level. */ +/* Dump in BUFFER an array type NODE in Ada syntax. SPC is the indentation + level. */ static void -dump_ada_array_type (pretty_printer *buffer, tree node, tree type, int spc) +dump_ada_array_type (pretty_printer *buffer, tree node, int spc) { const bool char_array = is_char_array (node); @@ -1823,8 +1816,8 @@ dump_ada_array_type (pretty_printer *buffer, tree node, tree type, int spc) || (!RECORD_OR_UNION_TYPE_P (tmp) && TREE_CODE (tmp) != ENUMERAL_TYPE)) dump_ada_node (buffer, tmp, node, spc, false, true); - else if (type) - dump_anonymous_type_name (buffer, tmp, type); + else + dump_anonymous_type_name (buffer, tmp); } } @@ -1954,11 +1947,10 @@ is_simple_enum (tree node) } /* Dump in BUFFER the declaration of enumeral NODE of type TYPE in Ada syntax. - PARENT is the parent node of NODE. SPC is the indentation level. */ + SPC is the indentation level. */ static void -dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, tree parent, - int spc) +dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, int spc) { if (is_simple_enum (node)) { @@ -2005,7 +1997,7 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, tree parent, else if (type) dump_ada_node (buffer, type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, node, parent); + dump_anonymous_type_name (buffer, node); pp_underscore (buffer); pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false); @@ -2016,7 +2008,7 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, tree parent, else if (type) dump_ada_node (buffer, type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, node, parent); + dump_anonymous_type_name (buffer, node); pp_string (buffer, " := "); dump_ada_node (buffer, int_val, node, spc, false, true); @@ -2106,7 +2098,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (name_only) dump_ada_node (buffer, TYPE_NAME (node), node, spc, false, true); else - dump_ada_enum_type (buffer, node, type, NULL_TREE, spc); + dump_ada_enum_type (buffer, node, type, spc); break; case REAL_TYPE: @@ -2116,6 +2108,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, pp_string (buffer, "Extensions.Float_128"); break; } + /* fallthrough */ case INTEGER_TYPE: @@ -2298,7 +2291,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access, true); else - dump_ada_array_type (buffer, node, type, spc); + dump_ada_array_type (buffer, node, spc); break; case RECORD_TYPE: @@ -2490,7 +2483,12 @@ dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc) TREE_VISITED (decl) = 1; } -static void dump_nested_type (pretty_printer *, tree, tree, tree, bitmap, int); +/* Bitmap of anonymous types already dumped. Anonymous array types are shared + throughout the compilation so it needs to be global. */ + +static bitmap dumped_anonymous_types; + +static void dump_nested_type (pretty_printer *, tree, tree, int); /* Dump in BUFFER anonymous types nested inside T's definition. PARENT is the parent node of T. DUMPED_TYPES is the bitmap of already dumped types. SPC @@ -2506,8 +2504,7 @@ static void dump_nested_type (pretty_printer *, tree, tree, tree, bitmap, int); pass on the nested TYPE_DECLs and a second pass on the unnamed types. */ static void -dump_nested_types_1 (pretty_printer *buffer, tree t, tree parent, - bitmap dumped_types, int spc) +dump_nested_types (pretty_printer *buffer, tree t, int spc) { tree type, field; @@ -2521,31 +2518,18 @@ dump_nested_types_1 (pretty_printer *buffer, tree t, tree parent, && DECL_NAME (field) != DECL_NAME (t) && !DECL_ORIGINAL_TYPE (field) && TYPE_NAME (TREE_TYPE (field)) != TYPE_NAME (type)) - dump_nested_type (buffer, field, t, parent, dumped_types, spc); + dump_nested_type (buffer, field, t, spc); for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !TYPE_NAME (TREE_TYPE (field))) - dump_nested_type (buffer, field, t, parent, dumped_types, spc); + dump_nested_type (buffer, field, t, spc); } -/* Likewise, but to be invoked only at top level. We dump each anonymous type - nested inside T's definition exactly once, even if it is referenced several - times in it (typically an array type), with a name prefixed by that of T. */ +/* Dump in BUFFER the anonymous type of FIELD inside T. SPC is the indentation + level. */ static void -dump_nested_types (pretty_printer *buffer, tree t, int spc) -{ - auto_bitmap dumped_types; - dump_nested_types_1 (buffer, t, t, dumped_types, spc); -} - -/* Dump in BUFFER the anonymous type of FIELD inside T. PARENT is the parent - node of T. DUMPED_TYPES is the bitmap of already dumped types. SPC is the - indentation level. */ - -static void -dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, - bitmap dumped_types, int spc) +dump_nested_type (pretty_printer *buffer, tree field, tree t, int spc) { tree field_type = TREE_TYPE (field); tree decl, tmp; @@ -2559,7 +2543,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, case ARRAY_TYPE: /* Anonymous array types are shared. */ - if (!bitmap_set_bit (dumped_types, TYPE_UID (field_type))) + if (!bitmap_set_bit (dumped_anonymous_types, TYPE_UID (field_type))) return; /* Recurse on the element type if need be. */ @@ -2573,7 +2557,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, && !TREE_VISITED (decl)) { /* Generate full declaration. */ - dump_nested_type (buffer, decl, t, parent, dumped_types, spc); + dump_nested_type (buffer, decl, t, spc); TREE_VISITED (decl) = 1; } else if (!decl && TREE_CODE (tmp) == POINTER_TYPE) @@ -2585,9 +2569,9 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, else pp_string (buffer, "type "); - dump_anonymous_type_name (buffer, field_type, parent); + dump_anonymous_type_name (buffer, field_type); pp_string (buffer, " is "); - dump_ada_array_type (buffer, field_type, parent, spc); + dump_ada_array_type (buffer, field_type, spc); pp_semicolon (buffer); newline_and_indent (buffer, spc); break; @@ -2601,23 +2585,23 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent, if (TYPE_NAME (field_type)) dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, field_type, parent); + dump_anonymous_type_name (buffer, field_type); pp_string (buffer, " is "); - dump_ada_enum_type (buffer, field_type, NULL_TREE, parent, spc); + dump_ada_enum_type (buffer, field_type, NULL_TREE, spc); pp_semicolon (buffer); newline_and_indent (buffer, spc); break; case RECORD_TYPE: case UNION_TYPE: - dump_nested_types_1 (buffer, field, parent, dumped_types, spc); + dump_nested_types (buffer, field, spc); pp_string (buffer, "type "); if (TYPE_NAME (field_type)) dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, field_type, parent); + dump_anonymous_type_name (buffer, field_type); if (TREE_CODE (field_type) == UNION_TYPE) pp_string (buffer, " (discr : unsigned := 0)"); @@ -2953,7 +2937,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (orig && TYPE_NAME (orig)) dump_ada_node (buffer, TYPE_NAME (orig), type, spc, false, true); else - dump_ada_array_type (buffer, TREE_TYPE (t), type, spc); + dump_ada_array_type (buffer, TREE_TYPE (t), spc); } else { @@ -2968,9 +2952,9 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (TYPE_NAME (TREE_TYPE (t))) dump_ada_node (buffer, TREE_TYPE (t), type, spc, false, true); else if (type) - dump_anonymous_type_name (buffer, TREE_TYPE (t), type); + dump_anonymous_type_name (buffer, TREE_TYPE (t)); else - dump_ada_array_type (buffer, TREE_TYPE (t), type, spc); + dump_ada_array_type (buffer, TREE_TYPE (t), spc); } } else if (TREE_CODE (t) == FUNCTION_DECL) @@ -3206,7 +3190,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) && TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE)) dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true); else if (type) - dump_anonymous_type_name (buffer, TREE_TYPE (t), type); + dump_anonymous_type_name (buffer, TREE_TYPE (t)); } } @@ -3516,7 +3500,11 @@ dump_ada_specs (void (*collect_all_refs)(const char *), /* Iterate over the list of files to dump specs for. */ for (int i = 0; i < source_refs_used; i++) - dump_ads (source_refs[i], collect_all_refs, check); + { + dumped_anonymous_types = BITMAP_ALLOC (NULL); + dump_ads (source_refs[i], collect_all_refs, check); + BITMAP_FREE (dumped_anonymous_types); + } /* Free various tables. */ free (source_refs); -- cgit v1.1 From 440c8a0a91b7ea1603e3e1eaae64fc0e12f0c4f1 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 4 Jun 2021 00:16:24 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index cb2757c..968322f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,40 @@ +2021-06-03 Eric Botcazou + + * c-ada-spec.c (dump_ada_macros): Minor tweaks. + (dump_ada_decl_name): Likewise. + (dump_anonymous_type_name): Remove parent parameter and adjust. + (dump_sloc): Minor tweak. + (dump_ada_array_type): Remove type parameter and adjust. + (dump_ada_enum_type): Remove parent parameter and adjust. + (dump_ada_node): Adjust calls to above functions. + (dumped_anonymous_types): New global variable. + (dump_nested_types_1): Rename into... + (dump_nested_types): ...this. + (dump_nested_type): Remove parent and dumped_types parameters. + : Replace dumped_types with dumped_anonymous_types. + Adjust calls to dump_anonymous_type_name and dump_ada_array_type. + (dump_ada_specs): Initialize and free dumped_anonymous_types. + +2021-06-03 Eric Botcazou + + * c-ada-spec.c (pp_ada_tree_identifier): Tidy up. + (dump_ada_node) : Deal specially with external subtypes. + +2021-06-03 Eric Botcazou + + * c-ada-spec.c (dump_ada_enum_type): Dump a prefix for constants. + (htable_t): New typedef. + (overloaded_names): Use it. + (add_name): New function. + (init_overloaded_names): Use add_name to populate the table and add + special cases for sigaction and stat. + (overloaded_name_p): Rename into... + (overloading_index): ...this. Do not initialize overloaded_names table + here. Return the index or zero. + (dump_ada_declaration): Minor tweaks. Do not skip overloaded functions + but add an overloading suffix instead. + (dump_ada_specs): Initialize overloaded_names tables here. + 2021-06-01 Martin Liska PR other/100759 -- cgit v1.1 From c6503fa93b5565c922f76611a55b0a53cd940a5f Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 4 Jun 2021 10:35:27 -0600 Subject: PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter gcc/ChangeLog: * attribs.c (init_attr_rdwr_indices): Use VLA bounds in the expected order. (attr_access::vla_bounds): Also handle VLA bounds. gcc/c-family/ChangeLog: * c-warn.c (warn_parm_array_mismatch): Check TREE_PURPOSE to test for element presence. gcc/testsuite/ChangeLog: * gcc.dg/Wvla-parameter-10.c: New test. * gcc.dg/Wvla-parameter-11.c: New test. --- gcc/c-family/c-warn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index c48dc2e..a587b99 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3511,7 +3511,7 @@ warn_parm_array_mismatch (location_t origloc, tree fndecl, tree newparms) && newa->sizarg != UINT_MAX && newa->sizarg == cura->sizarg && newa->minsize == cura->minsize - && !TREE_CHAIN (newa->size) && !TREE_CHAIN (cura->size)) + && !TREE_PURPOSE (newa->size) && !TREE_PURPOSE (cura->size)) continue; if (newa->size || cura->size) -- cgit v1.1 From 5328cad24f7460a39b2def12bb9b62be36c92a54 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 4 Jun 2021 11:21:51 -0600 Subject: PR c/100783 - ICE on -Wnonnull and erroneous type gcc/c-family/ChangeLog: PR c/100783 * c-attribs.c (positional_argument): Bail on erroneous types. gcc/c/ChangeLog: PR c/100783 * c-objc-common.c (print_type): Handle erroneous types. gcc/testsuite/ChangeLog: PR c/100783 * gcc.dg/nonnull-6.c: New test. --- gcc/c-family/c-attribs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 156f7b3..42026a8 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -698,6 +698,9 @@ positional_argument (const_tree fntype, const_tree atname, tree pos, if (tree argtype = type_argument_type (fntype, ipos)) { + if (argtype == error_mark_node) + return NULL_TREE; + if (flags & POSARG_ELLIPSIS) { if (argno < 1) -- cgit v1.1 From 600f90cbbbf2f1e4511d72a23a5d637d11e9f28b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 5 Jun 2021 00:16:29 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 968322f..3938ef1 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,13 @@ +2021-06-04 Martin Sebor + + PR c/100783 + * c-attribs.c (positional_argument): Bail on erroneous types. + +2021-06-04 Martin Sebor + + * c-warn.c (warn_parm_array_mismatch): Check TREE_PURPOSE to test + for element presence. + 2021-06-03 Eric Botcazou * c-ada-spec.c (dump_ada_macros): Minor tweaks. -- cgit v1.1 From 4d3907c222646174ec7e405491435aefc50bf1bb Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 4 Jun 2021 14:28:11 +0200 Subject: Reformat target.def for better parsing. gcc/c-family/ChangeLog: * c-target.def: Split long lines and replace them with '\n\'. gcc/ChangeLog: * common/common-target.def: Split long lines and replace them with '\n\'. * target.def: Likewise. * doc/tm.texi: Re-generated. --- gcc/c-family/c-target.def | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-target.def b/gcc/c-family/c-target.def index f2a1b7e..164f1b3 100644 --- a/gcc/c-family/c-target.def +++ b/gcc/c-family/c-target.def @@ -43,73 +43,73 @@ DEFHOOK DEFHOOK (objc_construct_string_object, - "Targets may provide a string object type that can be used within\ - and between C, C++ and their respective Objective-C dialects.\ - A string object might, for example, embed encoding and length information.\ - These objects are considered opaque to the compiler and handled as references.\ - An ideal implementation makes the composition of the string object\ - match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\ - allowing efficient interworking between C-only and Objective-C code.\ - If a target implements string objects then this hook should return a\ - reference to such an object constructed from the normal `C' string\ - representation provided in @var{string}.\ - At present, the hook is used by Objective-C only, to obtain a\ + "Targets may provide a string object type that can be used within\n\ +and between C, C++ and their respective Objective-C dialects.\n\ +A string object might, for example, embed encoding and length information.\n\ +These objects are considered opaque to the compiler and handled as references.\n\ +An ideal implementation makes the composition of the string object\n\ +match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\n\ +allowing efficient interworking between C-only and Objective-C code.\n\ +If a target implements string objects then this hook should return a\n\ +reference to such an object constructed from the normal `C' string\n\ +representation provided in @var{string}.\n\ +At present, the hook is used by Objective-C only, to obtain a\n\ common-format string object when the target provides one.", tree, (tree string), NULL) DEFHOOK (objc_declare_unresolved_class_reference, - "Declare that Objective C class @var{classname} is referenced\ - by the current TU.", + "Declare that Objective C class @var{classname} is referenced\n\ +by the current TU.", void, (const char *classname), NULL) DEFHOOK (objc_declare_class_definition, - "Declare that Objective C class @var{classname} is defined\ - by the current TU.", + "Declare that Objective C class @var{classname} is defined\n\ +by the current TU.", void, (const char *classname), NULL) DEFHOOK (string_object_ref_type_p, - "If a target implements string objects then this hook should return\ - @code{true} if @var{stringref} is a valid reference to such an object.", + "If a target implements string objects then this hook should return\n\ +@code{true} if @var{stringref} is a valid reference to such an object.", bool, (const_tree stringref), hook_bool_const_tree_false) DEFHOOK (check_string_object_format_arg, - "If a target implements string objects then this hook should should\ - provide a facility to check the function arguments in @var{args_list}\ - against the format specifiers in @var{format_arg} where the type of\ - @var{format_arg} is one recognized as a valid string reference type.", + "If a target implements string objects then this hook should should\n\ +provide a facility to check the function arguments in @var{args_list}\n\ +against the format specifiers in @var{format_arg} where the type of\n\ +@var{format_arg} is one recognized as a valid string reference type.", void, (tree format_arg, tree args_list), NULL) DEFHOOK (c_preinclude, - "Define this hook to return the name of a header file to be included at\ - the start of all compilations, as if it had been included with\ - @code{#include <@var{file}>}. If this hook returns @code{NULL}, or is\ - not defined, or the header is not found, or if the user specifies\ - @option{-ffreestanding} or @option{-nostdinc}, no header is included.\n\ + "Define this hook to return the name of a header file to be included at\n\ +the start of all compilations, as if it had been included with\n\ +@code{#include <@var{file}>}. If this hook returns @code{NULL}, or is\n\ +not defined, or the header is not found, or if the user specifies\n\ +@option{-ffreestanding} or @option{-nostdinc}, no header is included.\n\ \n\ - This hook can be used together with a header provided by the system C\ - library to implement ISO C requirements for certain macros to be\ - predefined that describe properties of the whole implementation rather\ - than just the compiler.", +This hook can be used together with a header provided by the system C\n\ +library to implement ISO C requirements for certain macros to be\n\ +predefined that describe properties of the whole implementation rather\n\ +than just the compiler.", const char *, (void), hook_constcharptr_void_null) DEFHOOK (cxx_implicit_extern_c, - "Define this hook to add target-specific C++ implicit extern C functions.\ - If this function returns true for the name of a file-scope function, that\ - function implicitly gets extern \"C\" linkage rather than whatever language\ - linkage the declaration would normally have. An example of such function\ - is WinMain on Win32 targets.", + "Define this hook to add target-specific C++ implicit extern C functions.\n\ +If this function returns true for the name of a file-scope function, that\n\ +function implicitly gets extern \"C\" linkage rather than whatever language\n\ +linkage the declaration would normally have. An example of such function\n\ +is WinMain on Win32 targets.", bool, (const char*), NULL) -- cgit v1.1 From 438aac594e1c5ad32b787e8753b3893044ecf26f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 8 Jun 2021 00:16:44 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3938ef1..8c9b355 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-06-07 Martin Liska + + * c-target.def: Split long lines and replace them + with '\n\'. + 2021-06-04 Martin Sebor PR c/100783 -- cgit v1.1 From 087253b9951766cbd93286b804ebb1ab59197aa8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 8 Jun 2021 17:48:49 -0400 Subject: c++: remove redundant warning [PR100879] Before my r277864, build_new_op promoted enums to int before passing them on to cp_build_binary_op; after that commit, it doesn't, so warn_for_sign_compare sees the enum operands and gives a redundant warning. This warning dates back to 1995, and seems to have been dead code for a long time--likely since build_new_op was added in 1997--so let's just remove it. PR c++/100879 gcc/c-family/ChangeLog: * c-warn.c (warn_for_sign_compare): Remove C++ enum mismatch warning. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/enum3.C: New test. --- gcc/c-family/c-warn.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index a587b99..cd3c99e 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -2240,18 +2240,6 @@ warn_for_sign_compare (location_t location, int op1_signed = !TYPE_UNSIGNED (TREE_TYPE (orig_op1)); int unsignedp0, unsignedp1; - /* In C++, check for comparison of different enum types. */ - if (c_dialect_cxx() - && TREE_CODE (TREE_TYPE (orig_op0)) == ENUMERAL_TYPE - && TREE_CODE (TREE_TYPE (orig_op1)) == ENUMERAL_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (orig_op0)) - != TYPE_MAIN_VARIANT (TREE_TYPE (orig_op1))) - { - warning_at (location, - OPT_Wsign_compare, "comparison between types %qT and %qT", - TREE_TYPE (orig_op0), TREE_TYPE (orig_op1)); - } - /* Do not warn if the comparison is being done in a signed type, since the signed type will only be chosen if it can represent all the values of the unsigned type. */ -- cgit v1.1 From 4f625f47b4456e5c05a025fca4d072831e59126c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 10 Jun 2021 00:16:30 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8c9b355..460ced3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-06-09 Jason Merrill + + PR c++/100879 + * c-warn.c (warn_for_sign_compare): Remove C++ enum mismatch + warning. + 2021-06-07 Martin Liska * c-target.def: Split long lines and replace them -- cgit v1.1 From 117c64266405e244da4dae3ae7b60905af63b955 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 11 Jun 2021 15:50:34 +0200 Subject: c++: Add C++23 consteval if support - P1938R3 [PR100974] The following patch implements consteval if support. There is a new IF_STMT_CONSTEVAL_P flag on IF_STMT and IF_COND is boolean_false_node to match the non-manifestly constant evaluation behavior, while constexpr evaluation special-cases it. Perhaps cleaner would be to set the condition to __builtin_is_constant_evaluated () call but we need the IF_STMT_CONSTEVAL_P flag anyway and the IL would be larger. And I'm not changing the libstdc++ side, where perhaps we could change std::is_constant_evaluated definition for #ifdef __cpp_if_consteval case to if consteval { return true; } else { return false; } but we need to keep it defined to __builtin_is_constant_evaluated () for C++20 or older. 2021-06-11 Jakub Jelinek PR c++/100974 gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Predefine __cpp_if_consteval for -std=c++2b for P1938R3 consteval if support. gcc/cp/ * cp-tree.h (struct saved_scope): Add consteval_if_p member. Formatting fix for the discarded_stmt comment. (in_consteval_if_p, IF_STMT_CONSTEVAL_P): Define. * parser.c (cp_parser_lambda_expression): Temporarily disable in_consteval_if_p when parsing lambda body. (cp_parser_selection_statement): Parse consteval if. * decl.c (struct named_label_entry): Add in_consteval_if member. (level_for_consteval_if): New function. (poplevel_named_label_1, check_previous_goto_1, check_goto): Handle consteval if. * constexpr.c (cxx_eval_builtin_function_call): Clarify in comment why CP_BUILT_IN_IS_CONSTANT_EVALUATED needs to *non_constant_p for !ctx->manifestly_const_eval. (cxx_eval_conditional_expression): For IF_STMT_CONSTEVAL_P evaluate condition as if it was __builtin_is_constant_evaluated call. (potential_constant_expression_1): For IF_STMT_CONSTEVAL_P always recurse on both branches. * cp-gimplify.c (genericize_if_stmt): Genericize IF_STMT_CONSTEVAL_P as the else branch. * pt.c (tsubst_expr) : Copy IF_STMT_CONSTEVAL_P. Temporarily set in_consteval_if_p when recursing on IF_STMT_CONSTEVAL_P then branch. (tsubst_lambda_expr): Temporarily disable in_consteval_if_p when instantiating lambda body. * call.c (immediate_invocation_p): Return false when in_consteval_if_p. gcc/testsuite/ * g++.dg/cpp23/consteval-if1.C: New test. * g++.dg/cpp23/consteval-if2.C: New test. * g++.dg/cpp23/consteval-if3.C: New test. * g++.dg/cpp23/consteval-if4.C: New test. * g++.dg/cpp23/consteval-if5.C: New test. * g++.dg/cpp23/consteval-if6.C: New test. * g++.dg/cpp23/consteval-if7.C: New test. * g++.dg/cpp23/consteval-if8.C: New test. * g++.dg/cpp23/consteval-if9.C: New test. * g++.dg/cpp23/consteval-if10.C: New test. * g++.dg/cpp23/feat-cxx2b.C: Add __cpp_if_consteval tests. --- gcc/c-family/c-cppbuiltin.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 42b7604..f79f939 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1029,6 +1029,7 @@ c_cpp_builtins (cpp_reader *pfile) { /* Set feature test macros for C++23. */ cpp_define (pfile, "__cpp_size_t_suffix=202011L"); + cpp_define (pfile, "__cpp_if_consteval=202106L"); } if (flag_concepts) { -- cgit v1.1 From f16f65f8364b5bf23c72a8fdbba4974ecadc5cb6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 12 Jun 2021 00:16:27 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 460ced3..12ab9cd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-06-11 Jakub Jelinek + + PR c++/100974 + * c-cppbuiltin.c (c_cpp_builtins): Predefine __cpp_if_consteval for + -std=c++2b for P1938R3 consteval if support. + 2021-06-09 Jason Merrill PR c++/100879 -- cgit v1.1 From c0f769fa3114ea852a26d93f0ee3f9595463de0b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 11 Jun 2021 16:10:50 -0400 Subject: c-family: don't warn for [[maybe_unused]] on data member The C++17 standard (and C2x) says that [[maybe_unused]] may be applied to a non-static data member, so we shouldn't warn about it. And I don't see a reason not to handle a FIELD_DECL the same as any other decl, by setting TREE_USED on it. It doesn't look like anything yet cares about that flag on a FIELD_DECL, but setting it shouldn't hurt. gcc/c-family/ChangeLog: * c-attribs.c (handle_unused_attribute): Handle FIELD_DECL. gcc/testsuite/ChangeLog: * g++.dg/ext/attrib62.C: No longer warn. * g++.dg/diagnostic/maybe_unused1.C: New test. gcc/ChangeLog: * doc/extend.texi (unused variable attribute): Applies to structure fields as well. --- gcc/c-family/c-attribs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 42026a8..6bf492a 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -1568,6 +1568,7 @@ handle_unused_attribute (tree *node, tree name, tree ARG_UNUSED (args), || VAR_OR_FUNCTION_DECL_P (decl) || TREE_CODE (decl) == LABEL_DECL || TREE_CODE (decl) == CONST_DECL + || TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == TYPE_DECL) { TREE_USED (decl) = 1; -- cgit v1.1 From 8b8c391279fd3d85286b918c45171b825b44b74c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 13 Jun 2021 00:16:35 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 12ab9cd..c14edd1 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-06-12 Jason Merrill + + * c-attribs.c (handle_unused_attribute): Handle FIELD_DECL. + 2021-06-11 Jakub Jelinek PR c++/100974 -- cgit v1.1 From 93bfadf3a1db7d73e9ca4a4a3d40f7f81ea16d39 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 14 Jun 2021 11:38:11 +0100 Subject: c-family: Add fix-it suggestions for more names [PR101052] PR c++/101052 gcc/c-family/ChangeLog: * known-headers.cc (get_stdlib_header_for_name): Add known headers for EXIT_FAILURE, EXIT_SUCCESS, abort, atexit, calloc, exit, and getenv. gcc/testsuite/ChangeLog: * g++.dg/spellcheck-stdlib.C: Add checks for names. * gcc.dg/spellcheck-stdlib.c: Likewise. --- gcc/c-family/known-headers.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/known-headers.cc b/gcc/c-family/known-headers.cc index 8592471..a391246 100644 --- a/gcc/c-family/known-headers.cc +++ b/gcc/c-family/known-headers.cc @@ -162,7 +162,14 @@ get_stdlib_header_for_name (const char *name, enum stdlib lib) {"stdout", {"", ""} }, /* and . */ + {"EXIT_FAILURE", {"", ""} }, + {"EXIT_SUCCESS", {"", ""} }, + {"abort", {"", ""} }, + {"atexit", {"", ""} }, + {"calloc", {"", ""} }, + {"exit", {"", ""} }, {"free", {"", ""} }, + {"getenv", {"", ""} }, {"malloc", {"", ""} }, {"realloc", {"", ""} }, -- cgit v1.1 From 8dc48181affa1d03ec8d47e513d1c62bd16da6f3 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 15 Jun 2021 00:16:37 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c14edd1..39fae4e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2021-06-14 Jonathan Wakely + + PR c++/101052 + * known-headers.cc (get_stdlib_header_for_name): Add known + headers for EXIT_FAILURE, EXIT_SUCCESS, abort, atexit, calloc, + exit, and getenv. + 2021-06-12 Jason Merrill * c-attribs.c (handle_unused_attribute): Handle FIELD_DECL. -- cgit v1.1 From ba2eef033e59d80fde35d0cc3acf4d82f7706e60 Mon Sep 17 00:00:00 2001 From: Robin Dapp Date: Tue, 15 Jun 2021 09:06:02 +0200 Subject: c-family: Copy DECL_USER_ALIGN even if DECL_ALIGN is similar. When re-declaring a function with differing attributes DECL_USER_ALIGN is usually not merged/copied when DECL_ALIGN is similar. On s390 this will cause a warning message not to be shown. Similarly, we warned about the wrong alignment when short-circuiting an alignment initialization in common_handle_aligned_attribute (). Fix this by copying DECL_USER_ALIGN even if DECL_ALIGN is similar as well as getting rid of the short-circuited initialization. gcc/c-family/ChangeLog: * c-attribs.c (common_handle_aligned_attribute): Remove short circuit and dead code. gcc/c/ChangeLog: * c-decl.c (merge_decls): Copy DECL_USER_ALIGN if DECL_ALIGN is similar. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Likewise. --- gcc/c-family/c-attribs.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 6bf492a..e60fb31 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -2338,14 +2338,17 @@ common_handle_aligned_attribute (tree *node, tree name, tree args, int flags, *no_add_attrs = true; } else if (TREE_CODE (decl) == FUNCTION_DECL - && ((curalign = DECL_ALIGN (decl)) > bitalign - || ((lastalign = DECL_ALIGN (last_decl)) > bitalign))) + && (((curalign = DECL_ALIGN (decl)) > bitalign) + | ((lastalign = DECL_ALIGN (last_decl)) > bitalign))) { /* Either a prior attribute on the same declaration or one on a prior declaration of the same function specifies stricter alignment than this attribute. */ - bool note = lastalign != 0; - if (lastalign) + bool note = (lastalign > curalign + || (lastalign == curalign + && (DECL_USER_ALIGN (last_decl) + > DECL_USER_ALIGN (decl)))); + if (note) curalign = lastalign; curalign /= BITS_PER_UNIT; @@ -2390,25 +2393,6 @@ common_handle_aligned_attribute (tree *node, tree name, tree args, int flags, This formally comes from the c++11 specification but we are doing it for the GNU attribute syntax as well. */ *no_add_attrs = true; - else if (!warn_if_not_aligned_p - && TREE_CODE (decl) == FUNCTION_DECL - && DECL_ALIGN (decl) > bitalign) - { - /* Don't warn for function alignment here if warn_if_not_aligned_p - is true. It will be warned about later. */ - if (DECL_USER_ALIGN (decl)) - { - /* Only reject attempts to relax/override an alignment - explicitly specified previously and accept declarations - that appear to relax the implicit function alignment for - the target. Both increasing and increasing the alignment - set by -falign-functions setting is permitted. */ - error ("alignment for %q+D was previously specified as %d " - "and may not be decreased", decl, - DECL_ALIGN (decl) / BITS_PER_UNIT); - *no_add_attrs = true; - } - } else if (warn_if_not_aligned_p && TREE_CODE (decl) == FIELD_DECL && !DECL_C_BIT_FIELD (decl)) -- cgit v1.1 From ede6c3568f383f62df7bf9234212ee80763fdf6b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 16 Jun 2021 00:17:05 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 39fae4e..ba218e6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-06-15 Robin Dapp + + * c-attribs.c (common_handle_aligned_attribute): Remove short + circuit and dead code. + 2021-06-14 Jonathan Wakely PR c++/101052 -- cgit v1.1 From 7619d33471c10fe3d149dcbb701d99ed3dd23528 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 24 Jun 2021 11:25:34 +0200 Subject: openmp: in_reduction clause support on target construct This patch adds support for in_reduction clause on target construct, though for now only for synchronous targets (without nowait clause). The encountering thread in that case runs the target task and blocks until the target region ends, so it is implemented by remapping it before entering the target, initializing the private copy if not yet initialized for the current thread and then using the remapped addresses for the mapping addresses. For nowait combined with in_reduction the patch contains a hack where the nowait clause is ignored. To implement it correctly, I think we would need to create a new private variable for the in_reduction and initialize it before doing the async target and adjust the map addresses to that private variable and then pass a function pointer to the library routine with code where the callback would remap the address to the current threads private variable and use in_reduction combiner to combine the private variable we've created into the thread's copy. The library would then need to make sure that the routine is called in some thread participating in the parallel (and not in an unshackeled thread). 2021-06-24 Jakub Jelinek gcc/ * tree.h (OMP_CLAUSE_MAP_IN_REDUCTION): Document meaning for OpenMP. * gimplify.c (gimplify_scan_omp_clauses): For OpenMP map clauses with OMP_CLAUSE_MAP_IN_REDUCTION flag partially defer gimplification of non-decl OMP_CLAUSE_DECL. For OMP_CLAUSE_IN_REDUCTION on OMP_TARGET user outer_ctx instead of ctx for placeholders and initializer/combiner gimplification. * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_MAP_IN_REDUCTION on target constructs. (lower_rec_input_clauses): Likewise. (lower_omp_target): Likewise. * omp-expand.c (expand_omp_target): Temporarily ignore nowait clause on target if in_reduction is present. gcc/c-family/ * c-common.h (enum c_omp_region_type): Add C_ORT_TARGET and C_ORT_OMP_TARGET. * c-omp.c (c_omp_split_clauses): For OMP_CLAUSE_IN_REDUCTION on combined target constructs also add map (always, tofrom:) clause. gcc/c/ * c-parser.c (omp_split_clauses): Pass C_ORT_OMP_TARGET instead of C_ORT_OMP for clauses on target construct. (OMP_TARGET_CLAUSE_MASK): Add in_reduction clause. (c_parser_omp_target): For non-combined target add map (always, tofrom:) clauses for OMP_CLAUSE_IN_REDUCTION. Pass C_ORT_OMP_TARGET to c_finish_omp_clauses. * c-typeck.c (handle_omp_array_sections): Adjust ort handling for addition of C_ORT_OMP_TARGET and simplify, mapping clauses are never present on C_ORT_*DECLARE_SIMD. (c_finish_omp_clauses): Likewise. Handle OMP_CLAUSE_IN_REDUCTION on C_ORT_OMP_TARGET, set OMP_CLAUSE_MAP_IN_REDUCTION on corresponding map clauses. gcc/cp/ * parser.c (cp_omp_split_clauses): Pass C_ORT_OMP_TARGET instead of C_ORT_OMP for clauses on target construct. (OMP_TARGET_CLAUSE_MASK): Add in_reduction clause. (cp_parser_omp_target): For non-combined target add map (always, tofrom:) clauses for OMP_CLAUSE_IN_REDUCTION. Pass C_ORT_OMP_TARGET to finish_omp_clauses. * semantics.c (handle_omp_array_sections_1): Adjust ort handling for addition of C_ORT_OMP_TARGET and simplify, mapping clauses are never present on C_ORT_*DECLARE_SIMD. (handle_omp_array_sections): Likewise. (finish_omp_clauses): Likewise. Handle OMP_CLAUSE_IN_REDUCTION on C_ORT_OMP_TARGET, set OMP_CLAUSE_MAP_IN_REDUCTION on corresponding map clauses. * pt.c (tsubst_expr): Pass C_ORT_OMP_TARGET instead of C_ORT_OMP for clauses on target construct. gcc/testsuite/ * c-c++-common/gomp/target-in-reduction-1.c: New test. * c-c++-common/gomp/clauses-1.c: Add in_reduction clauses on target or combined target constructs. libgomp/ * testsuite/libgomp.c-c++-common/target-in-reduction-1.c: New test. * testsuite/libgomp.c-c++-common/target-in-reduction-2.c: New test. * testsuite/libgomp.c++/target-in-reduction-1.C: New test. * testsuite/libgomp.c++/target-in-reduction-2.C: New test. --- gcc/c-family/c-common.h | 4 +++- gcc/c-family/c-omp.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index be4b29a..88022d0 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1208,7 +1208,9 @@ enum c_omp_region_type C_ORT_OMP = 1 << 0, C_ORT_ACC = 1 << 1, C_ORT_DECLARE_SIMD = 1 << 2, - C_ORT_OMP_DECLARE_SIMD = C_ORT_OMP | C_ORT_DECLARE_SIMD + C_ORT_TARGET = 1 << 3, + C_ORT_OMP_DECLARE_SIMD = C_ORT_OMP | C_ORT_DECLARE_SIMD, + C_ORT_OMP_TARGET = C_ORT_OMP | C_ORT_TARGET }; extern tree c_finish_omp_master (location_t, tree); diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 28fbb1d..cd81a08 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2092,6 +2092,19 @@ c_omp_split_clauses (location_t loc, enum tree_code code, s = C_OMP_CLAUSE_SPLIT_TEAMS; break; case OMP_CLAUSE_IN_REDUCTION: + if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) != 0) + { + /* When on target, map(always, tofrom: item) is added as + well. For non-combined target it is added in the FEs. */ + c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), + OMP_CLAUSE_MAP); + OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); + OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_ALWAYS_TOFROM); + OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; + cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = c; + s = C_OMP_CLAUSE_SPLIT_TARGET; + break; + } /* in_reduction on taskloop simd becomes reduction on the simd and keeps being in_reduction on taskloop. */ if (code == OMP_SIMD) -- cgit v1.1 From 9aa8327e86eba9a5ad6dacb4db505e3451854976 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 25 Jun 2021 00:16:53 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ba218e6..1521f2d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2021-06-24 Jakub Jelinek + + * c-common.h (enum c_omp_region_type): Add C_ORT_TARGET and + C_ORT_OMP_TARGET. + * c-omp.c (c_omp_split_clauses): For OMP_CLAUSE_IN_REDUCTION on + combined target constructs also add map (always, tofrom:) clause. + 2021-06-15 Robin Dapp * c-attribs.c (common_handle_aligned_attribute): Remove short -- cgit v1.1 From 43c3f96f296b272614e0981fe3b25b0b1997db96 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 24 Jun 2021 16:09:20 -0600 Subject: c-family: add support for per-location warning groups. gcc/c-family/ChangeLog: * c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING. (c_common_truthvalue_conversion): Replace direct uses of TREE_NO_WARNING with warning_suppressed_p, suppress_warning, and copy_no_warning. (check_function_arguments_recurse): Same. * c-gimplify.c (c_gimplify_expr): Same. * c-warn.c (overflow_warning): Same. (warn_logical_operator): Same. (warn_if_unused_value): Same. (do_warn_unused_parameter): Same. --- gcc/c-family/c-common.c | 9 +++------ gcc/c-family/c-gimplify.c | 2 +- gcc/c-family/c-warn.c | 10 +++++----- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index c4eb2b1..681fcc9 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3375,7 +3375,6 @@ pointer_int_sum (location_t loc, enum tree_code resultcode, tree c_wrap_maybe_const (tree expr, bool non_const) { - bool nowarning = TREE_NO_WARNING (expr); location_t loc = EXPR_LOCATION (expr); /* This should never be called for C++. */ @@ -3386,8 +3385,6 @@ c_wrap_maybe_const (tree expr, bool non_const) STRIP_TYPE_NOPS (expr); expr = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL, expr); C_MAYBE_CONST_EXPR_NON_CONST (expr) = non_const; - if (nowarning) - TREE_NO_WARNING (expr) = 1; protected_set_expr_location (expr, loc); return expr; @@ -3633,12 +3630,12 @@ c_common_truthvalue_conversion (location_t location, tree expr) break; case MODIFY_EXPR: - if (!TREE_NO_WARNING (expr) + if (!warning_suppressed_p (expr, OPT_Wparentheses) && warn_parentheses && warning_at (location, OPT_Wparentheses, "suggest parentheses around assignment used as " "truth value")) - TREE_NO_WARNING (expr) = 1; + suppress_warning (expr, OPT_Wparentheses); break; case CONST_DECL: @@ -6019,7 +6016,7 @@ check_function_arguments_recurse (void (*callback) void *ctx, tree param, unsigned HOST_WIDE_INT param_num) { - if (TREE_NO_WARNING (param)) + if (warning_suppressed_p (param)) return; if (CONVERT_EXPR_P (param) diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 39c969d..0d38b70 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -713,7 +713,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, && !TREE_STATIC (DECL_EXPR_DECL (*expr_p)) && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p)) && !warn_init_self) - TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1; + suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self); break; case PREINCREMENT_EXPR: diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index cd3c99e..3495959 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -155,7 +155,7 @@ overflow_warning (location_t loc, tree value, tree expr) value); if (warned) - TREE_NO_WARNING (value) = 1; + suppress_warning (value, OPT_Woverflow); } /* Helper function for walk_tree. Unwrap C_MAYBE_CONST_EXPRs in an expression @@ -219,7 +219,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, && INTEGRAL_TYPE_P (TREE_TYPE (op_left)) && !CONSTANT_CLASS_P (stripped_op_left) && TREE_CODE (stripped_op_left) != CONST_DECL - && !TREE_NO_WARNING (op_left) + && !warning_suppressed_p (op_left, OPT_Wlogical_op) && TREE_CODE (op_right) == INTEGER_CST && !integer_zerop (op_right) && !integer_onep (op_right)) @@ -234,7 +234,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, = warning_at (location, OPT_Wlogical_op, "logical % applied to non-boolean constant"); if (warned) - TREE_NO_WARNING (op_left) = true; + suppress_warning (op_left, OPT_Wlogical_op); return; } @@ -588,7 +588,7 @@ bool warn_if_unused_value (const_tree exp, location_t locus, bool quiet) { restart: - if (TREE_USED (exp) || TREE_NO_WARNING (exp)) + if (TREE_USED (exp) || warning_suppressed_p (exp, OPT_Wunused_value)) return false; /* Don't warn about void constructs. This includes casting to void, @@ -2410,7 +2410,7 @@ do_warn_unused_parameter (tree fn) decl; decl = DECL_CHAIN (decl)) if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) - && !TREE_NO_WARNING (decl)) + && !warning_suppressed_p (decl, OPT_Wunused_parameter)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter, "unused parameter %qD", decl); } -- cgit v1.1 From 90708f87b8d13da61f7d5cba7c6597fee0025bb1 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 26 Jun 2021 00:16:39 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1521f2d..fe6a44c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2021-06-25 Martin Sebor + + * c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING. + (c_common_truthvalue_conversion): Replace direct uses of + TREE_NO_WARNING with warning_suppressed_p, suppress_warning, and + copy_no_warning. + (check_function_arguments_recurse): Same. + * c-gimplify.c (c_gimplify_expr): Same. + * c-warn.c (overflow_warning): Same. + (warn_logical_operator): Same. + (warn_if_unused_value): Same. + (do_warn_unused_parameter): Same. + 2021-06-24 Jakub Jelinek * c-common.h (enum c_omp_region_type): Add C_ORT_TARGET and -- cgit v1.1 From 506c68e25fb6aea135468972dbc9d8abf816a443 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 1 Jul 2021 18:02:47 +0200 Subject: Fix duplicate name issues in output of -fdump-ada-spec #2 This extends the type name conflict detection mechanism to variables. gcc/c-family/ * c-ada-spec.c (check_name): Rename into... (check_type_name_conflict): ...this. Minor tweak. (dump_ada_function_declaration): Adjust to above renaming. (dump_ada_array_domains): Fix oversight. (dump_ada_declaration): Call check_type_name_conflict for variables. --- gcc/c-family/c-ada-spec.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index a2669c6..ea52be6 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -1540,9 +1540,8 @@ dump_ada_import (pretty_printer *buffer, tree t, int spc) otherwise in BUFFER. */ static void -check_name (pretty_printer *buffer, tree t) +check_type_name_conflict (pretty_printer *buffer, tree t) { - const char *s; tree tmp = TREE_TYPE (t); while (TREE_CODE (tmp) == POINTER_TYPE && !TYPE_NAME (tmp)) @@ -1550,6 +1549,8 @@ check_name (pretty_printer *buffer, tree t) if (TREE_CODE (tmp) != FUNCTION_TYPE) { + const char *s; + if (TREE_CODE (tmp) == IDENTIFIER_NODE) s = IDENTIFIER_POINTER (tmp); else if (!TYPE_NAME (tmp)) @@ -1641,7 +1642,7 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, { if (DECL_NAME (arg)) { - check_name (buffer, arg); + check_type_name_conflict (buffer, arg); pp_ada_tree_identifier (buffer, DECL_NAME (arg), NULL_TREE, false); pp_string (buffer, " : "); @@ -1710,7 +1711,8 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, static void dump_ada_array_domains (pretty_printer *buffer, tree node, int spc) { - int first = 1; + bool first = true; + pp_left_paren (buffer); for (; TREE_CODE (node) == ARRAY_TYPE; node = TREE_TYPE (node)) @@ -1724,7 +1726,7 @@ dump_ada_array_domains (pretty_printer *buffer, tree node, int spc) if (!first) pp_string (buffer, ", "); - first = 0; + first = false; if (min) dump_ada_node (buffer, min, NULL_TREE, spc, false, true); @@ -1738,7 +1740,10 @@ dump_ada_array_domains (pretty_printer *buffer, tree node, int spc) pp_string (buffer, "0"); } else - pp_string (buffer, "size_t"); + { + pp_string (buffer, "size_t"); + first = false; + } } pp_right_paren (buffer); } @@ -3152,8 +3157,9 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (need_indent) INDENT (spc); - if (TREE_CODE (t) == FIELD_DECL && DECL_NAME (t)) - check_name (buffer, t); + if ((TREE_CODE (t) == FIELD_DECL || TREE_CODE (t) == VAR_DECL) + && DECL_NAME (t)) + check_type_name_conflict (buffer, t); /* Print variable/type's name. */ dump_ada_node (buffer, t, t, spc, false, true); -- cgit v1.1 From a3d8860d6386cd12942bc0b1995765ea516297bd Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 1 Jul 2021 18:06:46 +0200 Subject: Improve packed record layout support with -fdump-ada-spec We cannot fully support packed record layout in -fdump-ada-spec, as packing in C and Ada does not behave the same, so we issue a warning. But simple cases are OK and can actually be handled without much work. gcc/c-family/ * c-ada-spec.c (packed_layout): New global variable. (dump_ada_declaration): Set it upon seeing a packed record type. Do not put the "aliased" keyword if it is set. (dump_ada_structure): Add Pack aspect if it is set and clear it. gcc/testsuite/ * c-c++-common/dump-ada-spec-14.c: Adjust dg-warning directive. --- gcc/c-family/c-ada-spec.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index ea52be6..827bcc7 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -2038,6 +2038,7 @@ is_float128 (tree node) } static bool bitfield_used = false; +static bool packed_layout = false; /* Recursively dump in BUFFER Ada declarations corresponding to NODE of type TYPE. SPC is the indentation level. LIMITED_ACCESS indicates whether NODE @@ -2851,14 +2852,14 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) return 1; } - /* ??? Packed record layout is not supported. */ + /* Packed record layout is not fully supported. */ if (TYPE_PACKED (TREE_TYPE (t))) { - warning_at (DECL_SOURCE_LOCATION (t), 0, - "unsupported record layout"); + warning_at (DECL_SOURCE_LOCATION (t), 0, "packed layout"); pp_string (buffer, "pragma Compile_Time_Warning (True, "); - pp_string (buffer, "\"probably incorrect record layout\");"); + pp_string (buffer, "\"packed layout may be incorrect\");"); newline_and_indent (buffer, spc); + packed_layout = true; } if (orig && TYPE_NAME (orig)) @@ -2951,7 +2952,8 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) pp_string (buffer, " : "); - if (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) != POINTER_TYPE) + if (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) != POINTER_TYPE + && !packed_layout) pp_string (buffer, "aliased "); if (TYPE_NAME (TREE_TYPE (t))) @@ -3185,7 +3187,8 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE && (TYPE_NAME (TREE_TYPE (t)) || (TREE_CODE (TREE_TYPE (t)) != INTEGER_TYPE - && TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE))) + && TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE)) + && !packed_layout) pp_string (buffer, "aliased "); if (TREE_READONLY (t) && TREE_CODE (t) != FIELD_DECL) @@ -3352,7 +3355,7 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, pp_string (buffer, "Unchecked_Union => True"); } - if (bitfield_used) + if (bitfield_used || packed_layout) { char buf[32]; pp_comma (buffer); @@ -3363,6 +3366,7 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, sprintf (buf, "Alignment => %d", TYPE_ALIGN (node) / BITS_PER_UNIT); pp_string (buffer, buf); bitfield_used = false; + packed_layout = false; } if (nested) -- cgit v1.1 From bea7c16a467cd1278375df261e4bc1d2d6e48d3b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 2 Jul 2021 00:16:47 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index fe6a44c..ae7cafc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,18 @@ +2021-07-01 Eric Botcazou + + * c-ada-spec.c (packed_layout): New global variable. + (dump_ada_declaration): Set it upon seeing a packed record type. + Do not put the "aliased" keyword if it is set. + (dump_ada_structure): Add Pack aspect if it is set and clear it. + +2021-07-01 Eric Botcazou + + * c-ada-spec.c (check_name): Rename into... + (check_type_name_conflict): ...this. Minor tweak. + (dump_ada_function_declaration): Adjust to above renaming. + (dump_ada_array_domains): Fix oversight. + (dump_ada_declaration): Call check_type_name_conflict for variables. + 2021-06-25 Martin Sebor * c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING. -- cgit v1.1 From 9984f63aab93a370101966b7eb198dc61130b3c8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 2 Jul 2021 21:59:21 +0200 Subject: openmp: Initial support for OpenMP directives expressed as C++11 attributes This is an OpenMP 5.1 feature, but I think it is something very useful for OpenMP users, so I'm committing it now instead of waiting until all 5.0 work is done. The support is incomplete, only attributes on statements (or block local declarations) are supported right now, while for non-executable directives they should be also supported at namespace scope and at class scope, and for declarations in all places that appertain to the declarations rather than e.g. types. I need to also fix up handling of C++11 non-OpenMP attributes mixed with OpenMP attributes before block local declarations (currently it throws them away), probably reject if the directives appertain to labels etc. In order not to complicate all the OpenMP directive parsing, it is done by remembering the tokens from the attribute, slightly adjusting them and feeding them through a temporary new lexer to cp_parse_pragma. 2021-07-02 Jakub Jelinek gcc/c-family/ * c-common.h (enum c_omp_directive_kind): New enum. (struct c_omp_directive): New type. (c_omp_categorize_directive): Declare. * c-omp.c (omp_directives): New variable. (c_omp_categorize_directive): New function. gcc/cp/ * parser.h (struct cp_lexer): Add in_omp_attribute_pragma member. (struct cp_omp_declare_simd_data): Likewise. * cp-tree.h (enum cp_tree_index): Add CPTI_OMP_IDENTIFIER. (omp_identifier): Define. * parser.c (cp_parser_skip_to_pragma_eol): Handle in_omp_attribute_pragma CPP_PRAGMA_EOL followed by CPP_EOF. (cp_parser_require_pragma_eol): Likewise. (struct cp_omp_attribute_data): New type. (cp_parser_handle_statement_omp_attributes): New function. (cp_parser_statement): Handle OpenMP directives in statement's attribute-specifier-seq. (cp_parser_omp_directive_args, cp_parser_omp_sequence_args): New functions. (cp_parser_std_attribute): Handle omp::directive and omp::sequence attributes. (cp_parser_omp_all_clauses): If in_omp_attribute_pragma, allow a comma also before the first clause. (cp_parser_omp_allocate): Likewise. (cp_parser_omp_atomic): Likewise. (cp_parser_omp_depobj): Likewise. (cp_parser_omp_flush): Likewise. (cp_parser_omp_ordered): Likewise. (cp_parser_omp_declare_simd): Save in_omp_attribute_pragma into struct cp_omp_declare_simd_data. (cp_finish_omp_declare_variant): Add in_omp_attribute_pragma argument. If set, allow a comma also before match clause. (cp_parser_late_parsing_omp_declare_simd): If in_omp_attribute_pragma, allow a comma also before the first clause. Adjust cp_finish_omp_declare_variant caller. (cp_parser_omp_declare_target): If in_omp_attribute_pragma, allow a comma also before the first clause. (cp_parser_omp_declare_reduction_exprs): Likewise. (cp_parser_omp_requires): Likewise. * decl.c (initialize_predefined_identifiers): Initialize omp_identifier. * decl2.c (cplus_decl_attributes): Reject omp::directive and omp::sequence attributes. gcc/testsuite/ * g++.dg/gomp/attrs-1.C: New test. * g++.dg/gomp/attrs-2.C: New test. * g++.dg/gomp/attrs-3.C: New test. --- gcc/c-family/c-common.h | 19 ++++++ gcc/c-family/c-omp.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 88022d0..50ca8fb 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1246,6 +1246,25 @@ extern void c_omp_mark_declare_variant (location_t, tree, tree); extern const char *c_omp_map_clause_name (tree, bool); extern void c_omp_adjust_map_clauses (tree, bool); +enum c_omp_directive_kind { + C_OMP_DIR_STANDALONE, + C_OMP_DIR_CONSTRUCT, + C_OMP_DIR_DECLARATIVE, + C_OMP_DIR_UTILITY, + C_OMP_DIR_INFORMATIONAL +}; + +struct c_omp_directive { + const char *first, *second, *third; + unsigned int id; + enum c_omp_directive_kind kind; + bool simd; +}; + +extern const struct c_omp_directive *c_omp_categorize_directive (const char *, + const char *, + const char *); + /* Return next tree in the chain for chain_next walking of tree nodes. */ static inline tree c_tree_chain_next (tree t) diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index cd81a08..e70974d 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2912,3 +2912,154 @@ c_omp_adjust_map_clauses (tree clauses, bool is_target) } } } + +static const struct c_omp_directive omp_directives[] = { + /* Keep this alphabetically sorted by the first word. Non-null second/third + if any should precede null ones. */ + { "allocate", nullptr, nullptr, PRAGMA_OMP_ALLOCATE, + C_OMP_DIR_DECLARATIVE, false }, + /* { "assume", nullptr, nullptr, PRAGMA_OMP_ASSUME, + C_OMP_DIR_INFORMATIONAL, false }, */ + /* { "assumes", nullptr, nullptr, PRAGMA_OMP_ASSUMES, + C_OMP_DIR_INFORMATIONAL, false }, */ + { "atomic", nullptr, nullptr, PRAGMA_OMP_ATOMIC, + C_OMP_DIR_CONSTRUCT, false }, + { "barrier", nullptr, nullptr, PRAGMA_OMP_BARRIER, + C_OMP_DIR_STANDALONE, false }, + /* { "begin", "assumes", nullptr, PRAGMA_OMP_BEGIN, + C_OMP_DIR_INFORMATIONAL, false }, */ + /* { "begin", "declare", "target", PRAGMA_OMP_BEGIN, + C_OMP_DIR_DECLARATIVE, false }, */ + /* { "begin", "declare", "variant", PRAGMA_OMP_BEGIN, + C_OMP_DIR_DECLARATIVE, false }, */ + /* { "begin", "metadirective", nullptr, PRAGMA_OMP_BEGIN, + C_OMP_DIR_???, ??? }, */ + { "cancel", nullptr, nullptr, PRAGMA_OMP_CANCEL, + C_OMP_DIR_STANDALONE, false }, + { "cancellation", "point", nullptr, PRAGMA_OMP_CANCELLATION_POINT, + C_OMP_DIR_STANDALONE, false }, + { "critical", nullptr, nullptr, PRAGMA_OMP_CRITICAL, + C_OMP_DIR_CONSTRUCT, false }, + /* { "declare", "mapper", nullptr, PRAGMA_OMP_DECLARE, + C_OMP_DIR_DECLARATIVE, false }, */ + { "declare", "reduction", nullptr, PRAGMA_OMP_DECLARE, + C_OMP_DIR_DECLARATIVE, true }, + { "declare", "simd", nullptr, PRAGMA_OMP_DECLARE, + C_OMP_DIR_DECLARATIVE, true }, + { "declare", "target", nullptr, PRAGMA_OMP_DECLARE, + C_OMP_DIR_DECLARATIVE, false }, + { "declare", "variant", nullptr, PRAGMA_OMP_DECLARE, + C_OMP_DIR_DECLARATIVE, false }, + { "depobj", nullptr, nullptr, PRAGMA_OMP_DEPOBJ, + C_OMP_DIR_STANDALONE, false }, + /* { "dispatch", nullptr, nullptr, PRAGMA_OMP_DISPATCH, + C_OMP_DIR_CONSTRUCT, false }, */ + { "distribute", nullptr, nullptr, PRAGMA_OMP_DISTRIBUTE, + C_OMP_DIR_CONSTRUCT, true }, + /* { "end", "assumes", nullptr, PRAGMA_OMP_END, + C_OMP_DIR_INFORMATIONAL, false }, */ + { "end", "declare", "target", PRAGMA_OMP_END_DECLARE_TARGET, + C_OMP_DIR_DECLARATIVE, false }, + /* { "end", "declare", "variant", PRAGMA_OMP_END, + C_OMP_DIR_DECLARATIVE, false }, */ + /* { "end", "metadirective", nullptr, PRAGMA_OMP_END, + C_OMP_DIR_???, ??? }, */ + /* error with at(execution) is C_OMP_DIR_STANDALONE. */ + /* { "error", nullptr, nullptr, PRAGMA_OMP_ERROR, + C_OMP_DIR_UTILITY, false }, */ + { "flush", nullptr, nullptr, PRAGMA_OMP_FLUSH, + C_OMP_DIR_STANDALONE, false }, + { "for", nullptr, nullptr, PRAGMA_OMP_FOR, + C_OMP_DIR_CONSTRUCT, true }, + /* { "interop", nullptr, nullptr, PRAGMA_OMP_INTEROP, + C_OMP_DIR_STANDALONE, false }, */ + { "loop", nullptr, nullptr, PRAGMA_OMP_LOOP, + C_OMP_DIR_CONSTRUCT, true }, + /* { "masked", nullptr, nullptr, PRAGMA_OMP_MASKED, + C_OMP_DIR_CONSTRUCT, true }, */ + { "master", nullptr, nullptr, PRAGMA_OMP_MASTER, + C_OMP_DIR_CONSTRUCT, true }, + /* { "metadirective", nullptr, nullptr, PRAGMA_OMP_METADIRECTIVE, + C_OMP_DIR_???, ??? }, */ + /* { "nothing", nullptr, nullptr, PRAGMA_OMP_NOTHING, + C_OMP_DIR_UTILITY, false }, */ + /* ordered with depend clause is C_OMP_DIR_STANDALONE. */ + { "ordered", nullptr, nullptr, PRAGMA_OMP_ORDERED, + C_OMP_DIR_CONSTRUCT, true }, + { "parallel", nullptr, nullptr, PRAGMA_OMP_PARALLEL, + C_OMP_DIR_CONSTRUCT, true }, + { "requires", nullptr, nullptr, PRAGMA_OMP_REQUIRES, + C_OMP_DIR_INFORMATIONAL, false }, + { "scan", nullptr, nullptr, PRAGMA_OMP_SCAN, + C_OMP_DIR_CONSTRUCT, true }, + /* { "scope", nullptr, nullptr, PRAGMA_OMP_SCOPE, + C_OMP_DIR_CONSTRUCT, false }, */ + { "section", nullptr, nullptr, PRAGMA_OMP_SECTION, + C_OMP_DIR_CONSTRUCT, false }, + { "sections", nullptr, nullptr, PRAGMA_OMP_SECTIONS, + C_OMP_DIR_CONSTRUCT, false }, + { "simd", nullptr, nullptr, PRAGMA_OMP_SIMD, + C_OMP_DIR_CONSTRUCT, true }, + { "single", nullptr, nullptr, PRAGMA_OMP_SINGLE, + C_OMP_DIR_CONSTRUCT, false }, + { "target", "data", nullptr, PRAGMA_OMP_TARGET, + C_OMP_DIR_CONSTRUCT, false }, + { "target", "enter", "data", PRAGMA_OMP_TARGET, + C_OMP_DIR_STANDALONE, false }, + { "target", "exit", "data", PRAGMA_OMP_TARGET, + C_OMP_DIR_STANDALONE, false }, + { "target", "update", nullptr, PRAGMA_OMP_TARGET, + C_OMP_DIR_STANDALONE, false }, + { "target", nullptr, nullptr, PRAGMA_OMP_TARGET, + C_OMP_DIR_CONSTRUCT, true }, + { "task", nullptr, nullptr, PRAGMA_OMP_TASK, + C_OMP_DIR_CONSTRUCT, false }, + { "taskgroup", nullptr, nullptr, PRAGMA_OMP_TASKGROUP, + C_OMP_DIR_CONSTRUCT, false }, + { "taskloop", nullptr, nullptr, PRAGMA_OMP_TASKLOOP, + C_OMP_DIR_CONSTRUCT, true }, + { "taskwait", nullptr, nullptr, PRAGMA_OMP_TASKWAIT, + C_OMP_DIR_STANDALONE, false }, + { "taskyield", nullptr, nullptr, PRAGMA_OMP_TASKYIELD, + C_OMP_DIR_STANDALONE, false }, + /* { "tile", nullptr, nullptr, PRAGMA_OMP_TILE, + C_OMP_DIR_CONSTRUCT, false }, */ + { "teams", nullptr, nullptr, PRAGMA_OMP_TEAMS, + C_OMP_DIR_CONSTRUCT, true }, + { "threadprivate", nullptr, nullptr, PRAGMA_OMP_THREADPRIVATE, + C_OMP_DIR_DECLARATIVE, false } + /* { "unroll", nullptr, nullptr, PRAGMA_OMP_UNROLL, + C_OMP_DIR_CONSTRUCT, false }, */ +}; + +/* Find (non-combined/composite) OpenMP directive (if any) which starts + with FIRST keyword and for multi-word directives has SECOND and + THIRD keyword after it. */ + +const struct c_omp_directive * +c_omp_categorize_directive (const char *first, const char *second, + const char *third) +{ + const size_t n_omp_directives = ARRAY_SIZE (omp_directives); + for (size_t i = 0; i < n_omp_directives; i++) + { + if ((unsigned char) omp_directives[i].first[0] + < (unsigned char) first[0]) + continue; + if ((unsigned char) omp_directives[i].first[0] + > (unsigned char) first[0]) + break; + if (strcmp (omp_directives[i].first, first)) + continue; + if (!omp_directives[i].second) + return &omp_directives[i]; + if (!second || strcmp (omp_directives[i].second, second)) + continue; + if (!omp_directives[i].third) + return &omp_directives[i]; + if (!third || strcmp (omp_directives[i].third, third)) + continue; + return &omp_directives[i]; + } + return NULL; +} -- cgit v1.1 From 7a60a6e8b36dec960939494baef0f1f15dbfc450 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 3 Jul 2021 00:16:31 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ae7cafc..cd01f5c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2021-07-02 Jakub Jelinek + + * c-common.h (enum c_omp_directive_kind): New enum. + (struct c_omp_directive): New type. + (c_omp_categorize_directive): Declare. + * c-omp.c (omp_directives): New variable. + (c_omp_categorize_directive): New function. + 2021-07-01 Eric Botcazou * c-ada-spec.c (packed_layout): New global variable. -- cgit v1.1 From 4f6e181181a48c341e524653cae0885fd170131e Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 6 Jul 2021 14:13:31 -0600 Subject: Remove support for %G and %K. gcc/c-family/ChangeLog: * c-format.c (gcc_tdiag_char_table): Remove support for %G and %K. (gcc_cdiag_char_table): Same. (gcc_cxxdiag_char_table): Same. gcc/c/ChangeLog: * c-objc-common.c (c_tree_printer): Remove support for %G and %K. gcc/cp/ChangeLog: * error.c (cp_printer): Remove support for %G and %K. gcc/ChangeLog: * gimple-pretty-print.c (percent_G_format): Remove. * tree-diagnostic.c (default_tree_printer): Remove calls. * tree-pretty-print.c (percent_K_format): Remove. * tree-pretty-print.h (percent_K_format): Remove. gcc/testsuite/ChangeLog: * gcc.dg/format/gcc_diag-10.c: Update expected warnings. * gcc.dg/plugin/diagnostic_plugin_test_inlining.c: Remove %G. --- gcc/c-family/c-format.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index bda3b18..6fd0bb3 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -781,10 +781,6 @@ static const format_char_info gcc_tdiag_char_table[] = /* These will require a "tree" at runtime. */ { "DFTV", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "'", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, - { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; @@ -799,10 +795,6 @@ static const format_char_info gcc_cdiag_char_table[] = /* These will require a "tree" at runtime. */ { "DFTV", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "'", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, - { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "v", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q#", "", NULL }, @@ -819,10 +811,6 @@ static const format_char_info gcc_cxxdiag_char_table[] = /* These will require a "tree" at runtime. */ { "ADFHISTVX",1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "'", NULL }, { "E", 1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "", NULL }, - { "K", 1, STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89,{ T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, /* These accept either an 'int' or an 'enum tree_code' (which is handled as an 'int'.) */ { "CLOPQ",0,STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, -- cgit v1.1 From 6fba0eea8d6464966ac6d37af98a7487a9a03d19 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 7 Jul 2021 00:17:12 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index cd01f5c..0f1b45d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-07-06 Martin Sebor + + * c-format.c (gcc_tdiag_char_table): Remove support for %G and %K. + (gcc_cdiag_char_table): Same. + (gcc_cxxdiag_char_table): Same. + 2021-07-02 Jakub Jelinek * c-common.h (enum c_omp_directive_kind): New enum. -- cgit v1.1 From b15e301748f0e042379909e32b3ade439dd8f8f9 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 9 Jul 2021 05:45:03 -0400 Subject: c++: enable -fdelete-dead-exceptions by default As I was discussing with richi, I don't think it makes sense to protect calls to pure/const functions from DCE just because they aren't explicitly declared noexcept. PR100382 indicates that there are different considerations for Go, which has non-call exceptions. But still turn the flag off for that specific testcase. gcc/c-family/ChangeLog: * c-opts.c (c_common_post_options): Set -fdelete-dead-exceptions. gcc/ChangeLog: * doc/invoke.texi: -fdelete-dead-exceptions is on by default for C++. gcc/testsuite/ChangeLog: * g++.dg/torture/pr100382.C: Pass -fno-delete-dead-exceptions. --- gcc/c-family/c-opts.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 60b5802..1c4e832c 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1015,6 +1015,10 @@ c_common_post_options (const char **pfilename) SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_finite_loops, optimize >= 2 && cxx_dialect >= cxx11); + /* It's OK to discard calls to pure/const functions that might throw. */ + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_delete_dead_exceptions, true); + if (cxx_dialect >= cxx11) { /* If we're allowing C++0x constructs, don't warn about C++98 -- cgit v1.1 From c4fee1c646d52a9001a53fa0d4072db86b9be791 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 15 Jul 2021 00:16:54 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0f1b45d..f98bf2b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-07-14 Jason Merrill + + * c-opts.c (c_common_post_options): Set -fdelete-dead-exceptions. + 2021-07-06 Martin Sebor * c-format.c (gcc_tdiag_char_table): Remove support for %G and %K. -- cgit v1.1 From 98f1f9f38c45218c06200feb1939c9433a2ab6ca Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 15 Jul 2021 10:11:23 -0600 Subject: Avoid -Wvla-parameter for nontrivial bounds [PR97548]. Resolves: PR c/101289 - bogus -Wvla-paramater warning when using const for vla param PR c/97548 - bogus -Wvla-parameter on a bound expression involving a parameter gcc/c-family/ChangeLog: PR c/101289 PR c/97548 * c-warn.c (warn_parm_array_mismatch): Use OEP_DECL_NAME. gcc/c/ChangeLog: PR c/101289 PR c/97548 * c-decl.c (get_parm_array_spec): Strip nops. gcc/ChangeLog: PR c/101289 PR c/97548 * fold-const.c (operand_compare::operand_equal_p): Handle OEP_DECL_NAME. (operand_compare::verify_hash_value): Same. * tree-core.h (OEP_DECL_NAME): New. gcc/testsuite/ChangeLog: * gcc.dg/Wvla-parameter-12.c: New test. --- gcc/c-family/c-warn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 3495959..552a29f 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3646,7 +3646,8 @@ warn_parm_array_mismatch (location_t origloc, tree fndecl, tree newparms) /* The VLA bounds don't refer to other function parameters. Compare them lexicographically to detect gross mismatches such as between T[foo()] and T[bar()]. */ - if (operand_equal_p (newbnd, curbnd, OEP_LEXICOGRAPHIC)) + if (operand_equal_p (newbnd, curbnd, + OEP_DECL_NAME | OEP_LEXICOGRAPHIC)) continue; if (warning_at (newloc, OPT_Wvla_parameter, -- cgit v1.1 From d97d71a1989e9ee8e1b8563b351c42b7732da108 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 16 Jul 2021 00:16:25 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f98bf2b..817f4c4 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-07-15 Martin Sebor + + PR c/101289 + PR c/97548 + * c-warn.c (warn_parm_array_mismatch): Use OEP_DECL_NAME. + 2021-07-14 Jason Merrill * c-opts.c (c_common_post_options): Set -fdelete-dead-exceptions. -- cgit v1.1 From e06b1c5ac00b1bd0339739d3d9377c90852a83c9 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Thu, 15 Jul 2021 18:07:09 -0700 Subject: Fix PR 101453: ICE with optimize and large integer constant The problem is the buffer is too small to hold "-O" and the interger. This fixes the problem by use the correct size instead. Changes since v1: * v2: Use HOST_BITS_PER_LONG and just divide by 3 instead of 3.32. OK? Bootstrapped and tested on x86_64-linux with no regressions. gcc/c-family/ChangeLog: PR c/101453 * c-common.c (parse_optimize_options): Use the correct size for buffer. --- gcc/c-family/c-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 681fcc9..fe3657b 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5798,7 +5798,7 @@ parse_optimize_options (tree args, bool attr_p) if (TREE_CODE (value) == INTEGER_CST) { - char buffer[20]; + char buffer[HOST_BITS_PER_LONG / 3 + 4]; sprintf (buffer, "-O%ld", (long) TREE_INT_CST_LOW (value)); vec_safe_push (optimize_args, ggc_strdup (buffer)); } -- cgit v1.1 From 87277b6a04486b606761b86dbcfbc9a4b6871f4c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 17 Jul 2021 00:16:31 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 817f4c4..a0dea4c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-07-16 Andrew Pinski + + PR c/101453 + * c-common.c (parse_optimize_options): Use the correct + size for buffer. + 2021-07-15 Martin Sebor PR c/101289 -- cgit v1.1 From 00dcc88a0ed7bd148ea86d900b6c93574a2e1f26 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 20 Jul 2021 11:14:19 -0600 Subject: Adjust by-value function vec arguments to by-reference. gcc/c-family/ChangeLog: * c-common.c (c_build_shufflevector): Adjust by-value argument to by-const-reference. * c-common.h (c_build_shufflevector): Same. gcc/c/ChangeLog: * c-tree.h (c_build_function_call_vec): Adjust by-value argument to by-const-reference. * c-typeck.c (c_build_function_call_vec): Same. gcc/ChangeLog: * cfgloop.h (single_likely_exit): Adjust by-value argument to by-const-reference. * cfgloopanal.c (single_likely_exit): Same. * cgraph.h (struct cgraph_node): Same. * cgraphclones.c (cgraph_node::create_virtual_clone): Same. * genautomata.c (merge_states): Same. * genextract.c (VEC_char_to_string): Same. * genmatch.c (dt_node::gen_kids_1): Same. (walk_captures): Adjust by-value argument to by-reference. * gimple-ssa-store-merging.c (check_no_overlap): Adjust by-value argument to by-const-reference. * gimple.c (gimple_build_call_vec): Same. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * gimple.h (gimple_build_call_vec): Adjust by-value argument to by-const-reference. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * haifa-sched.c (calc_priorities): Adjust by-value argument to by-const-reference. (sched_init_luids): Same. (haifa_init_h_i_d): Same. * ipa-cp.c (ipa_get_indirect_edge_target_1): Same. (adjust_callers_for_value_intersection): Adjust by-value argument to by-reference. (find_more_scalar_values_for_callers_subset): Adjust by-value argument to by-const-reference. (find_more_contexts_for_caller_subset): Same. (find_aggregate_values_for_callers_subset): Same. (copy_useful_known_contexts): Same. * ipa-fnsummary.c (remap_edge_summaries): Same. (remap_freqcounting_predicate): Same. * ipa-inline.c (add_new_edges_to_heap): Adjust by-value argument to by-reference. * ipa-predicate.c (predicate::remap_after_inlining): Adjust by-value argument to by-const-reference. * ipa-predicate.h (predicate::remap_after_inlining): Same. * ipa-prop.c (ipa_find_agg_cst_for_param): Same. * ipa-prop.h (ipa_find_agg_cst_for_param): Same. * ira-build.c (ira_loop_tree_body_rev_postorder): Same. * read-rtl.c (add_overload_instance): Same. * rtl.h (native_decode_rtx): Same. (native_decode_vector_rtx): Same. * sched-int.h (sched_init_luids): Same. (haifa_init_h_i_d): Same. * simplify-rtx.c (native_decode_vector_rtx): Same. (native_decode_rtx): Same. * tree-call-cdce.c (gen_shrink_wrap_conditions): Same. (shrink_wrap_one_built_in_call_with_conds): Same. (shrink_wrap_conditional_dead_built_in_calls): Same. * tree-data-ref.c (create_runtime_alias_checks): Same. (compute_all_dependences): Same. * tree-data-ref.h (compute_all_dependences): Same. (create_runtime_alias_checks): Same. (index_in_loop_nest): Same. * tree-if-conv.c (mask_exists): Same. * tree-loop-distribution.c (class loop_distribution): Same. (loop_distribution::create_rdg_vertices): Same. (dump_rdg_partitions): Same. (debug_rdg_partitions): Same. (partition_contains_all_rw): Same. (loop_distribution::distribute_loop): Same. * tree-parloops.c (oacc_entry_exit_ok_1): Same. (oacc_entry_exit_single_gang): Same. * tree-ssa-loop-im.c (hoist_memory_references): Same. (loop_suitable_for_sm): Same. * tree-ssa-loop-niter.c (bound_index): Same. * tree-ssa-reassoc.c (update_ops): Same. (swap_ops_for_binary_stmt): Same. (rewrite_expr_tree): Same. (rewrite_expr_tree_parallel): Same. * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Same. * tree-ssa-sccvn.h (ao_ref_init_from_vn_reference): Same. * tree-ssa-structalias.c (process_all_all_constraints): Same. (make_constraints_to): Same. (handle_lhs_call): Same. (find_func_aliases_for_builtin_call): Same. (sort_fieldstack): Same. (check_for_overlaps): Same. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Same. (vect_create_cond_for_unequal_addrs): Same. (vect_create_cond_for_lower_bounds): Same. (vect_create_cond_for_alias_checks): Same. * tree-vect-slp-patterns.c (vect_validate_multiplication): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. (vect_make_slp_decision): Same. (vect_slp_bbs): Same. (duplicate_and_interleave): Same. (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. * tree-vectorizer.h (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. (duplicate_and_interleave): Same. * tree.c (build_vector_from_ctor): Same. (build_vector): Same. (check_vector_cst): Same. (check_vector_cst_duplicate): Same. (check_vector_cst_fill): Same. (check_vector_cst_stepped): Same. * tree.h (build_vector_from_ctor): Same. --- gcc/c-family/c-common.c | 4 ++-- gcc/c-family/c-common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index fe3657b..aacdfb4 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1115,8 +1115,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, and have vector types, V0 has the same element type as V1, and the number of elements the result is that of MASK. */ tree -c_build_shufflevector (location_t loc, tree v0, tree v1, vec mask, - bool complain) +c_build_shufflevector (location_t loc, tree v0, tree v1, + const vec &mask, bool complain) { tree ret; bool wrap = true; diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 50ca8fb..c4b2789 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1049,7 +1049,7 @@ extern bool vector_targets_convertible_p (const_tree t1, const_tree t2); extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note); extern tree c_build_vec_perm_expr (location_t, tree, tree, tree, bool = true); extern tree c_build_shufflevector (location_t, tree, tree, - vec, bool = true); + const vec &, bool = true); extern tree c_build_vec_convert (location_t, tree, location_t, tree, bool = true); extern void init_c_lex (void); -- cgit v1.1 From 92d4550991de7e0970a38939422b31e9dc07dd11 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 21 Jul 2021 00:16:54 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a0dea4c..87d658a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-07-20 Martin Sebor + + * c-common.c (c_build_shufflevector): Adjust by-value argument to + by-const-reference. + * c-common.h (c_build_shufflevector): Same. + 2021-07-16 Andrew Pinski PR c/101453 -- cgit v1.1 From a61f6afbee370785cf091fe46e2e022748528307 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 21 Jul 2021 18:30:00 +0200 Subject: OpenACC 'nohost' clause Do not "compile a version of this procedure for the host". gcc/ * tree-core.h (omp_clause_code): Add 'OMP_CLAUSE_NOHOST'. * tree.c (omp_clause_num_ops, omp_clause_code_name, walk_tree_1): Handle it. * tree-pretty-print.c (dump_omp_clause): Likewise. * omp-general.c (oacc_verify_routine_clauses): Likewise. * gimplify.c (gimplify_scan_omp_clauses) (gimplify_adjust_omp_clauses): Likewise. * tree-nested.c (convert_nonlocal_omp_clauses) (convert_local_omp_clauses): Likewise. * omp-low.c (scan_sharing_clauses): Likewise. * omp-offload.c (execute_oacc_device_lower): Update. gcc/c-family/ * c-pragma.h (pragma_omp_clause): Add 'PRAGMA_OACC_CLAUSE_NOHOST'. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Handle 'nohost'. (c_parser_oacc_all_clauses): Handle 'PRAGMA_OACC_CLAUSE_NOHOST'. (OACC_ROUTINE_CLAUSE_MASK): Add 'PRAGMA_OACC_CLAUSE_NOHOST'. * c-typeck.c (c_finish_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Handle 'nohost'. (cp_parser_oacc_all_clauses): Handle 'PRAGMA_OACC_CLAUSE_NOHOST'. (OACC_ROUTINE_CLAUSE_MASK): Add 'PRAGMA_OACC_CLAUSE_NOHOST'. * pt.c (tsubst_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'. * semantics.c (finish_omp_clauses): Likewise. gcc/fortran/ * dump-parse-tree.c (show_attr): Update. * gfortran.h (symbol_attribute): Add 'oacc_routine_nohost' member. (gfc_omp_clauses): Add 'nohost' member. * module.c (ab_attribute): Add 'AB_OACC_ROUTINE_NOHOST'. (attr_bits, mio_symbol_attribute): Update. * openmp.c (omp_mask2): Add 'OMP_CLAUSE_NOHOST'. (gfc_match_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'. (OACC_ROUTINE_CLAUSES): Add 'OMP_CLAUSE_NOHOST'. (gfc_match_oacc_routine): Update. * trans-decl.c (add_attributes_to_decl): Update. * trans-openmp.c (gfc_trans_omp_clauses): Likewise. gcc/testsuite/ * c-c++-common/goacc/classify-routine-nohost.c: New file. * c-c++-common/goacc/classify-routine.c: Update. * c-c++-common/goacc/routine-2.c: Likewise. * c-c++-common/goacc/routine-nohost-1.c: New file. * c-c++-common/goacc/routine-nohost-2.c: Likewise. * g++.dg/goacc/template.C: Update. * gfortran.dg/goacc/classify-routine-nohost.f95: New file. * gfortran.dg/goacc/classify-routine.f95: Update. * gfortran.dg/goacc/pure-elemental-procedures-2.f90: Likewise. * gfortran.dg/goacc/routine-6.f90: Likewise. * gfortran.dg/goacc/routine-intrinsic-2.f: Likewise. * gfortran.dg/goacc/routine-module-1.f90: Likewise. * gfortran.dg/goacc/routine-module-2.f90: Likewise. * gfortran.dg/goacc/routine-module-3.f90: Likewise. * gfortran.dg/goacc/routine-module-mod-1.f90: Likewise. * gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise. * gfortran.dg/goacc/routine-multiple-directives-2.f90: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: New file. * testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-nohost-2_2.c: Likewise. * testsuite/libgomp.oacc-fortran/routine-nohost-1.f90: Likewise. Co-Authored-By: Joseph Myers Co-Authored-By: Cesar Philippidis --- gcc/c-family/c-pragma.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index e4fd3c9..c5d11ce 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -160,6 +160,7 @@ enum pragma_omp_clause { PRAGMA_OACC_CLAUSE_HOST, PRAGMA_OACC_CLAUSE_INDEPENDENT, PRAGMA_OACC_CLAUSE_NO_CREATE, + PRAGMA_OACC_CLAUSE_NOHOST, PRAGMA_OACC_CLAUSE_NUM_GANGS, PRAGMA_OACC_CLAUSE_NUM_WORKERS, PRAGMA_OACC_CLAUSE_PRESENT, -- cgit v1.1 From 419c6c68e60adc8801b44dab72ebcd680cfe1d97 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 22 Jul 2021 00:16:46 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 87d658a..55f18d9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-07-21 Thomas Schwinge + Joseph Myers + Cesar Philippidis + + * c-pragma.h (pragma_omp_clause): Add 'PRAGMA_OACC_CLAUSE_NOHOST'. + 2021-07-20 Martin Sebor * c-common.c (c_build_shufflevector): Adjust by-value argument to -- cgit v1.1 From 2c5d803d03209478b4f060785c6f6ba2f0de88ad Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 23 Jul 2021 09:37:36 +0200 Subject: openmp: Diagnose invalid mixing of the attribute and pragma syntax directives The OpenMP 5.1 spec says that the attribute and pragma syntax directives should not be mixed on the same statement. The following patch adds diagnostic for that, [[omp::directive (...)]] #pragma omp ... is always an error and for the other order #pragma omp ... [[omp::directive (...)]] it depends on whether the pragma directive is an OpenMP construct (then it is an error because it needs a structured block or loop or statement as body) or e.g. a standalone directive (then it is fine). Only block scope is handled for now though, namespace scope and class scope still needs implementing even the basic support. 2021-07-23 Jakub Jelinek gcc/c-family/ * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP__START_ and PRAGMA_OMP__LAST_ enumerators. gcc/cp/ * parser.h (struct cp_parser): Add omp_attrs_forbidden_p member. * parser.c (cp_parser_handle_statement_omp_attributes): Diagnose mixing of attribute and pragma syntax directives when seeing omp::directive if parser->omp_attrs_forbidden_p or if attribute syntax directives are followed by OpenMP pragma. (cp_parser_statement): Clear parser->omp_attrs_forbidden_p after the cp_parser_handle_statement_omp_attributes call. (cp_parser_omp_structured_block): Add disallow_omp_attrs argument, if true, set parser->omp_attrs_forbidden_p. (cp_parser_omp_scan_loop_body, cp_parser_omp_sections_scope): Pass false as disallow_omp_attrs to cp_parser_omp_structured_block. (cp_parser_omp_parallel, cp_parser_omp_task): Set parser->omp_attrs_forbidden_p. gcc/testsuite/ * g++.dg/gomp/attrs-4.C: New test. * g++.dg/gomp/attrs-5.C: New test. --- gcc/c-family/c-pragma.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index c5d11ce..abd6667 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -42,7 +42,9 @@ enum pragma_kind { PRAGMA_OACC_UPDATE, PRAGMA_OACC_WAIT, + /* PRAGMA_OMP__START_ should be equal to the first PRAGMA_OMP_* code. */ PRAGMA_OMP_ALLOCATE, + PRAGMA_OMP__START_ = PRAGMA_OMP_ALLOCATE, PRAGMA_OMP_ATOMIC, PRAGMA_OMP_BARRIER, PRAGMA_OMP_CANCEL, @@ -72,6 +74,8 @@ enum pragma_kind { PRAGMA_OMP_TASKYIELD, PRAGMA_OMP_THREADPRIVATE, PRAGMA_OMP_TEAMS, + /* PRAGMA_OMP__LAST_ should be equal to the last PRAGMA_OMP_* code. */ + PRAGMA_OMP__LAST_ = PRAGMA_OMP_TEAMS, PRAGMA_GCC_PCH_PREPROCESS, PRAGMA_IVDEP, -- cgit v1.1 From 7f7364108f7441e6bd6f6f79a2d991e4e0f71b28 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 23 Jul 2021 09:50:15 +0200 Subject: openmp: Add support for __has_attribute(omp::directive) and __has_attribute(omp::sequence) Now that the C++ FE supports these attributes, but not through registering them in the attributes tables (they work quite differently from other attributes), this teaches c_common_has_attributes about those. 2021-07-23 Jakub Jelinek * c-lex.c (c_common_has_attribute): Call canonicalize_attr_name also on attr_id. Return 1 for omp::directive or omp::sequence in C++11 and later. * c-c++-common/gomp/attrs-1.c: New test. * c-c++-common/gomp/attrs-2.c: New test. * c-c++-common/gomp/attrs-3.c: New test. --- gcc/c-family/c-lex.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index c44e7a1..4b04e71 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -338,7 +338,20 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) tree attr_id = get_identifier ((const char *) cpp_token_as_text (pfile, nxt_token)); - attr_name = build_tree_list (attr_ns, attr_id); + attr_id = canonicalize_attr_name (attr_id); + if (c_dialect_cxx ()) + { + /* OpenMP attributes need special handling. */ + if ((flag_openmp || flag_openmp_simd) + && is_attribute_p ("omp", attr_ns) + && (is_attribute_p ("directive", attr_id) + || is_attribute_p ("sequence", attr_id))) + result = 1; + } + if (result) + attr_name = NULL_TREE; + else + attr_name = build_tree_list (attr_ns, attr_id); } else { -- cgit v1.1 From ead235f60139edc6eb408d8d083cbb15e417b447 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 24 Jul 2021 00:16:44 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 55f18d9..ce5d70d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2021-07-23 Jakub Jelinek + + * c-lex.c (c_common_has_attribute): Call canonicalize_attr_name also + on attr_id. Return 1 for omp::directive or omp::sequence in C++11 + and later. + +2021-07-23 Jakub Jelinek + + * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP__START_ and + PRAGMA_OMP__LAST_ enumerators. + 2021-07-21 Thomas Schwinge Joseph Myers Cesar Philippidis -- cgit v1.1 From a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 27 Jul 2021 13:51:55 -0600 Subject: Use OEP_DECL_NAME when comparing VLA bounds [PR101585]. Resolves: PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters gcc/c-family: PR c/101585 * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME. gcc/testsuite: PR c/101585 * gcc.dg/Wvla-parameter-13.c: New test. --- gcc/c-family/c-warn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 552a29f..84ad663 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3275,7 +3275,8 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms) /* Move on if the bounds look the same. */ if (!pcurbndpos && !pnewbndpos && curbnd && newbnd - && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC)) + && operand_equal_p (curbnd, newbnd, + OEP_DECL_NAME | OEP_LEXICOGRAPHIC)) continue; if ((curbnd && TREE_CODE (curbnd) != INTEGER_CST) -- cgit v1.1 From af3f12e6e869adcbb1cec09cedba627d4bbf69a4 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 28 Jul 2021 00:16:25 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ce5d70d..10a8bf4 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-07-27 Martin Sebor + + PR c/101585 + * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME. + 2021-07-23 Jakub Jelinek * c-lex.c (c_common_has_attribute): Call canonicalize_attr_name also -- cgit v1.1 From e63d76234d18cac731c4f3610d513bd8b39b5520 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 21 Jul 2021 09:14:24 +0200 Subject: c/101512 - fix missing address-taking in c_common_mark_addressable_vec c_common_mark_addressable_vec fails to look through C_MAYBE_CONST_EXPR in the case it isn't at the toplevel. 2021-07-21 Richard Biener PR c/101512 gcc/c-family/ * c-common.c (c_common_mark_addressable_vec): Look through C_MAYBE_CONST_EXPR even if not at the toplevel. gcc/testsuite/ * gcc.dg/torture/pr101512.c: New testcase. --- gcc/c-family/c-common.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index aacdfb4..21da679 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6894,10 +6894,13 @@ complete_flexible_array_elts (tree init) void c_common_mark_addressable_vec (tree t) { - if (TREE_CODE (t) == C_MAYBE_CONST_EXPR) - t = C_MAYBE_CONST_EXPR_EXPR (t); - while (handled_component_p (t)) - t = TREE_OPERAND (t, 0); + while (handled_component_p (t) || TREE_CODE (t) == C_MAYBE_CONST_EXPR) + { + if (TREE_CODE (t) == C_MAYBE_CONST_EXPR) + t = C_MAYBE_CONST_EXPR_EXPR (t); + else + t = TREE_OPERAND (t, 0); + } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != COMPOUND_LITERAL_EXPR) -- cgit v1.1 From 6cd005a255f15c1b4b3eaae71c844ea2592c9dce Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 30 Jul 2021 18:38:41 +0200 Subject: c++: Implement P0466R5 __cpp_lib_is_pointer_interconvertible compiler helpers [PR101539] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following patch attempts to implement the compiler helpers for libstdc++ std::is_pointer_interconvertible_base_of trait and std::is_pointer_interconvertible_with_class template function. For the former __is_pointer_interconvertible_base_of trait that checks first whether base and derived aren't non-union class types that are the same ignoring toplevel cv-qualifiers, otherwise if derived is unambiguously derived from base without cv-qualifiers, derived being a complete type, and if so, my limited understanding of any derived object being pointer-interconvertible with base subobject IMHO implies (because one can't inherit from unions or unions can't inherit) that we check if derived is standard layout type and we walk bases of derived recursively, stopping on a class that has any non-static data members and check if any of the bases is base. On class with non-static data members no bases are compared already. Upon discussions, this is something that maybe should have been changed in the standard with CWG 2254 and the patch no longer performs this and assumes all base subobjects of standard-layout class types are pointer-interconvertible with the whole class objects. The latter is implemented using a FE __builtin_is_pointer_interconvertible_with_class, but because on the library side it will be a template function, the builtin takes ... arguments and only during folding verifies it has a single argument with pointer to member type. The initial errors IMHO can only happen if one uses the builtin incorrectly by hand, the template function should ensure that it has exactly a single argument that has pointer to member type. Otherwise, again with my limited understanding of what the template function should do and pointer-interconvertibility, it folds to false for pointer-to-member-function, errors if basetype of the OFFSET_TYPE is incomplete, folds to false for non-std-layout non-union basetype, then finds the first non-static data member in the basetype or its bases (by ignoring DECL_FIELD_IS_BASE FIELD_DECLs that are empty, recursing into DECL_FIELD_IS_BASE FIELD_DECLs type that are non-empty (I think std layout should ensure there is at most one), for unions checks if membertype is same type as any of the union FIELD_DECLs, for non-unions the first other FIELD_DECL only, and for anonymous aggregates similarly (union vs. non-union) but recurses into the anon aggr types with std layout check for anon structures. If membertype doesn't match the type of first non-static data member (or for unions any of the members), then the builtin folds to false, otherwise the built folds to a check whether the argument is equal to OFFSET_TYPE of 0 or not, either at compile time if it is constant (e.g. for constexpr folding) or at runtime otherwise. As I wrote in the PR, I've tried my testcases with MSVC on godbolt that claims to implement it, and https://godbolt.org/z/3PnjM33vM for the first testcase shows it disagrees with my expectations on static_assert (std::is_pointer_interconvertible_base_of_v); static_assert (std::is_pointer_interconvertible_base_of_v); static_assert (!std::is_pointer_interconvertible_base_of_v); static_assert (!std::is_pointer_interconvertible_base_of_v); static_assert (std::is_pointer_interconvertible_base_of_v); Is that a bug in my patch or is MSVC buggy on these (or mix thereof)? https://godbolt.org/z/aYeYnne9d shows the second testcase, here it differs on: static_assert (std::is_pointer_interconvertible_with_class (&F::b)); static_assert (std::is_pointer_interconvertible_with_class (&I::g)); static_assert (std::is_pointer_interconvertible_with_class (&L::b)); static_assert (std::is_pointer_interconvertible_with_class (&V::a)); static_assert (std::is_pointer_interconvertible_with_class (&V::b)); Again, my bug, MSVC bug, mix thereof? According to Jason the , case are the subject of the CWG 2254 above discussed change and the rest are likely MSVC bugs. Oh, and there is another thing, the standard has an example: struct A { int a; }; // a standard-layout class struct B { int b; }; // a standard-layout class struct C: public A, public B { }; // not a standard-layout class static_assert( is_pointer_interconvertible_with_class( &C::b ) ); // Succeeds because, despite its appearance, &C::b has type // “pointer to member of B of type int”. static_assert( is_pointer_interconvertible_with_class( &C::b ) ); // Forces the use of class C, and fails. It seems to work as written with MSVC (second assertion fails), but fails with GCC with the patch: /tmp/1.C:22:57: error: no matching function for call to ‘is_pointer_interconvertible_with_class(int B::*)’ 22 | static_assert( is_pointer_interconvertible_with_class( &C::b ) ); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ /tmp/1.C:8:1: note: candidate: ‘template constexpr bool std::is_pointer_interconvertible_with_class(M S::*)’ 8 | is_pointer_interconvertible_with_class (M S::*m) noexcept | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/1.C:8:1: note: template argument deduction/substitution failed: /tmp/1.C:22:57: note: mismatched types ‘C’ and ‘B’ 22 | static_assert( is_pointer_interconvertible_with_class( &C::b ) ); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ the second int argument isn't deduced. This boils down to: template bool foo (M S::*m) noexcept; struct A { int a; }; struct B { int b; }; struct C : public A, public B {}; bool a = foo (&C::b); bool b = foo (&C::b); bool c = foo (&C::b); which with /std:c++20 or -std=c++20 is accepted by latest MSVC and ICC but rejected by GCC and clang (in both cases on the last line). Is this a GCC/clang bug in argument deduction (in that case I think we want a separate PR), or a bug in ICC/MSVC and the standard itself that should specify in the examples both template arguments instead of just the first? And this has been raised with the CWG. 2021-07-30 Jakub Jelinek PR c++/101539 gcc/c-family/ * c-common.h (enum rid): Add RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF. * c-common.c (c_common_reswords): Add __is_pointer_interconvertible_base_of. gcc/cp/ * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_POINTER_INTERCONVERTIBLE_BASE_OF. (enum cp_built_in_function): Add CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS. (fold_builtin_is_pointer_inverconvertible_with_class): Declare. * parser.c (cp_parser_primary_expression): Handle RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF. (cp_parser_trait_expr): Likewise. * cp-objcp-common.c (names_builtin_p): Likewise. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER_INTERCONVERTIBLE_BASE_OF. * decl.c (cxx_init_decl_processing): Register __builtin_is_pointer_interconvertible_with_class builtin. * constexpr.c (cxx_eval_builtin_function_call): Handle CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS builtin. * semantics.c (pointer_interconvertible_base_of_p, first_nonstatic_data_member_p, fold_builtin_is_pointer_inverconvertible_with_class): New functions. (trait_expr_value): Handle CPTK_IS_POINTER_INTERCONVERTIBLE_BASE_OF. (finish_trait_expr): Likewise. Formatting fix. * cp-gimplify.c (cp_gimplify_expr): Fold CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS. Call fndecl_built_in_p just once. (cp_fold): Likewise. * tree.c (builtin_valid_in_constant_expr_p): Handle CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS. Call fndecl_built_in_p just once. * cxx-pretty-print.c (pp_cxx_trait_expression): Handle CPTK_IS_POINTER_INTERCONVERTIBLE_BASE_OF. gcc/testsuite/ * g++.dg/cpp2a/is-pointer-interconvertible-base-of1.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class1.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class2.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class3.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class4.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class5.C: New test. * g++.dg/cpp2a/is-pointer-interconvertible-with-class6.C: New test. --- gcc/c-family/c-common.c | 2 ++ gcc/c-family/c-common.h | 1 + 2 files changed, 3 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 21da679..00ac3c5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -421,6 +421,8 @@ const struct c_common_resword c_common_reswords[] = { "__is_enum", RID_IS_ENUM, D_CXXONLY }, { "__is_final", RID_IS_FINAL, D_CXXONLY }, { "__is_literal_type", RID_IS_LITERAL_TYPE, D_CXXONLY }, + { "__is_pointer_interconvertible_base_of", + RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF, D_CXXONLY }, { "__is_pod", RID_IS_POD, D_CXXONLY }, { "__is_polymorphic", RID_IS_POLYMORPHIC, D_CXXONLY }, { "__is_same", RID_IS_SAME_AS, D_CXXONLY }, diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index c4b2789..65d8c1c 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -174,6 +174,7 @@ enum rid RID_IS_BASE_OF, RID_IS_CLASS, RID_IS_EMPTY, RID_IS_ENUM, RID_IS_FINAL, RID_IS_LITERAL_TYPE, + RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF, RID_IS_POD, RID_IS_POLYMORPHIC, RID_IS_SAME_AS, RID_IS_STD_LAYOUT, RID_IS_TRIVIAL, -- cgit v1.1 From 4d17ca1bc74109e5cc4ef34890b6293c4bcb1d6a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 3 Aug 2021 07:49:16 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 10a8bf4..7306b36 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2021-07-30 Jakub Jelinek + + PR c++/101539 + * c-common.h (enum rid): Add RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF. + * c-common.c (c_common_reswords): Add + __is_pointer_interconvertible_base_of. + +2021-07-29 Richard Biener + + PR c/101512 + * c-common.c (c_common_mark_addressable_vec): Look through + C_MAYBE_CONST_EXPR even if not at the toplevel. + 2021-07-27 Martin Sebor PR c/101585 -- cgit v1.1 From d0befed793b94f3f407be44e6f69f81a02f5f073 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Aug 2021 22:41:17 +0200 Subject: openmp: Add support for OpenMP 5.1 masked construct This construct has been introduced as a replacement for master construct, but unlike that construct is slightly more general, has an optional clause which allows to choose which thread will be the one running the region, it can be some other thread than the master (primary) thread with number 0, or it could be no threads or multiple threads (then of course one needs to be careful about data races). It is way too early to deprecate the master construct though, we don't even have OpenMP 5.0 fully implemented, it has been deprecated in 5.1, will be also in 5.2 and removed in 6.0. But even then it will likely be a good idea to just -Wdeprecated warn about it and still accept it. The patch also contains something I should have done much earlier, for clauses that accept some integral expression where we only care about the value, forces during gimplification that value into either a min invariant (as before), SSA_NAME or a fresh temporary, but never e.g. a user VAR_DECL, so that for those clauses we don't need to worry about adjusting it. 2021-08-12 Jakub Jelinek gcc/ * tree.def (OMP_MASKED): New tree code. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_FILTER. * tree.h (OMP_MASKED_BODY, OMP_MASKED_CLAUSES, OMP_MASKED_COMBINED, OMP_CLAUSE_FILTER_EXPR): Define. * tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FILTER entry. (omp_clause_code_name): Likewise. (walk_tree_1): Handle OMP_CLAUSE_FILTER. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Handle OMP_CLAUSE_FILTER. (convert_nonlocal_reference_stmt, convert_local_reference_stmt, convert_gimple_call): Handle GIMPLE_OMP_MASTER. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FILTER. (dump_generic_node): Handle OMP_MASTER. * gimple.def (GIMPLE_OMP_MASKED): New gimple code. * gimple.c (gimple_build_omp_masked): New function. (gimple_copy): Handle GIMPLE_OMP_MASKED. * gimple.h (gimple_build_omp_masked): Declare. (gimple_has_substatements): Handle GIMPLE_OMP_MASKED. (gimple_omp_masked_clauses, gimple_omp_masked_clauses_ptr, gimple_omp_masked_set_clauses): New inline functions. (CASE_GIMPLE_OMP): Add GIMPLE_OMP_MASKED. * gimple-pretty-print.c (dump_gimple_omp_masked): New function. (pp_gimple_stmt_1): Handle GIMPLE_OMP_MASKED. * gimple-walk.c (walk_gimple_stmt): Likewise. * gimple-low.c (lower_stmt): Likewise. * gimplify.c (is_gimple_stmt): Handle OMP_MASTER. (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_FILTER. For clauses that take one expression rather than decl or constant, force gimplification of that into a SSA_NAME or temporary unless min invariant. (gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_FILTER. (gimplify_expr): Handle OMP_MASKED. * tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_MASKED. (estimate_num_insns): Likewise. * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FILTER. (check_omp_nesting_restrictions): Handle GIMPLE_OMP_MASKED. Adjust diagnostics for existence of masked construct. (scan_omp_1_stmt, lower_omp_master, lower_omp_1, diagnose_sb_1, diagnose_sb_2): Handle GIMPLE_OMP_MASKED. * omp-expand.c (expand_omp_synch, expand_omp, omp_make_gimple_edges): Likewise. gcc/c-family/ * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_MASKED. (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FILTER. * c-pragma.c (omp_pragmas_simd): Add masked construct. * c-common.h (enum c_omp_clause_split): Add C_OMP_CLAUSE_SPLIT_MASKED enumerator. (c_finish_omp_masked): Declare. * c-omp.c (c_finish_omp_masked): New function. (c_omp_split_clauses): Handle combined masked constructs. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Parse filter clause name. (c_parser_omp_clause_filter): New function. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER. (OMP_MASKED_CLAUSE_MASK): Define. (c_parser_omp_masked): New function. (c_parser_omp_parallel): Handle parallel masked. (c_parser_omp_construct): Handle PRAGMA_OMP_MASKED. * c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_FILTER. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Parse filter clause name. (cp_parser_omp_clause_filter): New function. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER. (OMP_MASKED_CLAUSE_MASK): Define. (cp_parser_omp_masked): New function. (cp_parser_omp_parallel): Handle parallel masked. (cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OMP_MASKED. * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_FILTER. * pt.c (tsubst_omp_clauses): Likewise. (tsubst_expr): Handle OMP_MASKED. gcc/testsuite/ * c-c++-common/gomp/clauses-1.c (bar): Add tests for combined masked constructs with clauses. * c-c++-common/gomp/clauses-5.c (foo): Add testcase for filter clause. * c-c++-common/gomp/clause-dups-1.c (f1): Likewise. * c-c++-common/gomp/masked-1.c: New test. * c-c++-common/gomp/masked-2.c: New test. * c-c++-common/gomp/masked-combined-1.c: New test. * c-c++-common/gomp/masked-combined-2.c: New test. * c-c++-common/goacc/uninit-if-clause.c: Remove xfails. * g++.dg/gomp/block-11.C: New test. * g++.dg/gomp/tpl-masked-1.C: New test. * g++.dg/gomp/attrs-1.C (bar): Add tests for masked construct and combined masked constructs with clauses in attribute syntax. * g++.dg/gomp/attrs-2.C (bar): Likewise. * gcc.dg/gomp/nesting-1.c (f1, f2): Add tests for masked construct nesting. * gfortran.dg/goacc/host_data-tree.f95: Allow also SSA_NAMEs in if clause. * gfortran.dg/goacc/kernels-tree.f95: Likewise. libgomp/ * testsuite/libgomp.c-c++-common/masked-1.c: New test. --- gcc/c-family/c-common.h | 4 +++- gcc/c-family/c-omp.c | 52 ++++++++++++++++++++++++++++++++++++------------- gcc/c-family/c-pragma.c | 1 + gcc/c-family/c-pragma.h | 2 ++ 4 files changed, 45 insertions(+), 14 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 65d8c1c..025123a 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1201,7 +1201,8 @@ enum c_omp_clause_split C_OMP_CLAUSE_SPLIT_COUNT, C_OMP_CLAUSE_SPLIT_SECTIONS = C_OMP_CLAUSE_SPLIT_FOR, C_OMP_CLAUSE_SPLIT_TASKLOOP = C_OMP_CLAUSE_SPLIT_FOR, - C_OMP_CLAUSE_SPLIT_LOOP = C_OMP_CLAUSE_SPLIT_FOR + C_OMP_CLAUSE_SPLIT_LOOP = C_OMP_CLAUSE_SPLIT_FOR, + C_OMP_CLAUSE_SPLIT_MASKED = C_OMP_CLAUSE_SPLIT_DISTRIBUTE }; enum c_omp_region_type @@ -1215,6 +1216,7 @@ enum c_omp_region_type }; extern tree c_finish_omp_master (location_t, tree); +extern tree c_finish_omp_masked (location_t, tree, tree); extern tree c_finish_omp_taskgroup (location_t, tree, tree); extern tree c_finish_omp_critical (location_t, tree, tree, tree); extern tree c_finish_omp_ordered (location_t, tree, tree); diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index e70974d..54eba61 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -86,6 +86,20 @@ c_finish_omp_master (location_t loc, tree stmt) return t; } +/* Complete a #pragma omp masked construct. BODY is the structured-block + that follows the pragma. LOC is the location of the #pragma. */ + +tree +c_finish_omp_masked (location_t loc, tree body, tree clauses) +{ + tree stmt = make_node (OMP_MASKED); + TREE_TYPE (stmt) = void_type_node; + OMP_MASKED_BODY (stmt) = body; + OMP_MASKED_CLAUSES (stmt) = clauses; + SET_EXPR_LOCATION (stmt, loc); + return add_stmt (stmt); +} + /* Complete a #pragma omp taskgroup construct. BODY is the structured-block that follows the pragma. LOC is the location of the #pragma. */ @@ -1542,11 +1556,16 @@ c_oacc_split_loop_clauses (tree clauses, tree *not_loop_clauses, #pragma omp distribute parallel for simd #pragma omp distribute simd #pragma omp for simd + #pragma omp masked taskloop + #pragma omp masked taskloop simd #pragma omp master taskloop #pragma omp master taskloop simd #pragma omp parallel for #pragma omp parallel for simd #pragma omp parallel loop + #pragma omp parallel masked + #pragma omp parallel masked taskloop + #pragma omp parallel masked taskloop simd #pragma omp parallel master #pragma omp parallel master taskloop #pragma omp parallel master taskloop simd @@ -1651,6 +1670,9 @@ c_omp_split_clauses (location_t loc, enum tree_code code, case OMP_CLAUSE_BIND: s = C_OMP_CLAUSE_SPLIT_LOOP; break; + case OMP_CLAUSE_FILTER: + s = C_OMP_CLAUSE_SPLIT_MASKED; + break; /* Duplicate this to all of taskloop, distribute, for, simd and loop. */ case OMP_CLAUSE_COLLAPSE: @@ -1700,10 +1722,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code, else s = C_OMP_CLAUSE_SPLIT_DISTRIBUTE; break; - /* Private clause is supported on all constructs but master, - it is enough to put it on the innermost one other than master. For - #pragma omp {for,sections} put it on parallel though, - as that's what we did for OpenMP 3.1. */ + /* Private clause is supported on all constructs but master/masked, + it is enough to put it on the innermost one other than + master/masked. For #pragma omp {for,sections} put it on parallel + though, as that's what we did for OpenMP 3.1. */ case OMP_CLAUSE_PRIVATE: switch (code) { @@ -1713,14 +1735,15 @@ c_omp_split_clauses (location_t loc, enum tree_code code, case OMP_DISTRIBUTE: s = C_OMP_CLAUSE_SPLIT_DISTRIBUTE; break; case OMP_TEAMS: s = C_OMP_CLAUSE_SPLIT_TEAMS; break; case OMP_MASTER: s = C_OMP_CLAUSE_SPLIT_PARALLEL; break; + case OMP_MASKED: s = C_OMP_CLAUSE_SPLIT_PARALLEL; break; case OMP_TASKLOOP: s = C_OMP_CLAUSE_SPLIT_TASKLOOP; break; case OMP_LOOP: s = C_OMP_CLAUSE_SPLIT_LOOP; break; default: gcc_unreachable (); } break; /* Firstprivate clause is supported on all constructs but - simd, master and loop. Put it on the outermost of those and - duplicate on teams and parallel. */ + simd, master, masked and loop. Put it on the outermost of those + and duplicate on teams and parallel. */ case OMP_CLAUSE_FIRSTPRIVATE: if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) != 0) @@ -1773,7 +1796,7 @@ c_omp_split_clauses (location_t loc, enum tree_code code, else if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOGROUP)) != 0) /* This must be - #pragma omp parallel master taskloop{, simd}. */ + #pragma omp parallel mas{ked,ter} taskloop{, simd}. */ s = C_OMP_CLAUSE_SPLIT_TASKLOOP; else /* This must be @@ -1805,9 +1828,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code, else if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOGROUP)) != 0) { - /* This must be #pragma omp {,{,parallel }master }taskloop simd + /* This must be + #pragma omp {,{,parallel }mas{ked,ter} }taskloop simd or - #pragma omp {,parallel }master taskloop. */ + #pragma omp {,parallel }mas{ked,ter} taskloop. */ gcc_assert (code == OMP_SIMD || code == OMP_TASKLOOP); s = C_OMP_CLAUSE_SPLIT_TASKLOOP; } @@ -2044,7 +2068,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code, } else if (code == OMP_SECTIONS || code == OMP_PARALLEL - || code == OMP_MASTER) + || code == OMP_MASTER + || code == OMP_MASKED) s = C_OMP_CLAUSE_SPLIT_PARALLEL; else if (code == OMP_TASKLOOP) s = C_OMP_CLAUSE_SPLIT_TASKLOOP; @@ -2455,7 +2480,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code, gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_TARGET] == NULL_TREE); if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) == 0) gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_TEAMS] == NULL_TREE); - if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) == 0) + if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) == 0 + && (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FILTER)) == 0) gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE] == NULL_TREE); if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) == 0) gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] == NULL_TREE); @@ -2975,8 +3001,8 @@ static const struct c_omp_directive omp_directives[] = { C_OMP_DIR_STANDALONE, false }, */ { "loop", nullptr, nullptr, PRAGMA_OMP_LOOP, C_OMP_DIR_CONSTRUCT, true }, - /* { "masked", nullptr, nullptr, PRAGMA_OMP_MASKED, - C_OMP_DIR_CONSTRUCT, true }, */ + { "masked", nullptr, nullptr, PRAGMA_OMP_MASKED, + C_OMP_DIR_CONSTRUCT, true }, { "master", nullptr, nullptr, PRAGMA_OMP_MASTER, C_OMP_DIR_CONSTRUCT, true }, /* { "metadirective", nullptr, nullptr, PRAGMA_OMP_METADIRECTIVE, diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index f46b5b9..b466a27 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1343,6 +1343,7 @@ static const struct omp_pragma_def omp_pragmas_simd[] = { { "distribute", PRAGMA_OMP_DISTRIBUTE }, { "for", PRAGMA_OMP_FOR }, { "loop", PRAGMA_OMP_LOOP }, + { "masked", PRAGMA_OMP_MASKED }, { "master", PRAGMA_OMP_MASTER }, { "ordered", PRAGMA_OMP_ORDERED }, { "parallel", PRAGMA_OMP_PARALLEL }, diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index abd6667..b7ec6e5 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -57,6 +57,7 @@ enum pragma_kind { PRAGMA_OMP_FLUSH, PRAGMA_OMP_FOR, PRAGMA_OMP_LOOP, + PRAGMA_OMP_MASKED, PRAGMA_OMP_MASTER, PRAGMA_OMP_ORDERED, PRAGMA_OMP_PARALLEL, @@ -104,6 +105,7 @@ enum pragma_omp_clause { PRAGMA_OMP_CLAUSE_DEVICE, PRAGMA_OMP_CLAUSE_DEVICE_TYPE, PRAGMA_OMP_CLAUSE_DIST_SCHEDULE, + PRAGMA_OMP_CLAUSE_FILTER, PRAGMA_OMP_CLAUSE_FINAL, PRAGMA_OMP_CLAUSE_FIRSTPRIVATE, PRAGMA_OMP_CLAUSE_FOR, -- cgit v1.1 From 72be20e20299ec57b4bc9ba03d5b7d6bf10e97cc Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 13 Aug 2021 00:16:43 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7306b36..9d0868d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2021-08-12 Jakub Jelinek + + * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_MASKED. + (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FILTER. + * c-pragma.c (omp_pragmas_simd): Add masked construct. + * c-common.h (enum c_omp_clause_split): Add C_OMP_CLAUSE_SPLIT_MASKED + enumerator. + (c_finish_omp_masked): Declare. + * c-omp.c (c_finish_omp_masked): New function. + (c_omp_split_clauses): Handle combined masked constructs. + 2021-07-30 Jakub Jelinek PR c++/101539 -- cgit v1.1 From 8cdcea51c0fd753e6a652c9b236e91b3a6e0911c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 9 Aug 2021 09:06:14 +0200 Subject: gcov: Add TARGET_GCOV_TYPE_SIZE target hook If -fprofile-update=atomic is used, then the target must provide atomic operations for the counters of the type returned by get_gcov_type(). This is a 64-bit type for targets which have a 64-bit long long type. On 32-bit targets this could be an issue since they may not provide 64-bit atomic operations. Allow targets to override the default type size with the new TARGET_GCOV_TYPE_SIZE target hook. If a 32-bit gcov type size is used, then there is currently a warning in libgcov-driver.c in a dead code block due to sizeof (counter) == sizeof (gcov_unsigned_t): libgcc/libgcov-driver.c: In function 'dump_counter': libgcc/libgcov-driver.c:401:46: warning: right shift count >= width of type [-Wshift-count-overflow] 401 | dump_unsigned ((gcov_unsigned_t)(counter >> 32), dump_fn, arg); | ^~ gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Define __LIBGCC_GCOV_TYPE_SIZE if flag_building_libgcc is true. gcc/ * config/sparc/rtemself.h (SPARC_GCOV_TYPE_SIZE): Define. * config/sparc/sparc.c (sparc_gcov_type_size): New. (TARGET_GCOV_TYPE_SIZE): Redefine if SPARC_GCOV_TYPE_SIZE is defined. * coverage.c (get_gcov_type): Use targetm.gcov_type_size(). * doc/tm.texi (TARGET_GCOV_TYPE_SIZE): Add hook under "Misc". * doc/tm.texi.in: Regenerate. * target.def (gcov_type_size): New target hook. * targhooks.c (default_gcov_type_size): New. * targhooks.h (default_gcov_type_size): Declare. * tree-profile.c (gimple_gen_edge_profiler): Use precision of gcov_type_node. (gimple_gen_time_profiler): Likewise. libgcc/ * libgcov.h (gcov_type): Define using __LIBGCC_GCOV_TYPE_SIZE. (gcov_type_unsigned): Likewise. --- gcc/c-family/c-cppbuiltin.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index f79f939..3fa62bc 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1450,6 +1450,8 @@ c_cpp_builtins (cpp_reader *pfile) /* For libgcov. */ builtin_define_with_int_value ("__LIBGCC_VTABLE_USES_DESCRIPTORS__", TARGET_VTABLE_USES_DESCRIPTORS); + builtin_define_with_int_value ("__LIBGCC_GCOV_TYPE_SIZE", + targetm.gcov_type_size()); } /* For use in assembly language. */ -- cgit v1.1 From 9d1d9fc8b4a1d0aefd13d573d3957ca5720dd519 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 17 Aug 2021 00:16:32 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9d0868d..a6fdf7b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-08-16 Sebastian Huber + + * c-cppbuiltin.c (c_cpp_builtins): Define + __LIBGCC_GCOV_TYPE_SIZE if flag_building_libgcc is true. + 2021-08-12 Jakub Jelinek * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_MASKED. -- cgit v1.1 From e45483c7c4badc4bf2d6ced22360ce1ab172967f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 17 Aug 2021 09:30:09 +0200 Subject: openmp: Implement OpenMP 5.1 scope construct This patch implements the OpenMP 5.1 scope construct, which is similar to worksharing constructs in many regards, but isn't one of them. The body of the construct is encountered by all threads though, it can be nested in itself or intermixed with taskgroup and worksharing etc. constructs can appear inside of it (but it can't be nested in worksharing etc. constructs). The main purpose of the construct is to allow reductions (normal and task ones) without the need to close the parallel and reopen another one. If it doesn't have task reductions, it can be implemented without any new library support, with nowait it just does the privatizations at the start if any and reductions before the end of the body, with without nowait emits a normal GOMP_barrier{,_cancel} at the end too. For task reductions, we need to ensure only one thread initializes the task reduction library data structures and other threads copy from that, so a new GOMP_scope_start routine is added to the library for that. It acts as if the start of the scope construct is a nowait worksharing construct (that is ok, it can't be nested in other worksharing constructs and all threads need to encounter the start in the same order) which does the task reduction initialization, but as the body can have other scope constructs and/or worksharing constructs, that is all where we use this dummy worksharing construct. With task reductions, the construct must not have nowait and ends with a GOMP_barrier{,_cancel}, followed by task reductions followed by GOMP_workshare_task_reduction_unregister. Only C/C++ FE support is done. 2021-08-17 Jakub Jelinek gcc/ * tree.def (OMP_SCOPE): New tree code. * tree.h (OMP_SCOPE_BODY, OMP_SCOPE_CLAUSES): Define. * tree-nested.c (convert_nonlocal_reference_stmt, convert_local_reference_stmt, convert_gimple_call): Handle GIMPLE_OMP_SCOPE. * tree-pretty-print.c (dump_generic_node): Handle OMP_SCOPE. * gimple.def (GIMPLE_OMP_SCOPE): New gimple code. * gimple.c (gimple_build_omp_scope): New function. (gimple_copy): Handle GIMPLE_OMP_SCOPE. * gimple.h (gimple_build_omp_scope): Declare. (gimple_has_substatements): Handle GIMPLE_OMP_SCOPE. (gimple_omp_scope_clauses, gimple_omp_scope_clauses_ptr, gimple_omp_scope_set_clauses): New inline functions. (CASE_GIMPLE_OMP): Add GIMPLE_OMP_SCOPE. * gimple-pretty-print.c (dump_gimple_omp_scope): New function. (pp_gimple_stmt_1): Handle GIMPLE_OMP_SCOPE. * gimple-walk.c (walk_gimple_stmt): Likewise. * gimple-low.c (lower_stmt): Likewise. * gimplify.c (is_gimple_stmt): Handle OMP_MASTER. (gimplify_scan_omp_clauses): For task reductions, handle OMP_SCOPE like ORT_WORKSHARE constructs. Adjust diagnostics for % allowing task reductions. Reject inscan reductions on scope. (omp_find_stores_stmt): Handle GIMPLE_OMP_SCOPE. (gimplify_omp_workshare, gimplify_expr): Handle OMP_SCOPE. * tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_SCOPE. (estimate_num_insns): Likewise. * omp-low.c (build_outer_var_ref): Look through GIMPLE_OMP_SCOPE contexts if var isn't privatized there. (check_omp_nesting_restrictions): Handle GIMPLE_OMP_SCOPE. (scan_omp_1_stmt): Likewise. (maybe_add_implicit_barrier_cancel): Look through outer scope constructs. (lower_omp_scope): New function. (lower_omp_task_reductions): Handle OMP_SCOPE. (lower_omp_1): Handle GIMPLE_OMP_SCOPE. (diagnose_sb_1, diagnose_sb_2): Likewise. * omp-expand.c (expand_omp_single): Support also GIMPLE_OMP_SCOPE. (expand_omp): Handle GIMPLE_OMP_SCOPE. (omp_make_gimple_edges): Likewise. * omp-builtins.def (BUILT_IN_GOMP_SCOPE_START): New built-in. gcc/c-family/ * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_SCOPE. * c-pragma.c (omp_pragmas): Add scope construct. * c-omp.c (omp_directives): Uncomment scope directive entry. gcc/c/ * c-parser.c (OMP_SCOPE_CLAUSE_MASK): Define. (c_parser_omp_scope): New function. (c_parser_omp_construct): Handle PRAGMA_OMP_SCOPE. gcc/cp/ * parser.c (OMP_SCOPE_CLAUSE_MASK): Define. (cp_parser_omp_scope): New function. (cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OMP_SCOPE. * pt.c (tsubst_expr): Handle OMP_SCOPE. gcc/testsuite/ * c-c++-common/gomp/nesting-2.c (foo): Add scope and masked construct tests. * c-c++-common/gomp/scan-1.c (f3): Add scope construct test.. * c-c++-common/gomp/cancel-1.c (f2): Add scope and masked construct tests. * c-c++-common/gomp/reduction-task-2.c (bar): Add scope construct test. Adjust diagnostics for the addition of scope. * c-c++-common/gomp/loop-1.c (f5): Add master, masked and scope construct tests. * c-c++-common/gomp/clause-dups-1.c (f1): Add scope construct test. * gcc.dg/gomp/nesting-1.c (f1, f2, f3): Add scope construct tests. * c-c++-common/gomp/scope-1.c: New test. * c-c++-common/gomp/scope-2.c: New test. * g++.dg/gomp/attrs-1.C (bar): Add scope construct tests. * g++.dg/gomp/attrs-2.C (bar): Likewise. * gfortran.dg/gomp/reduction4.f90: Adjust expected diagnostics. * gfortran.dg/gomp/reduction7.f90: Likewise. libgomp/ * Makefile.am (libgomp_la_SOURCES): Add scope.c * Makefile.in: Regenerated. * libgomp_g.h (GOMP_scope_start): Declare. * libgomp.map: Add GOMP_scope_start@@GOMP_5.1. * scope.c: New file. * testsuite/libgomp.c-c++-common/scope-1.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-16.c: New test. --- gcc/c-family/c-omp.c | 4 ++-- gcc/c-family/c-pragma.c | 1 + gcc/c-family/c-pragma.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 54eba61..de49d26 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -3018,8 +3018,8 @@ static const struct c_omp_directive omp_directives[] = { C_OMP_DIR_INFORMATIONAL, false }, { "scan", nullptr, nullptr, PRAGMA_OMP_SCAN, C_OMP_DIR_CONSTRUCT, true }, - /* { "scope", nullptr, nullptr, PRAGMA_OMP_SCOPE, - C_OMP_DIR_CONSTRUCT, false }, */ + { "scope", nullptr, nullptr, PRAGMA_OMP_SCOPE, + C_OMP_DIR_CONSTRUCT, false }, { "section", nullptr, nullptr, PRAGMA_OMP_SECTION, C_OMP_DIR_CONSTRUCT, false }, { "sections", nullptr, nullptr, PRAGMA_OMP_SECTIONS, diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index b466a27..5f0096f 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1329,6 +1329,7 @@ static const struct omp_pragma_def omp_pragmas[] = { { "end", PRAGMA_OMP_END_DECLARE_TARGET }, { "flush", PRAGMA_OMP_FLUSH }, { "requires", PRAGMA_OMP_REQUIRES }, + { "scope", PRAGMA_OMP_SCOPE }, { "section", PRAGMA_OMP_SECTION }, { "sections", PRAGMA_OMP_SECTIONS }, { "single", PRAGMA_OMP_SINGLE }, diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index b7ec6e5..2b9e5ea 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -63,6 +63,7 @@ enum pragma_kind { PRAGMA_OMP_PARALLEL, PRAGMA_OMP_REQUIRES, PRAGMA_OMP_SCAN, + PRAGMA_OMP_SCOPE, PRAGMA_OMP_SECTION, PRAGMA_OMP_SECTIONS, PRAGMA_OMP_SIMD, -- cgit v1.1 From 798666392b512a585f0de2983a5d3423e960959e Mon Sep 17 00:00:00 2001 From: Matt Jacobson Date: Thu, 29 Jul 2021 09:57:23 +0100 Subject: Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2. Signed-off-by: Matt Jacobson gcc/c-family/ChangeLog: * c-opts.c (c_common_post_options): Default to flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Warn about and reset flag_objc_sjlj_exceptions regardless of flag_objc_exceptions. (next_runtime_02_initialize): Use a checking assert that flag_objc_sjlj_exceptions is off. --- gcc/c-family/c-opts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 1c4e832c..373af0c 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -852,9 +852,9 @@ c_common_post_options (const char **pfilename) else if (!flag_gnu89_inline && !flag_isoc99) error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode"); - /* Default to ObjC sjlj exception handling if NeXT runtime. */ + /* Default to ObjC sjlj exception handling if NeXT runtime < v2. */ if (flag_objc_sjlj_exceptions < 0) - flag_objc_sjlj_exceptions = flag_next_runtime; + flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2); if (flag_objc_exceptions && !flag_objc_sjlj_exceptions) flag_exceptions = 1; -- cgit v1.1 From 32c3a75390623a0470df52af13f78baddd562981 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 17 Aug 2021 21:06:39 +0200 Subject: c++: Implement P0466R5 __cpp_lib_is_layout_compatible compiler helpers [PR101539] The following patch implements __is_layout_compatible trait and __builtin_is_corresponding_member helper function for the std::is_corresponding_member template function. As the current definition of layout compatible type has various problems, which result e.g. in corresponding members in layout compatible types having different member offsets, the patch anticipates some changes to the C++ standard: 1) class or enumeral types aren't layout compatible if they have different alignment or size 2) if two members have different offsets, they can't be corresponding members ([[no_unique_address]] with empty types can change that, or alignas on the member decls) 3) in unions, bitfields can't correspond to non-unions, or bitfields can't correspond to bitfields with different widths, or members with [[no_unique_address]] can't correspond to members without that attribute __builtin_is_corresponding_member for anonymous structs (GCC extension) will recurse into the anonymous structs. For anonymous unions it will emit a sorry if it can't prove such member types can't appear in the anonymous unions or anonymous aggregates in that union, because corresponding member is defined only using common initial sequence which is only defined for std-layout non-union class types and so I have no idea what to do otherwise in that case. 2021-08-17 Jakub Jelinek PR c++/101539 gcc/c-family/ * c-common.h (enum rid): Add RID_IS_LAYOUT_COMPATIBLE. * c-common.c (c_common_reswords): Add __is_layout_compatible. gcc/cp/ * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_LAYOUT_COMPATIBLE. (enum cp_built_in_function): Add CP_BUILT_IN_IS_CORRESPONDING_MEMBER. (fold_builtin_is_corresponding_member, next_common_initial_seqence, layout_compatible_type_p): Declare. * parser.c (cp_parser_primary_expression): Handle RID_IS_LAYOUT_COMPATIBLE. (cp_parser_trait_expr): Likewise. * cp-objcp-common.c (names_builtin_p): Likewise. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_LAYOUT_COMPATIBLE. * decl.c (cxx_init_decl_processing): Register __builtin_is_corresponding_member builtin. * constexpr.c (cxx_eval_builtin_function_call): Handle CP_BUILT_IN_IS_CORRESPONDING_MEMBER builtin. * semantics.c (is_corresponding_member_union, is_corresponding_member_aggr, fold_builtin_is_corresponding_member): New functions. (trait_expr_value): Handle CPTK_IS_LAYOUT_COMPATIBLE. (finish_trait_expr): Likewise. * typeck.c (next_common_initial_seqence, layout_compatible_type_p): New functions. * cp-gimplify.c (cp_gimplify_expr): Fold CP_BUILT_IN_IS_CORRESPONDING_MEMBER. (cp_fold): Likewise. * tree.c (builtin_valid_in_constant_expr_p): Handle CP_BUILT_IN_IS_CORRESPONDING_MEMBER. * cxx-pretty-print.c (pp_cxx_trait_expression): Handle CPTK_IS_LAYOUT_COMPATIBLE. * class.c (remove_zero_width_bit_fields): Remove. (layout_class_type): Don't call it. gcc/testsuite/ * g++.dg/cpp2a/is-corresponding-member1.C: New test. * g++.dg/cpp2a/is-corresponding-member2.C: New test. * g++.dg/cpp2a/is-corresponding-member3.C: New test. * g++.dg/cpp2a/is-corresponding-member4.C: New test. * g++.dg/cpp2a/is-corresponding-member5.C: New test. * g++.dg/cpp2a/is-corresponding-member6.C: New test. * g++.dg/cpp2a/is-corresponding-member7.C: New test. * g++.dg/cpp2a/is-corresponding-member8.C: New test. * g++.dg/cpp2a/is-layout-compatible1.C: New test. * g++.dg/cpp2a/is-layout-compatible2.C: New test. * g++.dg/cpp2a/is-layout-compatible3.C: New test. --- gcc/c-family/c-common.c | 1 + gcc/c-family/c-common.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 00ac3c5..017e415 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -420,6 +420,7 @@ const struct c_common_resword c_common_reswords[] = { "__is_empty", RID_IS_EMPTY, D_CXXONLY }, { "__is_enum", RID_IS_ENUM, D_CXXONLY }, { "__is_final", RID_IS_FINAL, D_CXXONLY }, + { "__is_layout_compatible", RID_IS_LAYOUT_COMPATIBLE, D_CXXONLY }, { "__is_literal_type", RID_IS_LITERAL_TYPE, D_CXXONLY }, { "__is_pointer_interconvertible_base_of", RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF, D_CXXONLY }, diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 025123a..d66bf15 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -173,7 +173,8 @@ enum rid RID_IS_ABSTRACT, RID_IS_AGGREGATE, RID_IS_BASE_OF, RID_IS_CLASS, RID_IS_EMPTY, RID_IS_ENUM, - RID_IS_FINAL, RID_IS_LITERAL_TYPE, + RID_IS_FINAL, RID_IS_LAYOUT_COMPATIBLE, + RID_IS_LITERAL_TYPE, RID_IS_POINTER_INTERCONVERTIBLE_BASE_OF, RID_IS_POD, RID_IS_POLYMORPHIC, RID_IS_SAME_AS, -- cgit v1.1 From 2d14d64bf2d42a87ec58dd3760be12aeaa4a4279 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 18 Aug 2021 00:16:48 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a6fdf7b..5595994 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,20 @@ +2021-08-17 Jakub Jelinek + + PR c++/101539 + * c-common.h (enum rid): Add RID_IS_LAYOUT_COMPATIBLE. + * c-common.c (c_common_reswords): Add __is_layout_compatible. + +2021-08-17 Matt Jacobson + + * c-opts.c (c_common_post_options): Default to + flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2. + +2021-08-17 Jakub Jelinek + + * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_SCOPE. + * c-pragma.c (omp_pragmas): Add scope construct. + * c-omp.c (omp_directives): Uncomment scope directive entry. + 2021-08-16 Sebastian Huber * c-cppbuiltin.c (c_cpp_builtins): Define -- cgit v1.1 From 5079b7781a2c506dcdfb241347d74c7891268225 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 18 Aug 2021 11:10:43 +0200 Subject: openmp: Add nothing directive support As has been clarified, it is intentional that nothing directive is accepted in substatements of selection and looping statements and after labels and is handled as if the directive just isn't there, so that void foo (int x) { if (x) #pragma omp metadirective when (...:nothing) when (...:parallel) bar (); } behaves consistently; declarative and stand-alone directives aren't allowed at that point, but constructs are parsed with the following statement as the construct body and nothing or missing default on metadirective therefore should handle the following statement as part of the if substatement instead of having nothing as the substatement and bar done unconditionally after the if. 2021-08-18 Jakub Jelinek gcc/c-family/ * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_NOTHING. * c-pragma.c (omp_pragmas): Add nothing directive. * c-omp.c (omp_directives): Uncomment nothing directive entry. gcc/c/ * c-parser.c (c_parser_omp_nothing): New function. (c_parser_pragma): Handle PRAGMA_OMP_NOTHING. gcc/cp/ * parser.c (cp_parser_omp_nothing): New function. (cp_parser_pragma): Handle PRAGMA_OMP_NOTHING. gcc/testsuite/ * c-c++-common/gomp/nothing-1.c: New test. * g++.dg/gomp/attrs-1.C (bar): Add nothing directive test. * g++.dg/gomp/attrs-2.C (bar): Likewise. * g++.dg/gomp/attrs-9.C: Likewise. libgomp/ * testsuite/libgomp.c-c++-common/nothing-1.c: New test. --- gcc/c-family/c-omp.c | 4 ++-- gcc/c-family/c-pragma.c | 1 + gcc/c-family/c-pragma.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index de49d26..d4e98bf 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -3007,8 +3007,8 @@ static const struct c_omp_directive omp_directives[] = { C_OMP_DIR_CONSTRUCT, true }, /* { "metadirective", nullptr, nullptr, PRAGMA_OMP_METADIRECTIVE, C_OMP_DIR_???, ??? }, */ - /* { "nothing", nullptr, nullptr, PRAGMA_OMP_NOTHING, - C_OMP_DIR_UTILITY, false }, */ + { "nothing", nullptr, nullptr, PRAGMA_OMP_NOTHING, + C_OMP_DIR_UTILITY, false }, /* ordered with depend clause is C_OMP_DIR_STANDALONE. */ { "ordered", nullptr, nullptr, PRAGMA_OMP_ORDERED, C_OMP_DIR_CONSTRUCT, true }, diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 5f0096f..238309d 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1328,6 +1328,7 @@ static const struct omp_pragma_def omp_pragmas[] = { { "depobj", PRAGMA_OMP_DEPOBJ }, { "end", PRAGMA_OMP_END_DECLARE_TARGET }, { "flush", PRAGMA_OMP_FLUSH }, + { "nothing", PRAGMA_OMP_NOTHING }, { "requires", PRAGMA_OMP_REQUIRES }, { "scope", PRAGMA_OMP_SCOPE }, { "section", PRAGMA_OMP_SECTION }, diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index 2b9e5ea..dc9e8a6 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -57,6 +57,7 @@ enum pragma_kind { PRAGMA_OMP_FLUSH, PRAGMA_OMP_FOR, PRAGMA_OMP_LOOP, + PRAGMA_OMP_NOTHING, PRAGMA_OMP_MASKED, PRAGMA_OMP_MASTER, PRAGMA_OMP_ORDERED, -- cgit v1.1 From 6e529985d8956f74492e3176026fc02dc8f01b6c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 19 Aug 2021 00:16:42 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5595994..ab566ba 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2021-08-18 Jakub Jelinek + + * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_NOTHING. + * c-pragma.c (omp_pragmas): Add nothing directive. + * c-omp.c (omp_directives): Uncomment nothing directive entry. + 2021-08-17 Jakub Jelinek PR c++/101539 -- cgit v1.1 From 0d973c0a0d90a0a302e7eda1a4d9709be3c5b102 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 20 Aug 2021 11:36:52 +0200 Subject: openmp: Implement the error directive This patch implements the error directive. Depending on clauses it is either a compile time diagnostics (in that case diagnosed right away) or runtime diagnostics (libgomp API call that diagnoses at runtime), and either fatal or warning (error or warning at compile time or fatal error vs. error at runtime) and either has no message or user supplied message (this kind of e.g. deprecated attribute). The directive is also stand-alone directive when at runtime while utility (thus disappears from the IL as if it wasn't there for parsing like nothing directive) at compile time. There are some clarifications in the works ATM, so this patch doesn't yet require that for compile time diagnostics the user message must be a constant string literal, there are uncertainities on what exactly is valid argument of message clause (whether just const char * type, convertible to const char *, qualified/unqualified const char * or char * or what else) and what to do in templates. Currently even in templates it is diagnosed right away for compile time diagnostics, if we'll need to substitute it, we'd need to queue something into the IL, have pt.c handle it and diagnose only later. 2021-08-20 Jakub Jelinek gcc/ * omp-builtins.def (BUILT_IN_GOMP_WARNING, BUILT_IN_GOMP_ERROR): New builtins. gcc/c-family/ * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_ERROR. * c-pragma.c (omp_pragmas): Add error directive. * c-omp.c (omp_directives): Uncomment error directive entry. gcc/c/ * c-parser.c (c_parser_omp_error): New function. (c_parser_pragma): Handle PRAGMA_OMP_ERROR. gcc/cp/ * parser.c (cp_parser_handle_statement_omp_attributes): Determine if PRAGMA_OMP_ERROR directive is C_OMP_DIR_STANDALONE. (cp_parser_omp_error): New function. (cp_parser_pragma): Handle PRAGMA_OMP_ERROR. gcc/fortran/ * types.def (BT_FN_VOID_CONST_PTR_SIZE): New DEF_FUNCTION_TYPE_2. * f95-lang.c (ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST): Define. gcc/testsuite/ * c-c++-common/gomp/error-1.c: New test. * c-c++-common/gomp/error-2.c: New test. * c-c++-common/gomp/error-3.c: New test. * g++.dg/gomp/attrs-1.C (bar): Add error directive test. * g++.dg/gomp/attrs-2.C (bar): Add error directive test. * g++.dg/gomp/attrs-13.C: New test. * g++.dg/gomp/error-1.C: New test. libgomp/ * libgomp.map (GOMP_5.1): Add GOMP_error and GOMP_warning. * libgomp_g.h (GOMP_warning, GOMP_error): Declare. * error.c (GOMP_warning, GOMP_error): New functions. * testsuite/libgomp.c-c++-common/error-1.c: New test. --- gcc/c-family/c-omp.c | 4 ++-- gcc/c-family/c-pragma.c | 1 + gcc/c-family/c-pragma.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index d4e98bf..18de7e4 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2991,8 +2991,8 @@ static const struct c_omp_directive omp_directives[] = { /* { "end", "metadirective", nullptr, PRAGMA_OMP_END, C_OMP_DIR_???, ??? }, */ /* error with at(execution) is C_OMP_DIR_STANDALONE. */ - /* { "error", nullptr, nullptr, PRAGMA_OMP_ERROR, - C_OMP_DIR_UTILITY, false }, */ + { "error", nullptr, nullptr, PRAGMA_OMP_ERROR, + C_OMP_DIR_UTILITY, false }, { "flush", nullptr, nullptr, PRAGMA_OMP_FLUSH, C_OMP_DIR_STANDALONE, false }, { "for", nullptr, nullptr, PRAGMA_OMP_FOR, diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 238309d..a9be8df 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1326,6 +1326,7 @@ static const struct omp_pragma_def omp_pragmas[] = { { "cancellation", PRAGMA_OMP_CANCELLATION_POINT }, { "critical", PRAGMA_OMP_CRITICAL }, { "depobj", PRAGMA_OMP_DEPOBJ }, + { "error", PRAGMA_OMP_ERROR }, { "end", PRAGMA_OMP_END_DECLARE_TARGET }, { "flush", PRAGMA_OMP_FLUSH }, { "nothing", PRAGMA_OMP_NOTHING }, diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index dc9e8a6..0c5b07a 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -53,6 +53,7 @@ enum pragma_kind { PRAGMA_OMP_DECLARE, PRAGMA_OMP_DEPOBJ, PRAGMA_OMP_DISTRIBUTE, + PRAGMA_OMP_ERROR, PRAGMA_OMP_END_DECLARE_TARGET, PRAGMA_OMP_FLUSH, PRAGMA_OMP_FOR, -- cgit v1.1 From 1b507b1e3c58c063b9cf803dff80c28d4626cb5d Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 20 Aug 2021 15:43:32 +0200 Subject: c-format.c/Fortran: Support %wd / host-wide integer in gfc_error This patch adds support for the 'll' (long double) and 'w' (HOST_WIDE_INT) length modifiers to the Fortran FE diagnostic function (gfc_error, gfc_warning, ...) gcc/c-family/ChangeLog: * c-format.c (gcc_gfc_length_specs): Add 'll' and 'w'. (gcc_gfc_char_table): Add T9L_LL and T9L_ULL to "di" and "u", respecitively; fill with BADLEN to match size of 'types'. (get_init_dynamic_hwi): Split off from ... (init_dynamic_diag_info): ... here. Call it. (init_dynamic_gfc_info): Call it. gcc/fortran/ChangeLog: * error.c (error_uinteger): Take 'long long unsigned' instead of 'long unsigned' as argumpent. (error_integer): Take 'long long' instead of 'long'. (error_hwuint, error_hwint): New. (error_print): Update to handle 'll' and 'w' length modifiers. * simplify.c (substring_has_constant_len): Use '%wd' in gfc_error. --- gcc/c-family/c-format.c | 142 +++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 67 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 6fd0bb3..b4cb765a 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -546,10 +546,11 @@ static const format_length_info strfmon_length_specs[] = }; -/* For now, the Fortran front-end routines only use l as length modifier. */ +/* Length modifiers used by the fortran/error.c routines. */ static const format_length_info gcc_gfc_length_specs[] = { - { "l", FMT_LEN_l, STD_C89, NO_FMT, 0 }, + { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C89, 0 }, + { "w", FMT_LEN_w, STD_C89, NO_FMT, 0 }, { NO_FMT, NO_FMT, 0 } }; @@ -821,10 +822,10 @@ static const format_char_info gcc_cxxdiag_char_table[] = static const format_char_info gcc_gfc_char_table[] = { /* C89 conversion specifiers. */ - { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, - { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, - { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, - { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "cR", NULL }, + { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, + { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, + { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "cR", NULL }, /* gfc conversion specifiers. */ @@ -4843,12 +4844,73 @@ init_dynamic_asm_fprintf_info (void) } } +static const format_length_info* +get_init_dynamic_hwi (void) +{ + static tree hwi; + static format_length_info *diag_ls; + + if (!hwi) + { + unsigned int i; + + /* Find the underlying type for HOST_WIDE_INT. For the 'w' + length modifier to work, one must have issued: "typedef + HOST_WIDE_INT __gcc_host_wide_int__;" in one's source code + prior to using that modifier. */ + if ((hwi = maybe_get_identifier ("__gcc_host_wide_int__"))) + { + hwi = identifier_global_value (hwi); + if (hwi) + { + if (TREE_CODE (hwi) != TYPE_DECL) + { + error ("%<__gcc_host_wide_int__%> is not defined as a type"); + hwi = 0; + } + else + { + hwi = DECL_ORIGINAL_TYPE (hwi); + gcc_assert (hwi); + if (hwi != long_integer_type_node + && hwi != long_long_integer_type_node) + { + error ("%<__gcc_host_wide_int__%> is not defined" + " as % or %"); + hwi = 0; + } + } + } + } + if (!diag_ls) + diag_ls = (format_length_info *) + xmemdup (gcc_diag_length_specs, + sizeof (gcc_diag_length_specs), + sizeof (gcc_diag_length_specs)); + if (hwi) + { + /* HOST_WIDE_INT must be one of 'long' or 'long long'. */ + i = find_length_info_modifier_index (diag_ls, 'w'); + if (hwi == long_integer_type_node) + diag_ls[i].index = FMT_LEN_l; + else if (hwi == long_long_integer_type_node) + diag_ls[i].index = FMT_LEN_ll; + else + gcc_unreachable (); + } + } + return diag_ls; +} + /* Determine the type of a "locus" in the code being compiled for use in GCC's __gcc_gfc__ custom format attribute. You must have set dynamic_format_types before calling this function. */ static void init_dynamic_gfc_info (void) { + dynamic_format_types[gcc_gfc_format_type].length_char_specs + = get_init_dynamic_hwi (); + if (!locus) { static format_char_info *gfc_fci; @@ -4985,67 +5047,13 @@ init_dynamic_diag_info (void) || local_event_ptr_node == void_type_node) local_event_ptr_node = get_named_type ("diagnostic_event_id_t"); - static tree hwi; - - if (!hwi) - { - static format_length_info *diag_ls; - unsigned int i; - - /* Find the underlying type for HOST_WIDE_INT. For the 'w' - length modifier to work, one must have issued: "typedef - HOST_WIDE_INT __gcc_host_wide_int__;" in one's source code - prior to using that modifier. */ - if ((hwi = maybe_get_identifier ("__gcc_host_wide_int__"))) - { - hwi = identifier_global_value (hwi); - if (hwi) - { - if (TREE_CODE (hwi) != TYPE_DECL) - { - error ("%<__gcc_host_wide_int__%> is not defined as a type"); - hwi = 0; - } - else - { - hwi = DECL_ORIGINAL_TYPE (hwi); - gcc_assert (hwi); - if (hwi != long_integer_type_node - && hwi != long_long_integer_type_node) - { - error ("%<__gcc_host_wide_int__%> is not defined" - " as % or %"); - hwi = 0; - } - } - } - } - - /* Assign the new data for use. */ - - /* All the GCC diag formats use the same length specs. */ - if (!diag_ls) - dynamic_format_types[gcc_diag_format_type].length_char_specs = - dynamic_format_types[gcc_tdiag_format_type].length_char_specs = - dynamic_format_types[gcc_cdiag_format_type].length_char_specs = - dynamic_format_types[gcc_cxxdiag_format_type].length_char_specs = - dynamic_format_types[gcc_dump_printf_format_type].length_char_specs = - diag_ls = (format_length_info *) - xmemdup (gcc_diag_length_specs, - sizeof (gcc_diag_length_specs), - sizeof (gcc_diag_length_specs)); - if (hwi) - { - /* HOST_WIDE_INT must be one of 'long' or 'long long'. */ - i = find_length_info_modifier_index (diag_ls, 'w'); - if (hwi == long_integer_type_node) - diag_ls[i].index = FMT_LEN_l; - else if (hwi == long_long_integer_type_node) - diag_ls[i].index = FMT_LEN_ll; - else - gcc_unreachable (); - } - } + /* All the GCC diag formats use the same length specs. */ + dynamic_format_types[gcc_diag_format_type].length_char_specs = + dynamic_format_types[gcc_tdiag_format_type].length_char_specs = + dynamic_format_types[gcc_cdiag_format_type].length_char_specs = + dynamic_format_types[gcc_cxxdiag_format_type].length_char_specs = + dynamic_format_types[gcc_dump_printf_format_type].length_char_specs + = get_init_dynamic_hwi (); /* It's safe to "re-initialize these to the same values. */ dynamic_format_types[gcc_diag_format_type].conversion_specs = -- cgit v1.1 From 7c9e1645836d7746838acebb7018b1774490ab5c Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 21 Aug 2021 00:16:29 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ab566ba..873d7ab 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,19 @@ +2021-08-20 Tobias Burnus + + * c-format.c (gcc_gfc_length_specs): Add 'll' and 'w'. + (gcc_gfc_char_table): Add T9L_LL and T9L_ULL to + "di" and "u", respecitively; fill with BADLEN to match + size of 'types'. + (get_init_dynamic_hwi): Split off from ... + (init_dynamic_diag_info): ... here. Call it. + (init_dynamic_gfc_info): Call it. + +2021-08-20 Jakub Jelinek + + * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_ERROR. + * c-pragma.c (omp_pragmas): Add error directive. + * c-omp.c (omp_directives): Uncomment error directive entry. + 2021-08-18 Jakub Jelinek * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_NOTHING. -- cgit v1.1 From 3ac6b5cff1eca4e1748c671960ef7b4ca5e47fd2 Mon Sep 17 00:00:00 2001 From: Lewis Hyatt Date: Tue, 24 Aug 2021 19:30:44 -0400 Subject: diagnostics: Support for -finput-charset [PR93067] Adds the logic to handle -finput-charset in layout_get_source_line(), so that source lines are converted from their input encodings prior to being output by diagnostics machinery. Also adds the ability to strip a UTF-8 BOM similarly. gcc/c-family/ChangeLog: PR other/93067 * c-opts.c (c_common_input_charset_cb): New function. (c_common_post_options): Call new function diagnostic_initialize_input_context(). gcc/d/ChangeLog: PR other/93067 * d-lang.cc (d_input_charset_callback): New function. (d_init): Call new function diagnostic_initialize_input_context(). gcc/fortran/ChangeLog: PR other/93067 * cpp.c (gfc_cpp_post_options): Call new function diagnostic_initialize_input_context(). gcc/ChangeLog: PR other/93067 * coretypes.h (typedef diagnostic_input_charset_callback): Declare. * diagnostic.c (diagnostic_initialize_input_context): New function. * diagnostic.h (diagnostic_initialize_input_context): Declare. * input.c (default_charset_callback): New function. (file_cache::initialize_input_context): New function. (file_cache_slot::create): Added ability to convert the input according to the input context. (file_cache::file_cache): Initialize the new input context. (class file_cache_slot): Added new m_alloc_offset member. (file_cache_slot::file_cache_slot): Initialize the new member. (file_cache_slot::~file_cache_slot): Handle potentially offset buffer. (file_cache_slot::maybe_grow): Likewise. (file_cache_slot::needs_read_p): Handle NULL fp, which is now possible. (file_cache_slot::get_next_line): Likewise. * input.h (class file_cache): Added input context member. libcpp/ChangeLog: PR other/93067 * charset.c (init_iconv_desc): Adapt to permit PFILE argument to be NULL. (_cpp_convert_input): Likewise. Also move UTF-8 BOM logic to... (cpp_check_utf8_bom): ...here. New function. (cpp_input_conversion_is_trivial): New function. * files.c (read_file_guts): Allow PFILE argument to be NULL. Add INPUT_CHARSET argument as an alternate source of this information. (read_file): Pass the new argument to read_file_guts. (cpp_get_converted_source): New function. * include/cpplib.h (struct cpp_converted_source): Declare. (cpp_get_converted_source): Declare. (cpp_input_conversion_is_trivial): Declare. (cpp_check_utf8_bom): Declare. gcc/testsuite/ChangeLog: PR other/93067 * gcc.dg/diagnostic-input-charset-1.c: New test. * gcc.dg/diagnostic-input-utf8-bom.c: New test. --- gcc/c-family/c-opts.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 373af0c..fdde082 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -188,6 +188,14 @@ c_common_diagnostics_set_defaults (diagnostic_context *context) context->opt_permissive = OPT_fpermissive; } +/* Input charset configuration for diagnostics. */ +static const char * +c_common_input_charset_cb (const char * /*filename*/) +{ + const char *cs = cpp_opts->input_charset; + return cpp_input_conversion_is_trivial (cs) ? nullptr : cs; +} + /* Whether options from all C-family languages should be accepted quietly. */ static bool accept_all_c_family_options = false; @@ -1136,6 +1144,11 @@ c_common_post_options (const char **pfilename) cpp_post_options (parse_in); init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in)); + /* Let diagnostics infrastructure know how to convert input files the same + way libcpp will do it, namely using the configured input charset and + skipping a UTF-8 BOM if present. */ + diagnostic_initialize_input_context (global_dc, + c_common_input_charset_cb, true); input_location = UNKNOWN_LOCATION; *pfilename = this_input_filename -- cgit v1.1 From 85d77ac4745c6263520c8fe66c0dfced8404003f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 26 Aug 2021 00:17:03 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 873d7ab..5e3ac92 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2021-08-25 Lewis Hyatt + + PR other/93067 + * c-opts.c (c_common_input_charset_cb): New function. + (c_common_post_options): Call new function + diagnostic_initialize_input_context(). + 2021-08-20 Tobias Burnus * c-format.c (gcc_gfc_length_specs): Add 'll' and 'w'. -- cgit v1.1 From e18e56c76be35e6a799e07a01c24e0fff3eb1978 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 27 Aug 2021 17:28:28 -0400 Subject: c++: Add warning about missing 'requires' I noticed that concepts-lambda14.C had two useless requires-expressions: static_assert(requires { C; }); always succeeds, because C is always a valid expression for any type, regardless of whether C is satisfied for a particular type. Presumably the user means static_assert(requires { requires C; }); to make the C a nested-requirement. Of course, static_assert(C); is much simpler and means the same thing; this is more relevant in the middle of a longer requires-expression, such as the bug this warning found in cmcstl2: template META_CONCEPT input_iterator = input_or_output_iterator && readable && requires(I& i, const I& ci) { typename iterator_category_t; derived_from, input_iterator_tag>; i++; }; where 'requires' is missing before 'derived_from'. gcc/ChangeLog: * doc/invoke.texi: Document -Wmissing-requires. gcc/c-family/ChangeLog: * c.opt: Add -Wmissing-requires. gcc/cp/ChangeLog: * parser.c (cp_parser_simple_requirement): Warn about missing requires. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-lambda14.C: Add expected warnings. --- gcc/c-family/c.opt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 9192970..c5fe900 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -839,6 +839,10 @@ Wmissing-field-initializers C ObjC C++ ObjC++ Var(warn_missing_field_initializers) Warning EnabledBy(Wextra) Warn about missing fields in struct initializers. +Wmissing-requires +C++ ObjC++ Var(warn_missing_requires) Init(1) Warning +Warn about likely missing requires keyword. + Wmultistatement-macros C ObjC C++ ObjC++ Var(warn_multistatement_macros) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) Warn about unsafe macros expanding to multiple statements used as a body of a clause such as if, else, while, switch, or for. -- cgit v1.1 From 1e2f030b80cb650708b02086dbd5431cd231495f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 31 Aug 2021 00:16:50 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5e3ac92..d3a48ff 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-08-30 Jason Merrill + + * c.opt: Add -Wmissing-requires. + 2021-08-25 Lewis Hyatt PR other/93067 -- cgit v1.1 From 8433baadec88e5f31fa141b6d78094e91256079d Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sun, 8 Nov 2020 09:04:07 +0000 Subject: C-family: Add attribute 'unavailable'. If an interface is marked 'deprecated' then, presumably, at some point it will be withdrawn and no longer available. The 'unavailable' attribute makes it possible to mark up interfaces to indicate this status. It is used quite extensively in some codebases where a single set of headers can be used to permit code generation for multiple system versions. From a configuration perspective, it also allows a compile test to determine that an interface is missing - rather than requiring a link test. The implementation follows the pattern of attribute deprecated, but produces an error (where deprecation produces a warning). This attribute has been implemented in clang for some years. Signed-off-by: Iain Sandoe gcc/c-family/ChangeLog: * c-attribs.c (handle_unavailable_attribute): New. gcc/c/ChangeLog: * c-decl.c (enum deprecated_states): Add unavailable state. (merge_decls): Copy unavailability. (quals_from_declspecs): Handle unavailable case. (start_decl): Amend the logic handling suppression of nested deprecation states to include unavailability. (smallest_type_quals_location): Amend comment. (grokdeclarator): Handle the unavailable deprecation state. (declspecs_add_type): Set TREE_UNAVAILABLE from the decl specs. * c-tree.h (struct c_declspecs): Add unavailable_p. * c-typeck.c (build_component_ref): Handle unavailability. (build_external_ref): Likewise. gcc/cp/ChangeLog: * call.c (build_over_call): Handle unavailable state in addition to deprecation. * class.c (type_build_ctor_call): Likewise. (type_build_dtor_call): Likewise. * cp-tree.h: Rename cp_warn_deprecated_use to cp_handle_deprecated_or_unavailable. * decl.c (duplicate_decls): Merge unavailability. (grokdeclarator): Handle unavailability in addition to deprecation. (type_is_unavailable): New. (grokparms): Handle unavailability in addition to deprecation. * decl.h (enum deprecated_states): Add UNAVAILABLE_DEPRECATED_SUPPRESS. * decl2.c (cplus_decl_attributes): Propagate unavailability to templates. (cp_warn_deprecated_use): Rename to ... (cp_handle_deprecated_or_unavailable): ... this and amend to handle the unavailable case. It remains a warning in the case of deprecation but becomes an error in the case of unavailability. (cp_warn_deprecated_use_scopes): Handle unavailability. (mark_used): Likewise. * parser.c (cp_parser_template_name): Likewise. (cp_parser_template_argument): Likewise. (cp_parser_parameter_declaration_list): Likewise. * typeck.c (build_class_member_access_expr): Likewise. (finish_class_member_access_expr): Likewise. * typeck2.c (build_functional_cast_1): Likewise. gcc/ChangeLog: * doc/extend.texi: Document unavailable attribute. * print-tree.c (print_node): Handle unavailable attribute. * tree-core.h (struct tree_base): Add a bit to carry unavailability. * tree.c (error_unavailable_use): New. * tree.h (TREE_UNAVAILABLE): New. (error_unavailable_use): New. gcc/objc/ChangeLog: * objc-act.c (objc_add_property_declaration): Register unavailable attribute. (maybe_make_artificial_property_decl): Set available. (objc_maybe_build_component_ref): Generalise to the method prototype to count availability. (objc_build_class_component_ref): Likewise. (build_private_template): Likewise. (objc_decl_method_attributes): Handle unavailable attribute. (lookup_method_in_hash_lists): Amend comments. (objc_finish_message_expr): Handle unavailability in addition to deprecation. (start_class): Likewise. (finish_class): Likewise. (lookup_protocol): Likewise. (objc_declare_protocol): Likewise. (start_protocol): Register unavailable attribute. (really_start_method): Likewise. (objc_gimplify_property_ref): Emit error on encountering an unavailable entity (and a warning for a deprecated one). gcc/testsuite/ChangeLog: * g++.dg/ext/attr-unavailable-1.C: New test. * g++.dg/ext/attr-unavailable-2.C: New test. * g++.dg/ext/attr-unavailable-3.C: New test. * g++.dg/ext/attr-unavailable-4.C: New test. * g++.dg/ext/attr-unavailable-5.C: New test. * g++.dg/ext/attr-unavailable-6.C: New test. * g++.dg/ext/attr-unavailable-7.C: New test. * g++.dg/ext/attr-unavailable-8.C: New test. * g++.dg/ext/attr-unavailable-9.C: New test. * gcc.dg/attr-unavailable-1.c: New test. * gcc.dg/attr-unavailable-2.c: New test. * gcc.dg/attr-unavailable-3.c: New test. * gcc.dg/attr-unavailable-4.c: New test. * gcc.dg/attr-unavailable-5.c: New test. * gcc.dg/attr-unavailable-6.c: New test. * obj-c++.dg/attributes/method-unavailable-1.mm: New test. * obj-c++.dg/attributes/method-unavailable-2.mm: New test. * obj-c++.dg/attributes/method-unavailable-3.mm: New test. * obj-c++.dg/property/at-property-unavailable-1.mm: New test. * obj-c++.dg/property/at-property-unavailable-2.mm: New test. * obj-c++.dg/property/dotsyntax-unavailable-1.mm: New test. * objc.dg/attributes/method-unavailable-1.m: New test. * objc.dg/attributes/method-unavailable-2.m: New test. * objc.dg/attributes/method-unavailable-3.m: New test. * objc.dg/property/at-property-unavailable-1.m: New test. * objc.dg/property/at-property-unavailable-2.m: New test. * objc.dg/property/dotsyntax-unavailable-1.m: New test. --- gcc/c-family/c-attribs.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index e60fb31..d14e9c4 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -123,6 +123,8 @@ static tree handle_pure_attribute (tree *, tree, tree, int, bool *); static tree handle_tm_attribute (tree *, tree, tree, int, bool *); static tree handle_tm_wrap_attribute (tree *, tree, tree, int, bool *); static tree handle_novops_attribute (tree *, tree, tree, int, bool *); +static tree handle_unavailable_attribute (tree *, tree, tree, int, + bool *); static tree handle_vector_size_attribute (tree *, tree, tree, int, bool *) ATTRIBUTE_NONNULL(3); static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); @@ -406,6 +408,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_novops_attribute, NULL }, { "deprecated", 0, 1, false, false, false, false, handle_deprecated_attribute, NULL }, + { "unavailable", 0, 1, false, false, false, false, + handle_unavailable_attribute, NULL }, { "vector_size", 1, 1, false, true, false, true, handle_vector_size_attribute, NULL }, { "visibility", 1, 1, false, false, false, false, @@ -4122,6 +4126,71 @@ handle_deprecated_attribute (tree *node, tree name, return NULL_TREE; } +/* Handle a "unavailable" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_unavailable_attribute (tree *node, tree name, + tree args, int flags, + bool *no_add_attrs) +{ + tree type = NULL_TREE; + int warn = 0; + tree what = NULL_TREE; + + if (!args) + *no_add_attrs = true; + else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST) + { + error ("the message attached to % is not a string"); + *no_add_attrs = true; + } + + if (DECL_P (*node)) + { + tree decl = *node; + type = TREE_TYPE (decl); + + if (TREE_CODE (decl) == TYPE_DECL + || TREE_CODE (decl) == PARM_DECL + || VAR_OR_FUNCTION_DECL_P (decl) + || TREE_CODE (decl) == FIELD_DECL + || TREE_CODE (decl) == CONST_DECL + || objc_method_decl (TREE_CODE (decl))) + TREE_UNAVAILABLE (decl) = 1; + else + warn = 1; + } + else if (TYPE_P (*node)) + { + if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE)) + *node = build_variant_type_copy (*node); + TREE_UNAVAILABLE (*node) = 1; + type = *node; + } + else + warn = 1; + + if (warn) + { + *no_add_attrs = true; + if (type && TYPE_NAME (type)) + { + if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) + what = TYPE_NAME (*node); + else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (type))) + what = DECL_NAME (TYPE_NAME (type)); + } + if (what) + warning (OPT_Wattributes, "%qE attribute ignored for %qE", name, what); + else + warning (OPT_Wattributes, "%qE attribute ignored", name); + } + + return NULL_TREE; +} + /* Return the "base" type from TYPE that is suitable to apply attribute vector_size to by stripping arrays, function types, etc. */ static tree -- cgit v1.1 From e11c6046f9c8bc891a67f37f0260ef4ece482f5d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 2 Sep 2021 00:16:59 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d3a48ff..a5bf82c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-09-01 Iain Sandoe + + * c-attribs.c (handle_unavailable_attribute): New. + 2021-08-30 Jason Merrill * c.opt: Add -Wmissing-requires. -- cgit v1.1 From 8d34ffb4e8ed5300d0276b55f573add6db2517e8 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 3 Sep 2021 11:18:01 +0200 Subject: Improve compatibility of -fdump-ada-spec with warnings This makes sure that the style and warning settings used in the C/C++ bindings generated by -fdump-ada-spec do not leak into the units that use them. gcc/c-family/ * c-ada-spec.c (dump_ads): Generate pragmas to disable style checks and -gnatwu warning for the package specification. --- gcc/c-family/c-ada-spec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 827bcc7..b197d55 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -3440,11 +3440,12 @@ dump_ads (const char *source_file, dump_ada_nodes (&pp, source_file); /* We require Ada 2012 syntax, so generate corresponding pragma. */ - fputs ("pragma Ada_2012;\n", f); + fputs ("pragma Ada_2012;\n\n", f); /* Disable style checks and warnings on unused entities since this file is auto-generated and always has a with clause for Interfaces.C. */ - fputs ("pragma Style_Checks (Off);\npragma Warnings (\"U\");\n\n", f); + fputs ("pragma Style_Checks (Off);\n", f); + fputs ("pragma Warnings (Off, \"-gnatwu\");\n\n", f); /* Dump withs. */ dump_ada_withs (f); @@ -3452,7 +3453,10 @@ dump_ads (const char *source_file, fprintf (f, "\npackage %s is\n\n", pkg_name); pp_write_text_to_stream (&pp); /* ??? need to free pp */ - fprintf (f, "end %s;\n", pkg_name); + fprintf (f, "end %s;\n\n", pkg_name); + + fputs ("pragma Style_Checks (On);\n", f); + fputs ("pragma Warnings (On, \"-gnatwu\");\n", f); fclose (f); } -- cgit v1.1 From 7b7395409c7aaef493337479c7fd586e52aea3d1 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 4 Sep 2021 00:16:38 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a5bf82c..abc4c76 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-09-03 Eric Botcazou + + * c-ada-spec.c (dump_ads): Generate pragmas to disable style checks + and -gnatwu warning for the package specification. + 2021-09-01 Iain Sandoe * c-attribs.c (handle_unavailable_attribute): New. -- cgit v1.1 From ba1cc6956b956eb5b92c45af79a8b1fe426ec4d3 Mon Sep 17 00:00:00 2001 From: Marcel Vollweiler Date: Tue, 7 Sep 2021 03:46:28 -0700 Subject: C, C++, Fortran, OpenMP: Add support for 'flush seq_cst' construct. This patch adds support for the 'seq_cst' memory order clause on the 'flush' directive which was introduced in OpenMP 5.1. gcc/c-family/ChangeLog: * c-omp.c (c_finish_omp_flush): Handle MEMMODEL_SEQ_CST. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_flush): Parse 'seq_cst' clause on 'flush' directive. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_flush): Parse 'seq_cst' clause on 'flush' directive. * semantics.c (finish_omp_flush): Handle MEMMODEL_SEQ_CST. gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_flush): Parse 'seq_cst' clause on 'flush' directive. * trans-openmp.c (gfc_trans_omp_flush): Handle OMP_MEMORDER_SEQ_CST. gcc/testsuite/ChangeLog: * c-c++-common/gomp/flush-1.c: Add test case for 'seq_cst'. * c-c++-common/gomp/flush-2.c: Add test case for 'seq_cst'. * g++.dg/gomp/attrs-1.C: Adapt test to handle all flush clauses. * g++.dg/gomp/attrs-2.C: Adapt test to handle all flush clauses. * gfortran.dg/gomp/flush-1.f90: Add test case for 'seq_cst'. * gfortran.dg/gomp/flush-2.f90: Add test case for 'seq_cst'. --- gcc/c-family/c-omp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 18de7e4..4b95fc1 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -606,7 +606,7 @@ c_finish_omp_flush (location_t loc, int mo) { tree x; - if (mo == MEMMODEL_LAST) + if (mo == MEMMODEL_LAST || mo == MEMMODEL_SEQ_CST) { x = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); x = build_call_expr_loc (loc, x, 0); -- cgit v1.1 From b2748138c05c6fba1a34f54980b6382bc6332f56 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 8 Sep 2021 00:16:23 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index abc4c76..3d40b9a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2021-09-07 Marcel Vollweiler + + * c-omp.c (c_finish_omp_flush): Handle MEMMODEL_SEQ_CST. + 2021-09-03 Eric Botcazou * c-ada-spec.c (dump_ads): Generate pragmas to disable style checks -- cgit v1.1 From f19a327077ecc34a51487761378b9edb43c82997 Mon Sep 17 00:00:00 2001 From: liuhongt Date: Mon, 2 Aug 2021 10:56:45 +0800 Subject: Support -fexcess-precision=16 which will enable FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 when backend supports _Float16. gcc/ada/ChangeLog: * gcc-interface/misc.c (gnat_post_options): Issue an error for -fexcess-precision=16. gcc/c-family/ChangeLog: * c-common.c (excess_precision_mode_join): Update below comments. (c_ts18661_flt_eval_method): Set excess_precision_type to EXCESS_PRECISION_TYPE_FLOAT16 when -fexcess-precision=16. * c-cppbuiltin.c (cpp_atomic_builtins): Update below comments. (c_cpp_flt_eval_method_iec_559): Set excess_precision_type to EXCESS_PRECISION_TYPE_FLOAT16 when -fexcess-precision=16. gcc/ChangeLog: * common.opt: Support -fexcess-precision=16. * config/aarch64/aarch64.c (aarch64_excess_precision): Return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 when EXCESS_PRECISION_TYPE_FLOAT16. * config/arm/arm.c (arm_excess_precision): Ditto. * config/i386/i386.c (ix86_get_excess_precision): Ditto. * config/m68k/m68k.c (m68k_excess_precision): Issue an error when EXCESS_PRECISION_TYPE_FLOAT16. * config/s390/s390.c (s390_excess_precision): Ditto. * coretypes.h (enum excess_precision_type): Add EXCESS_PRECISION_TYPE_FLOAT16. * doc/tm.texi (TARGET_C_EXCESS_PRECISION): Update documents. * doc/tm.texi.in (TARGET_C_EXCESS_PRECISION): Ditto. * doc/extend.texi (Half-Precision): Document -fexcess-precision=16. * flag-types.h (enum excess_precision): Add EXCESS_PRECISION_FLOAT16. * target.def (excess_precision): Update document. * tree.c (excess_precision_type): Set excess_precision_type to EXCESS_PRECISION_FLOAT16 when -fexcess-precision=16. gcc/fortran/ChangeLog: * options.c (gfc_post_options): Issue an error for -fexcess-precision=16. gcc/testsuite/ChangeLog: * gcc.target/i386/float16-6.c: New test. * gcc.target/i386/float16-7.c: New test. --- gcc/c-family/c-common.c | 6 ++++-- gcc/c-family/c-cppbuiltin.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 017e415..c6757f0 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8778,7 +8778,7 @@ excess_precision_mode_join (enum flt_eval_method x, This relates to the effective excess precision seen by the user, which is the join point of the precision the target requests for - -fexcess-precision={standard,fast} and the implicit excess precision + -fexcess-precision={standard,fast,16} and the implicit excess precision the target uses. */ static enum flt_eval_method @@ -8790,7 +8790,9 @@ c_ts18661_flt_eval_method (void) enum excess_precision_type flag_type = (flag_excess_precision == EXCESS_PRECISION_STANDARD ? EXCESS_PRECISION_TYPE_STANDARD - : EXCESS_PRECISION_TYPE_FAST); + : (flag_excess_precision == EXCESS_PRECISION_FLOAT16 + ? EXCESS_PRECISION_TYPE_FLOAT16 + : EXCESS_PRECISION_TYPE_FAST)); enum flt_eval_method requested = targetm.c.excess_precision (flag_type); diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 3fa62bc..48cbefd 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -753,7 +753,7 @@ cpp_atomic_builtins (cpp_reader *pfile) /* Return TRUE if the implicit excess precision in which the back-end will compute floating-point calculations is not more than the explicit excess precision that the front-end will apply under - -fexcess-precision=[standard|fast]. + -fexcess-precision=[standard|fast|16]. More intuitively, return TRUE if the excess precision proposed by the front-end is the excess precision that will actually be used. */ @@ -764,7 +764,9 @@ c_cpp_flt_eval_method_iec_559 (void) enum excess_precision_type front_end_ept = (flag_excess_precision == EXCESS_PRECISION_STANDARD ? EXCESS_PRECISION_TYPE_STANDARD - : EXCESS_PRECISION_TYPE_FAST); + : (flag_excess_precision == EXCESS_PRECISION_FLOAT16 + ? EXCESS_PRECISION_TYPE_FLOAT16 + : EXCESS_PRECISION_TYPE_FAST)); enum flt_eval_method back_end = targetm.c.excess_precision (EXCESS_PRECISION_TYPE_IMPLICIT); -- cgit v1.1 From b6db7cd41ccf821ffb10ff4f18845465e98803cd Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 9 Sep 2021 00:16:32 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3d40b9a..d5618a5 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2021-09-08 liuhongt + + * c-common.c (excess_precision_mode_join): Update below comments. + (c_ts18661_flt_eval_method): Set excess_precision_type to + EXCESS_PRECISION_TYPE_FLOAT16 when -fexcess-precision=16. + * c-cppbuiltin.c (cpp_atomic_builtins): Update below comments. + (c_cpp_flt_eval_method_iec_559): Set excess_precision_type to + EXCESS_PRECISION_TYPE_FLOAT16 when -fexcess-precision=16. + 2021-09-07 Marcel Vollweiler * c-omp.c (c_finish_omp_flush): Handle MEMMODEL_SEQ_CST. -- cgit v1.1 From a25e0b5e6ac8a77a71c229e0a7b744603365b0e9 Mon Sep 17 00:00:00 2001 From: qing zhao Date: Thu, 9 Sep 2021 15:44:49 -0700 Subject: Add -ftrivial-auto-var-init option and uninitialized variable attribute. Initialize automatic variables with either a pattern or with zeroes to increase the security and predictability of a program by preventing uninitialized memory disclosure and use. GCC still considers an automatic variable that doesn't have an explicit initializer as uninitialized, -Wuninitialized will still report warning messages on such automatic variables. With this option, GCC will also initialize any padding of automatic variables that have structure or union types to zeroes. You can control this behavior for a specific variable by using the variable attribute "uninitialized" to control runtime overhead. gcc/ChangeLog: 2021-09-09 qing zhao * builtins.c (expand_builtin_memset): Make external visible. * builtins.h (expand_builtin_memset): Declare extern. * common.opt (ftrivial-auto-var-init=): New option. * doc/extend.texi: Document the uninitialized attribute. * doc/invoke.texi: Document -ftrivial-auto-var-init. * flag-types.h (enum auto_init_type): New enumerated type auto_init_type. * gimple-fold.c (clear_padding_type): Add one new parameter. (clear_padding_union): Likewise. (clear_padding_emit_loop): Likewise. (clear_type_padding_in_mask): Likewise. (gimple_fold_builtin_clear_padding): Handle this new parameter. * gimplify.c (gimple_add_init_for_auto_var): New function. (gimple_add_padding_init_for_auto_var): New function. (is_var_need_auto_init): New function. (gimplify_decl_expr): Add initialization to automatic variables per users' requests. (gimplify_call_expr): Add one new parameter for call to __builtin_clear_padding. (gimplify_init_constructor): Add padding initialization in the end. * internal-fn.c (INIT_PATTERN_VALUE): New macro. (expand_DEFERRED_INIT): New function. * internal-fn.def (DEFERRED_INIT): New internal function. * tree-cfg.c (verify_gimple_call): Verify calls to .DEFERRED_INIT. * tree-sra.c (generate_subtree_deferred_init): New function. (scan_function): Avoid setting cannot_scalarize_away_bitmap for calls to .DEFERRED_INIT. (sra_modify_deferred_init): New function. (sra_modify_function_body): Handle calls to DEFERRED_INIT specially. * tree-ssa-structalias.c (find_func_aliases_for_call): Likewise. * tree-ssa-uninit.c (warn_uninit): Handle calls to DEFERRED_INIT specially. (check_defs): Likewise. (warn_uninitialized_vars): Likewise. * tree-ssa.c (ssa_undefined_value_p): Likewise. * tree.c (build_common_builtin_nodes): Build tree node for BUILT_IN_CLEAR_PADDING when needed. gcc/c-family/ChangeLog: 2021-09-09 qing zhao * c-attribs.c (handle_uninitialized_attribute): New function. (c_common_attribute_table): Add "uninitialized" attribute. gcc/testsuite/ChangeLog: 2021-09-09 qing zhao * c-c++-common/auto-init-1.c: New test. * c-c++-common/auto-init-10.c: New test. * c-c++-common/auto-init-11.c: New test. * c-c++-common/auto-init-12.c: New test. * c-c++-common/auto-init-13.c: New test. * c-c++-common/auto-init-14.c: New test. * c-c++-common/auto-init-15.c: New test. * c-c++-common/auto-init-16.c: New test. * c-c++-common/auto-init-2.c: New test. * c-c++-common/auto-init-3.c: New test. * c-c++-common/auto-init-4.c: New test. * c-c++-common/auto-init-5.c: New test. * c-c++-common/auto-init-6.c: New test. * c-c++-common/auto-init-7.c: New test. * c-c++-common/auto-init-8.c: New test. * c-c++-common/auto-init-9.c: New test. * c-c++-common/auto-init-esra.c: New test. * c-c++-common/auto-init-padding-1.c: New test. * c-c++-common/auto-init-padding-2.c: New test. * c-c++-common/auto-init-padding-3.c: New test. * g++.dg/auto-init-uninit-pred-1_a.C: New test. * g++.dg/auto-init-uninit-pred-2_a.C: New test. * g++.dg/auto-init-uninit-pred-3_a.C: New test. * g++.dg/auto-init-uninit-pred-4.C: New test. * gcc.dg/auto-init-sra-1.c: New test. * gcc.dg/auto-init-sra-2.c: New test. * gcc.dg/auto-init-uninit-1.c: New test. * gcc.dg/auto-init-uninit-12.c: New test. * gcc.dg/auto-init-uninit-13.c: New test. * gcc.dg/auto-init-uninit-14.c: New test. * gcc.dg/auto-init-uninit-15.c: New test. * gcc.dg/auto-init-uninit-16.c: New test. * gcc.dg/auto-init-uninit-17.c: New test. * gcc.dg/auto-init-uninit-18.c: New test. * gcc.dg/auto-init-uninit-19.c: New test. * gcc.dg/auto-init-uninit-2.c: New test. * gcc.dg/auto-init-uninit-20.c: New test. * gcc.dg/auto-init-uninit-21.c: New test. * gcc.dg/auto-init-uninit-22.c: New test. * gcc.dg/auto-init-uninit-23.c: New test. * gcc.dg/auto-init-uninit-24.c: New test. * gcc.dg/auto-init-uninit-25.c: New test. * gcc.dg/auto-init-uninit-26.c: New test. * gcc.dg/auto-init-uninit-3.c: New test. * gcc.dg/auto-init-uninit-34.c: New test. * gcc.dg/auto-init-uninit-36.c: New test. * gcc.dg/auto-init-uninit-37.c: New test. * gcc.dg/auto-init-uninit-4.c: New test. * gcc.dg/auto-init-uninit-5.c: New test. * gcc.dg/auto-init-uninit-6.c: New test. * gcc.dg/auto-init-uninit-8.c: New test. * gcc.dg/auto-init-uninit-9.c: New test. * gcc.dg/auto-init-uninit-A.c: New test. * gcc.dg/auto-init-uninit-B.c: New test. * gcc.dg/auto-init-uninit-C.c: New test. * gcc.dg/auto-init-uninit-H.c: New test. * gcc.dg/auto-init-uninit-I.c: New test. * gcc.target/aarch64/auto-init-1.c: New test. * gcc.target/aarch64/auto-init-2.c: New test. * gcc.target/aarch64/auto-init-3.c: New test. * gcc.target/aarch64/auto-init-4.c: New test. * gcc.target/aarch64/auto-init-5.c: New test. * gcc.target/aarch64/auto-init-6.c: New test. * gcc.target/aarch64/auto-init-7.c: New test. * gcc.target/aarch64/auto-init-8.c: New test. * gcc.target/aarch64/auto-init-padding-1.c: New test. * gcc.target/aarch64/auto-init-padding-10.c: New test. * gcc.target/aarch64/auto-init-padding-11.c: New test. * gcc.target/aarch64/auto-init-padding-12.c: New test. * gcc.target/aarch64/auto-init-padding-2.c: New test. * gcc.target/aarch64/auto-init-padding-3.c: New test. * gcc.target/aarch64/auto-init-padding-4.c: New test. * gcc.target/aarch64/auto-init-padding-5.c: New test. * gcc.target/aarch64/auto-init-padding-6.c: New test. * gcc.target/aarch64/auto-init-padding-7.c: New test. * gcc.target/aarch64/auto-init-padding-8.c: New test. * gcc.target/aarch64/auto-init-padding-9.c: New test. * gcc.target/i386/auto-init-1.c: New test. * gcc.target/i386/auto-init-2.c: New test. * gcc.target/i386/auto-init-21.c: New test. * gcc.target/i386/auto-init-22.c: New test. * gcc.target/i386/auto-init-23.c: New test. * gcc.target/i386/auto-init-24.c: New test. * gcc.target/i386/auto-init-3.c: New test. * gcc.target/i386/auto-init-4.c: New test. * gcc.target/i386/auto-init-5.c: New test. * gcc.target/i386/auto-init-6.c: New test. * gcc.target/i386/auto-init-7.c: New test. * gcc.target/i386/auto-init-8.c: New test. * gcc.target/i386/auto-init-padding-1.c: New test. * gcc.target/i386/auto-init-padding-10.c: New test. * gcc.target/i386/auto-init-padding-11.c: New test. * gcc.target/i386/auto-init-padding-12.c: New test. * gcc.target/i386/auto-init-padding-2.c: New test. * gcc.target/i386/auto-init-padding-3.c: New test. * gcc.target/i386/auto-init-padding-4.c: New test. * gcc.target/i386/auto-init-padding-5.c: New test. * gcc.target/i386/auto-init-padding-6.c: New test. * gcc.target/i386/auto-init-padding-7.c: New test. * gcc.target/i386/auto-init-padding-8.c: New test. * gcc.target/i386/auto-init-padding-9.c: New test. --- gcc/c-family/c-attribs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index d14e9c4..007b928 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -83,6 +83,7 @@ static tree handle_artificial_attribute (tree *, tree, tree, int, bool *); static tree handle_flatten_attribute (tree *, tree, tree, int, bool *); static tree handle_error_attribute (tree *, tree, tree, int, bool *); static tree handle_used_attribute (tree *, tree, tree, int, bool *); +static tree handle_uninitialized_attribute (tree *, tree, tree, int, bool *); static tree handle_externally_visible_attribute (tree *, tree, tree, int, bool *); static tree handle_no_reorder_attribute (tree *, tree, tree, int, @@ -333,6 +334,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_used_attribute, NULL }, { "unused", 0, 0, false, false, false, false, handle_unused_attribute, NULL }, + { "uninitialized", 0, 0, true, false, false, false, + handle_uninitialized_attribute, NULL }, { "retain", 0, 0, true, false, false, false, handle_retain_attribute, NULL }, { "externally_visible", 0, 0, true, false, false, false, @@ -1617,6 +1620,30 @@ handle_retain_attribute (tree *pnode, tree name, tree ARG_UNUSED (args), return NULL_TREE; } +/* Handle an "uninitialized" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_uninitialized_attribute (tree *node, tree name, tree ARG_UNUSED (args), + int ARG_UNUSED (flags), bool *no_add_attrs) +{ + tree decl = *node; + if (!VAR_P (decl)) + { + warning (OPT_Wattributes, "%qE attribute ignored because %qD " + "is not a variable", name, decl); + *no_add_attrs = true; + } + else if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)) + { + warning (OPT_Wattributes, "%qE attribute ignored because %qD " + "is not a local variable", name, decl); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Handle a "externally_visible" attribute; arguments as in struct attribute_spec.handler. */ -- cgit v1.1 From f84e2f0b7b022123232eb30d579984a8c1880782 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 10 Sep 2021 00:16:31 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d5618a5..c39dfe3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-09-09 qing zhao + + * c-attribs.c (handle_uninitialized_attribute): New function. + (c_common_attribute_table): Add "uninitialized" attribute. + 2021-09-08 liuhongt * c-common.c (excess_precision_mode_join): Update below comments. -- cgit v1.1 From 8122fbff770bcff183a9c3c72e8092c0ca32150b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 10 Sep 2021 20:41:33 +0200 Subject: openmp: Implement OpenMP 5.1 atomics, so far for C only This patch implements OpenMP 5.1 atomics (with clarifications from upcoming 5.2). The most important changes are that it is now possible to write (for C/C++, for Fortran it was possible before already) min/max atomics and more importantly compare and exchange in various forms. Also, acq_rel is now allowed on read/write and acq_rel/acquire are allowed on update, and there are new compare, weak and fail clauses. 2021-09-10 Jakub Jelinek gcc/ * tree-core.h (enum omp_memory_order): Add OMP_MEMORY_ORDER_MASK, OMP_FAIL_MEMORY_ORDER_UNSPECIFIED, OMP_FAIL_MEMORY_ORDER_RELAXED, OMP_FAIL_MEMORY_ORDER_ACQUIRE, OMP_FAIL_MEMORY_ORDER_RELEASE, OMP_FAIL_MEMORY_ORDER_ACQ_REL, OMP_FAIL_MEMORY_ORDER_SEQ_CST and OMP_FAIL_MEMORY_ORDER_MASK enumerators. (OMP_FAIL_MEMORY_ORDER_SHIFT): Define. * gimple-pretty-print.c (dump_gimple_omp_atomic_load, dump_gimple_omp_atomic_store): Print [weak] for weak atomic load/store. * gimple.h (enum gf_mask): Change GF_OMP_ATOMIC_MEMORY_ORDER to 6-bit mask, adjust GF_OMP_ATOMIC_NEED_VALUE value and add GF_OMP_ATOMIC_WEAK. (gimple_omp_atomic_weak_p, gimple_omp_atomic_set_weak): New inline functions. * tree.h (OMP_ATOMIC_WEAK): Define. * tree-pretty-print.c (dump_omp_atomic_memory_order): Adjust for fail memory order being encoded in the same enum and also print fail clause if present. (dump_generic_node): Print weak clause if OMP_ATOMIC_WEAK. * gimplify.c (goa_stabilize_expr): Add target_expr and rhs arguments, handle pre_p == NULL case as a test mode that only returns value but doesn't change gimplify nor change anything otherwise, adjust recursive calls, add MODIFY_EXPR, ADDR_EXPR, COND_EXPR, TARGET_EXPR and CALL_EXPR handling, adjust COMPOUND_EXPR handling for __builtin_clear_padding calls, for !rhs gimplify as lvalue rather than rvalue. (gimplify_omp_atomic): Adjust goa_stabilize_expr caller. Handle COND_EXPR rhs. Set weak flag on gimple load/store for OMP_ATOMIC_WEAK. * omp-expand.c (omp_memory_order_to_fail_memmodel): New function. (omp_memory_order_to_memmodel): Adjust for fail clause encoded in the same enum. (expand_omp_atomic_cas): New function. (expand_omp_atomic_pipeline): Use omp_memory_order_to_fail_memmodel function. (expand_omp_atomic): Attempt to optimize atomic compare and exchange using expand_omp_atomic_cas. gcc/c-family/ * c-common.h (c_finish_omp_atomic): Add r and weak arguments. * c-omp.c: Include gimple-fold.h. (c_finish_omp_atomic): Add r and weak arguments. Add support for OpenMP 5.1 atomics. gcc/c/ * c-parser.c (c_parser_conditional_expression): If omp_atomic_lhs and cond.value is >, < or == with omp_atomic_lhs as one of the operands, don't call build_conditional_expr, instead build a COND_EXPR directly. (c_parser_binary_expression): Avoid calling parser_build_binary_op if omp_atomic_lhs even in more cases for >, < or ==. (c_parser_omp_atomic): Update function comment for OpenMP 5.1 atomics, parse OpenMP 5.1 atomics and fail, compare and weak clauses, allow acq_rel on atomic read/write and acq_rel/acquire clauses on update. * c-typeck.c (build_binary_op): For flag_openmp only handle MIN_EXPR/MAX_EXPR. gcc/cp/ * parser.c (cp_parser_omp_atomic): Allow acq_rel on atomic read/write and acq_rel/acquire clauses on update. * semantics.c (finish_omp_atomic): Adjust c_finish_omp_atomic caller. gcc/testsuite/ * c-c++-common/gomp/atomic-17.c (foo): Add tests for atomic read, write or update with acq_rel clause and atomic update with acquire clause. * c-c++-common/gomp/atomic-18.c (foo): Adjust expected diagnostics wording, remove tests moved to atomic-17.c. * c-c++-common/gomp/atomic-21.c: Expect only 2 omp atomic release and 2 omp atomic acq_rel directives instead of 4 omp atomic release. * c-c++-common/gomp/atomic-25.c: New test. * c-c++-common/gomp/atomic-26.c: New test. * c-c++-common/gomp/atomic-27.c: New test. * c-c++-common/gomp/atomic-28.c: New test. * c-c++-common/gomp/atomic-29.c: New test. * c-c++-common/gomp/atomic-30.c: New test. * c-c++-common/goacc-gomp/atomic.c: Expect 1 omp atomic release and 1 omp atomic_acq_rel instead of 2 omp atomic release directives. * gcc.dg/gomp/atomic-5.c: Adjust expected error diagnostic wording. * g++.dg/gomp/atomic-18.C:Expect 4 omp atomic release and 1 omp atomic_acq_rel instead of 5 omp atomic release directives. libgomp/ * testsuite/libgomp.c-c++-common/atomic-19.c: New test. * testsuite/libgomp.c-c++-common/atomic-20.c: New test. * testsuite/libgomp.c-c++-common/atomic-21.c: New test. --- gcc/c-family/c-common.h | 4 +- gcc/c-family/c-omp.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 169 insertions(+), 8 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index d66bf15..849cefa 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1223,8 +1223,8 @@ extern tree c_finish_omp_critical (location_t, tree, tree, tree); extern tree c_finish_omp_ordered (location_t, tree, tree); extern void c_finish_omp_barrier (location_t); extern tree c_finish_omp_atomic (location_t, enum tree_code, enum tree_code, - tree, tree, tree, tree, tree, bool, - enum omp_memory_order, bool = false); + tree, tree, tree, tree, tree, tree, bool, + enum omp_memory_order, bool, bool = false); extern bool c_omp_depend_t_p (tree); extern void c_finish_omp_depobj (location_t, tree, enum omp_clause_depend_kind, tree); diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 4b95fc1..75184a3 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "gimplify.h" #include "langhooks.h" #include "bitmap.h" +#include "gimple-fold.h" /* Complete a #pragma oacc wait construct. LOC is the location of @@ -215,15 +216,17 @@ c_finish_omp_taskyield (location_t loc) tree c_finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode, tree lhs, tree rhs, - tree v, tree lhs1, tree rhs1, bool swapped, - enum omp_memory_order memory_order, bool test) + tree v, tree lhs1, tree rhs1, tree r, bool swapped, + enum omp_memory_order memory_order, bool weak, + bool test) { - tree x, type, addr, pre = NULL_TREE; + tree x, type, addr, pre = NULL_TREE, rtmp = NULL_TREE, vtmp = NULL_TREE; HOST_WIDE_INT bitpos = 0, bitsize = 0; + enum tree_code orig_opcode = opcode; if (lhs == error_mark_node || rhs == error_mark_node || v == error_mark_node || lhs1 == error_mark_node - || rhs1 == error_mark_node) + || rhs1 == error_mark_node || r == error_mark_node) return error_mark_node; /* ??? According to one reading of the OpenMP spec, complex type are @@ -243,6 +246,12 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, error_at (loc, "%<_Atomic%> expression in %<#pragma omp atomic%>"); return error_mark_node; } + if (r && r != void_list_node && !INTEGRAL_TYPE_P (TREE_TYPE (r))) + { + error_at (loc, "%<#pragma omp atomic compare capture%> with non-integral " + "comparison result"); + return error_mark_node; + } if (opcode == RDIV_EXPR) opcode = TRUNC_DIV_EXPR; @@ -299,6 +308,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, x = build1 (OMP_ATOMIC_READ, type, addr); SET_EXPR_LOCATION (x, loc); OMP_ATOMIC_MEMORY_ORDER (x) = memory_order; + gcc_assert (!weak); if (blhs) x = build3_loc (loc, BIT_FIELD_REF, TREE_TYPE (blhs), x, bitsize_int (bitsize), bitsize_int (bitpos)); @@ -313,12 +323,29 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, { lhs = build3_loc (loc, BIT_FIELD_REF, TREE_TYPE (blhs), lhs, bitsize_int (bitsize), bitsize_int (bitpos)); - if (swapped) + if (opcode == COND_EXPR) + { + bool save = in_late_binary_op; + in_late_binary_op = true; + std::swap (rhs, rhs1); + rhs1 = build_binary_op (loc, EQ_EXPR, lhs, rhs1, true); + in_late_binary_op = save; + } + else if (swapped) rhs = build_binary_op (loc, opcode, rhs, lhs, true); else if (opcode != NOP_EXPR) rhs = build_binary_op (loc, opcode, lhs, rhs, true); opcode = NOP_EXPR; } + else if (opcode == COND_EXPR) + { + bool save = in_late_binary_op; + in_late_binary_op = true; + std::swap (rhs, rhs1); + rhs1 = build_binary_op (loc, EQ_EXPR, lhs, rhs1, true); + in_late_binary_op = save; + opcode = NOP_EXPR; + } else if (swapped) { rhs = build_binary_op (loc, opcode, rhs, lhs, true); @@ -343,6 +370,100 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, if (blhs) rhs = build3_loc (loc, BIT_INSERT_EXPR, type, new_lhs, rhs, bitsize_int (bitpos)); + if (orig_opcode == COND_EXPR) + { + if (error_operand_p (rhs1)) + return error_mark_node; + gcc_assert (TREE_CODE (rhs1) == EQ_EXPR); + tree cmptype = TREE_TYPE (TREE_OPERAND (rhs1, 0)); + if (SCALAR_FLOAT_TYPE_P (cmptype)) + { + bool clear_padding = false; + if (BITS_PER_UNIT == 8 && CHAR_BIT == 8) + { + HOST_WIDE_INT sz = int_size_in_bytes (cmptype), i; + gcc_assert (sz > 0); + unsigned char *buf = XALLOCAVEC (unsigned char, sz); + memset (buf, ~0, sz); + clear_type_padding_in_mask (cmptype, buf); + for (i = 0; i < sz; i++) + if (buf[i] != (unsigned char) ~0) + { + clear_padding = true; + break; + } + } + tree inttype = NULL_TREE; + if (!clear_padding && tree_fits_uhwi_p (TYPE_SIZE (cmptype))) + { + HOST_WIDE_INT prec = tree_to_uhwi (TYPE_SIZE (cmptype)); + inttype = c_common_type_for_size (prec, 1); + if (inttype + && (!tree_int_cst_equal (TYPE_SIZE (cmptype), + TYPE_SIZE (inttype)) + || TYPE_PRECISION (inttype) != prec)) + inttype = NULL_TREE; + } + if (inttype) + { + TREE_OPERAND (rhs1, 0) + = build1_loc (loc, VIEW_CONVERT_EXPR, inttype, + TREE_OPERAND (rhs1, 0)); + TREE_OPERAND (rhs1, 1) + = build1_loc (loc, VIEW_CONVERT_EXPR, inttype, + TREE_OPERAND (rhs1, 1)); + } + else + { + tree pcmptype = build_pointer_type (cmptype); + tree tmp1 = create_tmp_var_raw (cmptype); + TREE_ADDRESSABLE (tmp1) = 1; + DECL_CONTEXT (tmp1) = current_function_decl; + tmp1 = build4 (TARGET_EXPR, cmptype, tmp1, + TREE_OPERAND (rhs1, 0), NULL, NULL); + tmp1 = build1 (ADDR_EXPR, pcmptype, tmp1); + tree tmp2 = create_tmp_var_raw (cmptype); + TREE_ADDRESSABLE (tmp2) = 1; + DECL_CONTEXT (tmp2) = current_function_decl; + tmp2 = build4 (TARGET_EXPR, cmptype, tmp2, + TREE_OPERAND (rhs1, 1), NULL, NULL); + tmp2 = build1 (ADDR_EXPR, pcmptype, tmp2); + tree fndecl = builtin_decl_explicit (BUILT_IN_MEMCMP); + rhs1 = build_call_expr_loc (loc, fndecl, 3, tmp1, tmp2, + TYPE_SIZE_UNIT (cmptype)); + rhs1 = build2 (EQ_EXPR, boolean_type_node, rhs1, + integer_zero_node); + if (clear_padding) + { + fndecl = builtin_decl_explicit (BUILT_IN_CLEAR_PADDING); + tree cp1 = build_call_expr_loc (loc, fndecl, 1, tmp1); + tree cp2 = build_call_expr_loc (loc, fndecl, 1, tmp2); + rhs1 = omit_two_operands_loc (loc, boolean_type_node, + rhs1, cp2, cp1); + } + } + } + if (r) + { + tree var = create_tmp_var (boolean_type_node); + DECL_CONTEXT (var) = current_function_decl; + rtmp = build4 (TARGET_EXPR, boolean_type_node, var, + NULL, NULL, NULL); + save = in_late_binary_op; + in_late_binary_op = true; + x = build_modify_expr (loc, var, NULL_TREE, NOP_EXPR, + loc, rhs1, NULL_TREE); + in_late_binary_op = save; + if (x == error_mark_node) + return error_mark_node; + gcc_assert (TREE_CODE (x) == MODIFY_EXPR + && TREE_OPERAND (x, 0) == var); + TREE_OPERAND (x, 0) = rtmp; + rhs1 = omit_one_operand_loc (loc, boolean_type_node, x, rtmp); + } + rhs = build3_loc (loc, COND_EXPR, type, rhs1, rhs, new_lhs); + rhs1 = NULL_TREE; + } /* Punt the actual generation of atomic operations to common code. */ if (code == OMP_ATOMIC) @@ -350,6 +471,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, x = build2 (code, type, addr, rhs); SET_EXPR_LOCATION (x, loc); OMP_ATOMIC_MEMORY_ORDER (x) = memory_order; + OMP_ATOMIC_WEAK (x) = weak; /* Generally it is hard to prove lhs1 and lhs are the same memory location, just diagnose different variables. */ @@ -412,8 +534,25 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, bitsize_int (bitsize), bitsize_int (bitpos)); type = TREE_TYPE (blhs); } - x = build_modify_expr (loc, v, NULL_TREE, NOP_EXPR, + if (r) + { + vtmp = create_tmp_var (TREE_TYPE (x)); + DECL_CONTEXT (vtmp) = current_function_decl; + } + else + vtmp = v; + x = build_modify_expr (loc, vtmp, NULL_TREE, NOP_EXPR, loc, x, NULL_TREE); + if (x == error_mark_node) + return error_mark_node; + if (r) + { + vtmp = build4 (TARGET_EXPR, boolean_type_node, vtmp, + NULL, NULL, NULL); + gcc_assert (TREE_CODE (x) == MODIFY_EXPR + && TREE_OPERAND (x, 0) == TARGET_EXPR_SLOT (vtmp)); + TREE_OPERAND (x, 0) = vtmp; + } if (rhs1 && rhs1 != orig_lhs) { tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, false); @@ -446,6 +585,28 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, if (pre) x = omit_one_operand_loc (loc, type, x, pre); + if (r && r != void_list_node) + { + in_late_binary_op = true; + tree x2 = build_modify_expr (loc, r, NULL_TREE, NOP_EXPR, + loc, rtmp, NULL_TREE); + in_late_binary_op = save; + if (x2 == error_mark_node) + return error_mark_node; + x = omit_one_operand_loc (loc, TREE_TYPE (x2), x2, x); + } + if (v && vtmp != v) + { + in_late_binary_op = true; + tree x2 = build_modify_expr (loc, v, NULL_TREE, NOP_EXPR, + loc, vtmp, NULL_TREE); + in_late_binary_op = save; + if (x2 == error_mark_node) + return error_mark_node; + x2 = build3_loc (loc, COND_EXPR, void_type_node, rtmp, + void_node, x2); + x = omit_one_operand_loc (loc, TREE_TYPE (x2), x2, x); + } return x; } -- cgit v1.1 From a26206ec7b8f8c60747c25d009ea7f9b94184215 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 11 Sep 2021 00:16:27 +0000 Subject: Daily bump. --- gcc/c-family/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c39dfe3..684d7d0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2021-09-10 Jakub Jelinek + + * c-common.h (c_finish_omp_atomic): Add r and weak arguments. + * c-omp.c: Include gimple-fold.h. + (c_finish_omp_atomic): Add r and weak arguments. Add support for + OpenMP 5.1 atomics. + 2021-09-09 qing zhao * c-attribs.c (handle_uninitialized_attribute): New function. -- cgit v1.1 From 76b75018b3d053a890ebe155e47814de14b3c9fb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 15 Jul 2021 15:30:17 -0400 Subject: c++: implement C++17 hardware interference size The last missing piece of the C++17 standard library is the hardware intereference size constants. Much of the delay in implementing these has been due to uncertainty about what the right values are, and even whether there is a single constant value that is suitable; the destructive interference size is intended to be used in structure layout, so program ABIs will depend on it. In principle, both of these values should be the same as the target's L1 cache line size. When compiling for a generic target that is intended to support a range of target CPUs with different cache line sizes, the constructive size should probably be the minimum size, and the destructive size the maximum, unless you are constrained by ABI compatibility with previous code. From discussion on gcc-patches, I've come to the conclusion that the solution to the difficulty of choosing stable values is to give up on it, and instead encourage only uses where ABI stability is unimportant: in particular, uses where the ABI is shared at most between translation units built at the same time with the same flags. To that end, I've added a warning for any use of the constant value of std::hardware_destructive_interference_size in a header or module export. Appropriate uses within a project can disable the warning. A previous iteration of this patch included an -finterference-tune flag to make the value vary with -mtune; this iteration makes that the default behavior, which should be appropriate for all reasonable uses of the variable. The previous default of "stable-ish" seems to me likely to have been more of an attractive nuisance; since we can't promise actual stability, we should instead make proper uses more convenient. JF Bastien's implementation proposal is summarized at https://github.com/itanium-cxx-abi/cxx-abi/issues/74 I implement this by adding new --params for the two sizes. Targets can override these values in targetm.target_option.override() to support a range of values for the generic target; otherwise, both will default to the L1 cache line size. 64 bytes still seems correct for all x86. I'm not sure why he proposed 64/64 for generic 32-bit ARM, since the Cortex A9 has a 32-byte cache line, so I'd think 32/64 would make more sense. He proposed 64/128 for generic AArch64, but since the A64FX now has a 256B cache line, I've changed that to 64/256. Other arch maintainers are invited to set ranges for their generic targets if that seems better than using the default cache line size for both values. With the above choice to reject stability as a goal, getting these values "right" is now just a matter of what we want the default optimization to be, and we can feel free to adjust them as CPUs with different cache lines become more and less common. gcc/ChangeLog: * params.opt: Add destructive-interference-size and constructive-interference-size. * doc/invoke.texi: Document them. * config/aarch64/aarch64.c (aarch64_override_options_internal): Set them. * config/arm/arm.c (arm_option_override): Set them. * config/i386/i386-options.c (ix86_option_override_internal): Set them. gcc/c-family/ChangeLog: * c.opt: Add -Winterference-size. * c-cppbuiltin.c (cpp_atomic_builtins): Add __GCC_DESTRUCTIVE_SIZE and __GCC_CONSTRUCTIVE_SIZE. gcc/cp/ChangeLog: * constexpr.c (maybe_warn_about_constant_value): Complain about std::hardware_destructive_interference_size. (cxx_eval_constant_expression): Call it. * decl.c (cxx_init_decl_processing): Check --param *-interference-size values. libstdc++-v3/ChangeLog: * include/std/version: Define __cpp_lib_hardware_interference_size. * libsupc++/new: Define hardware interference size variables. gcc/testsuite/ChangeLog: * g++.dg/warn/Winterference.H: New file. * g++.dg/warn/Winterference.C: New test. * g++.target/aarch64/interference.C: New test. * g++.target/arm/interference.C: New test. * g++.target/i386/interference.C: New test. --- gcc/c-family/c-cppbuiltin.c | 14 ++++++++++++++ gcc/c-family/c.opt | 5 +++++ 2 files changed, 19 insertions(+) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 48cbefd..ce88e70 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -741,6 +741,20 @@ cpp_atomic_builtins (cpp_reader *pfile) builtin_define_with_int_value ("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", targetm.atomic_test_and_set_trueval); + /* Macros for C++17 hardware interference size constants. Either both or + neither should be set. */ + gcc_assert (!param_destruct_interfere_size + == !param_construct_interfere_size); + if (param_destruct_interfere_size) + { + /* FIXME The way of communicating these values to the library should be + part of the C++ ABI, whether macro or builtin. */ + builtin_define_with_int_value ("__GCC_DESTRUCTIVE_SIZE", + param_destruct_interfere_size); + builtin_define_with_int_value ("__GCC_CONSTRUCTIVE_SIZE", + param_construct_interfere_size); + } + /* ptr_type_node can't be used here since ptr_mode is only set when toplev calls backend_init which is not done with -E or pch. */ psize = POINTER_SIZE_UNITS; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index c5fe900..9c151d1 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -722,6 +722,11 @@ Winit-list-lifetime C++ ObjC++ Var(warn_init_list) Warning Init(1) Warn about uses of std::initializer_list that can result in dangling pointers. +Winterference-size +C++ ObjC++ Var(warn_interference_size) Warning Init(1) +Warn about nonsensical values of --param destructive-interference-size or +constructive-interference-size. + Wimplicit C ObjC Var(warn_implicit) Warning LangEnabledBy(C ObjC,Wall) Warn about implicit declarations. -- cgit v1.1