From patchwork Tue May 15 19:57:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ollie Wild X-Patchwork-Id: 159428 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 43677B6FA5 for ; Wed, 16 May 2012 05:58:00 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1337716681; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=VjRgg8i seJkgCa6ZRU17unxIeHU=; b=ULvtNuJ1vSRDL125dSZyV2bUvA2A+uHg4NzE7cI +Xl4Xse3gNGUZ6HoliBfhYFppqK87h6F8ceAceWP7xB2jlVu7lFukmhAyxiOmuWX fW1dbfX7iW5hcIYzLcwUhc6Z4mAEEgv7bPz5CrDWW+2C7I4HuF9BendmQysN3PHZ K7Bc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GK9bxYGii5Co0ZQ67+aTqrqQJGxX+wSDZso86g4IR9YVPM6PnQ1nyjAc5oOKEQ cBZyoJjawXQOfYxeK5N2TJOaFQrJ5P8apxztybIyz04Z7FmMxe1nNq+TrOpNFa4j Stzby0znY5tm73ZdLvboT08oj6zUESJ/zAJgUKiRlbOtk=; Received: (qmail 3928 invoked by alias); 15 May 2012 19:57:56 -0000 Received: (qmail 3917 invoked by uid 22791); 15 May 2012 19:57:55 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-gg0-f201.google.com (HELO mail-gg0-f201.google.com) (209.85.161.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 May 2012 19:57:42 +0000 Received: by ggmi2 with SMTP id i2so677878ggm.2 for ; Tue, 15 May 2012 12:57:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=pLpr3+FEGYubxeTpFjN1t8RCc2ZemeukqTZ7D3uT638=; b=UXH74EFFJbInabP3lxwlmcZYQoPEO0UvjcKOzH1r97PPwfbx288b2sFuA4mBKiBe1D UL4r9VYdb1fmUFFTZTboQMXl+F/28u6eSDokyirJlkICQfu2huIISYLCOt+YGBmuhcNj gAvzdginQc77+5Q/0WQacYBepCnrgV2SurjyrxzUMHxnU2vBcDC5RlfCyxbUsVc4h36a ZObo+caVSBjqRakuGHy4g7QDpCzP7S1YxJ0vYjrdXTlNUNuA0CESCJPodVrUfPa2DMiI NNhSLGTcPXhCRjHVq8eiWIJ3SeMXHqUh9GpOMvkQGPpOtLAsN76OLzNS/4+Pz11R9oko 5F8g== Received: by 10.100.77.1 with SMTP id z1mr143852ana.5.1337111861992; Tue, 15 May 2012 12:57:41 -0700 (PDT) Received: by 10.100.77.1 with SMTP id z1mr143844ana.5.1337111861887; Tue, 15 May 2012 12:57:41 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id z24si148501yhh.1.2012.05.15.12.57.41 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 15 May 2012 12:57:41 -0700 (PDT) Received: from xoom.chi.corp.google.com (xoom.chi.corp.google.com [172.31.47.91]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id CDE921E004D; Tue, 15 May 2012 12:57:41 -0700 (PDT) Received: by xoom.chi.corp.google.com (Postfix, from userid 26705) id 80363A19A9; Tue, 15 May 2012 14:57:41 -0500 (CDT) To: reply@codereview.appspotmail.com, dnovillo@google.com, jyasskin@google.com, ppluzhnikov@google.com, gcc-patches@gcc.gnu.org Subject: [google/gcc-4_7] Allow static const floats unless -pedantic is passed (issue6212051) Message-Id: <20120515195741.80363A19A9@xoom.chi.corp.google.com> Date: Tue, 15 May 2012 14:57:41 -0500 (CDT) From: aaw@google.com (Ollie Wild) X-Gm-Message-State: ALoCoQmcQIWMLuC7nYjNu6oEA804Z41/3yvB4kp1E4ridZe6o0oUFItD4mWSAMtfKzTEAOkYNVQJxF5KNCfcRity8/DxH466/k6IIoJDIswMBkC9RX5kgseowpS/RyioTWQn1fkaQPKbIy/whM0A4TIAsNmrk0v+2Q== 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 To be applied to google/gcc-4_7. Allow static const floats unless -pedantic is passed. This patch allows us to migrate to C++11 more incrementally, since we can leave the static const float initializations in place, flip the switch, and then change it to use constexpr. This is a forward port of r180638 from google/gcc-4_6 (despite the fact that that revision says to NOT forward-port this). Minor additional fixups have been applied. 2012-05-15 Ollie Wild * gcc/cp/decl.c (check_static_variable_definition): Only generate a constexpr warning when -pedantic is enabled. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C: Replace -fpermissive with -pedantic. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C: New test. * gcc/testsuite/g++.old-deja/g++.ext/memconst.C: Compile with -pedantic -pedantic-errors to work around test failures with -std=gnu++11. --- This patch is available for review at http://codereview.appspot.com/6212051 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bb26d15..d2fe731 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7861,9 +7861,18 @@ check_static_variable_definition (tree decl, tree type) error ("in-class initialization of static data member %q#D of " "incomplete type", decl); else if (literal_type_p (type)) - permerror (input_location, - "% needed for in-class initialization of " - "static data member %q#D of non-integral type", decl); + { + /* FIXME google: This local modification allows us to + transition from C++98 to C++11 without moving static + const floats out of the class during the transition. It + should not be forward-ported to a 4.8 branch, since by + then we should be able to just fix the code to use + constexpr. */ + pedwarn (input_location, OPT_pedantic, + "% needed for in-class initialization of " + "static data member %q#D of non-integral type", decl); + return 0; + } else error ("in-class initialization of static data member %q#D of " "non-literal type", decl); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C index 7c84cf8..658a458 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C @@ -1,5 +1,5 @@ // PR c++/50258 -// { dg-options "-std=c++0x -fpermissive" } +// { dg-options "-std=c++0x -pedantic" } struct Foo { static const double d = 3.14; // { dg-warning "constexpr" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C new file mode 100644 index 0000000..28d34a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options "-std=c++0x" } + +struct Foo { + static const double d = 3.14; // no warning +}; +const double Foo::d; diff --git a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C index d934763..7e86156 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options "" } +// { dg-options "-pedantic -pedantic-errors" } // From: Ove.Ewerlid@syscon.uu.se (Ove Ewerlid) // Subject: ss-940630:cc1plus: internal error // Date: Sat, 2 Jul 1994 05:07:20 +0200