]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58888 ([c++11] Rejects-valid: static member with auto and initializer)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 29 Oct 2013 15:20:10 +0000 (15:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 29 Oct 2013 15:20:10 +0000 (15:20 +0000)
/cp
2013-10-29  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58888
* decl2.c (grokfield): Handle auto like NSDMI.

/testsuite
2013-10-29  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58888
* g++.dg/cpp0x/auto40.C: New.
* g++.dg/other/warning1.C: Adjust.

From-SVN: r204164

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto40.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/warning1.C

index 297d015a86691df941898e3a62683f022e5f4652..99f14e0ce8098601329fd871e12a03734e583778 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-29  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58888
+       * decl2.c (grokfield): Handle auto like NSDMI.
+
 2013-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58878
index 5e5f5e8291986566159f2e88ea4553b1b61f52c0..266884952569a0abe0f078ffa87f7034fb5c4d94 100644 (file)
@@ -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))
index 7e5438f5841d1af954cb0dbb2541c407e3c1ec8a..357939e9dd4ba6f799e6259ff8d3798f75e32364 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-29  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58888
+       * g++.dg/cpp0x/auto40.C: New.
+       * g++.dg/other/warning1.C: Adjust.
+
 2013-10-29  Richard Biener  <rguenther@suse.de>
 
        * 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 (file)
index 0000000..287191e
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/58888
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+struct A
+{
+  static constexpr auto b{1.0};
+};
+
+constexpr decltype(A::b) A::b;
index c65ae0ff6efbf02e7009bab7c0fe500187c2a543..a23d0ca6cba561c95f7be9c864d61630871bf25f 100644 (file)
@@ -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()