From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18911 invoked by alias); 14 Oct 2011 22:00:39 -0000 Received: (qmail 18894 invoked by uid 22791); 14 Oct 2011 22:00:37 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Oct 2011 22:00:21 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9EM0HHH010465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Oct 2011 22:00:18 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p9EM0GrX013151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Oct 2011 22:00:17 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p9EM0BkD029691; Fri, 14 Oct 2011 17:00:11 -0500 Received: from [192.168.1.4] (/79.43.235.225) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Oct 2011 15:00:10 -0700 Message-ID: <4E98B07E.6060409@oracle.com> Date: Fri, 14 Oct 2011 23:03:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 50732 References: <4E987E24.6000707@oracle.com> <4E987FDD.4060803@oracle.com> <4E9882FF.1050407@oracle.com> <4E9888AC.8070605@redhat.com> In-Reply-To: <4E9888AC.8070605@redhat.com> Content-Type: multipart/mixed; boundary="------------060403030000010602070308" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg01355.txt.bz2 This is a multi-part message in MIME format. --------------060403030000010602070308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 659 On 10/14/2011 09:08 PM, Jason Merrill wrote: > How about using complete_type_or_else? The CPTK_IS_BASE_OF case becomes much simpler indeed, thanks. For the unary traits, though, I don't see an advantage in using it, because in some cases in check_trait_type we don't want to error out even when complete_type_or_else would. Unless we can check whether we are dealing with an array of unknown bound *before* completing the type? That is: if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) && COMPLETE_TYPE_P (TREE_TYPE (type))) is the outcome always the same before and after trying to complete (type)? Thanks, Paolo. ////////////////////// --------------060403030000010602070308 Content-Type: text/plain; name="patch_50732_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_50732_2" Content-length: 2111 Index: testsuite/g++.dg/ext/is_base_of_diagnostic.C =================================================================== --- testsuite/g++.dg/ext/is_base_of_diagnostic.C (revision 180007) +++ testsuite/g++.dg/ext/is_base_of_diagnostic.C (working copy) @@ -1,7 +1,7 @@ class A { }; -class B; +class B; // { dg-error "forward declaration" } union C { }; Index: testsuite/g++.dg/ext/is_base_of_incomplete.C =================================================================== --- testsuite/g++.dg/ext/is_base_of_incomplete.C (revision 0) +++ testsuite/g++.dg/ext/is_base_of_incomplete.C (revision 0) @@ -0,0 +1,7 @@ +template +struct non_instantiable +{ + typedef typename T::THIS_TYPE_CANNOT_BE_INSTANTIATED type; +}; + +int check[__is_base_of(non_instantiable, void) ? -1 : 1]; Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 180007) +++ cp/semantics.c (working copy) @@ -5276,10 +5276,6 @@ finish_trait_expr (cp_trait_kind kind, tree type1, return trait_expr; } - complete_type (type1); - if (type2) - complete_type (type2); - switch (kind) { case CPTK_HAS_NOTHROW_ASSIGN: @@ -5297,9 +5293,10 @@ finish_trait_expr (cp_trait_kind kind, tree type1, case CPTK_IS_POLYMORPHIC: case CPTK_IS_STD_LAYOUT: case CPTK_IS_TRIVIAL: + complete_type (type1); if (!check_trait_type (type1)) { - error ("incomplete type %qT not allowed", type1); + error ("invalid use of incomplete type %qT", type1); return error_mark_node; } break; @@ -5307,11 +5304,9 @@ finish_trait_expr (cp_trait_kind kind, tree type1, case CPTK_IS_BASE_OF: if (NON_UNION_CLASS_TYPE_P (type1) && NON_UNION_CLASS_TYPE_P (type2) && !same_type_ignoring_top_level_qualifiers_p (type1, type2) - && !COMPLETE_TYPE_P (type2)) - { - error ("incomplete type %qT not allowed", type2); - return error_mark_node; - } + && !complete_type_or_else (type2, NULL_TREE)) + /* We already issued an error. */ + return error_mark_node; break; case CPTK_IS_CLASS: --------------060403030000010602070308--