init.c (perform_member_init): Homogenize uninitialized diagnostics.
authorFabien Chêne <fabien@gcc.gnu.org>
Tue, 1 Apr 2014 21:14:04 +0000 (23:14 +0200)
committerFabien Chêne <fabien@gcc.gnu.org>
Tue, 1 Apr 2014 21:14:04 +0000 (23:14 +0200)
2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>

* cp/init.c (perform_member_init): Homogenize uninitialized
diagnostics.

2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>

        * g++.dg/init/ctor4.C: Adjust.
* g++.dg/init/ctor4-1.C: New.
* g++.dg/cpp0x/defaulted2.C: Adjust.

From-SVN: r208998

12 files changed:
gcc/cp/ChangeLog
gcc/cp/ChangeLog-2008
gcc/cp/ChangeLog-2010
gcc/cp/ChangeLog-2011
gcc/cp/ChangeLog-2012
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/ChangeLog-2008
gcc/testsuite/ChangeLog-2010
gcc/testsuite/g++.dg/cpp0x/defaulted2.C
gcc/testsuite/g++.dg/init/ctor4-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/ctor4.C

index 2e6fd96..332894f 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>
+
+       * cp/init.c (perform_member_init): Homogenize uninitialized
+       diagnostics.
+
 2014-04-01  Jason Merrill  <jason@redhat.com>
 
        PR c++/60708
@@ -44,9 +49,9 @@
 2014-03-26  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/52369
-       * cp/method.c (walk_field_subobs): improve the diagnostic
+       * cp/method.c (walk_field_subobs): Improve the diagnostic
        locations for both REFERENCE_TYPEs and non-static const members.
-       * cp/init.c (diagnose_uninitialized_cst_or_ref_member): use %q#D
+       * cp/init.c (diagnose_uninitialized_cst_or_ref_member): Use %q#D
        instead of %qD to be consistent with the c++11 diagnostic.
 
 2014-03-25  Jason Merrill  <jason@redhat.com>
index 5a69a5d..83fd123 100644 (file)
        * g++spec.c (LIBSTDCXX_STATIC): New.
        (lang_spec_driver): Use LIBSTDCXX_STATIC when not
        shared_libgcc.
-       
-2008-11-05  Fabien Chene <fabien.chene@gmail.com>
+
+2008-11-05  Fabien Chêne <fabien@gcc.gnu.org>
 
        PR c++/32519
        * cp-tree.h: Fix DECL_NONSTATIC_MEMBER_P to handle member template
index 5f56315..e706b7c 100644 (file)
        * typeck.c (cp_build_modify_expr): Complain about assignment to
        array from init list.
 
-2010-05-10  Fabien Chêne  <fabien.chene@gmail.com>
+2010-05-10  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/43719
-       * decl.c (check_initializer): strip array type before checking for
+       * 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>
+2010-05-07  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/43951
        * init.c (diagnose_uninitialized_cst_or_ref_member_1): Returns the
        PR c++/43779
        * typeck.c (warn_args_num): New function.
        (convert_arguments): Use warn_args_num to print the diagnostic
-       messages. 
+       messages.
 
-2010-04-29  Fabien Chêne  <fabien.chene@gmail.com>
+2010-04-29  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/43890
-       * init.c (diagnose_uninitialized_cst_or_ref_member): check for
+       * init.c (diagnose_uninitialized_cst_or_ref_member): Check for
        user-provided constructor while recursing.
 
 2010-04-28  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * init.c (perform_member_init): Check CLASS_TYPE_P.
 
-2010-04-27  Fabien Chêne  <fabien.chene@gmail.com>
+2010-04-27  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/29043
-       * init.c (perform_member_init): check for uninitialized const or
+       * init.c (perform_member_init): Check for uninitialized const or
        reference members, including array types.
 
 2010-04-24  Jason Merrill  <jason@redhat.com>
        convert_like_real.
        * cp-tree.h: Adjust.
 
-2010-04-27  Fabien Chêne  <fabien.chene@gmail.com>
+2010-04-27  Fabien Chêne  <fabien@gcc.gnu.org>
            Jason Merrill  <jason@redhat.com>
 
        PR c++/42844
 
        * call.c (type_decays_to): Call cv_unqualified for non-class type.
 
-2010-04-12  Fabien Chene  <fabien.chene@gmail.com>
+2010-04-12  Fabien Chêne  <fabien@gcc.gnu.org>>
 
        PR c++/25811
        * cp-tree.h (diagnose_uninitialized_cst_or_ref_member): Declare.
index 5065989..02dde6e 100644 (file)
 2011-05-07  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/48859
-       * init.c (diagnose_uninitialized_cst_or_ref_member_1): stop the
+       * init.c (diagnose_uninitialized_cst_or_ref_member_1): Stop the
        recursion if there is user defined constructor.
 
 2011-05-09  Jason Merrill  <jason@redhat.com>
index a57051e..e63a3f7 100644 (file)
 2012-02-16  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/52126
-       * decl.c (xref_basetypes): call dependent_scope_p instead of
+       * decl.c (xref_basetypes): Call dependent_scope_p instead of
        dependent_type_p.
 
 2012-02-16  Jason Merrill  <jason@redhat.com>
index f85776c..fdc1011 100644 (file)
@@ -694,11 +694,14 @@ perform_member_init (tree member, tree init)
          if (CP_TYPE_CONST_P (type)
              && init == NULL_TREE
              && default_init_uninitialized_part (type))
-           /* TYPE_NEEDS_CONSTRUCTING can be set just because we have a
-              vtable; still give this diagnostic.  */
-           permerror (DECL_SOURCE_LOCATION (current_function_decl),
-                      "uninitialized member %qD with %<const%> type %qT",
-                      member, type);
+           {
+             /* TYPE_NEEDS_CONSTRUCTING can be set just because we have a
+                vtable; still give this diagnostic.  */
+             if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
+                            "uninitialized const member in %q#T", type))
+               inform (DECL_SOURCE_LOCATION (member),
+                       "%q#D should be initialized", member );
+           }
          finish_expr_stmt (build_aggr_init (decl, init, flags,
                                             tf_warning_or_error));
        }
@@ -710,13 +713,19 @@ perform_member_init (tree member, tree init)
          tree core_type;
          /* member traversal: note it leaves init NULL */
          if (TREE_CODE (type) == REFERENCE_TYPE)
-           permerror (DECL_SOURCE_LOCATION (current_function_decl),
-                      "uninitialized reference member %qD",
-                      member);
+           {
+             if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
+                            "uninitialized reference member in %q#T", type))
+               inform (DECL_SOURCE_LOCATION (member),
+                       "%q#D should be initialized", member);
+           }
          else if (CP_TYPE_CONST_P (type))
-           permerror (DECL_SOURCE_LOCATION (current_function_decl),
-                      "uninitialized member %qD with %<const%> type %qT",
-                      member, type);
+           {
+             if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
+                            "uninitialized const member in %q#T", type))
+                 inform (DECL_SOURCE_LOCATION (member),
+                         "%q#D should be initialized", member );
+           }
 
          core_type = strip_array_types (type);
 
index c802f14..7092fa7 100644 (file)
@@ -1,3 +1,9 @@
+2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>
+
+        * g++.dg/init/ctor4.C: Adjust.
+       * g++.dg/init/ctor4-1.C: New.
+       * g++.dg/cpp0x/defaulted2.C: Adjust.
+
 2014-04-01  Richard Henderson  <rth@redhat.com>
 
        PR target/60704
index ca95319..2c354ff 100644 (file)
        * gcc.dg/Warray-bounds-5.c: New test.
        * gcc.dg/Warray-bounds-6.c: New test.
 
-2008-11-05  Fabien Chene <fabien.chene@gmail.com>
+2008-11-05  Fabien Chene <fabien@gcc.gnu.org>
 
        PR c++/32519
        * g++.dg/template/pr32519.C: New test.
index b8d9464..47f39a3 100644 (file)
        * g++.dg/cpp0x/initlist26.C: Adjust.
        * g++.dg/cpp0x/initlist28.C: Adjust.
 
-2010-05-10  Fabien Chêne  <fabien.chene@gmail.com>
+2010-05-10  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/43719
        * g++.dg/init/pr43719.C: New.
        * gnat.dg/sizetype3.ad[sb]: New test.
        * gnat.dg/sizetype3_pkg.ads: New helper.
 
-2010-05-07  Fabien Chêne  <fabien.chene@gmail.com>
+2010-05-07  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/43951
        * g++.dg/init/new29.C: New.
 
        * gcc.dg/tree-ssa/builtin-free.c: New testcase.
 
-2010-04-29  Fabien Chêne  <fabien.chene@gmail.com>
-
-       PR c++/43890
-       * init.c (diagnose_uninitialized_cst_or_ref_member): check for
-       user-provided constructor while recursing.
-
 2010-04-29  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/42274
        * g++.dg/template/pr23510.C: Update.
        * lib/prune.exp: Filter out 'recursively instantiated'.
 
-2010-04-27  Fabien Chêne  <fabien.chene@gmail.com>
+2010-04-27  Fabien Chêne  <fabien@gcc.gnu.org>
 
        PR c++/29043
        * g++.dg/init/pr29043.C: New.
        * g++.dg/template/sfinae17.C: New.
        * g++.dg/template/sfinae18.C: New.
 
-2010-04-27  Fabien Chêne  <fabien.chene@gmail.com>
+2010-04-27  Fabien Chêne  <fabien@gcc.gnu.org>
 
        * g++.dg/init/pr42844.C: New.
        * g++.dg/cpp0x/pr42844-2.C: New.
        * g++.dg/cpp0x/lambda/lambda-conv4.C: New.
        * g++.dg/cpp0x/lambda/lambda-deduce2.C: New.
 
-2010-04-12  Fabien Chene  <fabien.chene@gmail.com>
+2010-04-12  Fabien Chene  <fabien@gcc.gnu.org>
 
        PR c++/25811
        * g++.dg/init/pr25811.C: New test.
index bd83c7f..63be997 100644 (file)
@@ -35,7 +35,7 @@ struct D: public C
 
 struct E
 {
-  const B b;
+  const B b;                   // { dg-message "should be initialized" }
   E() { }                      // { dg-error "uninitialized" }
 };
 
diff --git a/gcc/testsuite/g++.dg/init/ctor4-1.C b/gcc/testsuite/g++.dg/init/ctor4-1.C
new file mode 100644 (file)
index 0000000..1333b35
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+class foo {
+public:
+  foo();
+};
+
+class bar: public foo {        // { dg-error "uninitialized" }
+                  // { dg-message "implicitly deleted" "" { target c++11 } 8 }
+private:
+  int const a; // { dg-message "should be initialized" }
+};
+
+foo::foo() {
+}
+
+int main(int argc, char **argv)
+{
+  bar x; // { dg-error "deleted" "" { target c++11 } }
+        // { dg-message "synthesized" "" { target { ! c++11 } } 19 }
+}
index 1c92bb9..21034b6 100644 (file)
@@ -6,9 +6,10 @@ public:
   foo();
 };
 
-class bar: public foo {                // { dg-error "reference|bar::bar" }
+class bar: public foo {        // { dg-error "uninitialized" }
+                  // { dg-message "implicitly deleted" "" { target c++11 } 9 }
 private:
-  int &a;
+  int &a; // { dg-message "should be initialized" }
 };
 
 foo::foo() {
@@ -16,5 +17,6 @@ foo::foo() {
 
 int main(int argc, char **argv)
 {
-  bar x; // { dg-message "synthesized|deleted" }
+  bar x; // { dg-error "deleted" "" { target c++11 } }
+         // { dg-message "synthesized" "" { target { ! c++11 } } 20 }
 }