+2007-05-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR middle-end/7651
+ PR c++/11856
+ PR c/12963
+ PR c/23587
+ PR other/29694
+ * c.opt (Wtype-limits): New.
+ * doc/invoke.texi (Wtype-limits): Document it.
+ (Wextra): Enabled by -Wextra.
+ * c-opts.c (c_common_post_options): Enabled by -Wextra.
+ * c-common.c (shorten_compare): Warn with Wtype-limits.
+
2006-05-20 Uros Bizjak <ubizjak@gmail.com>
* config/i386/tmmintrin.h (_mm_alignr_epi32): Implement as always
if (TREE_CODE (primop0) != INTEGER_CST)
{
if (val == truthvalue_false_node)
- warning (0, "comparison is always false due to limited range of data type");
+ warning (OPT_Wtype_limits, "comparison is always false due to limited range of data type");
if (val == truthvalue_true_node)
- warning (0, "comparison is always true due to limited range of data type");
+ warning (OPT_Wtype_limits, "comparison is always true due to limited range of data type");
}
if (val != 0)
switch (code)
{
case GE_EXPR:
- /* All unsigned values are >= 0, so we warn if extra warnings
- are requested. However, if OP0 is a constant that is
- >= 0, the signedness of the comparison isn't an issue,
- so suppress the warning. */
- if (extra_warnings && !in_system_header
+ /* All unsigned values are >= 0, so we warn. However,
+ if OP0 is a constant that is >= 0, the signedness of
+ the comparison isn't an issue, so suppress the
+ warning. */
+ if (warn_type_limits && !in_system_header
&& !(TREE_CODE (primop0) == INTEGER_CST
&& !TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
- warning (0, "comparison of unsigned expression >= 0 is always true");
+ warning (OPT_Wtype_limits,
+ "comparison of unsigned expression >= 0 is always true");
value = truthvalue_true_node;
break;
case LT_EXPR:
- if (extra_warnings && !in_system_header
+ if (warn_type_limits && !in_system_header
&& !(TREE_CODE (primop0) == INTEGER_CST
&& !TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
- warning (0, "comparison of unsigned expression < 0 is always false");
+ warning (OPT_Wtype_limits,
+ "comparison of unsigned expression < 0 is always false");
value = truthvalue_false_node;
break;
if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
flag_exceptions = 1;
- /* -Wextra implies -Wclobbered, -Wempty-body, -Wsign-compare,
+ /* -Wextra implies -Wtype-limits, -Wclobbered,
+ -Wempty-body, -Wsign-compare,
-Wmissing-field-initializers, -Wmissing-parameter-type
-Wold-style-declaration, and -Woverride-init,
but not if explicitly overridden. */
+ if (warn_type_limits == -1)
+ warn_type_limits = extra_warnings;
if (warn_clobbered == -1)
warn_clobbered = extra_warnings;
if (warn_empty_body == -1)
C ObjC C++ ObjC++ Warning
Enable most warning messages
+Wtype-limits
+C ObjC C++ ObjC++ Var(warn_type_limits) Init(-1) Warning
+Warn if a comparison is always true or always false due to the limited range of the data type
+
Wassign-intercept
ObjC ObjC++ Var(warn_assign_intercept) Warning
Warn whenever an Objective-C assignment is being intercepted by the garbage collector
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
--w -Wextra -Wall -Waddress -Waggregate-return -Warray-bounds @gol
+-w -Wextra -Wall -Waddress -Waggregate-return -Warray-bounds @gol
-Wno-attributes -Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol
-Wchar-subscripts -Wclobbered -Wcomment @gol
-Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol
-Wstrict-aliasing -Wstrict-aliasing=n @gol
-Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wswitch -Wswitch-default -Wswitch-enum @gol
--Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
+-Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized @gol
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
-Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
-Wunused-value -Wunused-variable @gol
@itemize @bullet
@item
-An unsigned value is compared against zero with @samp{<} or @samp{>=}.
+Warn if a comparison is always true or always false due to the limited
+range of the data type, but do not warn for constant expressions. For
+example, warn if an unsigned variable is compared against zero with
+@samp{<} or @samp{>=}. This warning can be independently controlled
+by @option{-Wtype-limits}.
@item @r{(C only)}
Storage-class specifiers like @code{static} are not the first things
to functions. In C++, warn also when an arithmetic operation involves
@code{NULL}. This warning is also enabled by @option{-pedantic}.
+@item -Wtype-limits
+@opindex Wtype-limits
+@opindex Wno-type-limits
+Warn if a comparison is always true or always false due to the limited
+range of the data type, but do not warn for constant expressions. For
+example, warn if an unsigned variable is compared against zero with
+@samp{<} or @samp{>=}. This warning is also enabled by
+@option{-Wextra}.
+
@item -Wbad-function-cast @r{(C only)}
@opindex Wbad-function-cast
Warn whenever a function call is cast to a non-matching type.
+2007-05-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR middle-end/7651
+ PR c++/11856
+ PR c/12963
+ PR c/23587
+ PR other/29694
+ * gcc.dg/compare6.c: Replace Wall with Wtype-limits.
+ * gcc.dg/Wtype-limits.c: New.
+ * gcc.dg/Wtype-limits-Wextra.c: New.
+ * gcc.dg/Wtype-limits-no.c: New.
+ * g++.dg/warn/Wtype-limits.C: New.
+ * g++.dg/warn/Wtype-limits-Wextra.C: New.
+ * g++.dg/warn/Wtype-limits-no.C: New.
+
2006-05-20 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/sse-vect-types.c: Revert 'Use "-msse"
--- /dev/null
+/* Test that -Wtype-limits is enabled by -Wextra. */
+/* { dg-do compile } */
+/* { dg-options "-Wextra" } */
+extern void assert (int);
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 61 } */
+ return 1;
+ else
+ return 0;
+}
+
+template <typename Int, Int D>
+void f(Int x) {
+ assert(0 <= x and x <= D); // { dg-warning "comparison is always true due to limited range of data type" }
+}
+
+int ff(void) {
+ f<unsigned char, 2>(5);
+ f<signed char, 2>(5);
+}
+
+template <typename Int, Int D>
+void g(void) {
+ assert(0 <= D);
+}
+int gg(void) {
+ g<unsigned char, 2>();
+}
+
--- /dev/null
+/* Test disabling -Wtype-limits. */
+/* { dg-do compile } */
+/* { dg-options "-Wextra -Wno-type-limits" } */
+extern void assert (int);
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-bogus "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255)
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" } */
+ return 1;
+ else
+ return 0;
+}
+
+template <typename Int, Int D>
+void f(Int x) {
+ assert(0 <= x and x <= D); // { dg-bogus "comparison is always true due to limited range of data type" }
+}
+
+int ff(void) {
+ f<unsigned char, 2>(5);
+ f<signed char, 2>(5);
+}
+
+template <typename Int, Int D>
+void g(void) {
+ assert(0 <= D);
+}
+int gg(void) {
+ g<unsigned char, 2>();
+}
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wtype-limits" } */
+
+extern void assert (int);
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 61 } */
+ return 1;
+ else
+ return 0;
+}
+
+template <typename Int, Int D>
+void f(Int x) {
+ assert(0 <= x and x <= D); // { dg-warning "comparison is always true due to limited range of data type" }
+}
+
+int ff(void) {
+ f<unsigned char, 2>(5);
+ f<signed char, 2>(5);
+}
+
+template <typename Int, Int D>
+void g(void) {
+ assert(0 <= D);
+}
+int gg(void) {
+ g<unsigned char, 2>();
+}
+
--- /dev/null
+/* Test that -Wtype-limits is enabled by -Wextra */
+/* { dg-do compile } */
+/* { dg-options "-Wextra" } */
+
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 61 } */
+ return 1;
+ else
+ return 0;
+}
+
--- /dev/null
+/* Test disabling -Wtype-limits */
+/* { dg-do compile } */
+/* { dg-options "-Wextra -Wno-type-limits" } */
+
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-bogus "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255)
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL)
+ return 1;
+ else
+ return 0;
+}
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wtype-limits" } */
+
+
+
+void a (unsigned char x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */
+ return;
+ if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
+ return;
+ if (255 >= (unsigned char) 1)
+ return;
+
+}
+
+void b (unsigned short x)
+{
+ if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+ if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
+ if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
+}
+
+void c (unsigned int x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (1U >= 0) return;
+ if (1U < 0) return;
+ if (0 <= 1U) return;
+ if (0 > 1U) return;
+}
+
+void d (unsigned long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+void e (unsigned long long x)
+{
+ if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+ if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
+ if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
+}
+
+int test (int x)
+{
+ if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 61 } */
+ return 1;
+ else
+ return 0;
+}
+
/* PR c/2098 */
/* Test for a warning on comparison on out-of-range data. */
/* { dg-do compile { xfail c4x-*-* } } */
-/* { dg-options "-Wall" } */
+/* { dg-options "-Wtype-limits" } */
signed char sc;
unsigned char uc;