diff options
author | Maksim Ivanov <emaxx@google.com> | 2025-01-10 14:16:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 14:16:59 +0100 |
commit | 6b12272353b45def33bf5814cdf9e8587f32d40e (patch) | |
tree | 6465ce9fe35fe84684f301c536c4c93bff0e26f8 /clang/lib/Parse/ParseDecl.cpp | |
parent | 85ca5517633e06d7cf58688c9b246bf14f61e5bd (diff) | |
download | llvm-6b12272353b45def33bf5814cdf9e8587f32d40e.zip llvm-6b12272353b45def33bf5814cdf9e8587f32d40e.tar.gz llvm-6b12272353b45def33bf5814cdf9e8587f32d40e.tar.bz2 |
[clang] Informative error for lifetimebound in decl-spec (#118567)
Emit a bit more informative error when the `[[clang::lifetimebound]]`
attribute is wrongly appearing on a decl-spec:
```
'lifetimebound' attribute only applies to parameters and implicit
object parameters
```
instead of:
```
'lifetimebound' attribute cannot be applied to types
```
The new error is also consistent with the diagnostic emitted when the
attribute is misplaced in other parts of a declarator.
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 937a94b..7f3f6d5 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3706,8 +3706,14 @@ void Parser::ParseDeclarationSpecifiers( if (PA.isTypeAttr() && PA.getKind() != ParsedAttr::AT_LifetimeBound && PA.getKind() != ParsedAttr::AT_AnyX86NoCfCheck) continue; - Diag(PA.getLoc(), diag::err_attribute_not_type_attr) - << PA << PA.isRegularKeywordAttribute(); + + if (PA.getKind() == ParsedAttr::AT_LifetimeBound) + Diag(PA.getLoc(), diag::err_attribute_wrong_decl_type_str) + << PA << PA.isRegularKeywordAttribute() + << "parameters and implicit object parameters"; + else + Diag(PA.getLoc(), diag::err_attribute_not_type_attr) + << PA << PA.isRegularKeywordAttribute(); PA.setInvalid(); } |