From patchwork Thu Oct 31 19:10:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 287588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 341892C03DB for ; Fri, 1 Nov 2013 06:10:39 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=D6DCs2rQYaQRlcBVX9Pv3i1sShXR4C+0fIpsWG2+N7Z m3JD0xbLaVa0IYL5xkxeD057is6Xzehc107V04sAMqNfNgCHdz+0H9FgJLEUB9hP Q7kxhIqFwav71M0yE1S6g8ydF2qXbyrhEZqzcW448lT85i3rKBPtZM9vmLdnEOZg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=BLlRwK+DcM2SLabkWyTF4yBPpJw=; b=gu9bqhwQGE1kKZqtQ 73QoJglvMs72mi6LFSdygN/anXQ9+hF2n4YPLUIwxHX9rnye5rLIF9Fppz3uoRlc t1kTl/zajfQeqqOfl9dmv9vtqBNOfl9k1IpAVc5OYssnds3VfDjppHHNd2vRoRYP 8M9RW4PLKORwO4WsgCsAfEtp5g= Received: (qmail 14146 invoked by alias); 31 Oct 2013 19:10:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14134 invoked by uid 89); 31 Oct 2013 19:10:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Oct 2013 19:10:30 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9VJAShS004619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Oct 2013 15:10:29 -0400 Received: from tucnak.zalov.cz (vpn1-5-123.ams2.redhat.com [10.36.5.123]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9VJAQPJ030584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 31 Oct 2013 15:10:28 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id r9VJAPgv027632 for ; Thu, 31 Oct 2013 20:10:25 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id r9VJAPDD027631 for gcc-patches@gcc.gnu.org; Thu, 31 Oct 2013 20:10:25 +0100 Date: Thu, 31 Oct 2013 20:10:25 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Add diagnostics for aligned clause restrictions Message-ID: <20131031191025.GX27813@tucnak.zalov.cz> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! I've noticed I have missed diagnostics for invalid aligned clause arguments (the aligned clause support has been written before the restrictions were added to the standard). Tested on x86_64-linux, committed to trunk. 2013-10-31 Jakub Jelinek * c-typeck.c (c_finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array. * semantics.c (finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array nor reference to those. * g++.dg/gomp/simd-1.C: New test. * g++.dg/gomp/declare-simd-1.C (f32): Fix up aligned clause argument. * g++.dg/gomp/declare-simd-2.C (fn13, fn14): Add new tests. * gcc.dg/gomp/declare-simd-2.c (fn7, fn8, fn9, fn10, fn11): Likewise. * c-c++-common/gomp/simd6.c: New test. Jakub --- gcc/c/c-typeck.c.jj 2013-10-30 08:15:33.000000000 +0100 +++ gcc/c/c-typeck.c 2013-10-31 17:06:51.085755997 +0100 @@ -11504,6 +11504,14 @@ c_finish_omp_clauses (tree clauses) "%qE is not a variable in % clause", t); remove = true; } + else if (!POINTER_TYPE_P (TREE_TYPE (t)) + && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qE in % clause is neither a pointer nor " + "an array", t); + remove = true; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error_at (OMP_CLAUSE_LOCATION (c), --- gcc/cp/semantics.c.jj 2013-10-31 14:50:29.000000000 +0100 +++ gcc/cp/semantics.c 2013-10-31 17:08:00.527394011 +0100 @@ -5467,6 +5467,19 @@ finish_omp_clauses (tree clauses) error ("%qE is not a variable in % clause", t); remove = true; } + else if (!type_dependent_expression_p (t) + && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE + && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE + && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE + || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))) + && (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) + != ARRAY_TYPE)))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%qE in % clause is neither a pointer nor " + "an array nor a reference to pointer or array", t); + remove = true; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error ("%qD appears more than once in % clauses", t); --- gcc/testsuite/g++.dg/gomp/simd-1.C.jj 2013-10-31 19:23:29.394801317 +0100 +++ gcc/testsuite/g++.dg/gomp/simd-1.C 2013-10-31 19:25:25.218210869 +0100 @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-fopenmp" } + +extern int a[1024]; +int (&b)[1024] = a; + +struct S { int s; } s, &t = s; + +void +f1 (int &x, float &f, int *&p) +{ + int i; + #pragma omp simd aligned(x : 32) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(f) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(t : 16) // { dg-error "neither a pointer nor an array" } + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(a : 8) + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(b : 8) + for (i = 0; i < 1024; i++) + b[i]++; + #pragma omp simd aligned(p : 8) + for (i = 0; i < 1024; i++) + a[i]++; +} --- gcc/testsuite/g++.dg/gomp/declare-simd-1.C.jj 2013-10-11 11:23:59.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/declare-simd-1.C 2013-10-31 19:27:32.158559550 +0100 @@ -205,7 +205,7 @@ f30 (int x) template struct C { - #pragma omp declare simd simdlen (N) aligned (a : N * sizeof (int)) linear (c : N) notinbranch + #pragma omp declare simd simdlen (N) aligned (b : N * sizeof (int)) linear (c : N) notinbranch int f32 (int a, int *b, int c); }; --- gcc/testsuite/g++.dg/gomp/declare-simd-2.C.jj 2013-10-11 11:23:59.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/declare-simd-2.C 2013-10-31 19:31:36.812309117 +0100 @@ -64,4 +64,22 @@ struct D int e; }; +#pragma omp declare simd aligned (a, b, c, d) +int fn13 (int *a, int b[64], int *&c, int (&d)[64]); + +#pragma omp declare simd aligned (a) // { dg-error "neither a pointer nor an array" } +int fn14 (int a); + +#pragma omp declare simd aligned (b) // { dg-error "neither a pointer nor an array" } +int fn14 (int &b); + +#pragma omp declare simd aligned (c) // { dg-error "neither a pointer nor an array" } +int fn14 (float c); + +#pragma omp declare simd aligned (d) // { dg-error "neither a pointer nor an array" } +int fn14 (double &d); + +#pragma omp declare simd aligned (e) // { dg-error "neither a pointer nor an array" } +int fn14 (D e); + // { dg-error "has no member" "" { target *-*-* } 61 } --- gcc/testsuite/gcc.dg/gomp/declare-simd-2.c.jj 2013-10-11 11:23:59.000000000 +0200 +++ gcc/testsuite/gcc.dg/gomp/declare-simd-2.c 2013-10-31 19:32:59.044886760 +0100 @@ -22,3 +22,20 @@ int fn5 (int a); #pragma omp declare simd inbranch notinbranch /* { dg-error "clause is incompatible with" } */ int fn6 (int); + +#pragma omp declare simd aligned (a, b) +int fn7 (int *a, int b[64]); + +#pragma omp declare simd aligned (a) /* { dg-error "neither a pointer nor an array" } */ +int fn8 (int a); + +#pragma omp declare simd aligned (c) /* { dg-error "neither a pointer nor an array" } */ +int fn9 (float c); + +#pragma omp declare simd aligned (d) /* { dg-error "neither a pointer nor an array" } */ +int fn10 (double d); + +struct D { int d; }; + +#pragma omp declare simd aligned (e) /* { dg-error "neither a pointer nor an array" } */ +int fn11 (struct D e); --- gcc/testsuite/c-c++-common/gomp/simd6.c.jj 2013-10-31 17:32:56.000000000 +0100 +++ gcc/testsuite/c-c++-common/gomp/simd6.c 2013-10-31 17:52:27.587792500 +0100 @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +extern int a[1024]; + +struct S { int i; } s; + +void +f1 (int x, float f, int *p) +{ + int i; + #pragma omp simd aligned(x : 32) /* { dg-error "neither a pointer nor an array" } */ + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(f) /* { dg-error "neither a pointer nor an array" } */ + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(s : 16) /* { dg-error "neither a pointer nor an array" } */ + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(a : 8) + for (i = 0; i < 1024; i++) + a[i]++; + #pragma omp simd aligned(p : 8) + for (i = 0; i < 1024; i++) + a[i]++; +}