[cfe-commits] r95382 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaInit.cpp test/SemaTemplate/instantiate-decl-init.cpp
Douglas Gregor
dgregor at apple.com
Thu Feb 4 23:56:12 PST 2010
Author: dgregor
Date: Fri Feb 5 01:56:11 2010
New Revision: 95382
URL: http://llvm.org/viewvc/llvm-project?rev=95382&view=rev
Log:
A dependent initializer with zero arguments should return a NULL
initializer (for no initialization) rather than a ParenListExpr with
zero arguments in it.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=95382&r1=95381&r2=95382&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 5 01:56:11 2010
@@ -3727,7 +3727,8 @@
if (Init.isInvalid())
Var->setInvalidDecl();
else {
- Var->setInit(Context,
+ if (Init.get())
+ Var->setInit(Context,
MaybeCreateCXXExprWithTemporaries(Init.takeAs<Expr>()));
FinalizeVarWithDestructor(Var, InitType->getAs<RecordType>());
}
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=95382&r1=95381&r2=95382&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Feb 5 01:56:11 2010
@@ -3190,6 +3190,9 @@
if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast())
return Sema::OwningExprResult(S, Args.release()[0]);
+ if (Args.size() == 0)
+ return S.Owned((Expr *)0);
+
unsigned NumArgs = Args.size();
return S.Owned(new (S.Context) ParenListExpr(S.Context,
SourceLocation(),
Modified: cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp?rev=95382&r1=95381&r2=95382&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp Fri Feb 5 01:56:11 2010
@@ -34,3 +34,13 @@
template void f0<int>();
template void f0<float>();
+
+struct NonTrivial {
+ NonTrivial();
+ ~NonTrivial();
+};
+
+template<int N> void f1() {
+ NonTrivial array[N];
+}
+template<> void f1<2>();
More information about the cfe-commits
mailing list