xref: /llvm-project/clang/test/Sema/aix-attr-align.c (revision a61b202d4e3b00bf6bfd71dc1ea354d37f73b791)
1 // off-no-diagnostics
2 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify -fsyntax-only %s
3 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify -fsyntax-only %s
4 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -verify=off -Wno-aix-compat -fsyntax-only %s
5 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify=off -Wno-aix-compat -fsyntax-only %s
6 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
7 
8 // We do not warn on any declaration with a member aligned 16. Only when the struct is passed byval.
9 struct R {
10   int b[8] __attribute__((aligned(16))); // no-warning
11 };
12 
13 struct S {
14   int a[8] __attribute__((aligned(8)));  // no-warning
15   int b[8] __attribute__((aligned(16))); // expected-warning {{alignment of 16 bytes for a struct member is not binary compatible with IBM XL C/C++ for AIX 16.1.0 or older}}
16 };
17 
18 struct T {
19   int a[8] __attribute__((aligned(8))); // no-warning
20   int b[8] __attribute__((aligned(4))); // no-warning
21 };
22 
23 int a[8] __attribute__((aligned(8)));  // no-warning
24 int b[4] __attribute__((aligned(16))); // no-warning
25 
26 void baz(int a, int b, int *c, int d, int *e, int f, struct S);
27 void jaz(int a, int b, int *c, int d, int *e, int f, struct T);
28 void vararg_baz(int a,...);
static_baz(int a,int b,int * c,int d,int * e,int f,struct S sp2)29 static void static_baz(int a, int b, int *c, int d, int *e, int f, struct S sp2) {
30   a = *sp2.b + *c + *e;
31 }
32 
foo(int p1,int p2,int p3,int p4,int p5,int p6,int p7,int p8,struct S s,struct T t)33 void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
34          struct S s, struct T t) {
35 
36   baz(p1, p2, s.b, p3, b, p5, s);        // expected-note {{passing byval argument 's' with potentially incompatible alignment here}}
37   jaz(p1, p2, a, p3, s.a, p5, t);        // no-note
38   jaz(p1, p2, s.b, p3, b, p5, t);        // no-note
39   vararg_baz(p1, p2, s.b, p3, b, p5, s); // no-note
40   static_baz(p1, p2, s.b, p3, b, p5, s); // no-note
41 }
42