From patchwork Sun Nov 17 10:37:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 291818 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E20B62C009D for ; Sun, 17 Nov 2013 21:37:32 +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:cc:subject:content-type; q=dns; s=default; b=GK49UzHwoLxVEw9K/x18lsp0xCbFSo/ekFGLEO1FNJ7 P7eGP1zEJ/TT3nzTtWIvs710rUbVppXOQj2LtnXH75V0pH7bJbGuVGRERhFWzSSE 7s6c8yGx2a/0TgQSudPOAy/k3WDvTb9BdeQ+/ZLN4/i5+BYQZcGb7ECtm6uI5eDg = 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=QAmt21e0N23G+i63L/tyzViPjI0=; b=QtHeGVCLhlA6QdqeG g6i+5xhoIWAj38UTe/qM4UtGmXcMHlhORLTPKngcyxxRoCE5zdUGIWiljp65k3Tr u+aOz5n7F5Ssp8VM+gvFXz47r1u6t6FFkWab4OepZA9EnPUX5/nkimbDtYcxHHl2 36lhJPU/gsY24a6B2oqFxfx/24= Received: (qmail 21258 invoked by alias); 17 Nov 2013 10:37:23 -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 21249 invoked by uid 89); 17 Nov 2013 10:37:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: userp1040.oracle.com Received: from Unknown (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 17 Nov 2013 10:37:22 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rAHAbDh8028724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 17 Nov 2013 10:37:14 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAHAbCaB025172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 17 Nov 2013 10:37:12 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAHAbCBd010887; Sun, 17 Nov 2013 10:37:12 GMT Received: from poldo4.casa (/79.33.222.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 17 Nov 2013 02:37:12 -0800 Message-ID: <52889C56.4050306@oracle.com> Date: Sun, 17 Nov 2013 11:37:10 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 59123 X-IsSubscribed: yes Hi, C++11 7.1.5 seems very clear that redeclarations of *variables* differing in constexpr are fine (clang and icc agree). Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2013-11-17 Paolo Carlini PR c++/59123 * decl.c (validate_constexpr_redeclaration): Redeclarations of variables can differ in constexpr. /testsuite 2013-11-17 Paolo Carlini PR c++/59123 * g++.dg/cpp0x/constexpr-redeclaration1.C: New. * g++.dg/cpp0x/constexpr-decl.C: Adjust. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 204913) +++ cp/decl.c (working copy) @@ -1216,10 +1216,12 @@ validate_constexpr_redeclaration (tree old_decl, t if (! DECL_TEMPLATE_SPECIALIZATION (old_decl) && DECL_TEMPLATE_SPECIALIZATION (new_decl)) return true; + + error ("redeclaration %qD differs in %", new_decl); + error ("from previous declaration %q+D", old_decl); + return false; } - error ("redeclaration %qD differs in %", new_decl); - error ("from previous declaration %q+D", old_decl); - return false; + return true; } #define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn) \ Index: testsuite/g++.dg/cpp0x/constexpr-decl.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-decl.C (revision 204913) +++ testsuite/g++.dg/cpp0x/constexpr-decl.C (working copy) @@ -3,8 +3,7 @@ struct S { static constexpr int size; // { dg-error "must have an initializer" "must have" } - // { dg-error "previous declaration" "previous" { target *-*-* } 5 } }; const int limit = 2 * S::size; -constexpr int S::size = 256; // { dg-error "" } +constexpr int S::size = 256; Index: testsuite/g++.dg/cpp0x/constexpr-redeclaration1.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-redeclaration1.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-redeclaration1.C (working copy) @@ -0,0 +1,10 @@ +// PR c++/59123 +// { dg-do compile { target c++11 } } + +// Fwd-declarations +struct S; +extern const S s; + +// (... later) definitions +struct S {}; +constexpr S s {};