]> granicus.if.org Git - clang/commitdiff
Fix another decltype crash.
authorAnders Carlsson <andersca@mac.com>
Thu, 9 Jul 2009 22:00:53 +0000 (22:00 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 9 Jul 2009 22:00:53 +0000 (22:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75175 91177308-0d34-0410-b5e6-96231b3b80d8

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

index fa1c9152f443dac4aadf32a32fef00f1477d6f4a..d5dd776b7df6f13055ea536dc8787617111c98ca 100644 (file)
@@ -125,7 +125,7 @@ QualType Type::getDesugaredType(bool ForDisplay) const {
   if (const TypeOfType *TOT = dyn_cast<TypeOfType>(this))
     return TOT->getUnderlyingType().getDesugaredType();
   if (const DecltypeType *DTT = dyn_cast<DecltypeType>(this))
-    return DTT->getUnderlyingExpr()->getType().getDesugaredType();
+    return DTT->getCanonicalTypeInternal();
   if (const TemplateSpecializationType *Spec 
         = dyn_cast<TemplateSpecializationType>(this)) {
     if (ForDisplay)
diff --git a/test/SemaCXX/decltype-crash.cpp b/test/SemaCXX/decltype-crash.cpp
new file mode 100644 (file)
index 0000000..c16422e
--- /dev/null
@@ -0,0 +1,5 @@
+int& a();
+
+void f() {
+  decltype(a()) c;
+}