[cfe-commits] r74257 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaCXX/decltype-pr4448.cpp
Anders Carlsson
andersca at mac.com
Thu Jun 25 20:02:18 PDT 2009
Author: andersca
Date: Thu Jun 25 22:02:18 2009
New Revision: 74257
URL: http://llvm.org/viewvc/llvm-project?rev=74257&view=rev
Log:
Fix PR4448.
Added:
cfe/trunk/test/SemaCXX/decltype-pr4448.cpp
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=74257&r1=74256&r2=74257&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Jun 25 22:02:18 2009
@@ -365,14 +365,12 @@
SourceLocation StartLoc = ConsumeToken();
SourceLocation LParenLoc = Tok.getLocation();
-
if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"decltype")) {
SkipUntil(tok::r_paren);
return;
}
-
// Parse the expression
// C++0x [dcl.type.simple]p4:
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=74257&r1=74256&r2=74257&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Jun 25 22:02:18 2009
@@ -560,6 +560,11 @@
QualType
TemplateTypeInstantiator::InstantiateDecltypeType(const DecltypeType *T,
unsigned Quals) const {
+ // C++0x [dcl.type.simple]p4:
+ // The operand of the decltype specifier is an unevaluated operand.
+ EnterExpressionEvaluationContext Unevaluated(SemaRef,
+ Action::Unevaluated);
+
Sema::OwningExprResult E
= SemaRef.InstantiateExpr(T->getUnderlyingExpr(), TemplateArgs);
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=74257&r1=74256&r2=74257&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu Jun 25 22:02:18 2009
@@ -119,6 +119,14 @@
// FIXME: Clone the expression!
return SemaRef.Owned(Arg.getAsExpr());
+ if (Arg.getKind() == TemplateArgument::Declaration) {
+ ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl());
+
+ // FIXME: Can VD ever have a dependent type?
+ return SemaRef.BuildDeclRefExpr(VD, VD->getType(), E->getLocation(),
+ false, false);
+ }
+
assert(Arg.getKind() == TemplateArgument::Integral);
QualType T = Arg.getIntegralType();
if (T->isCharType() || T->isWideCharType())
Added: cfe/trunk/test/SemaCXX/decltype-pr4448.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype-pr4448.cpp?rev=74257&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/decltype-pr4448.cpp (added)
+++ cfe/trunk/test/SemaCXX/decltype-pr4448.cpp Thu Jun 25 22:02:18 2009
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+template< typename T, T t, decltype(t+2) v >
+struct Convoluted {};
+
+int test_array[5];
+
+Convoluted< int *, test_array, nullptr > tarray;
More information about the cfe-commits
mailing list