From patchwork Wed Apr 27 08:50:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 93004 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 44569B6EF3 for ; Wed, 27 Apr 2011 18:51:28 +1000 (EST) Received: (qmail 24550 invoked by alias); 27 Apr 2011 08:51:25 -0000 Received: (qmail 24538 invoked by uid 22791); 27 Apr 2011 08:51:23 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp205.alice.it (HELO smtp205.alice.it) (82.57.200.101) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Apr 2011 08:50:51 +0000 Received: from [192.168.1.4] (79.53.21.49) by smtp205.alice.it (8.5.124.08) id 4DB13A49005B4D92; Wed, 27 Apr 2011 10:50:49 +0200 Message-ID: <4DB7D8D4.1000802@oracle.com> Date: Wed, 27 Apr 2011 10:50:28 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 48771 X-IsSubscribed: yes 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 Hi, today I (re-)tested the below. As you can see, wrt the audit trail discussion, I also removed altogether valid_type_in_constexpr_fundecl_p, I can restore it if you want, just let me know. Tested x86_64-linux. Ok for mainline? (not sure if it qualifies for the branch or we want to reconsider it in a couple of weeks?!?) Thanks, Paolo. /////////////////////// /cp 2011-04-27 Paolo Carlini PR c++/48771 * semantics.c (literal_type_p): Reference types are literal types, per the FDIS. (valid_type_in_constexpr_fundecl_p): Remove. (is_valid_constexpr_fn): Adjust. /testsuite 2011-04-27 Paolo Carlini PR c++/48771 * g++.dg/ext/is_literal_type1.C: New. Index: testsuite/g++.dg/ext/is_literal_type1.C =================================================================== --- testsuite/g++.dg/ext/is_literal_type1.C (revision 0) +++ testsuite/g++.dg/ext/is_literal_type1.C (revision 0) @@ -0,0 +1,11 @@ +// PR c++/48771 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct NonLiteral { + NonLiteral(); + ~NonLiteral(); +}; + +static_assert(__is_literal_type(NonLiteral&), "Error"); +static_assert(__is_literal_type(NonLiteral&&), "Error"); Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 173012) +++ cp/semantics.c (working copy) @@ -5331,7 +5331,8 @@ float_const_decimal64_p (void) bool literal_type_p (tree t) { - if (SCALAR_TYPE_P (t)) + if (SCALAR_TYPE_P (t) + || TREE_CODE (t) == REFERENCE_TYPE) return true; if (CLASS_TYPE_P (t)) return CLASSTYPE_LITERAL_P (t); @@ -5406,18 +5407,6 @@ retrieve_constexpr_fundef (tree fun) return (constexpr_fundef *) htab_find (constexpr_fundef_table, &fundef); } -/* Return true if type expression T is a valid parameter type, or - a valid return type, of a constexpr function. */ - -static bool -valid_type_in_constexpr_fundecl_p (tree t) -{ - return (literal_type_p (t) - /* FIXME we allow ref to non-literal; should change standard to - match, or change back if not. */ - || TREE_CODE (t) == REFERENCE_TYPE); -} - /* Check whether the parameter and return types of FUN are valid for a constexpr function, and complain if COMPLAIN. */ @@ -5427,7 +5416,7 @@ is_valid_constexpr_fn (tree fun, bool complain) tree parm = FUNCTION_FIRST_USER_PARM (fun); bool ret = true; for (; parm != NULL; parm = TREE_CHAIN (parm)) - if (!valid_type_in_constexpr_fundecl_p (TREE_TYPE (parm))) + if (!literal_type_p (TREE_TYPE (parm))) { ret = false; if (complain) @@ -5438,7 +5427,7 @@ is_valid_constexpr_fn (tree fun, bool complain) if (!DECL_CONSTRUCTOR_P (fun)) { tree rettype = TREE_TYPE (TREE_TYPE (fun)); - if (!valid_type_in_constexpr_fundecl_p (rettype)) + if (!literal_type_p (rettype)) { ret = false; if (complain)