1 /* Portable assumptions */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23" } */
5 [[gnu::__assume__ (1)]] void f1 (void); /* { dg-warning "'assume' attribute not followed by ';'" } */
6 /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */
7 typedef int intx
[[gnu::assume (1)]]; /* { dg-warning "'assume' attribute ignored" } */
8 [[__gnu__::assume (1)]]; /* { dg-warning "'assume' attribute at top level" } */
9 __attribute__((assume (1))) void f1b ();/* { dg-warning "'assume' attribute not followed by ';'" } */
10 /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */
11 typedef int inty
__attribute__((assume (1))); /* { dg-warning "'assume' attribute ignored" } */
17 [[gnu::assume
]]; /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */
18 /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */
19 [[gnu::__assume__ ()]]; /* { dg-error "parentheses must be omitted if attribute argument list is empty" } */
20 /* { dg-error "wrong number of arguments specified for 'assume' attribute" "" { target *-*-* } .-1 } */
21 /* { dg-message "expected 1, found 0" "" { target *-*-* } .-2 } */
22 [[gnu::assume (1, 1)]]; /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */
23 /* { dg-message "expected 1, found 2" "" { target *-*-* } .-1 } */
24 [[gnu::assume (1)]] i
= 1; /* { dg-warning "'assume' attribute ignored" } */
25 [[gnu::assume (i
= 1)]]; /* { dg-error "expected" } */
26 /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */
27 __attribute__((assume
)); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */
28 /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */
29 __attribute__((assume ())); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */
30 /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */
31 __attribute__((assume (1, 1))); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */
32 /* { dg-message "expected 1, found 2" "" { target *-*-* } .-1 } */
33 __attribute__((assume (i
= 1))); /* { dg-error "expected" } */
39 __asm ("" : "+r" (x
));
46 [[gnu::assume (f2 (42) == 42)]];
53 __attribute__((assume (f2 (42) == 42)));
63 [[gnu::assume (s
)]]; /* { dg-error "used struct type value where scalar is required" } */
64 __attribute__((assume (s
))); /* { dg-error "used struct type value where scalar is required" } */