[all-commits] [llvm/llvm-project] 868661: [Clang] Fix: Restore warning inadvertently removed...

martinboehme via All-commits all-commits at lists.llvm.org
Mon Jun 27 23:53:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 86866107b89c0515d197ec70292ce776bce5a04b
      https://github.com/llvm/llvm-project/commit/86866107b89c0515d197ec70292ce776bce5a04b
  Author: Martin Boehme <mboehme at google.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseDeclCXX.cpp
    M clang/lib/Parse/ParseTemplate.cpp
    M clang/lib/Parse/Parser.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/SemaCXX/attr-declspec-ignored.cpp

  Log Message:
  -----------
  [Clang] Fix: Restore warning inadvertently removed by D126061.

Before D126061, Clang would warn about this code

```
struct X {
    [[deprecated]] struct Y {};
};
```

with the warning

    attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration

D126061 inadvertently caused this warning to no longer be emitted. This patch
restores the previous behavior.

The reason for the bug is that after D126061, C++11 attributes applied to a
member declaration are no longer placed in `DS.getAttributes()` but are instead
tracked in a separate list (`DeclAttrs`). In the case of a free-standing
decl-specifier-seq, we would simply ignore the contents of this list. Instead,
we now pass the list on to `Sema::ParsedFreeStandingDeclSpec()` so that it can
issue the appropriate warning.

Reviewed By: aaron.ballman

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




More information about the All-commits mailing list