[cfe-commits] r74175 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaCXX/decltype-pr4444.cpp
Anders Carlsson
andersca at mac.com
Thu Jun 25 08:00:40 PDT 2009
Author: andersca
Date: Thu Jun 25 10:00:34 2009
New Revision: 74175
URL: http://llvm.org/viewvc/llvm-project?rev=74175&view=rev
Log:
Decltype needs to have a dependent type if the expr passed to it is type dependent. Fixes PR4444.
Added:
cfe/trunk/test/SemaCXX/decltype-pr4444.cpp
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=74175&r1=74174&r2=74175&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jun 25 10:00:34 2009
@@ -1666,6 +1666,9 @@
/// getDecltypeForExpr - Given an expr, will return the decltype for that
/// expression, according to the rules in C++0x [dcl.type.simple]p4
static QualType getDecltypeForExpr(const Expr *e, ASTContext &Context) {
+ if (e->isTypeDependent())
+ return Context.DependentTy;
+
// If e is an id expression or a class member access, decltype(e) is defined
// as the type of the entity named by e.
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(e)) {
Added: cfe/trunk/test/SemaCXX/decltype-pr4444.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype-pr4444.cpp?rev=74175&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/decltype-pr4444.cpp (added)
+++ cfe/trunk/test/SemaCXX/decltype-pr4444.cpp Thu Jun 25 10:00:34 2009
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+template<typename T, T t>
+struct TestStruct {
+ typedef decltype(t+2) sum_type;
+};
More information about the cfe-commits
mailing list