From 5f546e16b7ebff030c8d8f933b99378ce2a271c8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 29 Oct 2013 15:20:10 +0000 Subject: [PATCH] re PR c++/58888 ([c++11] Rejects-valid: static member with auto and initializer) /cp 2013-10-29 Paolo Carlini PR c++/58888 * decl2.c (grokfield): Handle auto like NSDMI. /testsuite 2013-10-29 Paolo Carlini PR c++/58888 * g++.dg/cpp0x/auto40.C: New. * g++.dg/other/warning1.C: Adjust. From-SVN: r204164 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl2.c | 20 -------------------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/auto40.C | 11 +++++++++++ gcc/testsuite/g++.dg/other/warning1.C | 4 ++-- 5 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto40.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 297d015a866..99f14e0ce80 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-10-29 Paolo Carlini + + PR c++/58888 + * decl2.c (grokfield): Handle auto like NSDMI. + 2013-10-25 Paolo Carlini PR c++/58878 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 5e5f5e82919..26688495256 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -955,26 +955,6 @@ grokfield (const cp_declarator *declarator, /* C++11 NSDMI, keep going. */; else if (!VAR_P (value)) gcc_unreachable (); - else if (!processing_template_decl) - { - if (TREE_CODE (init) == CONSTRUCTOR) - init = digest_init (TREE_TYPE (value), init, tf_warning_or_error); - init = maybe_constant_init (init); - - if (init != error_mark_node && !TREE_CONSTANT (init)) - { - /* We can allow references to things that are effectively - static, since references are initialized with the - address. */ - if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE - || (TREE_STATIC (init) == 0 - && (!DECL_P (init) || DECL_EXTERNAL (init) == 0))) - { - error ("field initializer is not constant"); - init = error_mark_node; - } - } - } } if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e5438f5841..357939e9dd4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-10-29 Paolo Carlini + + PR c++/58888 + * g++.dg/cpp0x/auto40.C: New. + * g++.dg/other/warning1.C: Adjust. + 2013-10-29 Richard Biener * gcc.dg/torture/restrict-2.c: New testcase. diff --git a/gcc/testsuite/g++.dg/cpp0x/auto40.C b/gcc/testsuite/g++.dg/cpp0x/auto40.C new file mode 100644 index 00000000000..287191e5910 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto40.C @@ -0,0 +1,11 @@ +// PR c++/58888 +// { dg-do compile { target c++11 } } + +#include + +struct A +{ + static constexpr auto b{1.0}; +}; + +constexpr decltype(A::b) A::b; diff --git a/gcc/testsuite/g++.dg/other/warning1.C b/gcc/testsuite/g++.dg/other/warning1.C index c65ae0ff6ef..a23d0ca6cba 100644 --- a/gcc/testsuite/g++.dg/other/warning1.C +++ b/gcc/testsuite/g++.dg/other/warning1.C @@ -7,8 +7,8 @@ extern "C" int printf(const char *, ...); struct S { - static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|float|initializ" } - static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|float|initializ" } + static const float inf = 1.0f / 0.0f; // { dg-error "1.0|float|initializ" } + static const float nan = 0.0f / 0.0f; // { dg-error "0.0|float|initializ" } }; int main()