Skip to content

Commit d147292

Browse files
Abhin Parekadan JoseAbhinkop
Abhin Parekadan Jose
authored andcommitted
[clang] move -Wcast-function-type under -Wextra
1 parent 241e4c7 commit d147292

6 files changed

+47
-1
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ def Extra : DiagGroup<"extra", [
10261026
EmptyInitStatement,
10271027
StringConcatation,
10281028
FUseLdPath,
1029+
CastFunctionType,
10291030
]>;
10301031

10311032
def Most : DiagGroup<"most", [

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

Lines changed: 1 addition & 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);

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %clang_cc1 %s -fsyntax-only -Wextra -verify
2+
3+
4+
int t(int array[static 12]);
5+
int u(int i);
6+
const int v(int i); /* expected-warning {{'const' type qualifier on return type has no effec}} */
7+
int x(long);
8+
9+
typedef int (f1)(long);
10+
typedef int (f2)(void*);
11+
typedef int (f3)();
12+
typedef void (f4)();
13+
typedef void (f5)(void);
14+
typedef int (f6)(long, int);
15+
typedef int (f7)(long,...);
16+
typedef int (f8)(int *);
17+
typedef int (f9)(const int);
18+
typedef int (f10)(int);
19+
20+
f1 *a;
21+
f2 *b;
22+
f3 *c;
23+
f4 *d;
24+
f5 *e;
25+
f6 *f;
26+
f7 *g;
27+
f8 *h;
28+
f9 *i;
29+
f10 *j;
30+
31+
void foo(void) {
32+
a = (f1 *)x;
33+
b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function type}} */
34+
c = (f3 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f3 *' (aka 'int (*)()') converts to incompatible function type}} */
35+
d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)()') converts to incompatible function type}} */
36+
e = (f5 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f5 *' (aka 'void (*)(void)') converts to incompatible function type}} */
37+
f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function type}} */
38+
g = (f7 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f7 *' (aka 'int (*)(long, ...)') converts to incompatible function type}} */
39+
h = (f8 *)t;
40+
i = (f9 *)u;
41+
j = (f10 *)v; /* expected-warning {{cast from 'const int (*)(int)' to 'f10 *' (aka 'int (*)(int)') converts to incompatible function type}} */
42+
}

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)