From patchwork Thu May 5 19:59:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 94312 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 E1079B6EEB for ; Fri, 6 May 2011 05:59:43 +1000 (EST) Received: (qmail 32765 invoked by alias); 5 May 2011 19:59:41 -0000 Received: (qmail 32757 invoked by uid 22791); 5 May 2011 19:59:41 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Thu, 05 May 2011 19:59:26 +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 p45JxQdj002682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 May 2011 15:59:26 -0400 Received: from [127.0.0.1] (ovpn-113-126.phx2.redhat.com [10.3.113.126]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p45JxQvQ014218 for ; Thu, 5 May 2011 15:59:26 -0400 Message-ID: <4DC3019D.8030405@redhat.com> Date: Thu, 05 May 2011 15:59:25 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110421 Fedora/3.1.9-2.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: minor C++ PATCH to REFERENCE_REF_P 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 While working on something else I noticed that REFERENCE_REF_P was being clobbered by stabilize_expr, so this patch changes it to just use the type rather than a lang_flag. Tested x86_64-pc-linux-gnu, applying to trunk. commit f24566a2f2594c7d4c7d7d3e26a4341d87deaec6 Author: Jason Merrill Date: Thu May 5 13:14:47 2011 -0400 * cp-tree.h (REFERENCE_REF_P): Just check the type. * cvt.c (convert_from_reference): Adjust. * pt.c (build_non_dependent_expr): Adjust. * semantics.c (finish_offsetof): Adjust. * tree.c (lvalue_kind): Use it. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 961581e..fcb715c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -62,7 +62,6 @@ c-common.h, not after. STMT_EXPR_NO_SCOPE (in STMT_EXPR) BIND_EXPR_TRY_BLOCK (in BIND_EXPR) TYPENAME_IS_ENUM_P (in TYPENAME_TYPE) - REFERENCE_REF_P (in INDIRECT_EXPR) QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF) OMP_FOR_GIMPLIFYING_P (in OMP_FOR) BASELINK_QUALIFIED_P (in BASELINK) @@ -2781,9 +2780,12 @@ extern void decl_shadowed_for_var_insert (tree, tree); (LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE)) \ ->u.saved_language_function) -/* Indicates an indirect_expr is for converting a reference. */ -#define REFERENCE_REF_P(NODE) \ - TREE_LANG_FLAG_0 (INDIRECT_REF_CHECK (NODE)) +/* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference. */ +#define REFERENCE_REF_P(NODE) \ + (TREE_CODE (NODE) == INDIRECT_REF \ + && TREE_TYPE (TREE_OPERAND (NODE, 0)) \ + && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \ + == REFERENCE_TYPE)) #define NEW_EXPR_USE_GLOBAL(NODE) \ TREE_LANG_FLAG_0 (NEW_EXPR_CHECK (NODE)) diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 64fe871..db4ea46 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -520,7 +520,6 @@ convert_from_reference (tree val) TREE_THIS_VOLATILE (ref) = CP_TYPE_VOLATILE_P (t); TREE_SIDE_EFFECTS (ref) = (TREE_THIS_VOLATILE (ref) || TREE_SIDE_EFFECTS (val)); - REFERENCE_REF_P (ref) = 1; val = ref; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b56ab1f..d109e1b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18918,7 +18918,7 @@ build_non_dependent_expr (tree expr) /* Keep dereferences outside the NON_DEPENDENT_EXPR so lvalue_kind doesn't need to look inside. */ - if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr)) + if (REFERENCE_REF_P (expr)) return convert_from_reference (build_non_dependent_expr (TREE_OPERAND (expr, 0))); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 815824a..8bf5a52 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3428,7 +3428,7 @@ finish_offsetof (tree expr) error ("cannot apply % to member function %qD", expr); return error_mark_node; } - if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr)) + if (REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0); return fold_offsetof (expr, NULL_TREE); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9a6e26d..3230393 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -61,9 +61,7 @@ lvalue_kind (const_tree ref) INDIRECT_REFs. INDIRECT_REFs are just internal compiler representation, not part of the language, so we have to look through them. */ - if (TREE_CODE (ref) == INDIRECT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) - == REFERENCE_TYPE) + if (REFERENCE_REF_P (ref)) return lvalue_kind (TREE_OPERAND (ref, 0)); if (TREE_TYPE (ref)