From patchwork Fri Sep 24 19:37:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 65690 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 76A10B7101 for ; Sat, 25 Sep 2010 06:15:28 +1000 (EST) Received: (qmail 12591 invoked by alias); 24 Sep 2010 20:15:25 -0000 Received: (qmail 12578 invoked by uid 22791); 24 Sep 2010 20:15:23 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_SV, 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; Fri, 24 Sep 2010 20:15:17 +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.13.8/8.13.8) with ESMTP id o8OKFGmS032216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Sep 2010 16:15:16 -0400 Received: from [127.0.0.1] (ovpn-113-40.phx2.redhat.com [10.3.113.40]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8OJbi1a014262 for ; Fri, 24 Sep 2010 15:37:44 -0400 Message-ID: <4C9CFE07.2040708@redhat.com> Date: Fri, 24 Sep 2010 15:37:43 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100921 Lightning/1.0b1 Shredder/3.0.9pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to dependency checking of array types 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 Minor cleanup: compute_array_index_type already checks whether or not the size expression is type-dependent, so there's no reason to check it again in dependent_type_p_r. Tested x86_64-pc-linux-gnu, applied to trunk. commit 0a0fe6ffc113e0bd9cd6598faeb57a2b13ad78a2 Author: jason Date: Fri Sep 24 15:13:19 2010 +0000 * decl.c (compute_array_index_type): Remember type dependence of array bound. * pt.c (dependent_type_p_r): Don't recompute it here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164598 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3d1420a..6a44482 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7402,11 +7402,15 @@ compute_array_index_type (tree name, tree size) type = TREE_TYPE (size); } + /* A type is dependent if it is...an array type constructed from any + dependent type or whose size is specified by a constant expression + that is value-dependent. */ /* We can only call value_dependent_expression_p on integral constant expressions; the parser adds a dummy NOP_EXPR with TREE_SIDE_EFFECTS set if this isn't one. */ if (processing_template_decl - && (TREE_SIDE_EFFECTS (size) || value_dependent_expression_p (size))) + && (dependent_type_p (type) + || TREE_SIDE_EFFECTS (size) || value_dependent_expression_p (size))) { /* We cannot do any checking for a SIZE that isn't known to be constant. Just build the index type and mark that it requires @@ -7532,10 +7536,16 @@ compute_array_index_type (tree name, tree size) { tree t = build_index_type (itype); TYPE_CANONICAL (abi_1_itype) = TYPE_CANONICAL (t); - return abi_1_itype; + itype = abi_1_itype; } else - return build_index_type (itype); + itype = build_index_type (itype); + + /* If the index type were dependent, we would have returned early, so + remember that it isn't. */ + TYPE_DEPENDENT_P (itype) = 0; + TYPE_DEPENDENT_P_VALID (itype) = 1; + return itype; } /* Returns the scope (if any) in which the entity declared by diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5a90bdc..f5e09ee 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17479,7 +17479,10 @@ dependent_type_p_r (tree type) } /* -- an array type constructed from any dependent type or whose size is specified by a constant expression that is - value-dependent. */ + value-dependent. + + We checked for type- and value-dependence of the bounds in + compute_array_index_type, so TYPE_DEPENDENT_P is already set. */ if (TREE_CODE (type) == ARRAY_TYPE) { if (TYPE_DOMAIN (type) @@ -17487,14 +17490,6 @@ dependent_type_p_r (tree type) return true; return dependent_type_p (TREE_TYPE (type)); } - else if (TREE_CODE (type) == INTEGER_TYPE - && !TREE_CONSTANT (TYPE_MAX_VALUE (type))) - { - /* If this is the TYPE_DOMAIN of an array type, consider it - dependent. We already checked for value-dependence in - compute_array_index_type. */ - return type_dependent_expression_p (TYPE_MAX_VALUE (type)); - } /* -- a template-id in which either the template name is a template parameter ... */