brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 1b0621f Raw
145 lines · c
1// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify2// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify3// RUN: %clang_cc1 -triple arm64-arm-eabi %s -DNO_MTE -x c++ -emit-llvm-only -verify4#include <stddef.h>5#include <arm_acle.h>6 7#ifndef NO_MTE8int  *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);11}12 13int  *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);16}17 18int  *create_tag3(const int *a, unsigned b) {19#ifdef __cplusplus20  // 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);22#else23  // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}24  return __arm_mte_create_random_tag(a,b);25#endif26}27 28int  *create_tag4(volatile int *a, unsigned b) {29#ifdef __cplusplus30  // 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);32#else33  // expected-warning@+1 {{returning 'volatile int *' from a function with result type 'int *' discards qualifiers}}34  return __arm_mte_create_random_tag(a,b);35#endif36}37 38int  *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);41}42 43int  *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);46}47 48int  *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);51}52 53int  *increment_tag4(const int *a) {54#ifdef __cplusplus55  // 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);57#else58  // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}}59  return __arm_mte_increment_tag(a,5);60#endif61}62 63int *increment_tag5(const volatile int *a) {64#ifdef __cplusplus65  // 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);67#else68  // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}69  return __arm_mte_increment_tag(a,5);70#endif71}72 73unsigned 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);76}77 78unsigned 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);81}82 83void get_tag1(void) {84   // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}85   __arm_mte_get_tag();86}87 88int *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);91}92 93int *get_tag3(const volatile int *ptr) {94#ifdef __cplusplus95  // 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);97#else98  // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}}99  return __arm_mte_get_tag(ptr);100#endif101}102 103void set_tag1(void) {104   // expected-error@+1 {{too few arguments to function call, expected 1, have 0}}105   __arm_mte_set_tag();106}107 108void 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);111}112 113ptrdiff_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);116}117 118ptrdiff_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);121}122 123ptrdiff_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);126}127 128ptrdiff_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);131}132 133#ifdef __cplusplus134ptrdiff_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);137}138#endif139 140#else141int *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);144}145#endif