summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-07-18 20:37:06 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-07-18 20:37:06 +0000
commitd9b7dfe4a4dffed4455fbfcc1cc7b52b63895174 (patch)
tree6bfc7d07c74b549282f389314fbf0a032002d095 /clang/test/Sema
parent320a5a615bc389ae2256fd76bcff31c4475270ec (diff)
downloadbcm5719-llvm-d9b7dfe4a4dffed4455fbfcc1cc7b52b63895174.tar.gz
bcm5719-llvm-d9b7dfe4a4dffed4455fbfcc1cc7b52b63895174.zip
[Sema] Create a separate group for incompatible function pointer warning
Give incompatible function pointer warning its own diagnostic group but still leave it as a subgroup of incompatible-pointer-types. This is in preparation to promote -Wincompatible-function-pointer-types to error on darwin. Differential Revision: https://reviews.llvm.org/D22248 rdar://problem/12907612 llvm-svn: 275907
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/incompatible-function-pointer-types.c14
-rw-r--r--clang/test/Sema/initialize-noreturn.c2
-rw-r--r--clang/test/Sema/overloadable.c2
3 files changed, 16 insertions, 2 deletions
diff --git a/clang/test/Sema/incompatible-function-pointer-types.c b/clang/test/Sema/incompatible-function-pointer-types.c
new file mode 100644
index 00000000000..f0f594f8db8
--- /dev/null
+++ b/clang/test/Sema/incompatible-function-pointer-types.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-pointer-types -verify
+// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types -verify
+
+// This test ensures that the subgroup of -Wincompatible-pointer-types warnings
+// that concern function pointers can be promoted (or not promoted) to an error
+// *separately* from the other -Wincompatible-pointer-type warnings.
+typedef int (*MyFnTyA)(int *, char *);
+
+int bar(char *a, int *b) { return 0; }
+int foo(MyFnTyA x) { return 0; } // expected-note {{passing argument to parameter 'x' here}}
+
+void baz() {
+ foo(&bar); // expected-warning {{incompatible function pointer types passing 'int (*)(char *, int *)' to parameter of type 'MyFnTyA' (aka 'int (*)(int *, char *)')}}
+}
diff --git a/clang/test/Sema/initialize-noreturn.c b/clang/test/Sema/initialize-noreturn.c
index 55578628716..b90d46d6beb 100644
--- a/clang/test/Sema/initialize-noreturn.c
+++ b/clang/test/Sema/initialize-noreturn.c
@@ -8,7 +8,7 @@ void foo(void);
void foo_noret(void) __attribute__((noreturn));
void test() {
- Fn_noret fn2 = &foo; // expected-warning {{incompatible pointer types initializing 'Fn_noret'}}
+ Fn_noret fn2 = &foo; // expected-warning {{incompatible function pointer types initializing 'Fn_noret'}}
Fn_noret fn3 = &foo_noret;
Fn_ret fn4 = &foo_noret;
Fn_ret fn5 = &foo;
diff --git a/clang/test/Sema/overloadable.c b/clang/test/Sema/overloadable.c
index 5d95a317fa3..b518aa90a01 100644
--- a/clang/test/Sema/overloadable.c
+++ b/clang/test/Sema/overloadable.c
@@ -109,7 +109,7 @@ void fn_type_conversions() {
void (*ambiguous)(int *) = &foo; // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
void *vp_ambiguous = &foo; // expected-error{{initializing 'void *' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
- void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
+ void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible function pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
void *specific2 = (void (*)(void *))&foo;
void disabled(void *c) __attribute__((overloadable, enable_if(0, "")));
OpenPOWER on IntegriCloud