From patchwork Mon Apr 22 20:32:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 238662 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4A2952C0123 for ; Tue, 23 Apr 2013 06:33:08 +1000 (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:content-type; q= dns; s=default; b=S+lqJDercm5n9SrpH168xakjI+3tY3Oi4XBRIUBZc/10ol PTAiiJIKsihRWbEE+cCoOeADfvWkDXvsbcsEkPXh8rXLDugPC9Y8JoeWyq8YxCJw 0wD9bOWArFjumF6f7WxKpPJo5Z8/mwHSCsxLc1DhdcjxD1Ss6kxIE0OzzqkNo= 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:content-type; s= default; bh=Vmc2MZadDx7NDQgCCdlv0CyZiqc=; b=rsPYSHkIG+pPgeH1VADF wsNIHXHx4iGoG57FIf9PuvY1hVeRM1bQ46bUW4l/83KtVvKYwaioSe2mDlujywe9 uJ50cixjGSEe6H9m270ZHJV+atw4N7obOjXQU17Aew6qQ7pYKSfsNVc7WNEo3CqS fxGjMKMR0IwfHPK8qIQ+S9M= Received: (qmail 32064 invoked by alias); 22 Apr 2013 20:33:01 -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 32045 invoked by uid 89); 22 Apr 2013 20:33:01 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Apr 2013 20:32:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3MKWkKu001590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Apr 2013 16:32:47 -0400 Received: from [10.36.116.23] (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3MKWiBS024060; Mon, 22 Apr 2013 16:32:45 -0400 Message-ID: <51759E6B.7040306@redhat.com> Date: Mon, 22 Apr 2013 16:32:43 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Thunderbird/22.0a2 MIME-Version: 1.0 To: gcc-patches List , libstdc++ Subject: C++ PATCH for c++/48665 (typeid and function-cv-quals) - also disables some library tests X-Virus-Found: No This PR complained that G++ was using the same type_info node for a function type with or without function-cv-qualifiers. As I read the standard, typeid is not one of the few ways that a function-cv-qualifier can be used, so we should just give an error in that case. I'm also fixing the compiler to reject forming a pointer or reference to function-cv-qualified type at instantiation time as well as parse time. As a result of the latter change, I needed to comment out a bunch of libstdc++ tests that were trying to form a reference to function-cv-qualified type. Library folks may want to deal with this in some other way. Tested x86_64-pc-linux-gnu, applying to trunk. commit a18ad4a33d12b2dc4a76034baeddb8d74cc83388 Author: Jason Merrill Date: Thu Apr 11 18:41:30 2013 -0400 PR c++/48665 * rtti.c (get_typeid): Diagnose qualified function type. * pt.c (tsubst) [POINTER_TYPE]: Likewise. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 77329a4..6ce2770 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11521,6 +11521,21 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) return error_mark_node; } + else if (TREE_CODE (type) == FUNCTION_TYPE + && (type_memfn_quals (type) != TYPE_UNQUALIFIED + || type_memfn_rqual (type) != REF_QUAL_NONE)) + { + if (complain & tf_error) + { + if (code == POINTER_TYPE) + error ("forming pointer to qualified function type %qT", + type); + else + error ("forming reference to qualified function type %qT", + type); + } + return error_mark_node; + } else if (code == POINTER_TYPE) { r = build_pointer_type (type); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index b3c6687..4e73165 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -477,6 +477,16 @@ get_typeid (tree type, tsubst_flags_t complain) referenced type. */ type = non_reference (type); + /* This is not one of the uses of a qualified function type in 8.3.5. */ + if (TREE_CODE (type) == FUNCTION_TYPE + && (type_memfn_quals (type) != TYPE_UNQUALIFIED + || type_memfn_rqual (type) != REF_QUAL_NONE)) + { + if (complain & tf_error) + error ("typeid of qualified function type %qT", type); + return error_mark_node; + } + /* The top-level cv-qualifiers of the lvalue expression or the type-id that is the operand of typeid are always ignored. */ type = TYPE_MAIN_VARIANT (type); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype40.C b/gcc/testsuite/g++.dg/cpp0x/decltype40.C index 7933c95..55258f4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype40.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype40.C @@ -68,7 +68,7 @@ static_assert(sizeof(g(0)) == 2, "Ouch"); static_assert(sizeof(g(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); -static_assert(sizeof(f(0)) == 2, "Ouch"); +//static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); static_assert(sizeof(f(0)) == 2, "Ouch"); @@ -90,7 +90,7 @@ static_assert(sizeof(g2(0)) == 2, "Ouch"); static_assert(sizeof(g2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); -static_assert(sizeof(f2(0)) == 2, "Ouch"); +//static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); static_assert(sizeof(f2(0)) == 2, "Ouch"); diff --git a/gcc/testsuite/g++.dg/rtti/fn-quals.C b/gcc/testsuite/g++.dg/rtti/fn-quals.C new file mode 100644 index 0000000..75d24f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/fn-quals.C @@ -0,0 +1,12 @@ +// PR c++/48665 + +#include +extern "C" void abort(); + +template void f() { + if (typeid(A)==typeid(B)) abort(); // { dg-error "qualified function" } + if (typeid(A*)==typeid(B*)) abort(); // { dg-error "qualified function" } +} +int main() { + f(); +} diff --git a/libstdc++-v3/testsuite/20_util/is_assignable/value.cc b/libstdc++-v3/testsuite/20_util/is_assignable/value.cc index eade406..8d45671 100644 --- a/libstdc++-v3/testsuite/20_util/is_assignable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_assignable/value.cc @@ -277,8 +277,8 @@ static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); -static_assert(!std::is_assignable::value, "Error"); +// static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); -static_assert(std::is_assignable::value, "Error"); +//static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); static_assert(std::is_assignable::value, "Error"); @@ -636,8 +636,8 @@ static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); -static_assert(!std::is_assignable::value, "Error"); +// static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); static_assert(!std::is_assignable::value, "Error"); diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc index ba6ffab..f311911 100644 --- a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc +++ b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc @@ -72,8 +72,8 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, - "Error"); +// static_assert(!std::is_constructible::value, +// "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -461,20 +461,20 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, - "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, +// "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -488,8 +488,8 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); @@ -651,13 +651,13 @@ static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); -static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); +// static_assert(!std::is_constructible::value, "Error"); static_assert(!std::is_constructible, int, int>::value, "Error"); static_assert(!std::is_constructible, int, int>::value, diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc index 24cd6b9..e849a5d 100644 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc @@ -27,9 +27,9 @@ using namespace std; struct T; reference_wrapper::result_type i01; -reference_wrapper::result_type i02; -reference_wrapper::result_type i03; -reference_wrapper::result_type i04; +// reference_wrapper::result_type i02; +// reference_wrapper::result_type i03; +// reference_wrapper::result_type i04; reference_wrapper::result_type i05; reference_wrapper::result_type i06; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc index 89dcd3b..e0f7231 100644 --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc @@ -25,13 +25,13 @@ using namespace std; reference_wrapper::argument_type i01; -reference_wrapper::argument_type i02; -reference_wrapper::argument_type i03; -reference_wrapper::argument_type i04; +// reference_wrapper::argument_type i02; +// reference_wrapper::argument_type i03; +// reference_wrapper::argument_type i04; reference_wrapper::result_type i05; -reference_wrapper::result_type i06; -reference_wrapper::result_type i07; -reference_wrapper::result_type i08; +// reference_wrapper::result_type i06; +// reference_wrapper::result_type i07; +// reference_wrapper::result_type i08; reference_wrapper::argument_type i09; reference_wrapper::argument_type i10; @@ -43,17 +43,17 @@ reference_wrapper::result_type i15; reference_wrapper::result_type i16; reference_wrapper::first_argument_type i17; -reference_wrapper::first_argument_type i18; -reference_wrapper::first_argument_type i19; -reference_wrapper::first_argument_type i20; +// reference_wrapper::first_argument_type i18; +// reference_wrapper::first_argument_type i19; +// reference_wrapper::first_argument_type i20; reference_wrapper::second_argument_type i21; -reference_wrapper::second_argument_type i22; -reference_wrapper::second_argument_type i23; -reference_wrapper::second_argument_type i24; +// reference_wrapper::second_argument_type i22; +// reference_wrapper::second_argument_type i23; +// reference_wrapper::second_argument_type i24; reference_wrapper::result_type i25; -reference_wrapper::result_type i26; -reference_wrapper::result_type i27; -reference_wrapper::result_type i28; +// reference_wrapper::result_type i26; +// reference_wrapper::result_type i27; +// reference_wrapper::result_type i28; reference_wrapper::first_argument_type i29; reference_wrapper::first_argument_type i30;