]> granicus.if.org Git - clang/commitdiff
Don't crash when binding a reference to a temporary pointer created from
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Jan 2013 07:58:29 +0000 (07:58 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Jan 2013 07:58:29 +0000 (07:58 +0000)
resolving an overloaded function reference within an initializer list.
Previously we would try to resolve the overloaded function reference without
first stripping off the InitListExpr wrapper.

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

lib/Sema/SemaInit.cpp
test/SemaCXX/cxx0x-initializer-references.cpp

index 94dd2aa45c7f953bbda66f6fa51bf9af61d2d20e..26bb6efb8e05779b485c329dc76be7033d4aab0c 100644 (file)
@@ -3024,6 +3024,10 @@ static void TryReferenceListInitialization(Sema &S,
         Sequence.RewrapReferenceInitList(cv1T1, InitList);
       return;
     }
+
+    // Update the initializer if we've resolved an overloaded function.
+    if (Sequence.step_begin() != Sequence.step_end())
+      Sequence.RewrapReferenceInitList(cv1T1, InitList);
   }
 
   // Not reference-related. Create a temporary and bind to that.
index c4e9c907a37a3f095e3ce915a4bacc46aa33101b..283c32ac2efca8d3c0f4aa8cfd2dca6eda985ee5 100644 (file)
@@ -90,3 +90,10 @@ namespace PR12660 {
   const int &i { 1 };
   struct S { S(int); } const &s { 2 };
 }
+
+namespace b7891773 {
+  typedef void (*ptr)();
+  template <class T> void f();
+  int g(const ptr &);
+  int k = g({ f<int> });
+}