OSDN Git Service

PR c++/43719
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 May 2010 18:37:45 +0000 (18:37 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:04:42 +0000 (14:04 +0900)
* decl.c (check_initializer): strip array type before checking for
uninitialized const or ref members.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159242 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog

index d41a95f..c62f817 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-10  Fabien Chêne  <fabien.chene@gmail.com>
+
+       PR c++/43719
+       * decl.c (check_initializer): strip array type before checking for
+       uninitialized const or ref members.
+
 2010-05-07  Fabien Chêne  <fabien.chene@gmail.com>
 
        PR c++/43951
index 70b1041..4aa3441 100644 (file)
@@ -5207,6 +5207,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
 {
   tree type = TREE_TYPE (decl);
   tree init_code = NULL;
+  tree core_type;
 
   /* Things that are going to be initialized need to have complete
      type.  */
@@ -5318,14 +5319,12 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
       check_for_uninitialized_const_var (decl);
       return build_aggr_init_full_exprs (decl, init, flags);
     }
-  else if (MAYBE_CLASS_TYPE_P (type))
+  else if (MAYBE_CLASS_TYPE_P (core_type = strip_array_types (type)))
     {
-      tree core_type = strip_array_types (type);
-
-      if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type))
-       error ("structure %qD with uninitialized const members", decl);
-      if (CLASSTYPE_REF_FIELDS_NEED_INIT (core_type))
-       error ("structure %qD with uninitialized reference members", decl);
+      if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type)
+         || CLASSTYPE_REF_FIELDS_NEED_INIT (core_type))
+       diagnose_uninitialized_cst_or_ref_member (core_type, /*using_new=*/false,
+                                                 /*complain=*/true);
 
       check_for_uninitialized_const_var (decl);
     }
index 824920b..7f76632 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-10  Fabien Chêne  <fabien.chene@gmail.com>
+
+       PR c++/43719
+       * g++.dg/init/pr43719.C: New.
+       * g++.dg/anon-struct4.C: Adjust.
+
 2010-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/44028