[cfe-commits] [PATCH] Use static storage duration for file-scope compound literals in C++ dynamic initializers

Richard Smith richard at metafoo.co.uk
Tue Nov 22 18:16:02 PST 2011


On Wed, November 23, 2011 00:34, Eric Christopher wrote:
> On Nov 22, 2011, at 2:55 PM, Richard Smith wrote:
>> On Tue, November 22, 2011 22:39, Chandler Carruth wrote:
>>> On Tue, Nov 22, 2011 at 2:30 PM, Richard Smith
>>> <richard at metafoo.co.uk>wrote:
>>>> The attached patch fixes the compound-literals-in-C++ extension to
>>>> always use static storage duration for file-scope compound literals, as
>>>> per GCC's documentation for this extension. Currently we only give them
>>>> static storage duration if the initializer in which they appear is a
>>>> constant.
>>>>
>>>> OK to commit?
>>>>
>>>
>>> It's not clear to me why we need the helper function? Otherwise this
>>> looks fine to me...
>>
>> In r145087. We need the helper function because class ConstExprEmitter is
>> defined in that .cpp file.
>
> Looks like this broke one of the clang buildbots:
>
>
> ******************** TEST 'Clang :: CodeGenCXX/compound-literals.cpp' FAILED
> ********************Script:
> --
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-i386-darwin10-
> RA/clang-build/Release+Asserts/bin/clang -cc1 -internal-isystem
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-i386-darwin10
> -RA/clang-build/Release+Asserts/bin/../lib/clang/3.1/include -emit-llvm -o -
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-i386-darwin10
> -RA/clang.src/test/CodeGenCXX/compound-literals.cpp | FileCheck
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-i386-darwin10
> -RA/clang.src/test/CodeGenCXX/compound-literals.cpp
> --
> Exit Code: 1
> Command Output (stderr):
> --
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-i386-darwin10-
> RA/clang.src/test/CodeGenCXX/compound-literals.cpp:44:11: error: expected
> string not found in input // CHECK: store i32* getelementptr inbounds
> (%struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p, align 8
> ^
> <stdin>:59:47: note: scanning from here
> define internal void @__cxx_global_var_init() nounwind section
> "__TEXT,__StaticInit,regular,pure_instructions" {
> ^
> <stdin>:61:2: note: possible intended match here
> store i32* getelementptr inbounds (%struct.Z* @.compoundliteral, i32 0, i32 0,
> i32 0), i32** @p, align 4 ^
> --
>
> ********************
>
> Looks like it's a difference in alignment, but I'm not sure what it's
> supposed to be testing without looking closer.

The alignment is irrelevant to this test; removed in r145093.

Thanks!
Richard




More information about the cfe-commits mailing list