diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-06-25 03:22:07 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-06-25 03:22:07 +0000 |
commit | 4ced79f0971592e6e7122037de69ee9ae534ce72 (patch) | |
tree | f864ce489d064cd88454414a40f8a527b873f3ca /test/SemaTemplate/attributes.cpp | |
parent | fba9e8f85b3043da0e045cd653bcba9b6c60e067 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/attributes.cpp')
-rw-r--r-- | test/SemaTemplate/attributes.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/SemaTemplate/attributes.cpp b/test/SemaTemplate/attributes.cpp index b696c5cd98..f4c1887c25 100644 --- a/test/SemaTemplate/attributes.cpp +++ b/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; +} |