summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2016-11-30 19:42:03 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2016-11-30 19:42:03 +0000
commit21e5fdd89e8a906f9c4e4bf00151691a0ccbb2f3 (patch)
tree45915070cf62eb1ee59788361a0a2437f024221e /clang/test
parent5c289b77fa94d13f565d23a64a75b18140d36021 (diff)
downloadbcm5719-llvm-21e5fdd89e8a906f9c4e4bf00151691a0ccbb2f3.tar.gz
bcm5719-llvm-21e5fdd89e8a906f9c4e4bf00151691a0ccbb2f3.zip
[Sema] Teach -Wcast-align to look at the aligned attribute of the
declared variables. Teach Sema to check the aligned attribute attached to variable declarations so that it doesn't issue spurious warnings. rdar://problem/26517471 Differential revision: https://reviews.llvm.org/D21099 llvm-svn: 288267
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Sema/warn-cast-align.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-cast-align.c b/clang/test/Sema/warn-cast-align.c
index 9d64699bb5b..e8f85bc14d8 100644
--- a/clang/test/Sema/warn-cast-align.c
+++ b/clang/test/Sema/warn-cast-align.c
@@ -39,3 +39,23 @@ void test2(char *P) {
void test3(char *P) {
struct B *b = (struct B*) P;
}
+
+// Do not issue a warning. The aligned attribute changes the alignment of the
+// variables and fields.
+char __attribute__((aligned(4))) a[16];
+
+struct S0 {
+ char a[16];
+};
+
+struct S {
+ char __attribute__((aligned(4))) a[16];
+ struct S0 __attribute__((aligned(4))) s0;
+};
+
+void test4() {
+ struct S s;
+ int *i = (int *)s.a;
+ i = (int *)&s.s0;
+ i = (int *)a;
+}
OpenPOWER on IntegriCloud