From 4b7d9f8f51bd96d290aac230c71e501fcb6b21a6 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 22 Mar 2022 14:37:02 -0400 Subject: c: -Wmissing-field-initializers and designated inits [PR82283, PR84685] This patch fixes two kinds of wrong -Wmissing-field-initializers warnings. Our docs say that this warning "does not warn about designated initializers", but we give a warning for 1) the array case: struct S { struct N { int a; int b; } c[1]; } d = { .c[0].a = 1, .c[0].b = 1, // missing initializer for field 'b' of 'struct N' }; we warn because push_init_level, when constructing an array, clears constructor_designated (which the warning relies on), and we forget that we were in a designated initializer context. Fixed by the push_init_level hunk; and 2) the compound literal case: struct T { int a; int *b; int c; }; struct T t = { .b = (int[]){1} }; // missing initializer for field 'c' of 'struct T' where set_designator properly sets constructor_designated to 1, but the compound literal causes us to create a whole new initializer_stack in start_init, which clears constructor_designated. Then, after we've parsed the compound literal, finish_init flushes the initializer_stack entry, but doesn't restore constructor_designated, so we forget we were in a designated initializer context, which causes the bogus warning. (The designated flag is also tracked in constructor_stack, but in this case, we didn't perform push_init_level between set_designator and start_init so it wasn't saved anywhere.) PR c/82283 PR c/84685 gcc/c/ChangeLog: * c-typeck.cc (struct initializer_stack): Add 'designated' member. (start_init): Set it. (finish_init): Restore constructor_designated. (push_init_level): Set constructor_designated to the value of constructor_designated in the upper constructor_stack. gcc/testsuite/ChangeLog: * gcc.dg/Wmissing-field-initializers-1.c: New test. * gcc.dg/Wmissing-field-initializers-2.c: New test. * gcc.dg/Wmissing-field-initializers-3.c: New test. * gcc.dg/Wmissing-field-initializers-4.c: New test. * gcc.dg/Wmissing-field-initializers-5.c: New test. --- gcc/c/c-typeck.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index c0812de..6c4af5e 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -8438,6 +8438,7 @@ struct initializer_stack char top_level; char require_constant_value; char require_constant_elements; + char designated; rich_location *missing_brace_richloc; }; @@ -8464,6 +8465,7 @@ start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level, p->top_level = constructor_top_level; p->next = initializer_stack; p->missing_brace_richloc = richloc; + p->designated = constructor_designated; initializer_stack = p; constructor_decl = decl; @@ -8522,6 +8524,7 @@ finish_init (void) require_constant_value = p->require_constant_value; require_constant_elements = p->require_constant_elements; constructor_stack = p->constructor_stack; + constructor_designated = p->designated; constructor_range_stack = p->constructor_range_stack; constructor_elements = p->elements; spelling = p->spelling; @@ -8731,7 +8734,9 @@ push_init_level (location_t loc, int implicit, constructor_depth = SPELLING_DEPTH (); constructor_elements = NULL; constructor_incremental = 1; - constructor_designated = 0; + /* If the upper initializer is designated, then mark this as + designated too to prevent bogus warnings. */ + constructor_designated = p->designated; constructor_pending_elts = 0; if (!implicit) { @@ -8756,9 +8761,6 @@ push_init_level (location_t loc, int implicit, push_member_name (constructor_fields); constructor_depth++; } - /* If upper initializer is designated, then mark this as - designated too to prevent bogus warnings. */ - constructor_designated = p->designated; } else if (TREE_CODE (constructor_type) == ARRAY_TYPE) { -- cgit v1.1 From a2287813b1369b8fae67f2220d23c552945180ed Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 23 Mar 2022 00:16:45 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1c0d5ec..ea25ddb 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,13 @@ +2022-03-22 Marek Polacek + + PR c/82283 + PR c/84685 + * c-typeck.cc (struct initializer_stack): Add 'designated' member. + (start_init): Set it. + (finish_init): Restore constructor_designated. + (push_init_level): Set constructor_designated to the value of + constructor_designated in the upper constructor_stack. + 2022-03-12 Thomas Schwinge PR other/65095 -- cgit v1.1 From 6e2743687202c58a6553ae632ebbada3de38ad48 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 8 Apr 2022 09:16:30 +0200 Subject: c: Error on va_arg with function type [PR105149] In the PR Joseph said that the C standard for va_arg talks about pointers to object type and as a function type is not object type, it is invalid. The following patch diagnoses it in the FE, instead of ICEing later on when optimizations are turned on (and with -O0 doing something weird at runtime). 2022-04-08 Jakub Jelinek PR c/105149 * c-typeck.cc (c_build_va_arg): Reject function types. * gcc.dg/pr105149.c: New test. --- gcc/c/c-typeck.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 6c4af5e..e130196 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -15896,6 +15896,12 @@ c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type) "type %qT", type); return error_mark_node; } + else if (TREE_CODE (type) == FUNCTION_TYPE) + { + error_at (loc2, "second argument to % is a function type %qT", + type); + return error_mark_node; + } else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE) warning_at (loc2, OPT_Wc___compat, "C++ requires promoted type, not enum type, in %"); -- cgit v1.1 From 405eda0d34b69fb6ee12ba6ed0f69c2c2411d8ee Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 9 Apr 2022 00:16:56 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ea25ddb..b0fef44 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2022-04-08 Jakub Jelinek + + PR c/105149 + * c-typeck.cc (c_build_va_arg): Reject function types. + 2022-03-22 Marek Polacek PR c/82283 -- cgit v1.1 From 0c723bb4be2a67657828b692997855afcdc5d286 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 31 Mar 2022 18:31:39 -0400 Subject: c, c++: attribute format on a ctor with a vbase [PR101833, PR47634] Attribute format takes three arguments: archetype, string-index, and first-to-check. The last two specify the position in the function parameter list. r63030 clarified that "Since non-static C++ methods have an implicit this argument, the arguments of such methods should be counted from two, not one, when giving values for string-index and first-to-check." Therefore one has to write struct D { D(const char *, ...) __attribute__((format(printf, 2, 3))); }; However -- and this is the problem in this PR -- ctors with virtual bases also get two additional parameters: the in-charge parameter and the VTT parameter (added in maybe_retrofit_in_chrg). In fact we'll end up with two clones of the ctor: an in-charge and a not-in-charge version (see build_cdtor_clones). That means that the argument position the user specified in the attribute argument will refer to different arguments, depending on which constructor we're currently dealing with. This can cause a range of problems: wrong errors, confusing warnings, or crashes. This patch corrects that; for C we don't have to do anything, and in C++ we can use num_artificial_parms_for. It would be wrong to rewrite the attributes the user supplied, so I've changed POS to be passed by reference so that we don't have to change all the call sites of positional_argument and we still get the default_conversion adjustment. Attribute format_arg is not affected, because it requires that the function returns "const char *" which will never be the case for cdtors. PR c++/101833 PR c++/47634 gcc/c-family/ChangeLog: * c-attribs.cc (positional_argument): Pass POS by reference. Deal with FN being either a function declaration or function type. Use maybe_adjust_arg_pos_for_attribute. * c-common.cc (check_function_arguments): Maybe pass FNDECL down to check_function_format. * c-common.h (maybe_adjust_arg_pos_for_attribute): Declare. (positional_argument): Adjust. * c-format.cc (get_constant): Rename to ... (validate_constant): ... this. Take EXPR by reference. Return bool instead of tree. (handle_format_arg_attribute): Don't overwrite FORMAT_NUM_EXPR by the return value of validate_constant. (decode_format_attr): Don't overwrite FORMAT_NUM_EXPR and FIRST_ARG_NUM_EXPR by the return value of validate_constant. (check_function_format): Adjust a parameter name. (handle_format_attribute): Maybe pass FNDECL down to decode_format_attr. gcc/c/ChangeLog: * c-objc-common.cc (maybe_adjust_arg_pos_for_attribute): New. gcc/cp/ChangeLog: * tree.cc (maybe_adjust_arg_pos_for_attribute): New. gcc/ChangeLog: * tree-core.h (struct attribute_spec): Update comment for HANDLER. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-format-arg1.C: New test. * g++.dg/ext/attr-format1.C: New test. * g++.dg/ext/attr-format2.C: New test. * g++.dg/ext/attr-format3.C: New test. --- gcc/c/c-objc-common.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc index 97850ad..70e10a9 100644 --- a/gcc/c/c-objc-common.cc +++ b/gcc/c/c-objc-common.cc @@ -394,3 +394,12 @@ c_get_alias_set (tree t) return c_common_get_alias_set (t); } + +/* In C there are no invisible parameters like in C++ (this, in-charge, VTT, + etc.). */ + +int +maybe_adjust_arg_pos_for_attribute (const_tree) +{ + return 0; +} -- cgit v1.1 From a1947c92f7cda5f6cf7b8d8a9a44f6dd45352c03 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 8 May 2022 00:16:20 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b0fef44..b8167c2 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2022-05-07 Marek Polacek + + PR c++/101833 + PR c++/47634 + * c-objc-common.cc (maybe_adjust_arg_pos_for_attribute): New. + 2022-04-08 Jakub Jelinek PR c/105149 -- cgit v1.1 From 22d9c8802add09a93308319fc37dd3a0f1125393 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 3 Feb 2022 10:58:18 +0100 Subject: Come up with {,UN}LIKELY macros. gcc/c/ChangeLog: * c-parser.cc (c_parser_conditional_expression): Use {,UN}LIKELY macros. (c_parser_binary_expression): Likewise. gcc/cp/ChangeLog: * cp-gimplify.cc (cp_genericize_r): Use {,UN}LIKELY macros. * parser.cc (cp_finalize_omp_declare_simd): Likewise. (cp_finalize_oacc_routine): Likewise. gcc/ChangeLog: * system.h (LIKELY): Define. (UNLIKELY): Likewise. * domwalk.cc (sort_bbs_postorder): Use {,UN}LIKELY macros. * dse.cc (set_position_unneeded): Likewise. (set_all_positions_unneeded): Likewise. (any_positions_needed_p): Likewise. (all_positions_needed_p): Likewise. * expmed.cc (flip_storage_order): Likewise. * genmatch.cc (dt_simplify::gen_1): Likewise. * ggc-common.cc (gt_pch_save): Likewise. * print-rtl.cc: Likewise. * rtl-iter.h (T>::array_type::~array_type): Likewise. (T>::next): Likewise. * rtl-ssa/internals.inl: Likewise. * rtl-ssa/member-fns.inl: Likewise. * rtlanal.cc (T>::add_subrtxes_to_queue): Likewise. (rtx_properties::try_to_add_dest): Likewise. * rtlanal.h (growing_rtx_properties::repeat): Likewise. (vec_rtx_properties_base::~vec_rtx_properties_base): Likewise. * simplify-rtx.cc (simplify_replace_fn_rtx): Likewise. * sort.cc (likely): Likewise. (mergesort): Likewise. * wide-int.h (wi::eq_p): Likewise. (wi::ltu_p): Likewise. (wi::cmpu): Likewise. (wi::bit_and): Likewise. (wi::bit_and_not): Likewise. (wi::bit_or): Likewise. (wi::bit_or_not): Likewise. (wi::bit_xor): Likewise. (wi::add): Likewise. (wi::sub): Likewise. --- gcc/c/c-parser.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 129dd72..d431d5f 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -7669,7 +7669,7 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after, c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node; location_t loc1 = make_location (exp1.get_start (), exp1.src_range); location_t loc2 = make_location (exp2.get_start (), exp2.src_range); - if (__builtin_expect (omp_atomic_lhs != NULL, 0) + if (UNLIKELY (omp_atomic_lhs != NULL) && (TREE_CODE (cond.value) == GT_EXPR || TREE_CODE (cond.value) == LT_EXPR || TREE_CODE (cond.value) == EQ_EXPR) @@ -7865,7 +7865,7 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after, stack[sp].expr \ = convert_lvalue_to_rvalue (stack[sp].loc, \ stack[sp].expr, true, true); \ - if (__builtin_expect (omp_atomic_lhs != NULL_TREE, 0) && sp == 1 \ + if (UNLIKELY (omp_atomic_lhs != NULL_TREE) && sp == 1 \ && ((c_parser_next_token_is (parser, CPP_SEMICOLON) \ && ((1 << stack[sp].prec) \ & ((1 << PREC_BITOR) | (1 << PREC_BITXOR) \ -- cgit v1.1 From bd022ff9752262a70f44b57808447f823392989e Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 10 May 2022 00:17:14 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b8167c2..f697867 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2022-05-09 Martin Liska + + * c-parser.cc (c_parser_conditional_expression): Use {,UN}LIKELY + macros. + (c_parser_binary_expression): Likewise. + 2022-05-07 Marek Polacek PR c++/101833 -- cgit v1.1 From 7f78783dbedca0183d193e475262ca3c489fd365 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 May 2022 08:31:20 +0200 Subject: openmp: Add omp_all_memory support (C/C++ only so far) The ugly part is that OpenMP 5.1 made omp_all_memory a reserved identifier which isn't allowed to be used anywhere but in the depend clause, this is against how everything else has been handled in OpenMP so far (where some identifiers could have special meaning in some OpenMP clauses or pragmas but not elsewhere). The patch handles it by making it a conditional keyword (for -fopenmp only) and emitting a better diagnostics when it is used in a primary expression. Having a nicer diagnostics when e.g. trying to do int omp_all_memory; or int *omp_all_memory[10]; etc. would mean changing too many spots and hooking into name lookups to reject declaring any such symbols would be too ugly and I'm afraid there are way too many spots where one can introduce a name (variables, functions, namespaces, struct, enum, enumerators, template arguments, ...). Otherwise, the handling is quite simple, normal depend clauses lower into addresses of variables being handed over to the library, for omp_all_memory I'm using NULL pointers. omp_all_memory can only be used with inout or out depend kinds and means that a task is dependent on all previously created sibling tasks that have any dependency (of any depend kind) and that any later created sibling tasks will be dependent on it if they have any dependency. 2022-05-12 Jakub Jelinek gcc/ * gimplify.cc (gimplify_omp_depend): Don't build_fold_addr_expr if null_pointer_node. (gimplify_scan_omp_clauses): Likewise. * tree-pretty-print.cc (dump_omp_clause): Print null_pointer_node as omp_all_memory. gcc/c-family/ * c-common.h (enum rid): Add RID_OMP_ALL_MEMORY. * c-omp.cc (c_finish_omp_depobj): Don't build_fold_addr_expr if null_pointer_node. gcc/c/ * c-parser.cc (c_parse_init): Register omp_all_memory as keyword if flag_openmp. (c_parser_postfix_expression): Diagnose uses of omp_all_memory in postfix expressions. (c_parser_omp_variable_list): Handle omp_all_memory in depend clause. * c-typeck.cc (c_finish_omp_clauses): Handle omp_all_memory keyword in depend clause as null_pointer_node, diagnose invalid uses. gcc/cp/ * lex.cc (init_reswords): Register omp_all_memory as keyword if flag_openmp. * parser.cc (cp_parser_primary_expression): Diagnose uses of omp_all_memory in postfix expressions. (cp_parser_omp_var_list_no_open): Handle omp_all_memory in depend clause. * semantics.cc (finish_omp_clauses): Handle omp_all_memory keyword in depend clause as null_pointer_node, diagnose invalid uses. * pt.cc (tsubst_omp_clause_decl): Pass through omp_all_memory. gcc/testsuite/ * c-c++-common/gomp/all-memory-1.c: New test. * c-c++-common/gomp/all-memory-2.c: New test. * c-c++-common/gomp/all-memory-3.c: New test. * g++.dg/gomp/all-memory-1.C: New test. * g++.dg/gomp/all-memory-2.C: New test. libgomp/ * libgomp.h (struct gomp_task): Add depend_all_memory member. * task.c (gomp_init_task): Initialize depend_all_memory. (gomp_task_handle_depend): Handle omp_all_memory. (gomp_task_run_post_handle_depend_hash): Clear parent->depend_all_memory if equal to current task. (gomp_task_maybe_wait_for_dependencies): Handle omp_all_memory. * testsuite/libgomp.c-c++-common/depend-1.c: New test. * testsuite/libgomp.c-c++-common/depend-2.c: New test. * testsuite/libgomp.c-c++-common/depend-3.c: New test. --- gcc/c/c-parser.cc | 29 ++++++++++++++++++++++++++++- gcc/c/c-typeck.cc | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 13 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index d431d5f..51a0725 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -165,6 +165,14 @@ c_parse_init (void) C_SET_RID_CODE (id, RID_FIRST_INT_N + i); C_IS_RESERVED_WORD (id) = 1; } + + if (flag_openmp) + { + id = get_identifier ("omp_all_memory"); + C_SET_RID_CODE (id, RID_OMP_ALL_MEMORY); + C_IS_RESERVED_WORD (id) = 1; + ridpointers [RID_OMP_ALL_MEMORY] = id; + } } /* A parser structure recording information about the state and @@ -10202,6 +10210,13 @@ c_parser_postfix_expression (c_parser *parser) case RID_GENERIC: expr = c_parser_generic_selection (parser); break; + case RID_OMP_ALL_MEMORY: + gcc_assert (flag_openmp); + c_parser_consume_token (parser); + error_at (loc, "% may only be used in OpenMP " + "% clause"); + expr.set_error (); + break; default: c_parser_error (parser, "expected expression"); expr.set_error (); @@ -13025,7 +13040,19 @@ c_parser_omp_variable_list (c_parser *parser, if (c_parser_next_token_is_not (parser, CPP_NAME) || c_parser_peek_token (parser)->id_kind != C_ID_ID) { - struct c_expr expr = c_parser_expr_no_commas (parser, NULL); + struct c_expr expr; + if (kind == OMP_CLAUSE_DEPEND + && c_parser_next_token_is_keyword (parser, + RID_OMP_ALL_MEMORY) + && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA + || (c_parser_peek_2nd_token (parser)->type + == CPP_CLOSE_PAREN))) + { + expr.value = ridpointers[RID_OMP_ALL_MEMORY]; + c_parser_consume_token (parser); + } + else + expr = c_parser_expr_no_commas (parser, NULL); if (expr.value != error_mark_node) { tree u = build_omp_clause (clause_loc, kind); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index e130196..bcfe08b 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -14832,6 +14832,18 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } if (t == error_mark_node) remove = true; + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND + && t == ridpointers[RID_OMP_ALL_MEMORY]) + { + if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT + && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT) + { + error_at (OMP_CLAUSE_LOCATION (c), + "% used with % kind " + "other than % or %"); + remove = true; + } + } else if (!lvalue_p (t)) { error_at (OMP_CLAUSE_LOCATION (c), @@ -14873,24 +14885,32 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } if (!remove) { - tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c), ADDR_EXPR, - t, false); - if (addr == error_mark_node) - remove = true; + if (t == ridpointers[RID_OMP_ALL_MEMORY]) + t = null_pointer_node; else { + tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c), + ADDR_EXPR, t, false); + if (addr == error_mark_node) + { + remove = true; + break; + } t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr, RO_UNARY_STAR); if (t == error_mark_node) - remove = true; - else if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST - && TREE_PURPOSE (OMP_CLAUSE_DECL (c)) - && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c))) - == TREE_VEC)) - TREE_VALUE (OMP_CLAUSE_DECL (c)) = t; - else - OMP_CLAUSE_DECL (c) = t; + { + remove = true; + break; + } } + if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST + && TREE_PURPOSE (OMP_CLAUSE_DECL (c)) + && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c))) + == TREE_VEC)) + TREE_VALUE (OMP_CLAUSE_DECL (c)) = t; + else + OMP_CLAUSE_DECL (c) = t; } break; -- cgit v1.1 From 49ace834ab15c1614a96a81005304eae0f2f525e Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 13 May 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f697867..6db1152d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,15 @@ +2022-05-12 Jakub Jelinek + + * c-parser.cc (c_parse_init): Register omp_all_memory as keyword + if flag_openmp. + (c_parser_postfix_expression): Diagnose uses of omp_all_memory + in postfix expressions. + (c_parser_omp_variable_list): Handle omp_all_memory in depend + clause. + * c-typeck.cc (c_finish_omp_clauses): Handle omp_all_memory + keyword in depend clause as null_pointer_node, diagnose invalid + uses. + 2022-05-09 Martin Liska * c-parser.cc (c_parser_conditional_expression): Use {,UN}LIKELY -- cgit v1.1 From ca32b29ec3e92dcf8dda5c2501d0baf9dd1cb09d Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 13 Jan 2022 18:46:26 +0100 Subject: Use more ARRAY_SIZE. gcc/ada/ChangeLog: * locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE. (language_name_to_639_3): Likewise. (country_name_to_3166): Likewise. gcc/analyzer/ChangeLog: * engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE. * function-set.cc (test_stdio_example): Likewise. * sm-file.cc (get_file_using_fns): Likewise. * sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise. * sm-signal.cc (get_async_signal_unsafe_fns): Likewise. gcc/ChangeLog: * attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE. (decls_mismatched_attributes): Likewise. * builtins.cc (c_strlen): Likewise. * cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise. * common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): Likewise. * config/aarch64/aarch64-builtins.cc (aarch64_lookup_simd_builtin_type): Likewise. (aarch64_init_simd_builtin_types): Likewise. (aarch64_init_builtin_rsqrt): Likewise. * config/aarch64/aarch64.cc (is_madd_op): Likewise. * config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise. (arm_init_simd_builtin_types): Likewise. * config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise. (c_prefix): Likewise. (main): Likewise. * config/c6x/c6x.cc (N_SAVE_ORDER): Likewise. * config/darwin-c.cc (darwin_register_frameworks): Likewise. * config/gcn/mkoffload.cc (process_obj): Likewise. * config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise. (fold_builtin_cpu): Likewise. * config/m32c/m32c.cc (PUSHM_N): Likewise. * config/nvptx/mkoffload.cc (process): Likewise. * config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise. * config/s390/s390.cc (NR_C_MODES): Likewise. * config/tilepro/gen-mul-tables.cc (find_sequences): Likewise. (create_insn_code_compression_table): Likewise. * config/vms/vms.cc (NBR_CRTL_NAMES): Likewise. * diagnostic-format-json.cc (json_from_expanded_location): Likewise. * dwarf2out.cc (ARRAY_SIZE): Likewise. * genhooks.cc (emit_documentation): Likewise. (emit_init_macros): Likewise. * gimple-ssa-sprintf.cc (format_floating): Likewise. * gimple-ssa-warn-access.cc (memmodel_name): Likewise. * godump.cc (keyword_hash_init): Likewise. * hash-table.cc (hash_table_higher_prime_index): Likewise. * input.cc (for_each_line_table_case): Likewise. * ipa-free-lang-data.cc (free_lang_data): Likewise. * ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise. * optc-save-gen.awk: Likewise. * spellcheck.cc (test_metric_conditions): Likewise. * tree-vect-slp-patterns.cc (sizeof): Likewise. (ARRAY_SIZE): Likewise. * tree.cc (build_common_tree_nodes): Likewise. gcc/c-family/ChangeLog: * c-common.cc (ARRAY_SIZE): Use ARRAY_SIZE. (c_common_nodes_and_builtins): Likewise. * c-format.cc (check_tokens): Likewise. (check_plain): Likewise. * c-pragma.cc (c_pp_lookup_pragma): Likewise. (init_pragma): Likewise. * known-headers.cc (get_string_macro_hint): Likewise. (get_stdlib_header_for_name): Likewise. * c-attribs.cc: Likewise. gcc/c/ChangeLog: * c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE. gcc/cp/ChangeLog: * module.cc (depset::entity_kind_name): Use ARRAY_SIZE. * name-lookup.cc (get_std_name_hint): Likewise. * parser.cc (cp_parser_new): Likewise. gcc/fortran/ChangeLog: * frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE. * openmp.cc (gfc_match_omp_context_selector_specification): Likewise. * trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise. * trans-types.cc (gfc_get_array_descr_info): Likewise. gcc/jit/ChangeLog: * jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE. (get_string_for_type_id): Likewise. * jit-recording.cc (recording::context::context): Likewise. gcc/lto/ChangeLog: * lto-common.cc (lto_resolution_read): Use ARRAY_SIZE. * lto-lang.cc (lto_init): Likewise. --- gcc/c/c-decl.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index c701f07..e49879a 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -1658,7 +1658,7 @@ c_bind (location_t loc, tree decl, bool is_global) Used only by match_builtin_function_types. */ static const unsigned builtin_structptr_type_count - = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0]; + = ARRAY_SIZE (builtin_structptr_types); static GTY(()) tree last_structptr_types[builtin_structptr_type_count]; @@ -1705,10 +1705,8 @@ match_builtin_function_types (tree newtype, tree oldtype, tree newargs = TYPE_ARG_TYPES (newtype); tree tryargs = newargs; - const unsigned nlst - = sizeof last_structptr_types / sizeof last_structptr_types[0]; - const unsigned nbst - = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0]; + const unsigned nlst = ARRAY_SIZE (last_structptr_types); + const unsigned nbst = ARRAY_SIZE (builtin_structptr_types); gcc_checking_assert (nlst == nbst); -- cgit v1.1 From 702bd11fa7ddfce0d24581251e979e8a6d7c0d4d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 17 May 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6db1152d..30c3858 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,7 @@ +2022-05-16 Martin Liska + + * c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE. + 2022-05-12 Jakub Jelinek * c-parser.cc (c_parse_init): Register omp_all_memory as keyword -- cgit v1.1 From 2c16eb3157f86ae561468c540caf8eb326106b5f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 17 May 2022 15:40:27 +0200 Subject: openmp: Add support for inoutset depend-kind This patch adds support for inoutset depend-kind in depend clauses. It is very similar to the in depend-kind in that a task with a dependency with that depend-kind is dependent on all previously created sibling tasks with matching address unless they have the same depend-kind. In the in depend-kind case everything is dependent except for in -> in dependency, for inoutset everything is dependent except for inoutset -> inoutset dependency. mutexinoutset is also similar (everything is dependent except for mutexinoutset -> mutexinoutset dependency), but there is also the additional restriction that only one task with mutexinoutset for each address can be scheduled at once (i.e. mutual exclusitivty). For now we support mutexinoutset the same as inout/out, but the inoutset support is full. In order not to bump the ABI for dependencies each time (we've bumped it already once, the old ABI supports only inout/out and in depend-kind, the new ABI supports inout/out, mutexinoutset, in and depobj), this patch arranges for inoutset to be at least for the time being always handled as if it was specified through depobj even when it is not. So it uses the new ABI for that and inoutset are represented like depobj - pointer to a pair of pointers where the first one will be the actual address of the object mentioned in depend clause and second pointer will be (void *) GOMP_DEPEND_INOUTSET. 2022-05-17 Jakub Jelinek gcc/ * tree-core.h (enum omp_clause_depend_kind): Add OMP_CLAUSE_DEPEND_INOUTSET. * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_DEPEND_INOUTSET. * gimplify.cc (gimplify_omp_depend): Likewise. * omp-low.cc (lower_depend_clauses): Likewise. gcc/c-family/ * c-omp.cc (c_finish_omp_depobj): Handle OMP_CLAUSE_DEPEND_INOUTSET. gcc/c/ * c-parser.cc (c_parser_omp_clause_depend): Parse inoutset depend-kind. (c_parser_omp_depobj): Likewise. gcc/cp/ * parser.cc (cp_parser_omp_clause_depend): Parse inoutset depend-kind. (cp_parser_omp_depobj): Likewise. * cxx-pretty-print.cc (cxx_pretty_printer::statement): Handle OMP_CLAUSE_DEPEND_INOUTSET. gcc/testsuite/ * c-c++-common/gomp/all-memory-1.c (boo): Add test with inoutset depend-kind. * c-c++-common/gomp/all-memory-2.c (boo): Likewise. * c-c++-common/gomp/depobj-1.c (f1): Likewise. (f2): Adjusted expected diagnostics. * g++.dg/gomp/depobj-1.C (f4): Adjust expected diagnostics. include/ * gomp-constants.h (GOMP_DEPEND_INOUTSET): Define. libgomp/ * libgomp.h (struct gomp_task_depend_entry): Change is_in type from bool to unsigned char. * task.c (gomp_task_handle_depend): Handle GOMP_DEPEND_INOUTSET. Ignore dependencies where task->depend[i].is_in && task->depend[i].is_in == ent->is_in rather than just task->depend[i].is_in && ent->is_in. Remember whether GOMP_DEPEND_IN loop is needed and guard the loop with that conditional. (gomp_task_maybe_wait_for_dependencies): Handle GOMP_DEPEND_INOUTSET. Ignore dependencies where elem.is_in && elem.is_in == ent->is_in rather than just elem.is_in && ent->is_in. * testsuite/libgomp.c-c++-common/depend-1.c (test): Add task with inoutset depend-kind. * testsuite/libgomp.c-c++-common/depend-2.c (test): Likewise. * testsuite/libgomp.c-c++-common/depend-3.c (test): Likewise. * testsuite/libgomp.c-c++-common/depend-inoutset-1.c: New test. --- gcc/c/c-parser.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 51a0725..8df8f60 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -16067,7 +16067,7 @@ c_parser_omp_clause_affinity (c_parser *parser, tree list) depend ( depend-modifier , depend-kind: variable-list ) depend-kind: - in | out | inout | mutexinoutset | depobj + in | out | inout | mutexinoutset | depobj | inoutset depend-modifier: iterator ( iterators-definition ) */ @@ -16099,6 +16099,8 @@ c_parser_omp_clause_depend (c_parser *parser, tree list) kind = OMP_CLAUSE_DEPEND_IN; else if (strcmp ("inout", p) == 0) kind = OMP_CLAUSE_DEPEND_INOUT; + else if (strcmp ("inoutset", p) == 0) + kind = OMP_CLAUSE_DEPEND_INOUTSET; else if (strcmp ("mutexinoutset", p) == 0) kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET; else if (strcmp ("out", p) == 0) @@ -19063,12 +19065,14 @@ c_parser_omp_depobj (c_parser *parser) kind = OMP_CLAUSE_DEPEND_INOUT; else if (!strcmp ("mutexinoutset", p2)) kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET; + else if (!strcmp ("inoutset", p2)) + kind = OMP_CLAUSE_DEPEND_INOUTSET; } if (kind == OMP_CLAUSE_DEPEND_SOURCE) { clause = error_mark_node; - error_at (c2_loc, "expected %, %, % or " - "%"); + error_at (c2_loc, "expected %, %, %, " + "% or %"); } c_parens.skip_until_found_close (parser); } -- cgit v1.1 From 2c05a2d1a8e4697ea95d65c5da601aeae327e7a7 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 17 May 2022 13:41:56 -0400 Subject: c: use CONST_DECL for enumerators in TYPE_VALUES The C and C++ FEs differ in TYPE_VALUES for an enum type: an entry in the list in the C++ FE has a CONST_DECL in the TREE_VALUE, but the C FE has only the numerical value of the CONST_DECL there. This has caused me some trouble in my PR105497 patch. Using a CONST_DECL is preferable because a CONST_DECL can track more information (e.g., attributes), and you can always get the value simply by looking at its DECL_INITIAL. This turned out to be a trivial change. One place in godump.cc had to be adjusted. I'm not changing the CONST_DECL check in c_do_switch_warnings because I'll be changing it soon in my next patch. I didn't see any other checks that this patch makes redundant. gcc/c/ChangeLog: * c-decl.cc (finish_enum): Store the CONST_DECL into TREE_VALUE, not its value. gcc/ChangeLog: * godump.cc (go_output_typedef): Use the DECL_INITIAL of the TREE_VALUE. --- gcc/c/c-decl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index e49879a..8365554 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9253,7 +9253,9 @@ finish_enum (tree enumtype, tree values, tree attributes) DECL_INITIAL (enu) = ini; TREE_PURPOSE (pair) = DECL_NAME (enu); - TREE_VALUE (pair) = ini; + /* To match the C++ FE, store the CONST_DECL rather than just its + value. */ + TREE_VALUE (pair) = enu; } TYPE_VALUES (enumtype) = values; -- cgit v1.1 From 3d9439b1bb76c186958d5b86f0076f8b3017b8a2 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 18 May 2022 00:16:36 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 30c3858..25debc1 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,14 @@ +2022-05-17 Marek Polacek + + * c-decl.cc (finish_enum): Store the CONST_DECL into TREE_VALUE, not + its value. + +2022-05-17 Jakub Jelinek + + * c-parser.cc (c_parser_omp_clause_depend): Parse + inoutset depend-kind. + (c_parser_omp_depobj): Likewise. + 2022-05-16 Martin Liska * c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE. -- cgit v1.1 From 7da9a089608b0ca09683332ce014fb6184842724 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 1 Apr 2022 16:55:58 -0400 Subject: c: Implement new -Wenum-int-mismatch warning [PR105131] In C, an enumerated type is compatible with char, a signed integer type, or an unsigned integer type (6.7.2.2/5). Therefore this code compiles: enum E { l = -1, z = 0, g = 1 }; int foo(void); enum E foo(void) { return z; } if the underlying type of 'enum E' is 'int' (if not, we emit an error). This is different for typedefs, where C11 permits typedefs to be redeclared to the same type, but not to compatible types. In C++, the code above is invalid. It seems desirable to emit a warning in the C case, because it is probably a mistake and definitely a portability error, given that the choice of the underlying type is implementation-defined. To that end, this patch implements a new -Wenum-int-mismatch warning. Conveniently, we already have comptypes_check_enum_int to detect such mismatches. This warning is enabled by either -Wall or -Wc++-compat. PR c/105131 gcc/c-family/ChangeLog: * c.opt (Wenum-int-mismatch): New. gcc/c/ChangeLog: * c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type mismatches. * c-tree.h (comptypes_check_enum_int): Declare. * c-typeck.cc (comptypes): No longer static. gcc/ChangeLog: * doc/invoke.texi: Document -Wenum-int-mismatch. gcc/testsuite/ChangeLog: * gcc.dg/Wenum-int-mismatch-1.c: New test. * gcc.dg/Wenum-int-mismatch-2.c: New test. * gcc.dg/Wenum-int-mismatch-3.c: New test. * gcc.dg/Wenum-int-mismatch-4.c: New test. * gcc.dg/Wenum-int-mismatch-5.c: New test. --- gcc/c/c-decl.cc | 13 +++++++++++-- gcc/c/c-tree.h | 1 + gcc/c/c-typeck.cc | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 8365554..5266a61 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -1993,9 +1993,12 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, bool pedwarned = false; bool warned = false; + bool enum_and_int_p = false; auto_diagnostic_group d; - if (!comptypes (oldtype, newtype)) + int comptypes_result = comptypes_check_enum_int (oldtype, newtype, + &enum_and_int_p); + if (!comptypes_result) { if (TREE_CODE (olddecl) == FUNCTION_DECL && fndecl_built_in_p (olddecl, BUILT_IN_NORMAL) @@ -2137,6 +2140,13 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, return false; } } + /* Warn about enum/integer type mismatches. They are compatible types + (C2X 6.7.2.2/5), but may pose portability problems. */ + else if (enum_and_int_p && TREE_CODE (newdecl) != TYPE_DECL) + warned = warning_at (DECL_SOURCE_LOCATION (newdecl), + OPT_Wenum_int_mismatch, + "conflicting types for %q+D due to enum/integer " + "mismatch; have %qT", newdecl, newtype); /* Redeclaration of a type is a constraint violation (6.7.2.3p1), but silently ignore the redeclaration if either is in a system @@ -2146,7 +2156,6 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (TREE_CODE (newdecl) == TYPE_DECL) { bool types_different = false; - int comptypes_result; comptypes_result = comptypes_check_different_types (oldtype, newtype, &types_different); diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index c70f0ba..2bcb966 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -685,6 +685,7 @@ extern tree require_complete_type (location_t, tree); extern bool same_translation_unit_p (const_tree, const_tree); extern int comptypes (tree, tree); extern int comptypes_check_different_types (tree, tree, bool *); +extern int comptypes_check_enum_int (tree, tree, bool *); extern bool c_vla_type_p (const_tree); extern bool c_mark_addressable (tree, bool = false); extern void c_incomplete_type_error (location_t, const_tree, const_tree); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index bcfe08b..4f3611f 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -1055,7 +1055,7 @@ comptypes (tree type1, tree type2) /* Like comptypes, but if it returns non-zero because enum and int are compatible, it sets *ENUM_AND_INT_P to true. */ -static int +int comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p) { const struct tagged_tu_seen_cache * tagged_tu_seen_base1 = tagged_tu_seen_base; -- cgit v1.1 From 1cda629f96b4e982bb87343a35a6db39445d3962 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 19 May 2022 00:16:32 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 25debc1..00e236c 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2022-05-18 Marek Polacek + + PR c/105131 + * c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type + mismatches. + * c-tree.h (comptypes_check_enum_int): Declare. + * c-typeck.cc (comptypes): No longer static. + 2022-05-17 Marek Polacek * c-decl.cc (finish_enum): Store the CONST_DECL into TREE_VALUE, not -- cgit v1.1 From b43836914bdc2a37563cf31359b2c4803bfe4374 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 24 May 2022 09:12:44 +0200 Subject: openmp: Add taskwait nowait depend support [PR105378] This patch adds support for (so far C/C++) #pragma omp taskwait nowait depend(...) directive, which is like #pragma omp task depend(...) ; but slightly optimized on the library side, so that it creates the task only for the purpose of dependency tracking and doesn't actually schedule it and wait for it when the dependencies are satisfied, instead makes its dependencies satisfied right away. 2022-05-24 Jakub Jelinek PR c/105378 gcc/ * omp-builtins.def (BUILT_IN_GOMP_TASKWAIT_DEPEND_NOWAIT): New builtin. * gimplify.cc (gimplify_omp_task): Diagnose taskwait with nowait clause but no depend clauses. * omp-expand.cc (expand_taskwait_call): Use BUILT_IN_GOMP_TASKWAIT_DEPEND_NOWAIT rather than BUILT_IN_GOMP_TASKWAIT_DEPEND if nowait clause is present. gcc/c/ * c-parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause. gcc/cp/ * parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause. gcc/testsuite/ * c-c++-common/gomp/taskwait-depend-nowait-1.c: New test. libgomp/ * libgomp_g.h (GOMP_taskwait_depend_nowait): Declare. * libgomp.map (GOMP_taskwait_depend_nowait): Export at GOMP_5.1.1. * task.c (empty_task): New function. (gomp_task_run_post_handle_depend_hash): Declare earlier. (gomp_task_run_post_handle_depend): Declare. (GOMP_task): Optimize fn == empty_task if there is nothing to wait for. (gomp_task_run_post_handle_dependers): Optimize task->fn == empty_task. (GOMP_taskwait_depend_nowait): New function. * testsuite/libgomp.c-c++-common/taskwait-depend-nowait-1.c: New test. --- gcc/c/c-parser.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 8df8f60..492d995 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -20453,7 +20453,8 @@ c_parser_omp_task (location_t loc, c_parser *parser, bool *if_p) */ #define OMP_TASKWAIT_CLAUSE_MASK \ - (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) + ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static void c_parser_omp_taskwait (c_parser *parser) -- cgit v1.1 From 768f49a20f467648c8e006e2431d0da3eab11846 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 25 May 2022 00:17:06 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 00e236c..a886254 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2022-05-24 Jakub Jelinek + + PR c/105378 + * c-parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause. + 2022-05-18 Marek Polacek PR c/105131 -- cgit v1.1 From 7a3ee77a2e33b8b8ad31aea27996ebe92a5c8d83 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 25 May 2022 14:21:54 +0200 Subject: c: Improve build_component_ref diagnostics [PR91134] On the following testcase (the first dg-error line) we emit a weird diagnostics and even fixit on pointerpointer->member where pointerpointer is pointer to pointer to struct and we say 'pointerpointer' is a pointer; did you mean to use '->'? The first part is indeed true, but suggesting -> when the code already does use -> is confusing. The following patch adjusts callers so that they tell it if it is from . parsing or from -> parsing and in the latter case suggests to dereference the left operand instead by adding (* before it and ) after it (before ->). Or would a suggestion to add [0] before -> be better? 2022-05-25 Jakub Jelinek PR c/91134 gcc/c/ * c-tree.h (build_component_ref): Add ARROW_LOC location_t argument. * c-typeck.cc (build_component_ref): Likewise. If DATUM is INDIRECT_REF and ARROW_LOC isn't UNKNOWN_LOCATION, print a different diagnostic and fixit hint if DATUM has pointer type. * c-parser.cc (c_parser_postfix_expression, c_parser_omp_variable_list): Adjust build_component_ref callers. * gimple-parser.cc (c_parser_gimple_postfix_expression_after_primary): Likewise. gcc/objc/ * objc-act.cc (objc_build_component_ref): Adjust build_component_ref caller. gcc/testsuite/ * gcc.dg/pr91134.c: New test. --- gcc/c/c-parser.cc | 23 +++++++++++++++-------- gcc/c/c-tree.h | 3 ++- gcc/c/c-typeck.cc | 27 ++++++++++++++++++++------- gcc/c/gimple-parser.cc | 5 +++-- 4 files changed, 40 insertions(+), 18 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 492d995..aa24b43 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -9235,8 +9235,9 @@ c_parser_postfix_expression (c_parser *parser) if (c_parser_next_token_is (parser, CPP_NAME)) { c_token *comp_tok = c_parser_peek_token (parser); - offsetof_ref = build_component_ref - (loc, offsetof_ref, comp_tok->value, comp_tok->location); + offsetof_ref + = build_component_ref (loc, offsetof_ref, comp_tok->value, + comp_tok->location, UNKNOWN_LOCATION); c_parser_consume_token (parser); while (c_parser_next_token_is (parser, CPP_DOT) || c_parser_next_token_is (parser, @@ -9263,9 +9264,11 @@ c_parser_postfix_expression (c_parser *parser) break; } c_token *comp_tok = c_parser_peek_token (parser); - offsetof_ref = build_component_ref - (loc, offsetof_ref, comp_tok->value, - comp_tok->location); + offsetof_ref + = build_component_ref (loc, offsetof_ref, + comp_tok->value, + comp_tok->location, + UNKNOWN_LOCATION); c_parser_consume_token (parser); } else @@ -10612,7 +10615,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, finish = c_parser_peek_token (parser)->get_finish (); c_parser_consume_token (parser); expr.value = build_component_ref (op_loc, expr.value, ident, - comp_loc); + comp_loc, UNKNOWN_LOCATION); set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) @@ -10652,7 +10655,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser, build_indirect_ref (op_loc, expr.value, RO_ARROW), - ident, comp_loc); + ident, comp_loc, + expr.get_location ()); set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) @@ -13171,6 +13175,7 @@ c_parser_omp_variable_list (c_parser *parser, && c_parser_next_token_is (parser, CPP_DEREF))) { location_t op_loc = c_parser_peek_token (parser)->location; + location_t arrow_loc = UNKNOWN_LOCATION; if (c_parser_next_token_is (parser, CPP_DEREF)) { c_expr t_expr; @@ -13181,6 +13186,7 @@ c_parser_omp_variable_list (c_parser *parser, t_expr = convert_lvalue_to_rvalue (op_loc, t_expr, true, false); t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW); + arrow_loc = t_expr.get_location (); } c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_NAME)) @@ -13194,7 +13200,8 @@ c_parser_omp_variable_list (c_parser *parser, tree ident = comp_tok->value; location_t comp_loc = comp_tok->location; c_parser_consume_token (parser); - t = build_component_ref (op_loc, t, ident, comp_loc); + t = build_component_ref (op_loc, t, ident, comp_loc, + arrow_loc); } /* FALLTHROUGH */ case OMP_CLAUSE_AFFINITY: diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 2bcb966..3b322ad 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -699,7 +699,8 @@ extern struct c_expr convert_lvalue_to_rvalue (location_t, struct c_expr, extern tree decl_constant_value_1 (tree, bool); extern void mark_exp_read (tree); extern tree composite_type (tree, tree); -extern tree build_component_ref (location_t, tree, tree, location_t); +extern tree build_component_ref (location_t, tree, tree, location_t, + location_t); extern tree build_array_ref (location_t, tree, tree); extern tree build_external_ref (location_t, tree, bool, tree *); extern void pop_maybe_used (bool); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 4f3611f..6b05edd 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -2457,11 +2457,12 @@ should_suggest_deref_p (tree datum_type) /* Make an expression to refer to the COMPONENT field of structure or union value DATUM. COMPONENT is an IDENTIFIER_NODE. LOC is the location of the COMPONENT_REF. COMPONENT_LOC is the location - of COMPONENT. */ + of COMPONENT. ARROW_LOC is the location of the first -> operand if + it is from -> operator. */ tree build_component_ref (location_t loc, tree datum, tree component, - location_t component_loc) + location_t component_loc, location_t arrow_loc) { tree type = TREE_TYPE (datum); enum tree_code code = TREE_CODE (type); @@ -2577,11 +2578,23 @@ build_component_ref (location_t loc, tree datum, tree component, /* Special-case the error message for "ptr.field" for the case where the user has confused "." vs "->". */ rich_location richloc (line_table, loc); - /* "loc" should be the "." token. */ - richloc.add_fixit_replace ("->"); - error_at (&richloc, - "%qE is a pointer; did you mean to use %<->%>?", - datum); + if (TREE_CODE (datum) == INDIRECT_REF && arrow_loc != UNKNOWN_LOCATION) + { + richloc.add_fixit_insert_before (arrow_loc, "(*"); + richloc.add_fixit_insert_after (arrow_loc, ")"); + error_at (&richloc, + "%qE is a pointer to pointer; did you mean to dereference " + "it before applying %<->%> to it?", + TREE_OPERAND (datum, 0)); + } + else + { + /* "loc" should be the "." token. */ + richloc.add_fixit_replace ("->"); + error_at (&richloc, + "%qE is a pointer; did you mean to use %<->%>?", + datum); + } return error_mark_node; } else if (code != ERROR_MARK) diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index d1afd42..b909eac 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -1800,7 +1800,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, finish = c_parser_peek_token (parser)->get_finish (); c_parser_consume_token (parser); expr.value = build_component_ref (op_loc, expr.value, ident, - comp_loc); + comp_loc, UNKNOWN_LOCATION); set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) @@ -1848,7 +1848,8 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, expr.value = build_component_ref (op_loc, build_simple_mem_ref_loc (op_loc, expr.value), - ident, comp_loc); + ident, comp_loc, + expr.get_location ()); set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) -- cgit v1.1 From 3dff965cae6709a5fd1b7b05c51c3c8aba786961 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 26 May 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a886254..11d5af6 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,15 @@ +2022-05-25 Jakub Jelinek + + PR c/91134 + * c-tree.h (build_component_ref): Add ARROW_LOC location_t argument. + * c-typeck.cc (build_component_ref): Likewise. If DATUM is + INDIRECT_REF and ARROW_LOC isn't UNKNOWN_LOCATION, print a different + diagnostic and fixit hint if DATUM has pointer type. + * c-parser.cc (c_parser_postfix_expression, + c_parser_omp_variable_list): Adjust build_component_ref callers. + * gimple-parser.cc (c_parser_gimple_postfix_expression_after_primary): + Likewise. + 2022-05-24 Jakub Jelinek PR c/105378 -- cgit v1.1 From 0ccba4ed8571c18c7015413441e971d4863c3644 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 27 May 2022 12:48:48 +0200 Subject: openmp: Add support for enter clause on declare target OpenMP 5.1 and earlier had 2 different uses of to clause, one for target update construct with one semantics, and one for declare target directive with a different semantics. Under the hood we were using OMP_CLAUSE_TO_DECLARE to represent the latter. OpenMP 5.2 renamed the declare target clause to to enter, the old one is kept as a deprecated alias. As we are far from having full OpenMP 5.2 support, this patch adds support for the enter clause (and renames OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER with a flag to tell the spelling of the clause for better diagnostics), but doesn't deprecate the to clause on declare target just yet (that should be done as one of the last steps in 5.2 support). 2022-05-27 Jakub Jelinek gcc/ * tree-core.h (enum omp_clause_code): Rename OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER. * tree.h (OMP_CLAUSE_ENTER_TO): Define. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Rename OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER. * tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE, if OMP_CLAUSE_ENTER_TO, print "to" instead of "enter". * tree-nested.cc (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Handle OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE. gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ENTER. gcc/c/ * c-parser.cc (c_parser_omp_clause_name): Parse enter clause. (c_parser_omp_all_clauses): For to clause on declare target, use OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause. (c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE. * c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause name in diagnostics instead of omp_clause_code_name[OMP_CLAUSE_CODE (c)]. gcc/cp/ * parser.cc (cp_parser_omp_clause_name): Parse enter clause. (cp_parser_omp_all_clauses): For to clause on declare target, use OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause. (cp_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE. * semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause name in diagnostics instead of omp_clause_code_name[OMP_CLAUSE_CODE (c)]. gcc/testsuite/ * c-c++-common/gomp/clauses-3.c: Add tests with enter clause instead of to or modify some existing to clauses to enter. * c-c++-common/gomp/declare-target-1.c: Likewise. * c-c++-common/gomp/declare-target-2.c: Likewise. * c-c++-common/gomp/declare-target-3.c: Likewise. * g++.dg/gomp/attrs-9.C: Likewise. * g++.dg/gomp/declare-target-1.C: Likewise. libgomp/ * testsuite/libgomp.c-c++-common/target-40.c: Modify some existing to clauses to enter. * testsuite/libgomp.c/target-41.c: Likewise. --- gcc/c/c-parser.cc | 23 +++++++++++++++++++---- gcc/c/c-typeck.cc | 21 ++++++++++++--------- 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index aa24b43..678d914 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -12771,6 +12771,10 @@ c_parser_omp_clause_name (c_parser *parser) else if (!strcmp ("dist_schedule", p)) result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; break; + case 'e': + if (!strcmp ("enter", p)) + result = PRAGMA_OMP_CLAUSE_ENTER; + break; case 'f': if (!strcmp ("filter", p)) result = PRAGMA_OMP_CLAUSE_FILTER; @@ -17055,9 +17059,13 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, break; case PRAGMA_OMP_CLAUSE_TO: if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK)) != 0) - clauses - = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE, - clauses); + { + tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER, + clauses); + for (tree c = nl; c != clauses; c = OMP_CLAUSE_CHAIN (c)) + OMP_CLAUSE_ENTER_TO (c) = 1; + clauses = nl; + } else clauses = c_parser_omp_clause_to (parser, clauses); c_name = "to"; @@ -17158,6 +17166,12 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, clauses); c_name = "simd"; break; + case PRAGMA_OMP_CLAUSE_ENTER: + clauses + = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER, + clauses); + c_name = "enter"; + break; default: c_parser_error (parser, "expected %<#pragma omp%> clause"); goto saw_error; @@ -22006,6 +22020,7 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, #define OMP_DECLARE_TARGET_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TO) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ENTER) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE)) @@ -22020,7 +22035,7 @@ c_parser_omp_declare_target (c_parser *parser) "#pragma omp declare target"); else if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)) { - clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE, + clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER, clauses); clauses = c_finish_omp_clauses (clauses, C_ORT_OMP); c_parser_skip_to_pragma_eol (parser); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 6b05edd..21a93c3 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -15248,37 +15248,40 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } break; - case OMP_CLAUSE_TO_DECLARE: + case OMP_CLAUSE_ENTER: case OMP_CLAUSE_LINK: t = OMP_CLAUSE_DECL (c); + const char *cname; + cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)]; + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER + && OMP_CLAUSE_ENTER_TO (c)) + cname = "to"; if (TREE_CODE (t) == FUNCTION_DECL - && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE) + && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER) ; else if (!VAR_P (t)) { - if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER) error_at (OMP_CLAUSE_LOCATION (c), "%qE is neither a variable nor a function name in " - "clause %qs", t, - omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + "clause %qs", t, cname); else error_at (OMP_CLAUSE_LOCATION (c), - "%qE is not a variable in clause %qs", t, - omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + "%qE is not a variable in clause %qs", t, cname); remove = true; } else if (DECL_THREAD_LOCAL_P (t)) { error_at (OMP_CLAUSE_LOCATION (c), "%qD is threadprivate variable in %qs clause", t, - omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + cname); remove = true; } else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, - omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + cname); remove = true; } if (remove) -- cgit v1.1 From d9176e643f385c3ef3b8c28cbc0468776fd8a14f Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 28 May 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 11d5af6..291c0dd 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,17 @@ +2022-05-27 Jakub Jelinek + + * c-parser.cc (c_parser_omp_clause_name): Parse enter clause. + (c_parser_omp_all_clauses): For to clause on declare target, use + OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of + OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER. + (OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause. + (c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of + OMP_CLAUSE_TO_DECLARE. + * c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead + of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause + name in diagnostics instead of + omp_clause_code_name[OMP_CLAUSE_CODE (c)]. + 2022-05-25 Jakub Jelinek PR c/91134 -- cgit v1.1 From 931249276acb4bdab778fe2bf4e81a1a31a78e6c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 28 May 2022 08:26:57 +0200 Subject: openmp: Adjust diagnostics about same variable in link and to/enter clauses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote: > The 'TO'/'ENTER' usage is first stored in a linked list – and > then as attribute to the symbol. I am not sure how to handle it best. This reminds me I've left the C/C++ FE diagnostics about mixing link and to/enter on the same variable in separate directives as is, so it always talked about mixing link and to clauses. This patch adjusts it, so that if link is first, it talks about the clause actually used and if link is later, uses to or enter together in the wording. 2022-05-28 Jakub Jelinek gcc/c/ * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was seen first, use "%" or "%" depending on OMP_CLAUSE_ENTER_TO of the current clause, otherwise use "% or %" wording. gcc/cp/ * parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was seen first, use "%" or "%" depending on OMP_CLAUSE_ENTER_TO of the current clause, otherwise use "% or %" wording. gcc/testsuite/ * c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of link and to/enter clauses on separate directives. --- gcc/c/c-parser.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 678d914..7cc4d93c 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -22067,9 +22067,14 @@ c_parser_omp_declare_target (c_parser *parser) id = get_identifier ("omp declare target"); if (at2) { - error_at (OMP_CLAUSE_LOCATION (c), - "%qD specified both in declare target % and %" - " clauses", t); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER) + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and %qs" + " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter"); + else + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and " + "% or % clauses", t); continue; } if (!at1) -- cgit v1.1 From 37b3b5dabdcdbbc0d191b050116930010dd06acc Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 29 May 2022 00:16:31 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 291c0dd..1de21db 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2022-05-28 Jakub Jelinek + + * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was + seen first, use "%" or "%" depending on + OMP_CLAUSE_ENTER_TO of the current clause, otherwise use + "% or %" wording. + 2022-05-27 Jakub Jelinek * c-parser.cc (c_parser_omp_clause_name): Parse enter clause. -- cgit v1.1 From f38b20d68fade5a922b9f68c4c3841e653d1b83c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 31 May 2022 11:41:52 +0200 Subject: openmp: Add support for firstprivate and allocate clauses on scope construct OpenMP 5.2 adds support for firstprivate and allocate clauses on the scope construct and this patch adds that support to GCC. 5.2 unfortunately (IMNSHO mistakenly) marked scope construct as worksharing, which implies that it isn't possible to nest inside of it other scope, worksharing loop, sections, explicit barriers, single etc. which would make scope far less useful. I'm not implementing that part, keeping the 5.1 behavior here, and will file an issue to revert that for OpenMP 6.0. But, for firstprivate it keeps the restriction that is now implied from worksharing construct that listed var can't be private in outer context, where for reduction 5.1 had similar restriction explicit even for scope and 5.2 has it implicitly through worksharing construct. 2022-05-31 Jakub Jelinek gcc/ * omp-low.cc (build_outer_var_ref): For code == OMP_CLAUSE_ALLOCATE allow var to be private in the outer context. (lower_private_allocate): Pass OMP_CLAUSE_ALLOCATE as last argument to build_outer_var_ref. gcc/c/ * c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate clauses. gcc/cp/ * parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate clauses. gcc/testsuite/ * c-c++-common/gomp/scope-5.c: New test. * c-c++-common/gomp/scope-6.c: New test. * g++.dg/gomp/attrs-1.C (bar): Add firstprivate and allocate clauses to scope construct. * g++.dg/gomp/attrs-2.C (bar): Likewise. libgomp/ * testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add testcase for scope construct with allocate clause. * testsuite/libgomp.c-c++-common/allocate-3.c (foo): Likewise. * testsuite/libgomp.c-c++-common/scope-2.c: New test. --- gcc/c/c-parser.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 7cc4d93c..c9a8d14 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -20413,7 +20413,9 @@ c_parser_omp_single (location_t loc, c_parser *parser, bool *if_p) #define OMP_SCOPE_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static tree -- cgit v1.1 From a8b5d63503b8cf49de32d241218057409f8731ac Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 27 May 2022 12:15:36 -0400 Subject: build: TAGS and .cc transition A few globs missed in the .c -> .cc transition. Some targets were looking at both *.c and *.cc, but there are no longer any .c files to scan. gcc/ChangeLog: * Makefile.in (TAGS): Look at libcpp/*.cc. gcc/c/ChangeLog: * Make-lang.in (c.tags): Look at *.cc. gcc/cp/ChangeLog: * Make-lang.in (c++.tags): Just look at *.cc. gcc/d/ChangeLog: * Make-lang.in (d.tags): Just look at *.cc. gcc/fortran/ChangeLog: * Make-lang.in (fortran.tags): Look at *.cc. gcc/go/ChangeLog: * Make-lang.in (go.tags): Look at *.cc. gcc/objc/ChangeLog: * Make-lang.in (objc.tags): Look at *.cc. gcc/objcp/ChangeLog: * Make-lang.in (obj-c++.tags): Look at *.cc. --- gcc/c/Make-lang.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 1367a10..9bd9c0e 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -109,7 +109,7 @@ c.srcinfo: c.srcextra: gengtype-lex.cc -cp -p $^ $(srcdir) c.tags: force - cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.c *.h; \ + cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.cc *.h; \ $(ETAGS) --include TAGS.sub --include ../TAGS.sub c.man: c.srcman: -- cgit v1.1 From 820ead4519c266c83b4e3d11484a66d6691bc441 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 1 Jun 2022 00:16:34 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1de21db..3f1a135 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2022-05-31 Jason Merrill + + * Make-lang.in (c.tags): Look at *.cc. + +2022-05-31 Jakub Jelinek + + * c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate + clauses. + 2022-05-28 Jakub Jelinek * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was -- cgit v1.1 From 6cf276ddf22066af780335cd0072d2c27aabe468 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 2 Jun 2022 15:40:22 -0400 Subject: diagnostics: add SARIF output format This patch adds support to gcc's diagnostic subsystem for emitting diagnostics in SARIF, aka the Static Analysis Results Interchange Format: https://sarifweb.azurewebsites.net/ by extending -fdiagnostics-format= to add two new options: -fdiagnostics-format=sarif-stderr and: -fdiagnostics-format=sarif-file The patch targets SARIF v2.1.0 This is a JSON-based format suited for capturing the results of static analysis tools (like GCC's -fanalyzer), but it can also be used for plain GCC warnings and errors. SARIF supports per-event metadata in diagnostic paths such as ["acquire", "resource"] and ["release", "lock"] (specifically, the threadFlowLocation "kinds" property: SARIF v2.1.0 section 3.38.8), so the patch extends GCC"s diagnostic_event subclass with a "struct meaning" with similar purpose. The patch implements this for -fanalyzer so that the various state-machine-based warnings set these in the SARIF output. The heart of the implementation is in the new file diagnostic-format-sarif.cc. Much of the rest of the patch is interface classes, isolating the diagnostic subsystem (which has no knowledge of e.g. tree or langhook) from the "client" code in the compiler proper cc1 etc). The patch adds a langhook for specifying the SARIF v2.1.0 "artifact.sourceLanguage" property, based on the list in SARIF v2.1.0 Appendix J. The patch adds automated DejaGnu tests to our testsuite via new scan-sarif-file and scan-sarif-file-not directives (although these merely use regexps, rather than attempting to use a proper JSON parser). I've tested the patch by hand using the validator at: https://sarifweb.azurewebsites.net/Validation and the react-based viewer at: https://microsoft.github.io/sarif-web-component/ which successfully shows most of the information (although not paths, and not CWE IDs), and I've fixed all validation errors I've seen (though bugs no doubt remain). I've also tested the generated SARIF using the VS Code extension linked to from the SARIF website; I'm a novice with VS Code, but it seems to be able to handle my generated SARIF files (e.g. showing the data in the SARIF tab, and showing squiggly underlines under issues, and when I click on them, it visualizes the events in the path inline within the source window). Has anyone written an Emacs mode for SARIF files? (pretty please) gcc/ChangeLog: * Makefile.in (OBJS): Add tree-diagnostic-client-data-hooks.o and tree-logical-location.o. (OBJS-libcommon): Add diagnostic-format-sarif.o; reorder. (CFLAGS-tree-diagnostic-client-data-hooks.o): Add TARGET_NAME. * common.opt (fdiagnostics-format=): Add sarif-stderr and sarif-file. (sarif-stderr, sarif-file): New enum values. * diagnostic-client-data-hooks.h: New file. * diagnostic-format-sarif.cc: New file. * diagnostic-path.h (enum diagnostic_event::verb): New enum. (enum diagnostic_event::noun): New enum. (enum diagnostic_event::property): New enum. (struct diagnostic_event::meaning): New struct. (diagnostic_event::get_logical_location): New vfunc. (diagnostic_event::get_meaning): New vfunc. (simple_diagnostic_event::get_logical_location): New vfunc impl. (simple_diagnostic_event::get_meaning): New vfunc impl. * diagnostic.cc: Include "diagnostic-client-data-hooks.h". (diagnostic_initialize): Initialize m_client_data_hooks. (diagnostic_finish): Clean up m_client_data_hooks. (diagnostic_event::meaning::dump_to_pp): New. (diagnostic_event::meaning::maybe_get_verb_str): New. (diagnostic_event::meaning::maybe_get_noun_str): New. (diagnostic_event::meaning::maybe_get_property_str): New. (get_cwe_url): Make non-static. (diagnostic_output_format_init): Handle DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. * diagnostic.h (enum diagnostics_output_format): Add DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR and DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE. (class diagnostic_client_data_hooks): New forward decl. (class logical_location): New forward decl. (diagnostic_context::m_client_data_hooks): New field. (diagnostic_output_format_init_sarif_stderr): New decl. (diagnostic_output_format_init_sarif_file): New decl. (get_cwe_url): New decl. * doc/invoke.texi (-fdiagnostics-format=): Add sarif-stderr and sarif-file. * doc/sourcebuild.texi (Scan a particular file): Add scan-sarif-file and scan-sarif-file-not. * langhooks-def.h (lhd_get_sarif_source_language): New decl. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. * langhooks.cc (lhd_get_sarif_source_language): New. * langhooks.h (lang_hooks::get_sarif_source_language): New field. * logical-location.h: New file. * plugin.cc (struct for_each_plugin_closure): New. (for_each_plugin_cb): New. (for_each_plugin): New. * plugin.h (for_each_plugin): New decl. * tree-diagnostic-client-data-hooks.cc: New file. * tree-diagnostic.cc: Include "diagnostic-client-data-hooks.h". (tree_diagnostics_defaults): Populate m_client_data_hooks. * tree-logical-location.cc: New file. * tree-logical-location.h: New file. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/analyzer/ChangeLog: * checker-path.cc (checker_event::get_meaning): New. (function_entry_event::get_meaning): New. (state_change_event::get_desc): Add dump of meaning of the event to the -fanalyzer-verbose-state-changes output. (state_change_event::get_meaning): New. (cfg_edge_event::get_meaning): New. (call_event::get_meaning): New. (return_event::get_meaning): New. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New. * checker-path.h: Include "tree-logical-location.h". (checker_event::checker_event): Construct m_logical_loc. (checker_event::get_logical_location): New. (checker_event::get_meaning): New decl. (checker_event::m_logical_loc): New. (function_entry_event::get_meaning): New decl. (state_change_event::get_meaning): New decl. (cfg_edge_event::get_meaning): New decl. (call_event::get_meaning): New decl. (return_event::get_meaning): New decl. (start_consolidated_cfg_edges_event::get_meaning): New. (warning_event::get_meaning): New decl. * pending-diagnostic.h: Include "diagnostic-path.h". (pending_diagnostic::get_meaning_for_state_change): New vfunc. * sm-file.cc (file_diagnostic::get_meaning_for_state_change): New vfunc impl. * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change): Likewise. * sm-sensitive.cc (exposure_through_output_file::get_meaning_for_state_change): Likewise. * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change): Likewise. * varargs.cc (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise. gcc/c/ChangeLog: * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (c_get_sarif_source_language): New. * c-tree.h (c_get_sarif_source_language): New decl. gcc/cp/ChangeLog: * cp-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (cp_get_sarif_source_language): New. gcc/d/ChangeLog: * d-lang.cc (d_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/fortran/ChangeLog: * f95-lang.cc (gfc_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/go/ChangeLog: * go-lang.cc (go_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. gcc/objc/ChangeLog: * objc-act.h (objc_get_sarif_source_language): New decl. * objc-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. (objc_get_sarif_source_language): New. gcc/testsuite/ChangeLog: * c-c++-common/diagnostic-format-sarif-file-1.c: New test. * c-c++-common/diagnostic-format-sarif-file-2.c: New test. * c-c++-common/diagnostic-format-sarif-file-3.c: New test. * c-c++-common/diagnostic-format-sarif-file-4.c: New test. * gcc.dg/analyzer/file-meaning-1.c: New test. * gcc.dg/analyzer/malloc-meaning-1.c: New test. * gcc.dg/analyzer/malloc-sarif-1.c: New test. * gcc.dg/plugin/analyzer_gil_plugin.c (gil_diagnostic::get_meaning_for_state_change): New vfunc impl. * gcc.dg/plugin/diagnostic-test-paths-5.c: New test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-paths-5.c to tests for diagnostic_plugin_test_paths.c. * lib/gcc-dg.exp: Load scansarif.exp. * lib/scansarif.exp: New test. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Add load_gcc_lib of scansarif.exp. libgomp/ChangeLog: * testsuite/lib/libgomp.exp: Add load_gcc_lib of scansarif.exp. libitm/ChangeLog: * testsuite/lib/libitm.exp: Add load_gcc_lib of scansarif.exp. libphobos/ChangeLog: * testsuite/lib/libphobos-dg.exp: Add load_gcc_lib of scansarif.exp. Signed-off-by: David Malcolm --- gcc/c/c-lang.cc | 12 ++++++++++++ gcc/c/c-tree.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/c-lang.cc b/gcc/c/c-lang.cc index eecc0a0..0e67045 100644 --- a/gcc/c/c-lang.cc +++ b/gcc/c/c-lang.cc @@ -46,9 +46,21 @@ enum c_language_kind c_language = clk_c; #undef LANG_HOOKS_GET_SUBSTRING_LOCATION #define LANG_HOOKS_GET_SUBSTRING_LOCATION c_get_substring_location +#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE +#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE c_get_sarif_source_language + /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; +/* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property, + based on the list in SARIF v2.1.0 Appendix J. */ + +const char * +c_get_sarif_source_language (const char *) +{ + return "c"; +} + #if CHECKING_P namespace selftest { diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 3b322ad..e655afd 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -837,6 +837,8 @@ set_c_expr_source_range (c_expr *expr, /* In c-fold.cc */ extern vec incomplete_record_decls; +extern const char *c_get_sarif_source_language (const char *filename); + #if CHECKING_P namespace selftest { extern void run_c_tests (void); -- cgit v1.1 From b168441c8a6b7cb6b6623694eb9e1cc87a3d51af Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 3 Jun 2022 00:16:40 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3f1a135..0bc8b8e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2022-06-02 David Malcolm + + * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. + (c_get_sarif_source_language): New. + * c-tree.h (c_get_sarif_source_language): New decl. + 2022-05-31 Jason Merrill * Make-lang.in (c.tags): Look at *.cc. -- cgit v1.1 From 03b71406323ddc065b1d7837d8b43b17e4b048b5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Jun 2022 10:05:08 +0200 Subject: openmp: Add support for OpenMP 5.2 linear clause syntax for C/C++ The syntax for linear clause changed in 5.2, the original syntax which is still valid is: linear (var1, var2) linear (var3, var4 : step1) The 4.5 syntax with modifiers like: linear (val (var5, var6)) linear (val (var7, var8) : step2) is still supported in 5.2, but is deprecated there. Instead, one can use a new syntax: linear (var9, var10 : val) linear (var11, var12 : step (step3), val) As val, ref, uval or step (someexpr) can be valid expressions (and especially in C++ can be const / constexpr / consteval), the spec says that when the whole step expression is val (or ref or uval) or step ( ... ) then it is the new modifier syntax, one can use + 0 or 0 + or 1 * or * 1 or ()s to say it is the old step expression. Also, 5.2 now allows val modifier to be specified even outside of declare simd (but not the other modifiers). I've implemented this for the new modifier syntax only, the old one keeps the old restriction (which is why OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag has been introduced). 2022-06-07 Jakub Jelinek gcc/ * tree.h (OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER): Define. * tree-pretty-print.cc (dump_omp_clause) : Adjust clause printing style depending on OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER. gcc/c/ * c-parser.cc (c_parser_omp_clause_linear): Parse OpenMP 5.2 style linear clause modifiers. Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when old style modifiers are used. * c-typeck.cc (c_finish_omp_clauses): Only reject linear clause with val modifier on simd or for if the old style modifiers are used. gcc/cp/ * parser.cc (cp_parser_omp_clause_linear): Parse OpenMP 5.2 style linear clause modifiers. Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when old style modifiers are used. * semantics.cc (finish_omp_clauses): Only reject linear clause with val modifier on simd or for if the old style modifiers are used. gcc/fortran/ * trans-openmp.cc (gfc_trans_omp_clauses): Set OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER on OMP_CLAUSE_LINEAR clauses unconditionally for now. gcc/testsuite/ * c-c++-common/gomp/linear-2.c: New test. * c-c++-common/gomp/linear-3.c: New test. * g++.dg/gomp/linear-3.C: New test. * g++.dg/gomp/linear-4.C: New test. * g++.dg/gomp/linear-5.C: New test. --- gcc/c/c-parser.cc | 111 +++++++++++++++++++++++++++++++++++++++++++++++++----- gcc/c/c-typeck.cc | 6 ++- 2 files changed, 106 insertions(+), 11 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index c9a8d14..1704a52 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -15668,7 +15668,17 @@ c_parser_omp_clause_allocate (c_parser *parser, tree list) OpenMP 4.5: linear ( modifier ( variable-list ) ) - linear ( modifier ( variable-list ) : expression ) */ + linear ( modifier ( variable-list ) : expression ) + + modifier: + val + + OpenMP 5.2: + linear ( variable-list : modifiers-list ) + + modifiers: + val + step ( expression ) */ static tree c_parser_omp_clause_linear (c_parser *parser, tree list) @@ -15676,6 +15686,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list) location_t clause_loc = c_parser_peek_token (parser)->location; tree nl, c, step; enum omp_clause_linear_kind kind = OMP_CLAUSE_LINEAR_DEFAULT; + bool old_linear_modifier = false; matching_parens parens; if (!parens.require_open (parser)) @@ -15691,6 +15702,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list) kind = OMP_CLAUSE_LINEAR_DEFAULT; if (kind != OMP_CLAUSE_LINEAR_DEFAULT) { + old_linear_modifier = true; c_parser_consume_token (parser); c_parser_consume_token (parser); } @@ -15706,15 +15718,95 @@ c_parser_omp_clause_linear (c_parser *parser, tree list) { c_parser_consume_token (parser); location_t expr_loc = c_parser_peek_token (parser)->location; - c_expr expr = c_parser_expr_no_commas (parser, NULL); - expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); - step = expr.value; - step = c_fully_fold (step, false, NULL); - if (!INTEGRAL_TYPE_P (TREE_TYPE (step))) + bool has_modifiers = false; + if (kind == OMP_CLAUSE_LINEAR_DEFAULT + && c_parser_next_token_is (parser, CPP_NAME)) + { + c_token *tok = c_parser_peek_token (parser); + const char *p = IDENTIFIER_POINTER (tok->value); + unsigned int pos = 0; + if (strcmp ("val", p) == 0) + pos = 2; + else if (strcmp ("step", p) == 0 + && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN) + { + pos = 3; + if (c_parser_check_balanced_raw_token_sequence (parser, &pos) + && (c_parser_peek_nth_token_raw (parser, pos)->type + == CPP_CLOSE_PAREN)) + ++pos; + else + pos = 0; + } + if (pos) + { + tok = c_parser_peek_nth_token_raw (parser, pos); + if (tok->type == CPP_COMMA || tok->type == CPP_CLOSE_PAREN) + has_modifiers = true; + } + } + if (has_modifiers) + { + step = NULL_TREE; + while (c_parser_next_token_is (parser, CPP_NAME)) + { + c_token *tok = c_parser_peek_token (parser); + const char *p = IDENTIFIER_POINTER (tok->value); + if (strcmp ("val", p) == 0) + { + if (kind != OMP_CLAUSE_LINEAR_DEFAULT) + error_at (tok->location, "multiple linear modifiers"); + kind = OMP_CLAUSE_LINEAR_DEFAULT; + c_parser_consume_token (parser); + } + else if (strcmp ("step", p) == 0) + { + c_parser_consume_token (parser); + matching_parens parens2; + if (parens2.require_open (parser)) + { + if (step) + error_at (tok->location, + "multiple % modifiers"); + expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, + true); + step = c_fully_fold (expr.value, false, NULL); + if (!INTEGRAL_TYPE_P (TREE_TYPE (step))) + { + error_at (clause_loc, "% clause step " + "expression must be integral"); + step = integer_one_node; + } + parens2.skip_until_found_close (parser); + } + else + break; + } + else + break; + if (c_parser_next_token_is (parser, CPP_COMMA)) + { + c_parser_consume_token (parser); + continue; + } + break; + } + if (!step) + step = integer_one_node; + } + else { - error_at (clause_loc, "% clause step expression must " - "be integral"); - step = integer_one_node; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + step = c_fully_fold (expr.value, false, NULL); + if (!INTEGRAL_TYPE_P (TREE_TYPE (step))) + { + error_at (clause_loc, "% clause step expression must " + "be integral"); + step = integer_one_node; + } } } @@ -15725,6 +15817,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list) { OMP_CLAUSE_LINEAR_STEP (c) = step; OMP_CLAUSE_LINEAR_KIND (c) = kind; + OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c) = old_linear_modifier; } parens.skip_until_found_close (parser); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 21a93c3..fd0a7f8 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -14478,11 +14478,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) need_implicitly_determined = true; t = OMP_CLAUSE_DECL (c); if (ort != C_ORT_OMP_DECLARE_SIMD - && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT) + && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT + && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c)) { error_at (OMP_CLAUSE_LOCATION (c), "modifier should not be specified in % " - "clause on % or % constructs"); + "clause on % or % constructs when not " + "using OpenMP 5.2 modifiers"); OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; } if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) -- cgit v1.1 From 445ba599cb4e9a766526d30216863e3e01586557 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 8 Jun 2022 00:16:28 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0bc8b8e..5be3941 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,13 @@ +2022-06-07 Jakub Jelinek + + * c-parser.cc (c_parser_omp_clause_linear): Parse OpenMP 5.2 + style linear clause modifiers. Set + OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when + old style modifiers are used. + * c-typeck.cc (c_finish_omp_clauses): Only reject linear clause + with val modifier on simd or for if the old style modifiers are + used. + 2022-06-02 David Malcolm * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine. -- cgit v1.1 From d3e0da54c16e5383b9b969b7b40f7eadb35b0b8e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 16 Jun 2022 17:36:38 -0400 Subject: c-decl: fix "inform" grouping and conditionalization Whilst working on SARIF output I noticed some places where followup notes weren't being properly associated with their errors/warnings in c-decl.cc. Whilst fixing those I noticed some places where we "inform" after a "warning" without checking that the warning was actually emitted. Fixed the various issues seen in gcc/c/c-decl.cc thusly. gcc/c/ChangeLog: * c-decl.cc (implicitly_declare): Add auto_diagnostic_group to group the warning with any note. (warn_about_goto): Likewise to group error or warning with note. Bail out if the warning wasn't emitted, to avoid emitting orphan notes. (lookup_label_for_goto): Add auto_diagnostic_group to group the error with the note. (check_earlier_gotos): Likewise. (c_check_switch_jump_warnings): Likewise for any error/warning. Conditionalize emission of the notes. (diagnose_uninitialized_cst_member): Likewise for warning, conditionalizing emission of the note. (grokdeclarator): Add auto_diagnostic_group to group the "array type has incomplete element type" error with any note. (parser_xref_tag): Add auto_diagnostic_group to group warnings with their notes. Conditionalize emission of notes. (start_struct): Add auto_diagnostic_group to group the "redefinition of" errors with any note. (start_enum): Likewise for "redeclaration of %" error. (check_for_loop_decls): Likewise for pre-C99 error. Signed-off-by: David Malcolm --- gcc/c/c-decl.cc | 65 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 5266a61..ae8990c 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -3697,6 +3697,7 @@ implicitly_declare (location_t loc, tree functionid) (TREE_TYPE (decl))); if (!comptypes (newtype, TREE_TYPE (decl))) { + auto_diagnostic_group d; bool warned = warning_at (loc, OPT_Wbuiltin_declaration_mismatch, "incompatible implicit " @@ -3890,12 +3891,14 @@ lookup_label (tree name) static void warn_about_goto (location_t goto_loc, tree label, tree decl) { + auto_diagnostic_group d; if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) error_at (goto_loc, "jump into scope of identifier with variably modified type"); else - warning_at (goto_loc, OPT_Wjump_misses_init, - "jump skips variable initialization"); + if (!warning_at (goto_loc, OPT_Wjump_misses_init, + "jump skips variable initialization")) + return; inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl); } @@ -3950,6 +3953,7 @@ lookup_label_for_goto (location_t loc, tree name) if (label_vars->label_bindings.left_stmt_expr) { + auto_diagnostic_group d; error_at (loc, "jump into statement expression"); inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); } @@ -4040,6 +4044,7 @@ check_earlier_gotos (tree label, struct c_label_vars* label_vars) if (g->goto_bindings.stmt_exprs > 0) { + auto_diagnostic_group d; error_at (g->loc, "jump into statement expression"); inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); @@ -4159,19 +4164,26 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings, { if (decl_jump_unsafe (b->decl)) { + auto_diagnostic_group d; + bool emitted; if (variably_modified_type_p (TREE_TYPE (b->decl), NULL_TREE)) { saw_error = true; error_at (case_loc, ("switch jumps into scope of identifier with " "variably modified type")); + emitted = true; } else - warning_at (case_loc, OPT_Wjump_misses_init, - "switch jumps over variable initialization"); - inform (switch_loc, "switch starts here"); - inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here", - b->decl); + emitted + = warning_at (case_loc, OPT_Wjump_misses_init, + "switch jumps over variable initialization"); + if (emitted) + { + inform (switch_loc, "switch starts here"); + inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here", + b->decl); + } } } } @@ -4179,6 +4191,7 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings, if (switch_bindings->stmt_exprs > 0) { saw_error = true; + auto_diagnostic_group d; error_at (case_loc, "switch jumps into statement expression"); inform (switch_loc, "switch starts here"); } @@ -5317,10 +5330,11 @@ diagnose_uninitialized_cst_member (tree decl, tree type) if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST) { - warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, - "uninitialized const member in %qT is invalid in C++", - strip_array_types (TREE_TYPE (decl))); - inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field); + auto_diagnostic_group d; + if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, + "uninitialized const member in %qT is invalid in C++", + strip_array_types (TREE_TYPE (decl)))) + inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field); } if (RECORD_OR_UNION_TYPE_P (field_type)) @@ -6942,6 +6956,7 @@ grokdeclarator (const struct c_declarator *declarator, /* Complain about arrays of incomplete types. */ if (!COMPLETE_TYPE_P (type)) { + auto_diagnostic_group d; error_at (loc, "array type has incomplete element type %qT", type); /* See if we can be more helpful. */ @@ -8201,25 +8216,26 @@ parser_xref_tag (location_t loc, enum tree_code code, tree name, && loc != UNKNOWN_LOCATION && warn_cxx_compat) { + auto_diagnostic_group d; switch (code) { case ENUMERAL_TYPE: - warning_at (loc, OPT_Wc___compat, - ("enum type defined in struct or union " - "is not visible in C++")); - inform (refloc, "enum type defined here"); + if (warning_at (loc, OPT_Wc___compat, + ("enum type defined in struct or union " + "is not visible in C++"))) + inform (refloc, "enum type defined here"); break; case RECORD_TYPE: - warning_at (loc, OPT_Wc___compat, - ("struct defined in struct or union " - "is not visible in C++")); - inform (refloc, "struct defined here"); + if (warning_at (loc, OPT_Wc___compat, + ("struct defined in struct or union " + "is not visible in C++"))) + inform (refloc, "struct defined here"); break; case UNION_TYPE: - warning_at (loc, OPT_Wc___compat, - ("union defined in struct or union " - "is not visible in C++")); - inform (refloc, "union defined here"); + if (warning_at (loc, OPT_Wc___compat, + ("union defined in struct or union " + "is not visible in C++"))) + inform (refloc, "union defined here"); break; default: gcc_unreachable(); @@ -8295,6 +8311,7 @@ start_struct (location_t loc, enum tree_code code, tree name, if (TYPE_SIZE (ref)) { + auto_diagnostic_group d; if (code == UNION_TYPE) error_at (loc, "redefinition of %", name); else @@ -9121,6 +9138,7 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name) if (TYPE_VALUES (enumtype) != NULL_TREE) { /* This enum is a named one that has been declared already. */ + auto_diagnostic_group d; error_at (loc, "redeclaration of %", name); if (enumloc != UNKNOWN_LOCATION) inform (enumloc, "originally defined here"); @@ -10428,6 +10446,7 @@ check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error) /* If we get here, declarations have been used in a for loop without the C99 for loop scope. This doesn't make much sense, so don't allow it. */ + auto_diagnostic_group d; error_at (loc, "% loop initial declarations " "are only allowed in C99 or C11 mode"); if (hint) -- cgit v1.1 From bc7e9f76756f2f164bb5dc70b59bc0d838f9fa96 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 17 Jun 2022 00:16:23 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 5be3941..077b726 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,26 @@ +2022-06-16 David Malcolm + + * c-decl.cc (implicitly_declare): Add auto_diagnostic_group to + group the warning with any note. + (warn_about_goto): Likewise to group error or warning with note. + Bail out if the warning wasn't emitted, to avoid emitting orphan + notes. + (lookup_label_for_goto): Add auto_diagnostic_group to + group the error with the note. + (check_earlier_gotos): Likewise. + (c_check_switch_jump_warnings): Likewise for any error/warning. + Conditionalize emission of the notes. + (diagnose_uninitialized_cst_member): Likewise for warning, + conditionalizing emission of the note. + (grokdeclarator): Add auto_diagnostic_group to group the "array + type has incomplete element type" error with any note. + (parser_xref_tag): Add auto_diagnostic_group to group warnings + with their notes. Conditionalize emission of notes. + (start_struct): Add auto_diagnostic_group to group the + "redefinition of" errors with any note. + (start_enum): Likewise for "redeclaration of %" error. + (check_for_loop_decls): Likewise for pre-C99 error. + 2022-06-07 Jakub Jelinek * c-parser.cc (c_parser_omp_clause_linear): Parse OpenMP 5.2 -- cgit v1.1