diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-02-17 10:29:06 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-02-17 10:29:06 +0100 |
commit | f99ad11af953568e1a01e4f4fe31cba0f11879a5 (patch) | |
tree | 965f0a884111ea38f707392d8aebc25e98a8a53e /gcc/c | |
parent | 550cabd00238a8e74783ba6ad05a7580d074aabd (diff) | |
download | gcc-f99ad11af953568e1a01e4f4fe31cba0f11879a5.zip gcc-f99ad11af953568e1a01e4f4fe31cba0f11879a5.tar.gz gcc-f99ad11af953568e1a01e4f4fe31cba0f11879a5.tar.bz2 |
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 <jakub@redhat.com>
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.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-parser.cc | 11 |
1 files changed, 10 insertions, 1 deletions
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)) { |