From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id B351C398544E for ; Tue, 1 Sep 2020 07:37:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B351C398544E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-fiPwoBUpMv-qZK81VG4Sdw-1; Tue, 01 Sep 2020 03:37:15 -0400 X-MC-Unique: fiPwoBUpMv-qZK81VG4Sdw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2A7A801ADA for ; Tue, 1 Sep 2020 07:37:14 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-115.ams2.redhat.com [10.36.113.115]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C6A47DA37 for ; Tue, 1 Sep 2020 07:37:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 0817bAhl027790 for ; Tue, 1 Sep 2020 09:37:11 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 0817bAel027789 for gcc-patches@gcc.gnu.org; Tue, 1 Sep 2020 09:37:10 +0200 Date: Tue, 1 Sep 2020 09:37:10 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867] Message-ID: <20200901073710.GU18149@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2020 07:37:18 -0000 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 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