[cfe-commits] r69227 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Anders Carlsson
andersca at mac.com
Wed Apr 15 14:48:22 PDT 2009
Author: andersca
Date: Wed Apr 15 16:48:18 2009
New Revision: 69227
URL: http://llvm.org/viewvc/llvm-project?rev=69227&view=rev
Log:
When declaring a variable that has a constructor and a direct initializer, for example:
struct X {
X(int, int);
};
X x(10, 10);
we model that as
X x = X(10, 10);
inserting a temporary object expr.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=69227&r1=69226&r2=69227&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr 15 16:48:18 2009
@@ -1796,15 +1796,19 @@
IK_Direct);
if (!Constructor)
RealDecl->setInvalidDecl();
- else
- Exprs.release();
-
- // Let clients know that initialization was done with a direct
- // initializer.
- VDecl->setCXXDirectInitializer(true);
-
- // FIXME: Add ExprTys and Constructor to the RealDecl as part of
- // the initializer.
+ else {
+ // Let clients know that initialization was done with a direct
+ // initializer.
+ VDecl->setCXXDirectInitializer(true);
+
+ Expr *Temp =
+ new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType,
+ SourceLocation(),
+ (Expr**)Exprs.release(),
+ NumExprs,
+ SourceLocation());
+ AddInitializerToDecl(Dcl, ExprArg(*this, Temp), /*DirectInit=*/true);
+ }
return;
}
More information about the cfe-commits
mailing list