+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/5089
+ * doc/invoke.texi (-Wold-style-cast): Only warn about non-void casts.
+
2002-01-02 Kazu Hirata <kazu@hxi.com>
* config/h8300/fixunssfsi.c: Update copyright.
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/5089
+ * decl2.c (reparse_absdcl_as_casts): Don't warn about casts to void.
+
+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
PR c++/3716
* pt.c (tsubst_aggr_type): Move pmf handling into tsubst.
(tsubst, case POINTER_TYPE): Handle pmfs here.
tree decl, expr;
{
tree type;
+ int non_void_p = 0;
if (TREE_CODE (expr) == CONSTRUCTOR
&& TREE_TYPE (expr) == 0)
{
type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
decl = TREE_OPERAND (decl, 0);
+ if (!VOID_TYPE_P (type))
+ non_void_p = 1;
expr = build_c_cast (type, expr);
}
if (warn_old_style_cast && ! in_system_header
- && current_lang_name != lang_name_c)
+ && non_void_p && current_lang_name != lang_name_c)
warning ("use of old-style cast");
return expr;
@item -Wold-style-cast @r{(C++ only)}
@opindex Wold-style-cast
-Warn if an old-style (C-style) cast is used within a C++ program. The
-new-style casts (@samp{static_cast}, @samp{reinterpret_cast}, and
-@samp{const_cast}) are less vulnerable to unintended effects, and much
-easier to grep for.
+Warn if an old-style (C-style) cast to a non-void type is used within
+a C++ program. The new-style casts (@samp{static_cast},
+@samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to
+unintended effects, and much easier to grep for.
@item -Woverloaded-virtual @r{(C++ only)}
@opindex Woverloaded-virtual
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.dg/warn/oldcast1.C: New test.
+
* g++.dg/template/ptrmem1.C: New test.
* g++.dg/template/ptrmem2.C: New test.
--- /dev/null
+// { dg-do compile }
+// { dg-options "-ansi -pedantic-errors -Wold-style-cast" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@codesourcery.com>
+
+// PR 5089. old style cast to void should be permitted (think assert)
+
+void foo ()
+{
+ int i;
+ float f = (float)i; // { dg-warning "use of old-style cast" "" }
+
+ (void)i;
+}
+