From patchwork Thu Jun 21 07:34:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 166240 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 C3CE2B6FD3 for ; Thu, 21 Jun 2012 17:35:09 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340868910; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=yfWpuAD exBLMtCccKsEiRZJzi0c=; b=wtB52AJauRnC3uyZuxnYiuMvKxMD7NnUbVfQA48 eC2epBReITklvghJep8Ccr3z9fXKI0qFoqRPEx1XEZIrSg6OB01dj+0XFkLApILm ZyiAveC+Z0ei3xCtsXI3baniZcrYooISGTVU53MK5HEv+W8z1MGaEIG7Jjy/zvZS nuQQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=vRgADXiUimWmGCjBeAMcPzwYPVPEX/HFI1ZKw2Y6RmA7FTxhgE5e7bYb4coNcE y+V6dNdUdkxMPWS2Wo8vFh5oN68Thv81o9ZLuVjCMfdVgLcyNxwV2Hj9wmKSzm9B EJ7LV3VPlz8bs3Y6mw7hmLJtkUR7LRhFR+7213BbVq+40=; Received: (qmail 15092 invoked by alias); 21 Jun 2012 07:35:02 -0000 Received: (qmail 14885 invoked by uid 22791); 21 Jun 2012 07:35:00 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, 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; Thu, 21 Jun 2012 07:34:40 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5L7YdFx018501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Jun 2012 03:34:40 -0400 Received: from [10.3.113.17] ([10.3.113.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q5L7YYLN016695; Thu, 21 Jun 2012 03:34:37 -0400 Message-ID: <4FE2CE88.2090104@redhat.com> Date: Thu, 21 Jun 2012 00:34:32 -0700 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jakub Jelinek CC: gcc-patches List Subject: RFC: C++/OMP PATCH for c++/53565 (libgomp for-2.C failure) 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 A recent change of mine caused auto to persist until instantiation time in more cases, and the OMP for instantiation code wasn't prepared to deal with that. This patch simplifies the handling of the for-init-expr in an OMP loop by processing the DECL_EXPR right away, rather than trying to split handling it between tsubst_omp_for_iterator and tsubst_expr. All the tests in the libgomp and gcc testsuites pass with this patch, but I'm not very confident about it because I don't fully understand what the code is doing. In particular, I'm not sure what the condition controlling the code in tsubst_omp_for_iterator that looks at the clauses should be; init can never be a DECL_EXPR at that point anymore. I'm also not sure whether moving the begin_omp_structured_block is necessary, but it seemed like a good idea since we're handling the DECL_EXPR earlier. Does this make sense to you? commit a31dd0fa43b7d0d75e18b566501c3dad6f477e2b Author: Jason Merrill Date: Wed Jun 20 19:16:01 2012 -0700 PR c++/53565 * pt.c (tsubst_omp_for_iterator): Simplify DECL_EXPR handling. (tsubst_expr) [OMP_FOR]: Here, too. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5e02c8c..cec244a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12659,22 +12659,23 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv, #define RECUR(NODE) \ tsubst_expr ((NODE), args, complain, in_decl, \ integral_constant_expression_p) - tree decl, init, cond, incr, auto_node; + tree decl, init, cond, incr; + bool init_decl; init = TREE_VEC_ELT (OMP_FOR_INIT (t), i); gcc_assert (TREE_CODE (init) == MODIFY_EXPR); - decl = RECUR (TREE_OPERAND (init, 0)); + decl = TREE_OPERAND (init, 0); init = TREE_OPERAND (init, 1); - auto_node = type_uses_auto (TREE_TYPE (decl)); - if (auto_node && init) + init_decl = (init && TREE_CODE (init) == DECL_EXPR); + /* Do this before substituting into decl to handle 'auto'. */ + init = RECUR (init); + decl = RECUR (decl); + if (init_decl) { - tree init_expr = init; - if (TREE_CODE (init_expr) == DECL_EXPR) - init_expr = DECL_INITIAL (DECL_EXPR_DECL (init_expr)); - init_expr = RECUR (init_expr); - TREE_TYPE (decl) - = do_auto_deduction (TREE_TYPE (decl), init_expr, auto_node); + gcc_assert (!processing_template_decl); + init = DECL_INITIAL (decl); } + gcc_assert (!type_dependent_expression_p (decl)); if (!CLASS_TYPE_P (TREE_TYPE (decl))) @@ -13189,34 +13190,13 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, condv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t))); incrv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t))); + stmt = begin_omp_structured_block (); + for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (t)); i++) tsubst_omp_for_iterator (t, i, declv, initv, condv, incrv, &clauses, args, complain, in_decl, integral_constant_expression_p); - stmt = begin_omp_structured_block (); - - for (i = 0; i < TREE_VEC_LENGTH (initv); i++) - if (TREE_VEC_ELT (initv, i) == NULL - || TREE_CODE (TREE_VEC_ELT (initv, i)) != DECL_EXPR) - TREE_VEC_ELT (initv, i) = RECUR (TREE_VEC_ELT (initv, i)); - else if (CLASS_TYPE_P (TREE_TYPE (TREE_VEC_ELT (initv, i)))) - { - tree init = RECUR (TREE_VEC_ELT (initv, i)); - gcc_assert (init == TREE_VEC_ELT (declv, i)); - TREE_VEC_ELT (initv, i) = NULL_TREE; - } - else - { - tree decl_expr = TREE_VEC_ELT (initv, i); - tree init = DECL_INITIAL (DECL_EXPR_DECL (decl_expr)); - gcc_assert (init != NULL); - TREE_VEC_ELT (initv, i) = RECUR (init); - DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = NULL; - RECUR (decl_expr); - DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = init; - } - pre_body = push_stmt_list (); RECUR (OMP_FOR_PRE_BODY (t)); pre_body = pop_stmt_list (pre_body); diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C index 7c56719..4441a29 100644 --- a/gcc/testsuite/g++.dg/gomp/for-19.C +++ b/gcc/testsuite/g++.dg/gomp/for-19.C @@ -26,8 +26,8 @@ template void f3 (void) { -#pragma omp for // { dg-error "forbids incrementing a pointer of type" } - for (T q = T (p); q < T (p + 4); q++) +#pragma omp for + for (T q = T (p); q < T (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } ; }