[llvm] r210808 - Add missing "InitializerConstant" to global variable syntax in LangRef.

Bob Wilson bob.wilson at apple.com
Thu Jun 12 13:48:38 PDT 2014


On Jun 12, 2014, at 1:03 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:

> 
>> On 2014-Jun-12, at 11:42, Bob Wilson <bob.wilson at apple.com> wrote:
>> 
>> Author: bwilson
>> Date: Thu Jun 12 13:42:55 2014
>> New Revision: 210808
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=210808&view=rev
>> Log:
>> Add missing "InitializerConstant" to global variable syntax in LangRef.
>> 
>> The syntax for Global Variables in LangRef is missing the initializer.
>> This syntax section was added in r199218 along with changes to the
>> dllexport/dllimport handling, and I guess it was just an oversight to omit the
>> initializer values. I’ve marked the initializer as optional because this syntax
>> is used for both declarations and definitions.
>> 
>> Modified:
>>   llvm/trunk/docs/LangRef.rst
>> 
>> Modified: llvm/trunk/docs/LangRef.rst
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=210808&r1=210807&r2=210808&view=diff
>> ==============================================================================
>> --- llvm/trunk/docs/LangRef.rst (original)
>> +++ llvm/trunk/docs/LangRef.rst Thu Jun 12 13:42:55 2014
>> @@ -589,8 +589,8 @@ Syntax::
>> 
>>    [@<GlobalVarName> =] [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal]
>>                         [unnamed_addr] [AddrSpace] [ExternallyInitialized]
>> -                         <global | constant> <Type>
>> -                         [, section "name"] [, align <Alignment>]
>> +                         <global | constant> <Type> [<InitializerConstant>
>> +                         [, section "name"] [, align <Alignment>]]
> 
> Was it intentional to require an InitializerConstant any time there's a
> section name and/or an Alignment?  In particular, it seems unlikely that
> a declaration (without a value) can't specify the alignment.

It was intentional based on my reading of the spec, but you are right about the alignment. The section can also be specified for declarations. I’m not really sure what that means, but there are some test cases in the tree that do it. That might just be an artifact of bugpoint-reduced test cases, but it seems to be legal now regardless.

I have tried to clarify the doc in r210819.






More information about the llvm-commits mailing list