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