From 95668c0d97e6184729f3a3e9621a58d9edffb6b0 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Wed, 1 Feb 2023 08:44:04 +0530 Subject: [PATCH] [Clang] Add -Wtype-limits to -Wextra for GCC compatibility GCC added the -Wtype-limits warning group to -Wextra around GCC 4.4 and the group has some very helpful extra warnings like tautological comparison type limit warnings (comparingan unsigned int to see if it's positive, etc). Fix https://github.com/llvm/llvm-project/issues/58375 Reviewed By: #clang-vendors, thesamesam Differential Revision: https://reviews.llvm.org/D142826 --- clang/docs/ReleaseNotes.rst | 3 +++ clang/include/clang/Basic/DiagnosticGroups.td | 1 + clang/test/Sema/tautological-constant-compare.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2b2ca8b..e5d09ce 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -61,6 +61,9 @@ Bug Fixes templates. This fixes `Issue 60344 `_. +- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes + `Issue 58375 `_. + Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - We now generate a diagnostic for signed integer overflow due to unary minus diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 6c997c3..39e6c94 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -992,6 +992,7 @@ def Extra : DiagGroup<"extra", [ 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 index 04b8a14..5909418 100644 --- 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 -DTEST -verify %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -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 -- 2.7.4