]> granicus.if.org Git - clang/commit
[Attr] Print enum attributes at correct position
authorJoel E. Denny <jdenny.ornl@gmail.com>
Tue, 24 Apr 2018 14:50:23 +0000 (14:50 +0000)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Tue, 24 Apr 2018 14:50:23 +0000 (14:50 +0000)
commit4d48be1aa7744f3e4f5b0a53dad7fdde7885da41
treea9c19ac1578e57f005cc3621cf0516dbd2f829cb
parente7db806bfc0c96adbe0417fd8047a2647ab984ed
[Attr] Print enum attributes at correct position

For example, given:

  void fn() {
    enum __attribute__((deprecated)) T *p;
  }

-ast-print produced:

  void fn() {
    enum T __attribute__((deprecated(""))) *p;
  }

-ast-print on that produced:

  void fn() {
    enum T *p __attribute__((deprecated("")));
  }

The attribute is on enum T in the first case, but it's on p in the
other cases.

Details:

Within enum declarations, enum attributes were always printed after
the tag and any member list.  When no member list was present but the
enum was a type specifier in a variable declaration, the attribute
then applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D45456

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330722 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/DeclPrinter.cpp
test/Sema/ast-print.c