1*135fecd4SAbhina Sree // RUN: %clang_cc1 -triple s390x-ibm-zos %s -fsyntax-only -fzos-extensions -verify 2*135fecd4SAbhina Sree // RUN: %clang_cc1 -triple s390x-ibm-zos %s -fsyntax-only -verify 3*135fecd4SAbhina Sree 4*135fecd4SAbhina Sree struct A { 5*135fecd4SAbhina Sree int a; 6*135fecd4SAbhina Sree short b; 7*135fecd4SAbhina Sree float q; 8*135fecd4SAbhina Sree double z; 9*135fecd4SAbhina Sree }; 10*135fecd4SAbhina Sree 11*135fecd4SAbhina Sree union B { 12*135fecd4SAbhina Sree int a; 13*135fecd4SAbhina Sree short b; 14*135fecd4SAbhina Sree float q; 15*135fecd4SAbhina Sree double z; 16*135fecd4SAbhina Sree }; 17*135fecd4SAbhina Sree 18*135fecd4SAbhina Sree class C { 19*135fecd4SAbhina Sree int a; 20*135fecd4SAbhina Sree short b; 21*135fecd4SAbhina Sree float q; 22*135fecd4SAbhina Sree double z; 23*135fecd4SAbhina Sree }; 24*135fecd4SAbhina Sree 25*135fecd4SAbhina Sree // ************************ 26*135fecd4SAbhina Sree // INCORRECT DECLARATION 27*135fecd4SAbhina Sree // ************************ 28*135fecd4SAbhina Sree int * __ptr64 p64; // expected-error {{expected ';' after top level declarator}} 29*135fecd4SAbhina Sree int *wrong_var3 __ptr32; // expected-error {{expected ';' after top level declarator}} expected-warning {{declaration does not declare anything}} 30*135fecd4SAbhina Sree 31*135fecd4SAbhina Sree // ************************** 32*135fecd4SAbhina Sree // INCORRECT USAGES OF PTR32 33*135fecd4SAbhina Sree // ************************** 34*135fecd4SAbhina Sree struct D { 35*135fecd4SAbhina Sree int __ptr32 *a; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 36*135fecd4SAbhina Sree }; 37*135fecd4SAbhina Sree 38*135fecd4SAbhina Sree union E { 39*135fecd4SAbhina Sree int __ptr32 *b; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 40*135fecd4SAbhina Sree }; 41*135fecd4SAbhina Sree 42*135fecd4SAbhina Sree char __ptr32 *a; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 43*135fecd4SAbhina Sree signed char __ptr32 *b; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 44*135fecd4SAbhina Sree unsigned char __ptr32 *c; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 45*135fecd4SAbhina Sree int __ptr32 *d; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 46*135fecd4SAbhina Sree signed int __ptr32 *e; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 47*135fecd4SAbhina Sree unsigned int __ptr32 *f; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 48*135fecd4SAbhina Sree short int __ptr32 *g; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 49*135fecd4SAbhina Sree signed short int __ptr32 *h; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 50*135fecd4SAbhina Sree unsigned short int __ptr32 *i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 51*135fecd4SAbhina Sree long int __ptr32 *j; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 52*135fecd4SAbhina Sree signed long int __ptr32 *k; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 53*135fecd4SAbhina Sree unsigned long int __ptr32 *l; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 54*135fecd4SAbhina Sree long long int __ptr32 *m; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 55*135fecd4SAbhina Sree signed long long int __ptr32 *n; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 56*135fecd4SAbhina Sree unsigned long long int __ptr32 *o; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 57*135fecd4SAbhina Sree float __ptr32 *p; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 58*135fecd4SAbhina Sree double __ptr32 *q; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 59*135fecd4SAbhina Sree int __ptr32 **r; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 60*135fecd4SAbhina Sree int __ptr32 *__ptr32 *s; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 61*135fecd4SAbhina Sree int __ptr32 *__ptr32 *__ptr32 t; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 62*135fecd4SAbhina Sree int __ptr32 *__ptr32 *__ptr32 *__ptr32 u; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 63*135fecd4SAbhina Sree int __ptr32 __ptr32 **v_i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} 64*135fecd4SAbhina Sree int __ptr32 __ptr32 __ptr32 w_i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} 65*135fecd4SAbhina Sree 66*135fecd4SAbhina Sree __ptr32 int wrong_var; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 67*135fecd4SAbhina Sree 68*135fecd4SAbhina Sree struct A __ptr32 *c1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 69*135fecd4SAbhina Sree struct A __ptr32 **e1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 70*135fecd4SAbhina Sree struct A __ptr32 *__ptr32 *f1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 71*135fecd4SAbhina Sree struct A __ptr32 *__ptr32 *__ptr32 g1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 72*135fecd4SAbhina Sree union B __ptr32 *d1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 73*135fecd4SAbhina Sree union B __ptr32 **h1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 74*135fecd4SAbhina Sree union B __ptr32 * __ptr32 *i1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 75*135fecd4SAbhina Sree union B __ptr32 * __ptr32 * __ptr32 j1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 76*135fecd4SAbhina Sree 77*135fecd4SAbhina Sree C __ptr32 **k1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 78*135fecd4SAbhina Sree C __ptr32 * __ptr32 *l1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 79*135fecd4SAbhina Sree C __ptr32 * __ptr32 * __ptr32 m1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 80*135fecd4SAbhina Sree 81*135fecd4SAbhina Sree struct D n1; 82*135fecd4SAbhina Sree union E o1; 83*135fecd4SAbhina Sree 84*135fecd4SAbhina Sree int incorrect_func() { 85*135fecd4SAbhina Sree int __ptr32 = 1; // expected-error {{expected unqualified-id}} 86*135fecd4SAbhina Sree return __ptr32; // expected-error {{expected expression}} 87*135fecd4SAbhina Sree } 88*135fecd4SAbhina Sree 89*135fecd4SAbhina Sree typedef int __ptr32; // expected-warning {{typedef requires a name}} 90*135fecd4SAbhina Sree int incorrect_func2() { 91*135fecd4SAbhina Sree return 1; 92*135fecd4SAbhina Sree } 93*135fecd4SAbhina Sree 94*135fecd4SAbhina Sree typedef int __ptr32 *v; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} 95*135fecd4SAbhina Sree int incorrect_func3() { 96*135fecd4SAbhina Sree v v1; 97*135fecd4SAbhina Sree return 0; 98*135fecd4SAbhina Sree } 99*135fecd4SAbhina Sree 100*135fecd4SAbhina Sree int *__ptr32 a_ptr; //expected-note {{previous definition is here}} 101*135fecd4SAbhina Sree int *a_ptr; // expected-error {{redefinition of 'a_ptr' with a different type: 'int *' vs 'int * __ptr32'}} 102*135fecd4SAbhina Sree 103*135fecd4SAbhina Sree // ******************************************************* 104*135fecd4SAbhina Sree // FUNCTION OVERLOADING BETWEEN PTR32 AND REGULAR POINTERS 105*135fecd4SAbhina Sree // ******************************************************* 106*135fecd4SAbhina Sree void func(int * __ptr32 p32) {} // expected-note {{previous definition is here}} 107*135fecd4SAbhina Sree void func(int *p64) {} // expected-error {{redefinition of 'func'}} 108*135fecd4SAbhina Sree 109*135fecd4SAbhina Sree // Overloads between ptr32 and other non-pointer types are permissible 110*135fecd4SAbhina Sree void func1(int *__ptr32 p32) {} 111*135fecd4SAbhina Sree void func1(int p64) {} 112*135fecd4SAbhina Sree 113*135fecd4SAbhina Sree // ****** 114*135fecd4SAbhina Sree // MISC 115*135fecd4SAbhina Sree // ****** 116*135fecd4SAbhina Sree void func2() { 117*135fecd4SAbhina Sree char * __ptr32 v = ((char * __ptr32 *)1028)[0]; 118*135fecd4SAbhina Sree char *v1 = ((char ** __ptr32 *)1028)[0][1]; 119*135fecd4SAbhina Sree } 120*135fecd4SAbhina Sree 121