[cfe-commits] r86460 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-decl-init.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sun Nov 8 02:16:44 PST 2009
Author: cornedbee
Date: Sun Nov 8 04:16:43 2009
New Revision: 86460
URL: http://llvm.org/viewvc/llvm-project?rev=86460&view=rev
Log:
Don't reprocess non-dependent initializers of non-dependent VarDecls. Fixes PR5426.
Added:
cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=86460&r1=86459&r2=86460&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Nov 8 04:16:43 2009
@@ -186,6 +186,15 @@
= SemaRef.SubstExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
Var->setInvalidDecl();
+ else if (!D->getType()->isDependentType() &&
+ !D->getInit()->isTypeDependent() &&
+ !D->getInit()->isValueDependent()) {
+ // If neither the declaration's type nor its initializer are dependent,
+ // we don't want to redo all the checking, especially since the
+ // initializer might have been wrapped by a CXXConstructExpr since we did
+ // it the first time.
+ Var->setInit(SemaRef.Context, Init.takeAs<Expr>());
+ }
else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {
// FIXME: We're faking all of the comma locations, which is suboptimal.
// Do we even need these comma locations?
Added: cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp?rev=86460&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-decl-init.cpp Sun Nov 8 04:16:43 2009
@@ -0,0 +1,22 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// PR5426 - the non-dependent obj would be fully processed and wrapped in a
+// CXXConstructExpr at definition time, which would lead to a failure at
+// instantiation time.
+struct arg {
+ arg();
+};
+
+struct oldstylemove {
+ oldstylemove(oldstylemove&);
+ oldstylemove(const arg&);
+};
+
+template <typename T>
+void fn(T t, const arg& arg) {
+ oldstylemove obj(arg);
+}
+
+void test() {
+ fn(1, arg());
+}
More information about the cfe-commits
mailing list