Jordan Rose | 3b917fe | 2016-11-10 23:28:30 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -std=gnu++11 -verify %s |
| 2 | // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fblocks -std=gnu++11 %s 2>&1 | FileCheck %s |
| 3 | |
| 4 | #pragma clang assume_nonnull begin |
| 5 | |
| 6 | extern void *array[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 7 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull " |
| 8 | |
| 9 | extern void* array2[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 10 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" _Nonnull" |
| 11 | |
| 12 | extern void *nestedArray[2][3]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 13 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull " |
| 14 | |
| 15 | |
| 16 | typedef const void *CFTypeRef; |
| 17 | |
| 18 | extern CFTypeRef typedefArray[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 19 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull" |
| 20 | |
| 21 | |
| 22 | extern void *&ref; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 23 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
| 24 | |
| 25 | extern void * &ref2; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 26 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
| 27 | |
| 28 | extern void *&&ref3; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 29 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
| 30 | |
| 31 | extern void * &&ref4; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 32 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
| 33 | |
| 34 | extern void *(&arrayRef)[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 35 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"_Nonnull" |
| 36 | |
| 37 | extern void * (&arrayRef2)[2]; // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 38 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:" _Nonnull" |
| 39 | |
| 40 | extern CFTypeRef &typedefRef; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 41 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull" |
| 42 | extern CFTypeRef& typedefRef2; // expected-warning {{inferring '_Nonnull' for pointer type within reference is deprecated}} |
| 43 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:" _Nonnull " |
| 44 | |
| 45 | |
| 46 | void arrayNameless(void *[]); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 47 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"_Nonnull" |
| 48 | |
| 49 | void arrayNameless2(void * []); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 50 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:27-[[@LINE-1]]:27}:" _Nonnull" |
| 51 | |
| 52 | void arrayNamelessTypedef(CFTypeRef[]); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 53 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:36-[[@LINE-1]]:36}:" _Nonnull " |
| 54 | |
| 55 | void arrayNamelessTypedef2(CFTypeRef []); // expected-warning {{inferring '_Nonnull' for pointer type within array is deprecated}} |
| 56 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:37}:" _Nonnull" |
| 57 | |
| 58 | |
| 59 | extern int (*pointerToArray)[2]; // no-warning |
| 60 | int checkTypePTA = pointerToArray; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'int (* _Nonnull)[2]'}} |
| 61 | |
| 62 | int **arrayOfNestedPointers[2]; // no-warning |
| 63 | int checkTypeANP = arrayOfNestedPointers; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'int **[2]'}} |
| 64 | |
| 65 | CFTypeRef *arrayOfNestedPointersTypedef[2]; // no-warning |
| 66 | int checkTypeANPT = arrayOfNestedPointersTypedef; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'CFTypeRef *[2]'}} |
| 67 | |
| 68 | #pragma clang assume_nonnull end |