From patchwork Fri Jan 3 17:29:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 306638 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D5AD82C00A5 for ; Sat, 4 Jan 2014 04:29:26 +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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=xQhmxBHdEsITiWNYV 9cMhpVV01irmT34Kn5xQDzd9+YRqbwNaKiTGRp0mrSSK7Wbp1lAVEG07KGAm541M 7ingnIwZRXo1bpTtYOPjYhwBKABy8HzB51oHYKmYiWNrMrFiRUmPyc2c/2C5gVjm JjshqHx5vvJbzuRnda6Uwv8vSg= 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=0VtP1AVIMT4EKZolVGISE84 t7Y8=; b=efO8lrVUZpeOOf8SDPJK4lCLRzhxSDeMySvhrrghVfqNpcWV2PkfWIk tCvAqGh8Yn3/RB+TTuwtvV1ZkF9L5BkhUsMAQAVgIQ605r7F+6KpgkQLiqed/LXc I5rbkMb9l4w7xhK2eZCkceaydZwMtFSuIcBnxov8JT7B9Ny+mMbM= Received: (qmail 32024 invoked by alias); 3 Jan 2014 17:29:17 -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 31906 invoked by uid 89); 3 Jan 2014 17:29:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 03 Jan 2014 17:29:15 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s03HTCt1030278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jan 2014 17:29:13 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s03HTBOA002297 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Jan 2014 17:29:11 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s03HTBqH002293; Fri, 3 Jan 2014 17:29:11 GMT Received: from [192.168.1.4] (/79.33.223.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Jan 2014 09:29:10 -0800 Message-ID: <52C6F365.4040700@oracle.com> Date: Fri, 03 Jan 2014 18:29:09 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] Fix __is_base_of vs incomplete types References: <52A3B01A.6070006@oracle.com> <52A93513.3010703@redhat.com> <52A93B24.3060200@oracle.com> <52A9C5FF.9040401@redhat.com> <52BD6C6C.5080606@oracle.com> <52C5DE26.5000409@redhat.com> In-Reply-To: <52C5DE26.5000409@redhat.com> X-IsSubscribed: yes Hi, On 01/02/2014 10:46 PM, Jason Merrill wrote: > On 12/27/2013 07:02 AM, Paolo Carlini wrote: >> the same arguments. Conservatively but still more neatly than my first >> try, we could maybe use same_type_ignoring_top_level_qualifiers_p in the >> definition of the DERIVED_FROM_P macro? > > Sure, let's do that. And add something about incomplete types to the > pre-function comment for lookup_base. Great. Thus I successfully tested on x86_64-linux the below. Thanks, Paolo. //////////////////////// /cp 2014-01-03 Paolo Carlini * cp-tree.h (DERIVED_FROM_P): True when PARENT and TYPE are the same class-type (even if incomplete). * search.c (lookup_base): Extend comment. /testsuite 2014-01-03 Paolo Carlini * g++.dg/ext/is_base_of_incomplete-2.C: New. Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 206313) +++ cp/cp-tree.h (working copy) @@ -1324,7 +1324,9 @@ enum languages { lang_c, lang_cplusplus, lang_java /* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and ambiguity issues. */ #define DERIVED_FROM_P(PARENT, TYPE) \ - (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE) + (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE \ + || ((TYPE) && NON_UNION_CLASS_TYPE_P (TYPE) \ + && same_type_ignoring_top_level_qualifiers_p ((PARENT), (TYPE)))) /* Gives the visibility specification for a class type. */ #define CLASSTYPE_VISIBILITY(TYPE) \ Index: cp/search.c =================================================================== --- cp/search.c (revision 206313) +++ cp/search.c (working copy) @@ -177,8 +177,8 @@ accessible_base_p (tree t, tree base, bool conside discovered. If the base is inaccessible, or ambiguous, then error_mark_node is - returned. If the tf_error bit of COMPLAIN is not set, no error - is issued. */ + returned. If the tf_error bit of COMPLAIN is not set, no error is + issued. If the base in incomplete, then NULL_TREE is returned. */ tree lookup_base (tree t, tree base, base_access access, Index: testsuite/g++.dg/ext/is_base_of_incomplete-2.C =================================================================== --- testsuite/g++.dg/ext/is_base_of_incomplete-2.C (revision 0) +++ testsuite/g++.dg/ext/is_base_of_incomplete-2.C (working copy) @@ -0,0 +1,5 @@ +struct T; + +int check1[__is_base_of(T, T) ? 1 : -1]; +int check2[__is_base_of(T, const T) ? 1 : -1]; +int check3[__is_base_of(volatile T, T) ? 1 : -1];