1 // RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s 2 invalid1(const int * arg)3const void *invalid1(const int *arg) { 4 return __builtin_preserve_access_index(&arg[1], 1); // expected-error {{too many arguments to function call, expected 1, have 2}} 5 } 6 valid2(void)7int valid2(void) { 8 return __builtin_preserve_access_index(1); 9 } 10 invalid3(const int * arg)11void *invalid3(const int *arg) { 12 return __builtin_preserve_access_index(&arg[1]); // expected-warning {{returning 'const int *' from a function with result type 'void *' discards qualifiers}} 13 } 14 invalid4(volatile const int * arg)15const void *invalid4(volatile const int *arg) { 16 return __builtin_preserve_access_index(arg); // expected-warning {{returning 'const volatile int *' from a function with result type 'const void *' discards qualifiers}} 17 } 18 valid5(int * arg)19int *valid5(int *arg) { 20 return __builtin_preserve_access_index(arg); 21 } 22 valid6(const volatile int * arg)23int valid6(const volatile int *arg) { 24 return *__builtin_preserve_access_index(arg); 25 } 26 27 struct s { int a; int b; }; 28 valid7(struct s * arg)29int valid7(struct s *arg) { 30 return *__builtin_preserve_access_index(&arg->b); 31 } 32 valid8(struct s * arg)33int valid8(struct s *arg) { 34 return __builtin_preserve_access_index(arg->a + arg->b); 35 } 36 valid9(struct s * arg)37int valid9(struct s *arg) { 38 return __builtin_preserve_access_index(({arg->a = 2; arg->b = 3; })); 39 } 40