From 499f8d4c2bc585b985882b4716f35b4c1553ce32 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 9 Feb 2022 20:45:31 +0100 Subject: c: Fix up __builtin_assoc_barrier handling in the C FE [PR104427] The following testcase ICEs, because when creating PAREN_EXPR for __builtin_assoc_barrier the FE doesn't do the usual tweaks for EXCESS_PRECISION_EXPR or C_MAYBE_CONST_EXPR. I believe that the declared effect of the builtin is just association barrier, so e.g. excess precision should be still handled like if it wasn't there. The following patch uses build_unary_op to handle those. 2022-02-09 Jakub Jelinek PR c/104427 * c-parser.cc (c_parser_postfix_expression) : Use parser_build_unary_op instead of build1_loc to build PAREN_EXPR. * c-typeck.cc (build_unary_op): Handle PAREN_EXPR. * c-fold.cc (c_fully_fold_internal): Likewise. * gcc.dg/pr104427.c: New test. --- gcc/c/c-fold.cc | 1 + gcc/c/c-parser.cc | 3 +-- gcc/c/c-typeck.cc | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-fold.cc b/gcc/c/c-fold.cc index fc593753..76ea25b 100644 --- a/gcc/c/c-fold.cc +++ b/gcc/c/c-fold.cc @@ -465,6 +465,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, case BIT_NOT_EXPR: case TRUTH_NOT_EXPR: case CONJ_EXPR: + case PAREN_EXPR: unary: /* Unary operations. */ orig_op0 = op0 = TREE_OPERAND (expr, 0); diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index e9086c5..7e81c33 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -10128,8 +10128,7 @@ c_parser_postfix_expression (c_parser *parser) mark_exp_read (e1.value); location_t end_loc = c_parser_peek_token (parser)->get_finish (); parens.skip_until_found_close (parser); - expr.value = build1_loc (loc, PAREN_EXPR, TREE_TYPE (e1.value), - e1.value); + expr = parser_build_unary_op (loc, PAREN_EXPR, e1); set_c_expr_source_range (&expr, start_loc, end_loc); } break; diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index b06f078..39094cc 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4921,6 +4921,10 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, ret = val; goto return_build_unary_op; + case PAREN_EXPR: + ret = build1 (code, TREE_TYPE (arg), arg); + goto return_build_unary_op; + default: gcc_unreachable (); } -- cgit v1.1 From 3adf509fe6feca9442fb36c35dd9a81a3a369d08 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 10 Feb 2022 00:16:27 +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 012800a..faf7a19 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2022-02-09 Jakub Jelinek + + PR c/104427 + * c-parser.cc (c_parser_postfix_expression) + : Use parser_build_unary_op + instead of build1_loc to build PAREN_EXPR. + * c-typeck.cc (build_unary_op): Handle PAREN_EXPR. + * c-fold.cc (c_fully_fold_internal): Likewise. + 2022-01-17 Martin Liska * Make-lang.in: Rename .c names to .cc. -- cgit v1.1 From bbb7f8604e1dfc08f44354cfd93d2287f2fdd489 Mon Sep 17 00:00:00 2001 From: Marcel Vollweiler Date: Wed, 9 Feb 2022 23:47:12 -0800 Subject: C, C++, Fortran, OpenMP: Add 'has_device_addr' clause to 'target' construct. This patch adds the 'has_device_addr' clause to the OpenMP 'target' construct which was introduced in OpenMP 5.1 (OpenMP API 5.1 specification pp. 197ff): has_device_addr(list) "The has_device_addr clause indicates that its list items already have device addresses and therefore they may be directly accessed from a target device. If the device address of a list item is not for the device on which the target region executes, accessing the list item inside the region results in unspecified behavior. The list items may include array sections." (p. 200) "A list item may not be specified in both an is_device_ptr clause and a has_device_addr clause on the directive." (p. 202) "A list item that appears in an is_device_ptr or a has_device_addr clause must not be specified in any data-sharing attribute clause on the same target construct." (p. 203) gcc/c-family/ChangeLog: * c-omp.cc (c_omp_split_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR case. * c-pragma.h (enum pragma_kind): Added 5.1 in comment. (enum pragma_omp_clause): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' clause. (c_parser_omp_variable_list): Handle array sections. (c_parser_omp_clause_has_device_addr): Added. (c_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR case. (c_parser_omp_target_exit_data): Added HAS_DEVICE_ADDR to OMP_CLAUSE_MASK. * c-typeck.cc (handle_omp_array_sections): Handle clause restrictions. (c_finish_omp_clauses): Handle array sections. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_name): Parse 'has_device_addr' clause. (cp_parser_omp_var_list_no_open): Handle array sections. (cp_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR case. (cp_parser_omp_target_update): Added HAS_DEVICE_ADDR to OMP_CLAUSE_MASK. * semantics.cc (handle_omp_array_sections): Handle clause restrictions. (finish_omp_clauses): Handle array sections. gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_clauses): Added OMP_LIST_HAS_DEVICE_ADDR case. * gfortran.h: Added OMP_LIST_HAS_DEVICE_ADDR. * openmp.cc (enum omp_mask2): Added OMP_CLAUSE_HAS_DEVICE_ADDR. (gfc_match_omp_clauses): Parse HAS_DEVICE_ADDR clause. (resolve_omp_clauses): Same. * trans-openmp.cc (gfc_trans_omp_variable_list): Added OMP_LIST_HAS_DEVICE_ADDR case. (gfc_trans_omp_clauses): Firstprivatize of array descriptors. gcc/ChangeLog: * gimplify.cc (gimplify_scan_omp_clauses): Added cases for OMP_CLAUSE_HAS_DEVICE_ADDR and handle array sections. (gimplify_adjust_omp_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR case. * omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_HAS_DEVICE_ADDR. (lower_omp_target): Same. * tree-core.h (enum omp_clause_code): Same. * tree-nested.cc (convert_nonlocal_omp_clauses): Same. (convert_local_omp_clauses): Same. * tree-pretty-print.cc (dump_omp_clause): Same. * tree.cc: Same. libgomp/ChangeLog: * libgomp.texi: Updated entry for HAS_DEVICE_ADDR. * target.c (copy_firstprivate_data): Copy only if host address is not NULL. * testsuite/libgomp.c++/target-has-device-addr-2.C: New test. * testsuite/libgomp.c++/target-has-device-addr-4.C: New test. * testsuite/libgomp.c++/target-has-device-addr-5.C: New test. * testsuite/libgomp.c++/target-has-device-addr-6.C: New test. * testsuite/libgomp.c-c++-common/target-has-device-addr-1.c: New test. * testsuite/libgomp.c/target-has-device-addr-3.c: New test. * testsuite/libgomp.fortran/target-has-device-addr-1.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-2.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-3.f90: New test. * testsuite/libgomp.fortran/target-has-device-addr-4.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/clauses-1.c: Added has_device_addr to test cases. * g++.dg/gomp/attrs-1.C: Added has_device_addr to test cases. * g++.dg/gomp/attrs-2.C: Added has_device_addr to test cases. * c-c++-common/gomp/target-has-device-addr-1.c: New test. * c-c++-common/gomp/target-has-device-addr-2.c: New test. * c-c++-common/gomp/target-is-device-ptr-1.c: New test. * c-c++-common/gomp/target-is-device-ptr-2.c: New test. * gfortran.dg/gomp/is_device_ptr-3.f90: New test. * gfortran.dg/gomp/target-has-device-addr-1.f90: New test. * gfortran.dg/gomp/target-has-device-addr-2.f90: New test. --- gcc/c/c-parser.cc | 22 ++++++++++++++++++++-- gcc/c/c-typeck.cc | 32 +++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 7e81c33..3b1d2d4 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -12771,7 +12771,9 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_GRAINSIZE; break; case 'h': - if (!strcmp ("hint", p)) + if (!strcmp ("has_device_addr", p)) + result = PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR; + else if (!strcmp ("hint", p)) result = PRAGMA_OMP_CLAUSE_HINT; else if (!strcmp ("host", p)) result = PRAGMA_OACC_CLAUSE_HOST; @@ -13164,6 +13166,7 @@ c_parser_omp_variable_list (c_parser *parser, case OMP_CLAUSE_REDUCTION: case OMP_CLAUSE_IN_REDUCTION: case OMP_CLAUSE_TASK_REDUCTION: + case OMP_CLAUSE_HAS_DEVICE_ADDR: array_section_p = false; dims.truncate (0); while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE)) @@ -14324,6 +14327,16 @@ c_parser_omp_clause_use_device_addr (c_parser *parser, tree list) list); } +/* OpenMP 5.1: + has_device_addr ( variable-list ) */ + +static tree +c_parser_omp_clause_has_device_addr (c_parser *parser, tree list) +{ + return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_HAS_DEVICE_ADDR, + list); +} + /* OpenMP 4.5: is_device_ptr ( variable-list ) */ @@ -17052,6 +17065,10 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, clauses = c_parser_omp_clause_use_device_addr (parser, clauses); c_name = "use_device_addr"; break; + case PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR: + clauses = c_parser_omp_clause_has_device_addr (parser, clauses); + c_name = "has_device_addr"; + break; case PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR: clauses = c_parser_omp_clause_is_device_ptr (parser, clauses); c_name = "is_device_ptr"; @@ -21034,7 +21051,8 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT) \ - | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)) + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)\ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR)) static bool c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 39094cc..3075c88 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -13804,6 +13804,8 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) } first = c_fully_fold (first, false, NULL); OMP_CLAUSE_DECL (c) = first; + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR) + return false; if (size) size = c_fully_fold (size, false, NULL); OMP_CLAUSE_SIZE (c) = size; @@ -14109,7 +14111,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head; - bitmap_head oacc_reduction_head; + bitmap_head oacc_reduction_head, is_on_device_head; tree c, t, type, *pc; tree simdlen = NULL_TREE, safelen = NULL_TREE; bool branch_seen = false; @@ -14145,6 +14147,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head. */ bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack); + bitmap_initialize (&is_on_device_head, &bitmap_default_obstack); if (ort & C_ORT_ACC) for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) @@ -14573,7 +14576,9 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qE appears more than once in data clauses", t); remove = true; } - else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) && bitmap_bit_p (&map_head, DECL_UID (t))) { if (ort == C_ORT_ACC) @@ -15187,7 +15192,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qD appears more than once in data clauses", t); remove = true; } - else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))) + else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t)) + || bitmap_bit_p (&is_on_device_head, DECL_UID (t))) { if (ort == C_ORT_ACC) error_at (OMP_CLAUSE_LOCATION (c), @@ -15272,6 +15278,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_USE_DEVICE_PTR: t = OMP_CLAUSE_DECL (c); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR @@ -15292,6 +15300,24 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } goto check_dup_generic; + case OMP_CLAUSE_HAS_DEVICE_ADDR: + t = OMP_CLAUSE_DECL (c); + if (TREE_CODE (t) == TREE_LIST) + { + if (handle_omp_array_sections (c, ort)) + remove = true; + else + { + t = OMP_CLAUSE_DECL (c); + while (TREE_CODE (t) == ARRAY_REF) + t = TREE_OPERAND (t, 0); + } + } + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); + if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) + c_mark_addressable (t); + goto check_dup_generic_t; + case OMP_CLAUSE_USE_DEVICE_ADDR: t = OMP_CLAUSE_DECL (c); if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) -- cgit v1.1 From a645583d4d68eecdd9101e1013e7bf01907ea786 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 11 Feb 2022 00:16:25 +0000 Subject: Daily bump. --- gcc/c/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index faf7a19..29c7b74 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,16 @@ +2022-02-10 Marcel Vollweiler + + * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' + clause. + (c_parser_omp_variable_list): Handle array sections. + (c_parser_omp_clause_has_device_addr): Added. + (c_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR + case. + (c_parser_omp_target_exit_data): Added HAS_DEVICE_ADDR to + OMP_CLAUSE_MASK. + * c-typeck.cc (handle_omp_array_sections): Handle clause restrictions. + (c_finish_omp_clauses): Handle array sections. + 2022-02-09 Jakub Jelinek PR c/104427 -- cgit v1.1 From ae117af43944101ca47b99b743c85a3c528b4b4f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 11 Feb 2022 12:43:22 +0100 Subject: [gimplefe] Add vector_mask attribute to get access to vector bools The following adds __attribute__((vector_mask)) to get access to the corresponding mask type for a vector type. The implementation simply uses truth_type_for so creating a mask type that's not what the target would choose as canonical, say a AVX2 style one when AVX512VL is enabled, is not possible. It might be possible to provide access to that with an optional argument specifying the precision of the bool element. The syntax is as simple as typedef vector_type mask_type __attribute__((vector_mask)); In theory this allows to create unit testcases for vector lowering and ISEL. 2022-02-11 Richard Biener gcc/c-family/ * c-attribs.cc (c_common_attribute_table): Add entry for vector_mask. (handle_vector_mask_attribute): New. gcc/c/ * gimple-parser.cc (c_parser_gimple_statement): Properly parse VEC_COND_EXPRs. gcc/testsuite/ * gcc.dg/gimplefe-48.c: New testcase. --- gcc/c/gimple-parser.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 51ddd86..31075237 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -860,9 +860,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (lhs.value != error_mark_node && rhs.value != error_mark_node) { - /* If we parsed a comparison and the next token is a '?' then - parse a conditional expression. */ - if (COMPARISON_CLASS_P (rhs.value) + /* If we parsed a comparison or an identifier and the next token + is a '?' then parse a conditional expression. */ + if ((COMPARISON_CLASS_P (rhs.value) + || SSA_VAR_P (rhs.value)) && c_parser_next_token_is (parser, CPP_QUERY)) { struct c_expr trueval, falseval; @@ -874,7 +875,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (trueval.value == error_mark_node || falseval.value == error_mark_node) return; - rhs.value = build3_loc (loc, COND_EXPR, TREE_TYPE (trueval.value), + rhs.value = build3_loc (loc, + VECTOR_TYPE_P (TREE_TYPE (rhs.value)) + ? VEC_COND_EXPR : COND_EXPR, + TREE_TYPE (trueval.value), rhs.value, trueval.value, falseval.value); } if (get_gimple_rhs_class (TREE_CODE (rhs.value)) == GIMPLE_INVALID_RHS) -- cgit v1.1 From e8d68f0a456e00437587461d9645852272fb2322 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 12 Feb 2022 00:16:23 +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 29c7b74..6e420e0 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2022-02-11 Richard Biener + + * gimple-parser.cc (c_parser_gimple_statement): Properly parse + VEC_COND_EXPRs. + 2022-02-10 Marcel Vollweiler * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' -- cgit v1.1 From f99ad11af953568e1a01e4f4fe31cba0f11879a5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 17 Feb 2022 10:29:06 +0100 Subject: openmp: Ensure proper diagnostics for -> in map/to/from clauses [PR104532] The following patch uses the functions normal CPP_DEREF parsing uses, i.e. convert_lvalue_to_rvalue and build_indirect_ref, instead of blindly calling build_simple_mem_ref, so that if the variable does not have correct type, we properly diagnose it instead of ICEing on it. 2022-02-17 Jakub Jelinek PR c/104532 * c-parser.cc (c_parser_omp_variable_list): For CPP_DEREF, use convert_lvalue_to_rvalue and build_indirect_ref instead of build_simple_mem_ref. * gcc.dg/gomp/pr104532.c: New test. --- gcc/c/c-parser.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 3b1d2d4..84deac0 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -13145,7 +13145,16 @@ c_parser_omp_variable_list (c_parser *parser, { location_t op_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_DEREF)) - t = build_simple_mem_ref (t); + { + c_expr t_expr; + t_expr.value = t; + t_expr.original_code = ERROR_MARK; + t_expr.original_type = NULL; + set_c_expr_source_range (&t_expr, op_loc, op_loc); + t_expr = convert_lvalue_to_rvalue (op_loc, t_expr, + true, false); + t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW); + } c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_NAME)) { -- cgit v1.1 From 0bdb049877f405f361a9a3f597267ff5e44733a2 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 18 Feb 2022 00:16:39 +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 6e420e0..ae4fd17 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2022-02-17 Jakub Jelinek + + PR c/104532 + * c-parser.cc (c_parser_omp_variable_list): For CPP_DEREF, use + convert_lvalue_to_rvalue and build_indirect_ref instead of + build_simple_mem_ref. + 2022-02-11 Richard Biener * gimple-parser.cc (c_parser_gimple_statement): Properly parse -- cgit v1.1 From f4ed267fa5b82d6dafbc8afc82baf45bfcae549c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 23 Feb 2022 11:05:50 +0100 Subject: Support SSA name declarations with pointer type Currently we fail to parse int * _3; as SSA name and instead get a VAR_DECL because of the way the C frontends declarator specs work. That causes havoc if those supposed SSA names are used in PHIs or in other places where VAR_DECLs are not allowed. The following fixes the pointer case in an ad-hoc way - for more complex type declarators we probably have to find a way to re-use the C frontend grokdeclarator without actually creating a VAR_DECL there (or maybe make it create an SSA name). Pointers appear too often to be neglected though, thus the following ad-hoc fix for this. This also adds verification that we do not end up with SSA names without definitions as can happen when reducing a GIMPLE testcase. Instead of working through segfaults one-by-one we emit errors for all of those at once now. 2022-02-23 Richard Biener gcc/c * gimple-parser.cc (c_parser_parse_gimple_body): Diagnose SSA names without definition. (c_parser_gimple_declaration): Handle pointer typed SSA names. gcc/testsuite/ * gcc.dg/gimplefe-49.c: New testcase. * gcc.dg/gimplefe-error-13.c: Likewise. --- gcc/c/gimple-parser.cc | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 31075237..d1afd42 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -330,13 +330,17 @@ c_parser_parse_gimple_body (c_parser *cparser, char *gimple_pass, } gsi_remove (&gsi, true); } - /* Fill SSA name gaps, putting them on the freelist. */ + /* Fill SSA name gaps, putting them on the freelist and diagnose + SSA names without definition. */ for (unsigned i = 1; i < num_ssa_names; ++i) if (!ssa_name (i)) { tree name = make_ssa_name_fn (cfun, integer_type_node, NULL, i); release_ssa_name_fn (cfun, name); } + else if (!SSA_NAME_DEF_STMT (ssa_name (i))) + error ("SSA name %qE with version %d has no definition", + ssa_name (i), i); /* No explicit virtual operands (yet). */ bitmap_obstack_initialize (NULL); update_ssa (TODO_update_ssa_only_virtuals); @@ -2061,16 +2065,34 @@ c_parser_gimple_declaration (gimple_parser &parser) /* Handle SSA name decls specially, they do not go into the identifier table but we simply build the SSA name for later lookup. */ unsigned version, ver_offset; - if (declarator->kind == cdk_id - && is_gimple_reg_type (specs->type) - && c_parser_parse_ssa_name_id (declarator->u.id.id, + /* Handle SSA pointer declarations in a very simplistic ways, we + probably would like to call grokdeclarator in a special mode to + just build the type of the decl - start_decl already pushes + the identifier to the bindings for lookup, something we do not + want. */ + struct c_declarator *id_declarator = declarator; + while (id_declarator->kind == cdk_pointer) + id_declarator = id_declarator->declarator; + if (id_declarator->kind == cdk_id + && (declarator->kind == cdk_pointer + || is_gimple_reg_type (specs->type)) + && c_parser_parse_ssa_name_id (id_declarator->u.id.id, &version, &ver_offset) /* The following restricts it to unnamed anonymous SSA names which fails parsing of named ones in dumps (we could decide to not dump their name for -gimple). */ && ver_offset == 0) - c_parser_parse_ssa_name (parser, declarator->u.id.id, specs->type, - version, ver_offset); + { + struct c_declarator *p = declarator; + tree type = specs->type; + while (p->kind == cdk_pointer) + { + type = build_pointer_type (type); + p = p->declarator; + } + c_parser_parse_ssa_name (parser, id_declarator->u.id.id, type, + version, ver_offset); + } else { tree postfix_attrs = NULL_TREE; -- cgit v1.1 From 4bf3bac15145c71d01152a06052f3b4603b26163 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 24 Feb 2022 00:16:22 +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 ae4fd17..b177355 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2022-02-23 Richard Biener + + * gimple-parser.cc (c_parser_parse_gimple_body): Diagnose + SSA names without definition. + (c_parser_gimple_declaration): Handle pointer typed SSA names. + 2022-02-17 Jakub Jelinek PR c/104532 -- cgit v1.1