aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorMaksim Ivanov <emaxx@google.com>2025-01-10 14:16:59 +0100
committerGitHub <noreply@github.com>2025-01-10 14:16:59 +0100
commit6b12272353b45def33bf5814cdf9e8587f32d40e (patch)
tree6465ce9fe35fe84684f301c536c4c93bff0e26f8 /clang/lib/Parse/ParseDecl.cpp
parent85ca5517633e06d7cf58688c9b246bf14f61e5bd (diff)
downloadllvm-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.cpp10
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();
}