Douglas Gregor | ac06a0e | 2010-05-18 23:01:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
Chandler Carruth | 4ced79f | 2010-06-25 03:22:07 +0000 | [diff] [blame] | 3 | namespace attribute_aligned { |
| 4 | template<int N> |
| 5 | struct X { |
| 6 | char c[1] __attribute__((__aligned__((N)))); // expected-error {{alignment is not a power of 2}} |
| 7 | }; |
Douglas Gregor | ac06a0e | 2010-05-18 23:01:22 +0000 | [diff] [blame] | 8 | |
Chandler Carruth | 4ced79f | 2010-06-25 03:22:07 +0000 | [diff] [blame] | 9 | template <bool X> struct check { |
Chandler Carruth | b2b5cc0 | 2011-01-04 04:44:35 +0000 | [diff] [blame] | 10 | int check_failed[X ? 1 : -1]; // expected-error {{array with a negative size}} |
Chandler Carruth | 4ced79f | 2010-06-25 03:22:07 +0000 | [diff] [blame] | 11 | }; |
| 12 | |
| 13 | template <int N> struct check_alignment { |
| 14 | typedef check<N == sizeof(X<N>)> t; // expected-note {{in instantiation}} |
| 15 | }; |
| 16 | |
| 17 | check_alignment<1>::t c1; |
| 18 | check_alignment<2>::t c2; |
| 19 | check_alignment<3>::t c3; // expected-note 2 {{in instantiation}} |
| 20 | check_alignment<4>::t c4; |
| 21 | } |
Douglas Gregor | 6c73a29 | 2011-10-09 22:26:49 +0000 | [diff] [blame] | 22 | |
| 23 | namespace PR9049 { |
| 24 | extern const void *CFRetain(const void *ref); |
| 25 | |
| 26 | template<typename T> __attribute__((cf_returns_retained)) |
| 27 | inline T WBCFRetain(T aValue) { return aValue ? (T)CFRetain(aValue) : (T)0; } |
| 28 | |
| 29 | |
| 30 | extern void CFRelease(const void *ref); |
| 31 | |
| 32 | template<typename T> |
| 33 | inline void WBCFRelease(__attribute__((cf_consumed)) T aValue) { if(aValue) CFRelease(aValue); } |
| 34 | } |