[cfe-commits] r172517 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/SemaCXX/cxx0x-initializer-references.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Jan 14 23:58:29 PST 2013


Author: rsmith
Date: Tue Jan 15 01:58:29 2013
New Revision: 172517

URL: http://llvm.org/viewvc/llvm-project?rev=172517&view=rev
Log:
Don't crash when binding a reference to a temporary pointer created from
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.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=172517&r1=172516&r2=172517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jan 15 01:58:29 2013
@@ -3024,6 +3024,10 @@
         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.

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp?rev=172517&r1=172516&r2=172517&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp Tue Jan 15 01:58:29 2013
@@ -90,3 +90,10 @@
   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> });
+}





More information about the cfe-commits mailing list