PR 25509
PR 40614
* c.opt (Wunused-result): New.
* doc/invoke.texi: Document it.
* c-common.c (c_warn_unused_result): Use it.
testsuite/
* g++.dg/warn/unused-result1-Werror.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149458
138bc75d-0d04-0410-961f-
82ee72b054a4
+2009-07-10 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 25509
+ PR 40614
+ * c.opt (Wunused-result): New.
+ * doc/invoke.texi: Document it.
+ * c-common.c (c_warn_unused_result): Use it.
+
2009-07-09 DJ Delorie <dj@redhat.com>
* targhooks.c (default_target_can_inline_p): Rename from
location_t loc = gimple_location (g);
if (fdecl)
- warning_at (loc, 0, "ignoring return value of %qD, "
+ warning_at (loc, OPT_Wunused_result,
+ "ignoring return value of %qD, "
"declared with attribute warn_unused_result",
fdecl);
else
- warning_at (loc, 0, "ignoring return value of function "
+ warning_at (loc, OPT_Wunused_result,
+ "ignoring return value of function "
"declared with attribute warn_unused_result");
}
break;
C ObjC C++ ObjC++ Warning
Warn about macros defined in the main file that are not used
+Wunused-result
+C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning
+Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
+
Wvariadic-macros
C ObjC C++ ObjC++ Warning
Do not warn about using variadic macros when -pedantic
-Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized @gol
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
-Wunsuffixed-float-constants -Wunused -Wunused-function @gol
--Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable @gol
+-Wunused-label -Wunused-parameter -Wno-unused-result -Wunused-value -Wunused-variable @gol
-Wvariadic-macros -Wvla @gol
-Wvolatile-register-var -Wwrite-strings}
To suppress this warning use the @samp{unused} attribute
(@pxref{Variable Attributes}).
+@item -Wno-unused-result
+@opindex Wunused-result
+@opindex Wno-unused-result
+Do not warn if a caller of a function marked with attribute
+@code{warn_unused_result} (@pxref{Variable Attributes}) does not use
+its return value. The default is @option{-Wunused-result}.
+
@item -Wunused-variable
@opindex Wunused-variable
@opindex Wno-unused-variable
+2009-07-10 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 25509
+ PR 40614
+ * g++.dg/warn/unused-result1-Werror.c: New.
+
2009-07-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/39334
--- /dev/null
+// PR 40614
+// { dg-options "-Werror=unused-result" }
+class QByteArray {
+public:
+ QByteArray(const QByteArray &);
+};
+class QString {
+ QByteArray toLocal8Bit() const __attribute__ ((warn_unused_result));
+ void fooWarnHere() const { toLocal8Bit(); } // { dg-error "ignoring" }
+};