Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-assume-2.c
blob0c8323972114325619ce466b37e0c9df378b9531
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" } */
13 void
14 foo ()
16 int i;
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" } */
36 int
37 f2 (int x)
39 __asm ("" : "+r" (x));
40 return x;
43 int
44 f3 (int x)
46 [[gnu::assume (f2 (42) == 42)]];
47 return x;
50 int
51 f3a (int x)
53 __attribute__((assume (f2 (42) == 42)));
54 return x;
57 struct S {};
59 int
60 f4 ()
62 struct S s;
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" } */
65 return 0;