Skip to content

Commit

Permalink
[AST Printer] Print attributes on enum constants
Browse files Browse the repository at this point in the history
The AST printer was dropping attributes on enumerators (enum
constants). Now it's not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292571 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jrose-apple committed Jan 20, 2017
1 parent 39c61e3 commit d57ab75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/AST/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ void DeclPrinter::VisitRecordDecl(RecordDecl *D) {

void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
Out << *D;
prettyPrintAttributes(D);
if (Expr *Init = D->getInitExpr()) {
Out << " = ";
Init->printPretty(Out, nullptr, Policy, Indentation);
Expand Down
9 changes: 9 additions & 0 deletions test/Sema/ast-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ void initializers() {
// CHECK: } z = {(struct Z){}};
} z = {(struct Z){}};
}

// CHECK-LABEL: enum EnumWithAttributes {
enum EnumWithAttributes {
// CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
EnumWithAttributesFoo __attribute__((deprecated)),
// CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
EnumWithAttributesBar __attribute__((unavailable)) = 50
// CHECK-NEXT: } __attribute__((deprecated("")))
} __attribute__((deprecated));

0 comments on commit d57ab75

Please sign in to comment.