diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -58,6 +58,9 @@ inside a namespace. This fixes `Issue 59446 `_. +- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes + `Issue 58375 `_. + Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -992,6 +992,7 @@ EmptyInitStatement, StringConcatation, FUseLdPath, + TypeLimits, ]>; def Most : DiagGroup<"most", [ diff --git a/clang/test/Sema/tautological-constant-compare.c b/clang/test/Sema/tautological-constant-compare.c --- a/clang/test/Sema/tautological-constant-compare.c +++ b/clang/test/Sema/tautological-constant-compare.c @@ -4,8 +4,8 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify -x c++ %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify -x c++ %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify=silent %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify=silent -x c++ %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify -x c++ %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent -x c++ %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=silent %s @@ -28,7 +28,7 @@ if (c > 255) // expected-warning {{comparison 'unsigned char' > 255 is always false}} return; #else - if (c > 255) + if (c > 255) // expected-warning {{result of comparison 'unsigned char' > 255 is always false}} return; #endif @@ -194,9 +194,9 @@ return 0; if (s < 32767) return 0; - if (s <= 32767) + if (s <= 32767) // expected-warning {{result of comparison 'short' <= 32767 is always true}} return 0; - if (s > 32767) + if (s > 32767) // expected-warning {{result of comparison 'short' > 32767 is always false}} return 0; if (s >= 32767) return 0; @@ -205,13 +205,13 @@ return 0; if (32767 != s) return 0; - if (32767 < s) + if (32767 < s) // expected-warning {{result of comparison 32767 < 'short' is always false}} return 0; if (32767 <= s) return 0; if (32767 > s) return 0; - if (32767 >= s) + if (32767 >= s) // expected-warning {{result of comparison 32767 >= 'short' is always true}} return 0; // FIXME: assumes two's complement @@ -219,13 +219,13 @@ return 0; if (s != -32768) return 0; - if (s < -32768) + if (s < -32768) // expected-warning {{result of comparison 'short' < -32768 is always false}} return 0; if (s <= -32768) return 0; if (s > -32768) return 0; - if (s >= -32768) + if (s >= -32768) // expected-warning {{result of comparison 'short' >= -32768 is always true}} return 0; if (-32768 == s) @@ -234,9 +234,9 @@ return 0; if (-32768 < s) return 0; - if (-32768 <= s) + if (-32768 <= s) // expected-warning {{result of comparison -32768 <= 'short' is always true}} return 0; - if (-32768 > s) + if (-32768 > s) // expected-warning {{result of comparison -32768 > 'short' is always false}} return 0; if (-32768 >= s) return 0; @@ -272,13 +272,13 @@ return 0; if (s != -32768L) return 0; - if (s < -32768L) + if (s < -32768L) // expected-warning {{esult of comparison 'short' < -32768 is always false}} return 0; if (s <= -32768L) return 0; if (s > -32768L) return 0; - if (s >= -32768L) + if (s >= -32768L) // expected-warning {{esult of comparison 'short' >= -32768 is always true}} return 0; if (-32768L == s) @@ -287,9 +287,9 @@ return 0; if (-32768L < s) return 0; - if (-32768L <= s) + if (-32768L <= s) // expected-warning {{result of comparison -32768 <= 'short' is always true}} return 0; - if (-32768L > s) + if (-32768L > s) // expected-warning {{result of comparison -32768 > 'short' is always false}} return 0; if (-32768L >= s) return 0; @@ -382,9 +382,9 @@ return 0; if (us < 65535) return 0; - if (us <= 65535) + if (us <= 65535) // expected-warning {{result of comparison 'unsigned short' <= 65535 is always true}} return 0; - if (us > 65535) + if (us > 65535) // expected-warning {{result of comparison 'unsigned short' > 65535 is always false}} return 0; if (us >= 65535) return 0; @@ -393,13 +393,13 @@ return 0; if (65535 != us) return 0; - if (65535 < us) + if (65535 < us) // expected-warning {{result of comparison 65535 < 'unsigned short' is always false}} return 0; if (65535 <= us) return 0; if (65535 > us) return 0; - if (65535 >= us) + if (65535 >= us) // expected-warning {{result of comparison 65535 >= 'unsigned short' is always true}} return 0; if (us == 65535UL) @@ -408,9 +408,9 @@ return 0; if (us < 65535UL) return 0; - if (us <= 65535UL) + if (us <= 65535UL) // expected-warning {{result of comparison 'unsigned short' <= 65535 is always true}} return 0; - if (us > 65535UL) + if (us > 65535UL) // expected-warning {{result of comparison 'unsigned short' > 65535 is always false}} return 0; if (us >= 65535UL) return 0; @@ -419,13 +419,13 @@ return 0; if (65535UL != us) return 0; - if (65535UL < us) + if (65535UL < us) // expected-warning {{result of comparison 65535 < 'unsigned short' is always false}} return 0; if (65535UL <= us) return 0; if (65535UL > us) return 0; - if (65535UL >= us) + if (65535UL >= us) // expected-warning {{result of comparison 65535 >= 'unsigned short' is always true}} return 0; #endif