[cfe-commits] r91542 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/SemaCXX/decl-init-ref.cpp test/SemaTemplate/instantiate-template-template-parm.cpp test/SemaTemplate/metafun-apply.cpp

Douglas Gregor dgregor at apple.com
Wed Dec 16 08:54:16 PST 2009


Author: dgregor
Date: Wed Dec 16 10:54:16 2009
New Revision: 91542

URL: http://llvm.org/viewvc/llvm-project?rev=91542&view=rev
Log:
In Sema::CheckInitializerTypes, replace a use of CheckReferenceInit with an InitializationSequence

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/SemaCXX/decl-init-ref.cpp
    cfe/trunk/test/SemaTemplate/instantiate-template-template-parm.cpp
    cfe/trunk/test/SemaTemplate/metafun-apply.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=91542&r1=91541&r2=91542&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Dec 16 10:54:16 2009
@@ -192,11 +192,17 @@
   //   A variable declared to be a T& or T&&, that is "reference to type T"
   //   (8.3.2), shall be initialized by an object, or function, of
   //   type T or by an object that can be converted into a T.
-  if (DeclType->isReferenceType())
-    return CheckReferenceInit(Init, DeclType, InitLoc,
-                              /*SuppressUserConversions=*/false,
-                              /*AllowExplicit=*/DirectInit,
-                              /*ForceRValue=*/false);
+  if (DeclType->isReferenceType()) {
+    InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
+    OwningExprResult CurInit = InitSeq.Perform(*this, Entity, Kind,
+                                         MultiExprArg(*this, (void**)&Init, 1),
+                                               &DeclType);
+    if (CurInit.isInvalid())
+      return true;
+
+    Init = CurInit.takeAs<Expr>();
+    return false;
+  }
 
   // C99 6.7.8p3: The type of the entity to be initialized shall be an array
   // of unknown size ("[]") or an object type that is not a variable array type.

Modified: cfe/trunk/test/SemaCXX/decl-init-ref.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-init-ref.cpp?rev=91542&r1=91541&r2=91542&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/decl-init-ref.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-init-ref.cpp Wed Dec 16 10:54:16 2009
@@ -18,7 +18,7 @@
 
 extern B f();
 
-const int& ri = (void)0; // expected-error {{invalid initialization of reference of type 'int const &' from expression of type 'void'}}
+const int& ri = (void)0; // expected-error {{reference to type 'int const' could not bind to an rvalue of type 'void'}}
 
 int main() {
         const A& rca = f(); // expected-error {{conversion from 'class B' to 'struct A const' is ambiguous}}

Modified: cfe/trunk/test/SemaTemplate/instantiate-template-template-parm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-template-template-parm.cpp?rev=91542&r1=91541&r2=91542&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-template-template-parm.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-template-template-parm.cpp Wed Dec 16 10:54:16 2009
@@ -17,7 +17,7 @@
 int i;
 apply<add_pointer, int>::type ip = &i;
 apply<add_reference, int>::type ir = i;
-apply<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a value of type 'int'}}
+apply<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
 
 // Template template parameters
 template<int> struct B; // expected-note{{has a different type 'int'}}

Modified: cfe/trunk/test/SemaTemplate/metafun-apply.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/metafun-apply.cpp?rev=91542&r1=91541&r2=91542&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/metafun-apply.cpp (original)
+++ cfe/trunk/test/SemaTemplate/metafun-apply.cpp Wed Dec 16 10:54:16 2009
@@ -29,7 +29,7 @@
 int i;
 apply1<add_pointer, int>::type ip = &i;
 apply1<add_reference, int>::type ir = i;
-apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a value of type 'int'}}
+apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
 
 void test() {
   apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'struct apply1<struct add_reference, void>' requested here}} \





More information about the cfe-commits mailing list