[cfe-commits] [libcxx] r157764 - in /libcxx/trunk: include/__config src/iostream.cpp

Eli Friedman eli.friedman at gmail.com
Thu May 31 13:11:15 PDT 2012


On Thu, May 31, 2012 at 1:02 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> On May 31, 2012, at 3:58 PM, Chandler Carruth wrote:
>
>> On Thu, May 31, 2012 at 12:31 PM, Howard Hinnant <hhinnant at apple.com> wrote:
>> Author: hhinnant
>> Date: Thu May 31 14:31:14 2012
>> New Revision: 157764
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=157764&view=rev
>> Log:
>> Protect use of alignas against older versions of clang
>>
>> Modified:
>>    libcxx/trunk/include/__config
>>    libcxx/trunk/src/iostream.cpp
>>
>> Modified: libcxx/trunk/include/__config
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=157764&r1=157763&r2=157764&view=diff
>> ==============================================================================
>> --- libcxx/trunk/include/__config (original)
>> +++ libcxx/trunk/include/__config Thu May 31 14:31:14 2012
>> @@ -145,8 +145,10 @@
>>  #if defined(__clang__)
>>
>>  #if __has_feature(cxx_alignas)
>> +#  define _ALIGNAS_TYPE(x) alignas(x)
>>  #  define _ALIGNAS(x) alignas(x)
>>  #else
>> +#  define _ALIGNAS_TYPE(x) __attribute__((__aligned__))
>>
>> Should this be __aligned__(x) as it is here:
>>
>>  #  define _ALIGNAS(x) __attribute__((__aligned__(x)))
>>
>> Or are you intentionally shooting for the 'maximally aligned' thing? If the latter, maybe comment that this is intentional and not a typo?
>
> It's intentional.  My first try was using _ALIGNAS, and the compiler really didn't like it:
>
> ../src/iostream.cpp:16:21: error: expected ')'
> _ALIGNAS (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
>                    ^
> ../include/__config:149:50: note: expanded from macro '_ALIGNAS'
> #  define _ALIGNAS(x) __attribute__((__aligned__(x)))
>                                                 ^
>
> And so I punted by introducing _ALIGNAS_TYPE.
>
> I can add a comment, but I'd really like to hold trunk stable for just a couple more hours.

The correct definition for _ALIGNAS_TYPE is something like the following:

#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))

-Eli




More information about the cfe-commits mailing list