1 // RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
3 const 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}}
8 return __builtin_preserve_access_index(1);
11 void *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}}
15 const 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}}
19 int *valid5(int *arg
) {
20 return __builtin_preserve_access_index(arg
);
23 int valid6(const volatile int *arg
) {
24 return *__builtin_preserve_access_index(arg
);
27 struct s
{ int a
; int b
; };
29 int valid7(struct s
*arg
) {
30 return *__builtin_preserve_access_index(&arg
->b
);
33 int valid8(struct s
*arg
) {
34 return __builtin_preserve_access_index(arg
->a
+ arg
->b
);
37 int valid9(struct s
*arg
) {
38 return __builtin_preserve_access_index(({arg
->a
= 2; arg
->b
= 3; }));