public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3711] OpenMP: Avoid ICE in c_parser_omp_clause_allocate with invalid expr
@ 2023-09-05 14:52 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2023-09-05 14:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:55243898f8f9560371f258fe0c6ca202ab7b2085

commit r14-3711-g55243898f8f9560371f258fe0c6ca202ab7b2085
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Sep 5 14:57:01 2023 +0200

    OpenMP: Avoid ICE in c_parser_omp_clause_allocate with invalid expr
    
    gcc/c/ChangeLog:
    
            * c-parser.cc (c_parser_omp_clause_allocate): Handle
            error_mark_node.
    
    gcc/testsuite/ChangeLog:
    
            * c-c++-common/gomp/allocate-13.c: New test.

Diff:
---
 gcc/c/c-parser.cc                             |  4 +++-
 gcc/testsuite/c-c++-common/gomp/allocate-13.c | 28 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index cae10ba9c80e..c8d285fbda13 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -16676,7 +16676,9 @@ c_parser_omp_clause_allocate (c_parser *parser, tree list)
 	      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);
-	      if (strcmp (p, "allocator") == 0)
+	      if (expr.value == error_mark_node)
+		;
+	      else if (strcmp (p, "allocator") == 0)
 		{
 		  allocator = expr.value;
 		  allocator = c_fully_fold (allocator, false, NULL);
diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-13.c b/gcc/testsuite/c-c++-common/gomp/allocate-13.c
new file mode 100644
index 000000000000..847fe55ea2a3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/allocate-13.c
@@ -0,0 +1,28 @@
+typedef enum omp_allocator_handle_t
+#if __cplusplus >= 201103L
+: __UINTPTR_TYPE__
+#endif
+{
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+void
+f ()
+{
+  int i;
+  #pragma omp parallel firstprivate(i) \
+        allocate(allocator(omp_low_latency_mem_alloc): i)
+/* { dg-error "'omp_low_latency_mem_alloc' undeclared \\(first use in this function\\); did you mean 'omp_low_lat_mem_alloc'\\\?" "" { target c } .-1 } */
+/* { dg-error "'omp_low_latency_mem_alloc' was not declared in this scope; did you mean 'omp_low_lat_mem_alloc'\\\?" "" { target c++ } .-2 } */
+/* { dg-note "each undeclared identifier is reported only once for each function it appears in" "" { target c } .-3 } */
+   i = 4;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-05 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 14:52 [gcc r14-3711] OpenMP: Avoid ICE in c_parser_omp_clause_allocate with invalid expr Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).