1 // RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify
2 // RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify
3 // RUN: %clang_cc1 -triple arm64-arm-eabi %s -DNO_MTE -x c++ -emit-llvm-only -verify
8 int *create_tag1(int a
, unsigned b
) {
9 // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
10 return __arm_mte_create_random_tag(a
,b
);
13 int *create_tag2(int *a
, unsigned *b
) {
14 // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('unsigned int *' invalid)}}
15 return __arm_mte_create_random_tag(a
,b
);
18 int *create_tag3(const int *a
, unsigned b
) {
20 // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
21 return __arm_mte_create_random_tag(a
,b
);
23 // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
24 return __arm_mte_create_random_tag(a
,b
);
28 int *create_tag4(volatile int *a
, unsigned b
) {
30 // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'volatile int *'}}
31 return __arm_mte_create_random_tag(a
,b
);
33 // expected-warning@+1 {{returning 'volatile int *' from a function with result type 'int *' discards qualifiers}}
34 return __arm_mte_create_random_tag(a
,b
);
38 int *increment_tag1(int *a
, unsigned b
) {
39 // expected-error@+1 {{argument to '__builtin_arm_addg' must be a constant integer}}
40 return __arm_mte_increment_tag(a
,b
);
43 int *increment_tag2(int *a
) {
44 // expected-error@+1 {{argument value 16 is outside the valid range [0, 15]}}
45 return __arm_mte_increment_tag(a
,16);
48 int *increment_tag3(int *a
) {
49 // expected-error@+1 {{argument value -1 is outside the valid range [0, 15]}}
50 return __arm_mte_increment_tag(a
,-1);
53 int *increment_tag4(const int *a
) {
55 // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
56 return __arm_mte_increment_tag(a
,5);
58 // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}
59 return __arm_mte_increment_tag(a
,5);
63 int *increment_tag5(const volatile int *a
) {
65 // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
66 return __arm_mte_increment_tag(a
,5);
68 // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
69 return __arm_mte_increment_tag(a
,5);
73 unsigned exclude_tag1(int *ptr
, unsigned m
) {
74 // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
75 return __arm_mte_exclude_tag(*ptr
, m
);
78 unsigned exclude_tag2(int *ptr
, int *m
) {
79 // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('int *' invalid)}}
80 return __arm_mte_exclude_tag(ptr
, m
);
84 // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
88 int *get_tag2(int ptr
) {
89 // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
90 return __arm_mte_get_tag(ptr
);
93 int *get_tag3(const volatile int *ptr
) {
95 // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}}
96 return __arm_mte_get_tag(ptr
);
98 // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}
99 return __arm_mte_get_tag(ptr
);
103 void set_tag1(void) {
104 // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}
108 void set_tag2(int ptr
) {
109 // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
110 __arm_mte_set_tag(ptr
);
113 ptrdiff_t subtract_pointers1(int a
, int *b
) {
114 // expected-error@+1 {{first argument of MTE builtin function must be a null or a pointer ('int' invalid)}}
115 return __arm_mte_ptrdiff(a
, b
);
118 ptrdiff_t subtract_pointers2(int *a
, int b
) {
119 // expected-error@+1 {{second argument of MTE builtin function must be a null or a pointer ('int' invalid)}}
120 return __arm_mte_ptrdiff(a
, b
);
123 ptrdiff_t subtract_pointers3(char *a
, int *b
) {
124 // expected-error@+1 {{'char *' and 'int *' are not pointers to compatible types}}
125 return __arm_mte_ptrdiff(a
, b
);
128 ptrdiff_t subtract_pointers4(int *a
, char *b
) {
129 // expected-error@+1 {{'int *' and 'char *' are not pointers to compatible types}}
130 return __arm_mte_ptrdiff(a
, b
);
134 ptrdiff_t subtract_pointers5() {
135 // expected-error@+1 {{at least one argument of MTE builtin function must be a pointer ('std::nullptr_t', 'std::nullptr_t' invalid)}}
136 return __arm_mte_ptrdiff(nullptr, nullptr);
141 int *create_tag1(int *a
, unsigned b
) {
142 // expected-error@+1 {{'__builtin_arm_irg' needs target feature mte}}
143 return __arm_mte_create_random_tag(a
,b
);