summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/attributes.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-06-25 03:22:07 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-06-25 03:22:07 +0000
commitf40c42f2cd8967381ba1a11671b796f93e768546 (patch)
tree3cc3748fb9e5e9348447ca69b90c6f90990cda27 /clang/test/SemaTemplate/attributes.cpp
parente9eaaa91d846a084b6c1c3b8aa4969e1f5131478 (diff)
downloadbcm5719-llvm-f40c42f2cd8967381ba1a11671b796f93e768546.tar.gz
bcm5719-llvm-f40c42f2cd8967381ba1a11671b796f93e768546.zip
Implement dependent alignment attribute support. This is a bit gross given the
current attribute system, but it is enough to handle class templates which specify parts of their alignment in terms of their template parameters. This also replaces the attributes test in SemaTemplate with one that actually tests working attributes instead of broken ones. I plan to add more tests here for non-dependent attributes in a subsequent patch. Thanks to John for walking me through some of this. =D llvm-svn: 106818
Diffstat (limited to 'clang/test/SemaTemplate/attributes.cpp')
-rw-r--r--clang/test/SemaTemplate/attributes.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/clang/test/SemaTemplate/attributes.cpp b/clang/test/SemaTemplate/attributes.cpp
index b696c5cd984..f4c1887c25e 100644
--- a/clang/test/SemaTemplate/attributes.cpp
+++ b/clang/test/SemaTemplate/attributes.cpp
@@ -1,8 +1,21 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-template<int N>
-struct X {
- struct __attribute__((__aligned__((N)))) Aligned { }; // expected-error{{'aligned' attribute requires integer constant}}
+namespace attribute_aligned {
+ template<int N>
+ struct X {
+ char c[1] __attribute__((__aligned__((N)))); // expected-error {{alignment is not a power of 2}}
+ };
- int __attribute__((__address_space__(N))) *ptr; // expected-error{{attribute requires 1 argument(s)}}
-};
+ template <bool X> struct check {
+ int check_failed[X ? 1 : -1]; // expected-error {{array size is negative}}
+ };
+
+ template <int N> struct check_alignment {
+ typedef check<N == sizeof(X<N>)> t; // expected-note {{in instantiation}}
+ };
+
+ check_alignment<1>::t c1;
+ check_alignment<2>::t c2;
+ check_alignment<3>::t c3; // expected-note 2 {{in instantiation}}
+ check_alignment<4>::t c4;
+}
OpenPOWER on IntegriCloud