From: Vassil Vassilev Date: Fri, 8 Jul 2016 16:04:22 +0000 (+0000) Subject: Don't crash when printing auto variables. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb6076f3bf0f1aeca6089de675c2b9b13210457d;p=clang Don't crash when printing auto variables. Patch by Axel Naumann! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274859 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 6868ea2a6d..bfdb47b90d 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -132,6 +132,8 @@ static QualType GetBaseType(QualType T) { BaseType = VTy->getElementType(); else if (const ReferenceType *RTy = BaseType->getAs()) BaseType = RTy->getPointeeType(); + else if (const AutoType *ATy = BaseType->getAs()) + BaseType = ATy->getDeducedType(); else llvm_unreachable("Unknown declarator!"); } diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 39a52ab8d7..733931803b 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -227,3 +227,12 @@ template struct Foo : T { using T::operator-; }; } + +namespace dont_crash { +struct T { enum E {X = 12ll }; }; +struct S { + struct { int I; } ADecl; + static const auto Y = T::X; +}; +//CHECK: static const auto Y = T::X; +}