]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/50965 (C++11 Non static member initializer are not run when class is initia...
authorOlivier Goffart <olivier@woboq.com>
Fri, 4 Nov 2011 17:15:02 +0000 (17:15 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 4 Nov 2011 17:15:02 +0000 (13:15 -0400)
PR c++/50965
* class.c (check_field_decls): NSDMI makes a class non-aggregate.

Co-Authored-By: Jason Merrill <jason@redhat.com>
From-SVN: r180965

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nsdmi1.C

index 47e79fe9c5ab7a1bf2620bfcd69ba0ac89223ba4..27c8b70924752c479e6932038cb62cd485d906f1 100644 (file)
@@ -1,3 +1,9 @@
+2011-11-04  Olivier Goffart  <olivier@woboq.com>
+           Jason Merrill  <jason@redhat.com>
+
+       PR c++/50965
+       * class.c (check_field_decls): NSDMI makes a class non-aggregate.
+
 2011-11-04  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/48420
index 41d182a4ca88c2d486d3eeec2549cdae62234c9f..1775868aa8ad496e68a6096911b665210585041c 100644 (file)
@@ -3189,6 +3189,12 @@ check_field_decls (tree t, tree *access_decls,
                          no_const_asn_ref_p,
                          &any_default_members);
 
+      /* Now that we've removed bit-field widths from DECL_INITIAL,
+        anything left in DECL_INITIAL is an NSDMI that makes the class
+        non-aggregate.  */
+      if (DECL_INITIAL (x))
+       CLASSTYPE_NON_AGGREGATE (t) = true;
+
       /* If any field is const, the structure type is pseudo-const.  */
       if (CP_TYPE_CONST_P (type))
        {
index dc52d29e5b494f1e7d3c18bee408a4bc29a64fd6..c941abc1a55a7b375350cf88089319a3bd804690 100644 (file)
@@ -3205,8 +3205,9 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 
 /* [dcl.init.aggr]
 
-   An aggregate is an array or a class with no user-declared
-   constructors, no private or protected non-static data members, no
+   An aggregate is an array or a class with no user-provided
+   constructors, no brace-or-equal-initializers for non-static data
+   members, no private or protected non-static data members, no
    base classes, and no virtual functions.
 
    As an extension, we also treat vectors as aggregates.  Keep these
index f47a503822c8de8c5c1768d92d08b2261d79160d..c9bd2480833970c980464e7dafac889172a3b132 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-04  Olivier Goffart  <olivier@woboq.com>
+
+       PR c++/50965
+       * g++.dg/cpp0x/nsdmi1.C: Add more cases.
+
 2011-11-04  Jiangning Liu  <jiangning.liu@arm.com>
 
        PR rtl-optimization/38644
index f6381d0fdb4b4c6404b2ea3d7a13388e630d4cc9..159c16de851791208295893d1efd4b1de8e7a772 100644 (file)
@@ -31,8 +31,8 @@ int main()
 {
   A a1;
   if (a1.i != 42) return 1;
-  A a2 = { 24 };
-  if (a2.i != 24) return 2;
+  A a2{};
+  if (a2.i != 42) return 2;
   A a3[1];
   if (a3[0].i != 42) return 3;
 
@@ -43,7 +43,7 @@ int main()
 
   C<int,3> c1;
   if (c1.m != 3) return 5;
-  C<int,3> c2 { 5 };
+  C<int,5> c2 {};
   if (c2.m != 5) return 6;
 
   D<int,3> d1;