diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-08-08 23:32:23 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-08-08 23:32:23 +0000 |
commit | c73d5dd948d68fb2550f7d178d1483aebcfbcaea (patch) | |
tree | bc97d77632044f39e89c6f57ff0998acec035a7c /gcc | |
parent | 63a3341a9d1f760b1761b365f57a27523bfb548b (diff) | |
download | gcc-c73d5dd948d68fb2550f7d178d1483aebcfbcaea.zip gcc-c73d5dd948d68fb2550f7d178d1483aebcfbcaea.tar.gz gcc-c73d5dd948d68fb2550f7d178d1483aebcfbcaea.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 10 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wuninitializable-member-no.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wuninitializable-member.C | 14 |
7 files changed, 56 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 569efd1..8ba80b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d37f31f..4637090 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f7e46a7..b08f9c8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4306,7 +4306,7 @@ check_bases_and_members (tree t) /* 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) @@ -4325,13 +4325,13 @@ check_bases_and_members (tree 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); } } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cb02995..051f6d1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2749,10 +2749,6 @@ A pointer is compared against integer zero with @samp{<}, @samp{<=}, 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 @@ -3173,8 +3169,10 @@ either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies @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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index db2088f..6be4d94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/testsuite/g++.dg/warn/Wuninitializable-member-no.C b/gcc/testsuite/g++.dg/warn/Wuninitializable-member-no.C new file mode 100644 index 0000000..0f6ccfd --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wuninitializable-member-no.C @@ -0,0 +1,15 @@ +// 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; } +}; diff --git a/gcc/testsuite/g++.dg/warn/Wuninitializable-member.C b/gcc/testsuite/g++.dg/warn/Wuninitializable-member.C new file mode 100644 index 0000000..1c37e3e --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wuninitializable-member.C @@ -0,0 +1,14 @@ +// { 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; } +}; |