[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: [C++11 Patch] NSMI and aggregate type
From:       Jason Merrill <jason () redhat ! com>
Date:       2011-11-04 17:15:33
Message-ID: 4EB41DB5.1040604 () redhat ! com
[Download RAW message or body]

We don't want to check DECL_INITIAL up there, as it might still be a 
bit-field size.  So I moved the check down a bit and checked it in.  Thanks!

Jason

["50965.patch" (text/x-patch)]

commit 5b18fa4cd800c94783b70c1cef1b711b424afe0d
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Nov 4 17:15:02 2011 +0000

    	PR c++/50965
    	* class.c (check_field_decls): NSDMI makes a class non-aggregate.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180965 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 41d182a..1775868 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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))
 	{
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dc52d29..c941abc 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi1.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi1.C
index f6381d0..159c16d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nsdmi1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi1.C
@@ -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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic