re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)

2008-08-09  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR 7651
	* doc/invoke.texi (-Wextra): Move warning from here...
	(-Wuninitialized): ... to here.
cp/
	* class.c (check_bases_and_members): Warn with -Wuninitialized
	instead of -Wextra.
testsuite/
	* g++.dg/warn/Wuninitializable-member.C: New.
	* g++.dg/warn/Wuninitializable-member-no.C: New.

From-SVN: r138892
parent 63a3341a
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> 2008-08-08 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 28875 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> 2008-08-08 Volker Reichelt <v.reichelt@netcologne.de>
PR c++/35985 PR c++/35985
......
...@@ -4306,7 +4306,7 @@ check_bases_and_members (tree t) ...@@ -4306,7 +4306,7 @@ check_bases_and_members (tree t)
/* If the class has no user-declared constructor, but does have /* If the class has no user-declared constructor, but does have
non-static const or reference data members that can never be non-static const or reference data members that can never be
initialized, issue a warning. */ initialized, issue a warning. */
if (extra_warnings if (warn_uninitialized
/* Classes with user-declared constructors are presumed to /* Classes with user-declared constructors are presumed to
initialize these members. */ initialize these members. */
&& !TYPE_HAS_USER_CONSTRUCTOR (t) && !TYPE_HAS_USER_CONSTRUCTOR (t)
...@@ -4325,13 +4325,13 @@ check_bases_and_members (tree t) ...@@ -4325,13 +4325,13 @@ check_bases_and_members (tree t)
type = TREE_TYPE (field); type = TREE_TYPE (field);
if (TREE_CODE (type) == REFERENCE_TYPE) if (TREE_CODE (type) == REFERENCE_TYPE)
warning (OPT_Wextra, "non-static reference %q+#D in class " warning (OPT_Wuninitialized, "non-static reference %q+#D "
"without a constructor", field); "in class without a constructor", field);
else if (CP_TYPE_CONST_P (type) else if (CP_TYPE_CONST_P (type)
&& (!CLASS_TYPE_P (type) && (!CLASS_TYPE_P (type)
|| !TYPE_HAS_DEFAULT_CONSTRUCTOR (type))) || !TYPE_HAS_DEFAULT_CONSTRUCTOR (type)))
warning (OPT_Wextra, "non-static const member %q+#D in class " warning (OPT_Wuninitialized, "non-static const member %q+#D "
"without a constructor", field); "in class without a constructor", field);
} }
} }
......
...@@ -2749,10 +2749,6 @@ A pointer is compared against integer zero with @samp{<}, @samp{<=}, ...@@ -2749,10 +2749,6 @@ A pointer is compared against integer zero with @samp{<}, @samp{<=},
conditional expression. conditional expression.
@item @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. (C++ only) Ambiguous virtual bases.
@item @item
...@@ -3173,8 +3169,10 @@ either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies ...@@ -3173,8 +3169,10 @@ either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
@item -Wuninitialized @item -Wuninitialized
@opindex Wuninitialized @opindex Wuninitialized
@opindex Wno-uninitialized @opindex Wno-uninitialized
Warn if an automatic variable is used without first being initialized or Warn if an automatic variable is used without first being initialized
if a variable may be clobbered by a @code{setjmp} call. 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 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. 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> 2008-08-08 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 28875 PR 28875
......
// 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; }
};
// { 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; }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment