From: Sebastian Redl Date: Wed, 7 Mar 2012 16:10:45 +0000 (+0000) Subject: Be smarter in discovering list-initialization of temporaries. Fixes PR12182. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbf82092cdb9e3a2e8528384c878f2084a14981c;p=clang Be smarter in discovering list-initialization of temporaries. Fixes PR12182. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152231 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 5d2536ae1b..f18c344b8b 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -5110,7 +5110,7 @@ InitializationSequence::Perform(Sema &S, // unwrap references here and rewrap them afterwards. // We also need to create a InitializeTemporary entity for this. QualType Ty = ResultType ? ResultType->getNonReferenceType() : Step->Type; - bool IsTemporary = ResultType && (*ResultType)->isReferenceType(); + bool IsTemporary = Entity.getType()->isReferenceType(); InitializedEntity TempEntity = InitializedEntity::InitializeTemporary(Ty); InitListChecker PerformInitList(S, IsTemporary ? TempEntity : Entity, InitList, Ty, /*VerifyOnly=*/false, diff --git a/test/SemaCXX/cxx0x-initializer-references.cpp b/test/SemaCXX/cxx0x-initializer-references.cpp index fb962641de..d8fdd5a5a0 100644 --- a/test/SemaCXX/cxx0x-initializer-references.cpp +++ b/test/SemaCXX/cxx0x-initializer-references.cpp @@ -77,3 +77,11 @@ namespace reference { } } + +namespace PR12182 { + void f(int const(&)[3]); + + void g() { + f({1, 2}); + } +}