From patchwork Tue Sep 2 09:37:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 385032 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 82BE51400D2 for ; Tue, 2 Sep 2014 19:37:53 +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:cc:subject:content-type; q=dns; s=default; b=ONRyajT6GWa+it7z/IsbczCu2Cy3UgPgu1Z82SNBcun Sxj/RZJoHFTjUr/wot7criZtdodVMjuSS1hX4Uyu2Et4C0xQqT67sA+Id3jj0bOp lupKIfwfEVdW1B2ufp7zvNeA6/Enq0wysuARRwmwKwJN3Fe9e3oHnOKla1ZA4Xwo = 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:cc:subject:content-type; s=default; bh=9NNqQXgLLALFT0KFec4y2l61WGQ=; b=iP1Jp62UGURFaeM3g 3u8xgWlcoXCGJK2KSLL2v9bRf/EHYd1Qp6WmG781Kw5t3NopFPsUrI9WqYiNInbx MxsXLDfYOGdvdyoiTQFDZm8HUTkXtf+XmC+aM4WDRDATXJmYWUpZwkxU2pJNmSFg E1dxTBvJq5ehm/caQvmvLBrESs= Received: (qmail 31939 invoked by alias); 2 Sep 2014 09:37:45 -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 31930 invoked by uid 89); 2 Sep 2014 09:37:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham 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; Tue, 02 Sep 2014 09:37:44 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s829beCT009249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Sep 2014 09:37:41 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s829bd1N028099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Sep 2014 09:37:40 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s829bdxU024509; Tue, 2 Sep 2014 09:37:39 GMT Received: from [192.168.1.4] (/87.11.217.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Sep 2014 02:37:39 -0700 Message-ID: <54058FE1.3090805@oracle.com> Date: Tue, 02 Sep 2014 11:37:37 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] DR 1453 X-IsSubscribed: yes Hi, while looking into c++/58102 and DR 1405 I noticed that we don't implement DR 1453 either, sort of dual issue with volatile instead of mutable. Tested x86_64-linux. Thanks, Paolo. //////////////////////// /cp 2014-09-02 Paolo Carlini DR 1453 * class.c (check_field_decls): A class of literal type cannot have volatile non-static data members and base classes. (explain_non_literal_class): Update. /testsuite 2014-09-02 Paolo Carlini DR 1453 * g++.dg/cpp0x/constexpr-volatile.C: New. * g++.dg/ext/is_literal_type2.C: Likewise. Index: cp/class.c =================================================================== --- cp/class.c (revision 214808) +++ cp/class.c (working copy) @@ -3528,9 +3528,11 @@ check_field_decls (tree t, tree *access_decls, CLASSTYPE_NON_AGGREGATE (t) = 1; /* If at least one non-static data member is non-literal, the whole - class becomes non-literal. Note: if the type is incomplete we - will complain later on. */ - if (COMPLETE_TYPE_P (type) && !literal_type_p (type)) + class becomes non-literal. Per Core/1453, volatile non-static + data members and base classes are also not allowed. + Note: if the type is incomplete we will complain later on. */ + if (COMPLETE_TYPE_P (type) + && (!literal_type_p (type) || CP_TYPE_VOLATILE_P (type))) CLASSTYPE_LITERAL_P (t) = false; /* A standard-layout class is a class that: @@ -5431,6 +5433,9 @@ explain_non_literal_class (tree t) if (CLASS_TYPE_P (ftype)) explain_non_literal_class (ftype); } + if (CP_TYPE_VOLATILE_P (ftype)) + inform (0, " non-static data member %q+D has " + "volatile type", field); } } } Index: testsuite/g++.dg/cpp0x/constexpr-volatile.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-volatile.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-volatile.C (working copy) @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +constexpr S s; // { dg-error "literal" } + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +constexpr T t; // { dg-error "literal" } + +struct U : Z { + constexpr U() : Z{} { } +}; + +constexpr U u; // { dg-error "literal" } Index: testsuite/g++.dg/ext/is_literal_type2.C =================================================================== --- testsuite/g++.dg/ext/is_literal_type2.C (revision 0) +++ testsuite/g++.dg/ext/is_literal_type2.C (working copy) @@ -0,0 +1,26 @@ +// DR 1453 +// { dg-do compile { target c++11 } } + +struct S { + constexpr S() : n{} { } + volatile int n; +}; + +static_assert(!__is_literal_type(S), ""); + +struct Z { + volatile int m; +}; + +struct T { + constexpr T() : n{} { } + Z n; +}; + +static_assert(!__is_literal_type(T), ""); + +struct U : Z { + constexpr U() : Z{} { } +}; + +static_assert(!__is_literal_type(U), "");