From patchwork Mon May 30 12:24:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 97908 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]) by ozlabs.org (Postfix) with SMTP id D71D1B6F71 for ; Mon, 30 May 2011 22:24:33 +1000 (EST) Received: (qmail 16973 invoked by alias); 30 May 2011 12:24:30 -0000 Received: (qmail 16956 invoked by uid 22791); 30 May 2011 12:24:29 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 May 2011 12:24:14 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4UCOErw008693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 May 2011 08:24:14 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4UCODRF001110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 30 May 2011 08:24:14 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p4UCOCdY015660 for ; Mon, 30 May 2011 14:24:13 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p4UCOCcW015659 for gcc-patches@gcc.gnu.org; Mon, 30 May 2011 14:24:12 +0200 Date: Mon, 30 May 2011 14:24:12 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix ICE on OpenMP clause in template (PR c++/49223) Message-ID: <20110530122412.GK17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! finish_omp_clauses calls require_complete_type, but that returns t immediately if processing_template_decl, so we need to check COMPLETE_TYPE_P before calling cxx_omp_create_clause_info. Additionally, for copyin/copyprivate we need to call require_complete_type too. While the OpenMP standard doesn't mention anything about complete types in copyin/copyprivate restrictions, that is only because threadprivate directive requires complete type. If one mixes __thread with copyin/copyprivate, we could have there incomplete type though. Both issues fixed thusly, regtested on x86_64-linux, committed to trunk/4.6. 2011-05-30 Jakub Jelinek PR c++/49223 * semantics.c (finish_omp_clauses): Call require_complete_type even for copyin/copyprivate clauses. Only call cxx_omp_create_clause_info if inner_type is COMPLETE_TYPE_P. * g++.dg/gomp/pr49223-1.C: New test. * g++.dg/gomp/pr49223-2.C: New test. Jakub --- gcc/cp/semantics.c.jj 2011-05-25 16:30:03.000000000 +0200 +++ gcc/cp/semantics.c 2011-05-30 13:33:08.000000000 +0200 @@ -4041,12 +4041,13 @@ finish_omp_clauses (tree clauses) break; } - if (need_complete_non_reference) + if (need_complete_non_reference || need_copy_assignment) { t = require_complete_type (t); if (t == error_mark_node) remove = true; - else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) + else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE + && need_complete_non_reference) { error ("%qE has reference type for %qs", t, name); remove = true; @@ -4088,6 +4090,7 @@ finish_omp_clauses (tree clauses) Save the results, because later we won't be in the right context for making these queries. */ if (CLASS_TYPE_P (inner_type) + && COMPLETE_TYPE_P (inner_type) && (need_default_ctor || need_copy_ctor || need_copy_assignment) && !type_dependent_expression_p (t) && cxx_omp_create_clause_info (c, inner_type, need_default_ctor, --- gcc/testsuite/g++.dg/gomp/pr49223-1.C.jj 2011-05-30 13:38:40.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/pr49223-1.C 2011-05-30 13:38:08.000000000 +0200 @@ -0,0 +1,28 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +struct V +{ + V () {} + ~V () {} +}; + +template +struct S +{ + void foo () + { + V <0> v; + #pragma omp parallel private (v) + ; + } +}; + +void +bar (void) +{ + S <0> s; + s.foo (); +} --- gcc/testsuite/g++.dg/gomp/pr49223-2.C.jj 2011-05-30 13:40:59.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/pr49223-2.C 2011-05-30 13:46:05.000000000 +0200 @@ -0,0 +1,16 @@ +// PR c++/49223 +// { dg-do compile } +// { dg-require-effective-target tls } +// { dg-options "-fopenmp" } + +struct S; // { dg-error "forward declaration" } +extern __thread struct S s; // { dg-error "has incomplete type" } +struct T; +extern __thread struct T t; + +void +foo () +{ + #pragma omp parallel copyin (s) + ; +}