Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f1c383
[Clang] disallow operator in attribute argument lists
a-tarasyuk Jul 7, 2025
962f703
update diagnostic message
a-tarasyuk Jul 7, 2025
a697990
disallow and operators in C++ mode only
a-tarasyuk Jul 7, 2025
697e437
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Jul 7, 2025
a762e0e
Merge branch 'main' into fix/147217
a-tarasyuk Jul 7, 2025
2a40e22
Merge branch 'main' into fix/147217
a-tarasyuk Jul 8, 2025
ac38e4d
update release notes
a-tarasyuk Jul 8, 2025
9204a36
handle preprocessor tokens in unknown attributes
a-tarasyuk Jul 8, 2025
b4f416c
Merge branch 'fix/147217' of https://github.com/a-tarasyuk/llvm-proje…
a-tarasyuk Jul 8, 2025
f923464
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Jul 8, 2025
2f1fc4b
Merge branch 'main' into fix/147217
a-tarasyuk Jul 9, 2025
20e9ce8
Merge branch 'main' into fix/147217
a-tarasyuk Jul 14, 2025
dc71fbf
Merge branch 'main' into fix/147217
a-tarasyuk Jul 17, 2025
7abb6d0
Merge branch 'main' into fix/147217
a-tarasyuk Jul 25, 2025
31aa310
Merge branch 'main' into fix/147217
a-tarasyuk Jul 30, 2025
4e429b0
update release notes
a-tarasyuk Jul 30, 2025
0667a32
Merge branch 'fix/147217' of https://github.com/a-tarasyuk/llvm-proje…
a-tarasyuk Jul 30, 2025
b495eed
change diagnostic category from error to extension
a-tarasyuk Aug 4, 2025
d3ea7c2
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Aug 4, 2025
7bbd741
add new diagnostic group
a-tarasyuk Aug 4, 2025
086460c
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
a-tarasyuk Aug 4, 2025
e34a235
Merge branch 'main' into fix/147217
a-tarasyuk Aug 5, 2025
a21db7e
Merge branch 'main' into fix/147217
a-tarasyuk Aug 7, 2025
25a868c
Merge branch 'main' into fix/147217
a-tarasyuk Aug 8, 2025
aca39da
Merge branch 'main' into fix/147217
a-tarasyuk Aug 11, 2025
2a3b5db
Merge branch 'main' into fix/147217
a-tarasyuk Aug 14, 2025
7d827df
Merge branch 'main' into fix/147217
a-tarasyuk Aug 19, 2025
f065d6f
Merge branch 'main' into fix/147217
a-tarasyuk Aug 19, 2025
f9d5ccb
Merge branch 'main' into fix/147217
a-tarasyuk Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@ Improvements to Clang's diagnostics
- Clang now accepts ``@tparam`` comments on variable template partial
specializations. (#GH144775)

- Clang now rejects ``#`` operators in attribute argument lists. (#GH147217)

Improvements to Clang's time-trace
----------------------------------

Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ def err_ms_property_expected_comma_or_rparen : Error<
"expected ',' or ')' at end of property accessor list">;
def err_ms_property_initializer : Error<
"property declaration cannot have a default member initializer">;
def err_invalid_attribute_argument
: Error<"'%0' is not allowed in an attribute argument list">;

def err_assume_attr_expects_cond_expr : Error<
"use of this expression in an %0 attribute requires parentheses">;
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@ unsigned Parser::ParseAttributeArgsCommon(
bool AttributeHasVariadicIdentifierArg =
attributeHasVariadicIdentifierArg(*AttrName, Form.getSyntax(), ScopeName);

if (getLangOpts().CPlusPlus && Tok.isOneOf(tok::hash, tok::hashhash)) {
Diag(Tok.getLocation(), diag::err_invalid_attribute_argument)
<< PP.getSpelling(Tok);
SkipUntil(tok::r_paren, StopAtSemi);
return 0;
}

// Interpret "kw_this" as an identifier if the attributed requests it.
if (ChangeKWThisToIdent && Tok.is(tok::kw_this))
Tok.setKind(tok::identifier);
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Parser/cxx0x-attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,10 @@ namespace P2361 {
}

alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced attributes; expected attributes here}}

namespace GH147217 {
[[clang::annotate(#)]] void a(); // expected-error {{'#' is not allowed in an attribute argument list}}
[[clang::annotate(##)]] void b(); // expected-error {{'##' is not allowed in an attribute argument list}}
[[clang::annotate(%:)]] void c(); // expected-error {{'%:' is not allowed in an attribute argument list}}
[[clang::annotate(%:%:)]] void d(); // expected-error {{'%:%:' is not allowed in an attribute argument list}}
}