]> granicus.if.org Git - clang/commitdiff
Decltype needs to have a dependent type if the expr passed to it is type dependent...
authorAnders Carlsson <andersca@mac.com>
Thu, 25 Jun 2009 15:00:34 +0000 (15:00 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 25 Jun 2009 15:00:34 +0000 (15:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74175 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/SemaCXX/decltype-pr4444.cpp [new file with mode: 0644]

index 377d2fbe9a30f1d631252b896c442935064e3ee0..16a62fdd8cddcb5d1b08821d7b177ad47a358cf2 100644 (file)
@@ -1666,6 +1666,9 @@ QualType ASTContext::getTypeOfType(QualType tofType) {
 /// 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)) {
diff --git a/test/SemaCXX/decltype-pr4444.cpp b/test/SemaCXX/decltype-pr4444.cpp
new file mode 100644 (file)
index 0000000..8b2f584
--- /dev/null
@@ -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;
+};