* cp-tree.h (warn_float_equal): Declare.
* decl2.c (warn_float_equal): Define.
(lang_decode_option): Recognize -W[no-]float-equal.
* typeck.c (build_binary_op_nodefault): Conditionally warn
about equality tests of floating point types.
From-SVN: r29721
+Thu Sep 30 00:13:27 1999 Dirk Zoller <duz@rtsffm.com>
+
+ * cp-tree.h (warn_float_equal): Declare.
+ * decl2.c (warn_float_equal): Define.
+ (lang_decode_option): Recognize -W[no-]float-equal.
+ * typeck.c (build_binary_op_nodefault): Conditionally warn
+ about equality tests of floating point types.
+
1999-09-29 Jason Merrill <jason@yorick.cygnus.com>
Support normal type_info-based EH mechanisms with -fno-rtti.
extern int warn_sign_compare;
+/* Warn about testing equality of floating point numbers. */
+
+extern int warn_float_equal;
+
/* Warn about a subscript that has type char. */
extern int warn_char_subscripts;
int warn_sign_compare;
+/* Warn about testing equality of floating point numbers. */
+
+int warn_float_equal = 0;
+
/* Warn about *printf or *scanf format/argument anomalies. */
int warn_format;
warn_missing_braces = setting;
else if (!strcmp (p, "sign-compare"))
warn_sign_compare = setting;
+ else if (!strcmp (p, "float-equal"))
+ warn_float_equal = setting;
else if (!strcmp (p, "format"))
warn_format = setting;
else if (!strcmp (p, "conversion"))
case EQ_EXPR:
case NE_EXPR:
+ if (warn_float_equal && (code0 == REAL_TYPE || code1 == REAL_TYPE))
+ warning ("comparing floating point with == or != is unsafe");
+
build_type = boolean_type_node;
if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
|| code0 == COMPLEX_TYPE)