From: Eli Friedman Date: Wed, 24 Oct 2012 20:21:25 +0000 (+0000) Subject: Don't print scope qualifiers for references to a type defined locally in a function... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a45451d0959501c7d82582c61571a29cfdacdb0b;p=clang Don't print scope qualifiers for references to a type defined locally in a function. Patch by Grzegorz Jablonski. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166617 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 4cf4b1847f..90b2ca9cce 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -799,6 +799,7 @@ void TypePrinter::printAtomicAfter(const AtomicType *T, raw_ostream &OS) { } /// Appends the given scope to the end of a string. void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS) { if (DC->isTranslationUnit()) return; + if (DC->isFunctionOrMethod()) return; AppendScope(DC->getParent(), OS); if (NamespaceDecl *NS = dyn_cast(DC)) { diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 0dad623d47..aeb4039d59 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -64,3 +64,20 @@ template void test7() // CHECK: t.~T(); template void test8(T t) { t.~T(); } + + +// CHECK: enum E { +// CHECK-NEXT: A, +// CHECK-NEXT: B, +// CHECK-NEXT: C +// CHECK-NEXT: }; +// CHECK-NEXT: {{^[ ]+}}E a = A; + +struct test9 +{ + void f() + { + enum E { A, B, C }; + E a = A; + } +};