public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867]
@ 2020-09-01  7:37 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-01  7:37 UTC (permalink / raw)
  To: gcc-patches

Hi!

The C++ macro performs a PARM_DECL_CHECK, so will ICE if not tested on a PARM_DECL,
C_ARRAY_PARAMETER doesn't, but probably should, otherwise it is testing e.g.
C_DECL_VARIABLE_SIZE on VAR_DECLs.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk.

2020-09-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/96867
	* c-typeck.c (handle_omp_array_sections_1): Test C_ARRAY_PARAMETER
	only on PARM_DECLs.

	* semantics.c (handle_omp_array_sections_1): Test
	DECL_ARRAY_PARAMETER_P only on PARM_DECLs.

	* c-c++-common/gomp/pr96867.c: New test.

--- gcc/c/c-typeck.c.jj	2020-08-25 21:13:54.832897428 +0200
+++ gcc/c/c-typeck.c	2020-08-31 15:06:10.143426584 +0200
@@ -13298,7 +13298,7 @@ handle_omp_array_sections_1 (tree c, tre
     {
       if (length == NULL_TREE)
 	{
-	  if (C_ARRAY_PARAMETER (ret))
+	  if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
 	    error_at (OMP_CLAUSE_LOCATION (c),
 		      "for array function parameter length expression "
 		      "must be specified");
--- gcc/cp/semantics.c.jj	2020-08-31 14:10:15.983919186 +0200
+++ gcc/cp/semantics.c	2020-08-31 15:05:47.528753277 +0200
@@ -5083,7 +5083,7 @@ handle_omp_array_sections_1 (tree c, tre
     {
       if (length == NULL_TREE)
 	{
-	  if (DECL_ARRAY_PARAMETER_P (ret))
+	  if (TREE_CODE (ret) == PARM_DECL && DECL_ARRAY_PARAMETER_P (ret))
 	    error_at (OMP_CLAUSE_LOCATION (c),
 		      "for array function parameter length expression "
 		      "must be specified");
--- gcc/testsuite/c-c++-common/gomp/pr96867.c.jj	2020-08-31 15:07:29.271283504 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr96867.c	2020-08-31 15:07:13.429512357 +0200
@@ -0,0 +1,9 @@
+/* PR c++/96867 */
+
+int *v;
+
+void
+foo (int x)
+{
+  #pragma omp target update to (x, v[:])	/* { dg-error "for pointer type length expression must be specified" } */
+}

	Jakub


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

only message in thread, other threads:[~2020-09-01  7:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01  7:37 [committed] openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867] Jakub Jelinek

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).