+2008-08-09 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 7651
+ * doc/invoke.texi (-Wextra): Move warning from here...
+ (-Wuninitialized): ... to here.
+
2008-08-08 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 28875
+2008-08-09 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 7651
+ * class.c (check_bases_and_members): Warn with -Wuninitialized
+ instead of -Wextra.
+
2008-08-08 Volker Reichelt <v.reichelt@netcologne.de>
PR c++/35985
/* If the class has no user-declared constructor, but does have
non-static const or reference data members that can never be
initialized, issue a warning. */
- if (extra_warnings
+ if (warn_uninitialized
/* Classes with user-declared constructors are presumed to
initialize these members. */
&& !TYPE_HAS_USER_CONSTRUCTOR (t)
type = TREE_TYPE (field);
if (TREE_CODE (type) == REFERENCE_TYPE)
- warning (OPT_Wextra, "non-static reference %q+#D in class "
- "without a constructor", field);
+ warning (OPT_Wuninitialized, "non-static reference %q+#D "
+ "in class without a constructor", field);
else if (CP_TYPE_CONST_P (type)
&& (!CLASS_TYPE_P (type)
|| !TYPE_HAS_DEFAULT_CONSTRUCTOR (type)))
- warning (OPT_Wextra, "non-static const member %q+#D in class "
- "without a constructor", field);
+ warning (OPT_Wuninitialized, "non-static const member %q+#D "
+ "in class without a constructor", field);
}
}
(C++ only) An enumerator and a non-enumerator both appear in a
conditional expression.
-@item
-(C++ only) A non-static reference or non-static @samp{const} member
-appears in a class without constructors.
-
@item
(C++ only) Ambiguous virtual bases.
@item -Wuninitialized
@opindex Wuninitialized
@opindex Wno-uninitialized
-Warn if an automatic variable is used without first being initialized or
-if a variable may be clobbered by a @code{setjmp} call.
+Warn if an automatic variable is used without first being initialized
+or if a variable may be clobbered by a @code{setjmp} call. In C++,
+warn if a non-static reference or non-static @samp{const} member
+appears in a class without constructors.
If you want to warn about code which uses the uninitialized value of the
variable in its own initializer, use the @option{-Winit-self} option.
+2008-08-09 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR 7651
+ * g++.dg/warn/Wuninitializable-member.C: New.
+ * g++.dg/warn/Wuninitializable-member-no.C: New.
+
2008-08-08 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 28875
--- /dev/null
+// Test disabling
+// { dg-do compile }
+// { dg-options "-Wall -Wextra -Wno-uninitialized" }
+
+class X {
+ int & flag;// { dg-bogus "non-static reference 'int& X::flag' in class without a constructor" }
+public:
+ void f(){ flag++ ; }
+};
+
+class Y {
+ const int var;// { dg-bogus "non-static const member 'const int Y::var' in class without a constructor" }
+public:
+ int g(){ return 2*var; }
+};
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Wuninitialized" }
+
+class X {
+ int & flag;// { dg-warning "non-static reference 'int& X::flag' in class without a constructor" }
+public:
+ void f(){ flag++ ; }
+};
+
+class Y {
+ const int var;// { dg-warning "non-static const member 'const int Y::var' in class without a constructor" }
+public:
+ int g(){ return 2*var; }
+};