]> granicus.if.org Git - clang/commitdiff
PR12660: Don't crash when initializing a const reference from a braced init list
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Apr 2012 03:16:45 +0000 (03:16 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Apr 2012 03:16:45 +0000 (03:16 +0000)
which creates a temporary by calling a constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155608 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Initialization.h
test/SemaCXX/cxx0x-initializer-references.cpp

index 4433843ff861f0b666e6cefba92d1b00ccc3c8f9..0dd68875a9ec2834af105272866fc08323557bbf 100644 (file)
@@ -225,7 +225,9 @@ public:
   
   /// \brief Create the initialization entity for a temporary.
   static InitializedEntity InitializeTemporary(QualType Type) {
-    return InitializedEntity(EK_Temporary, SourceLocation(), Type);
+    InitializedEntity Result(EK_Temporary, SourceLocation(), Type);
+    Result.TypeInfo = 0;
+    return Result;
   }
 
   /// \brief Create the initialization entity for a temporary.
index d8fdd5a5a07a5578ba152a58030e5aed0556060d..c4e9c907a37a3f095e3ce915a4bacc46aa33101b 100644 (file)
@@ -85,3 +85,8 @@ namespace PR12182 {
       f({1, 2});
   }
 }
+
+namespace PR12660 {
+  const int &i { 1 };
+  struct S { S(int); } const &s { 2 };
+}