Skip to content

Commit 1de7e6c

Browse files
authored
[clang] move -Wcast-function-type under -Wextra (#77178)
The -Wcast-fuction-type-strict has been moved under dignstic group -Wextra. Edited the test cases for -Wcast-fuction-type-strict and -Wcast-fuction-type in Sema an SemaCXX. Added a new test case which include a functionality that was already in the -Wextra group, i.e -Wignored-qualifiers with -Wcast-fuction-type-strict. Fixes: #76872
1 parent 679e594 commit 1de7e6c

6 files changed

+8
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ Modified Compiler Flags
193193
``-Wreturn-type``, and moved some of the diagnostics previously controlled by
194194
``-Wreturn-type`` under this new flag. Fixes #GH72116.
195195

196+
- Added ``-Wcast-function-type`` as a warning enabled by ``-Wextra``. #GH76872
197+
196198
Removed Compiler Flags
197199
-------------------------
198200

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ def Extra : DiagGroup<"extra", [
10381038
EmptyInitStatement,
10391039
StringConcatation,
10401040
FUseLdPath,
1041+
CastFunctionType,
10411042
]>;
10421043

10431044
def Most : DiagGroup<"most", [

clang/test/Sema/warn-cast-function-type-strict.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 %s -fsyntax-only -Wcast-function-type -verify
22
// RUN: %clang_cc1 %s -fsyntax-only -Wcast-function-type-strict -verify
3-
3+
// RUN: %clang_cc1 %s -fsyntax-only -Wextra -Wno-ignored-qualifiers -verify
44

55
int t(int array[static 12]);
66
int u(int i);
@@ -39,5 +39,6 @@ void foo(void) {
3939
g = (f7 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f7 *' (aka 'int (*)(long, ...)') converts to incompatible function type}} */
4040
h = (f8 *)t;
4141
i = (f9 *)u;
42+
// FIXME: return type qualifier should not be included in the function type . Warning should be absent after this issue is fixed. https://github.com/llvm/llvm-project/issues/39494 .
4243
j = (f10 *)v; /* expected-warning {{cast from 'const int (*)(int)' to 'f10 *' (aka 'int (*)(int)') converts to incompatible function type}} */
4344
}

clang/test/Sema/warn-cast-function-type.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 %s -fsyntax-only -Wcast-function-type -Wno-cast-function-type-strict -verify
2+
// RUN: %clang_cc1 %s -fsyntax-only -Wextra -Wno-cast-function-type-strict -verify
23

34
int x(long);
45

clang/test/SemaCXX/warn-cast-function-type-strict.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang_cc1 %s -fblocks -fsyntax-only -Wcast-function-type -verify
22
// RUN: %clang_cc1 %s -fblocks -fsyntax-only -Wcast-function-type-strict -verify
3+
// RUN: %clang_cc1 %s -fblocks -fsyntax-only -Wextra -verify
34

45
int x(long);
56

clang/test/SemaCXX/warn-cast-function-type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 %s -fblocks -fsyntax-only -Wcast-function-type -Wno-cast-function-type-strict -verify
2+
// RUN: %clang_cc1 %s -fblocks -fsyntax-only -Wextra -Wno-cast-function-type-strict -verify
23

34
int x(long);
45

0 commit comments

Comments
 (0)