Looks good to me. Yay for kicking the can down the road. ;)

On Tue, May 15, 2012 at 12:57 PM, Ollie Wild <a...@google.com> wrote:
> 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  <a...@google.com>
>
>        * 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.
>
> 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,
> -                  "%<constexpr%> 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,
> +                   "%<constexpr%> 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.ewer...@syscon.uu.se (Ove Ewerlid)
>  // Subject: ss-940630:cc1plus: internal error
>  // Date: Sat, 2 Jul 1994 05:07:20 +0200
>
> --
> This patch is available for review at http://codereview.appspot.com/6212051

Reply via email to