Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(369)

Issue 6212051: [google/gcc-4_7] Allow static const floats unless -pedantic is passed

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 4 months ago by Ollie Wild
Modified:
12 years, 4 months ago
CC:
ppluzhnikov, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -5 lines) Patch
M gcc/cp/decl.c View 1 chunk +12 lines, -3 lines 0 comments Download
M gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C View 1 chunk +1 line, -1 line 0 comments Download
A gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C View 1 chunk +7 lines, -0 lines 0 comments Download
M gcc/testsuite/g++.old-deja/g++.ext/memconst.C View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 2
Ollie Wild
To be applied to google/gcc-4_7. Allow static const floats unless -pedantic is passed. This patch ...
12 years, 4 months ago (2012-05-15 19:57:42 UTC) #1
Jeffrey Yasskin (google)
12 years, 4 months ago (2012-05-15 21:32:08 UTC) #2
Looks good to me. Yay for kicking the can down the road. ;)

On Tue, May 15, 2012 at 12:57 PM, Ollie Wild <aaw@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  <aaw@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.Ewerlid@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
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b