Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -std=gnu++11 -I %S/Inputs -verify %s |
| 2 | // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fblocks -std=gnu++11 -I %S/Inputs %s >%t.txt 2>&1 |
| 3 | // RUN: FileCheck %s < %t.txt |
| 4 | // RUN: FileCheck %S/Inputs/nullability.h < %t.txt |
Volodymyr Sapsai | 43e6f7b | 2017-09-28 23:18:49 +0000 | [diff] [blame] | 5 | // RUN: FileCheck %S/Inputs/nullability-objc.h < %t.txt |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 6 | |
| 7 | #include "nullability.h" |
Volodymyr Sapsai | 43e6f7b | 2017-09-28 23:18:49 +0000 | [diff] [blame] | 8 | #include "nullability-objc.h" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 9 | |
| 10 | #pragma clang assume_nonnull begin |
| 11 | |
| 12 | extern void *array[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 13 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull " |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 14 | |
| 15 | extern void* array2[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 16 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 17 | |
| 18 | extern void *nestedArray[2][3]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 19 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull " |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 20 | |
Jordan Rose | 281139c | 2016-12-19 22:35:24 +0000 | [diff] [blame] | 21 | // No fix-its on either the macro definition or instantiation. |
| 22 | // CHECK-NOT: fix-it:"{{.*}}nullability.mm":{[[@LINE+2]] |
| 23 | // CHECK-NOT: fix-it:"{{.*}}nullability.mm":{[[@LINE+2]] |
| 24 | #define PTR(X) X * |
| 25 | extern PTR(void) array[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 26 | |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 27 | |
| 28 | typedef const void *CFTypeRef; |
| 29 | |
| 30 | extern CFTypeRef typedefArray[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 31 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 32 | |
| 33 | |
| 34 | extern void *&ref; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 35 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 36 | |
| 37 | extern void * &ref2; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 38 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 39 | |
| 40 | extern void *&&ref3; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 41 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 42 | |
| 43 | extern void * &&ref4; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 44 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 45 | |
| 46 | extern void *(&arrayRef)[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 47 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 48 | |
| 49 | extern void * (&arrayRef2)[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 50 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 51 | |
| 52 | extern CFTypeRef &typedefRef; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 53 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 54 | extern CFTypeRef& typedefRef2; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 55 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull " |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 56 | |
| 57 | |
| 58 | void arrayNameless(void *[]); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 59 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"_Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 60 | |
| 61 | void arrayNameless2(void * []); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 62 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:27-[[@LINE-1]]:27}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 63 | |
| 64 | void arrayNamelessTypedef(CFTypeRef[]); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 65 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:36-[[@LINE-1]]:36}:" _Nonnull " |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 66 | |
| 67 | void arrayNamelessTypedef2(CFTypeRef []); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
Jordan Rose | 06dd406 | 2016-12-19 20:58:20 +0000 | [diff] [blame] | 68 | // CHECK: fix-it:"{{.*}}nullability.mm":{[[@LINE-1]]:37-[[@LINE-1]]:37}:" _Nonnull" |
Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame] | 69 | |
| 70 | |
| 71 | extern int (*pointerToArray)[2]; // no-warning |
| 72 | int checkTypePTA = pointerToArray; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'int (* _Nonnull)[2]'}} |
| 73 | |
| 74 | int **arrayOfNestedPointers[2]; // no-warning |
| 75 | int checkTypeANP = arrayOfNestedPointers; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'int **[2]'}} |
| 76 | |
| 77 | CFTypeRef *arrayOfNestedPointersTypedef[2]; // no-warning |
| 78 | int checkTypeANPT = arrayOfNestedPointersTypedef; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'CFTypeRef *[2]'}} |
| 79 | |
| 80 | #pragma clang assume_nonnull end |