This revision was automatically updated to reflect the committed changes.
Closed by commit rG179d24d764ac: Parse: handle another case of invalid handling
for attributes (authored by compnerd).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140507/new/
https://reviews.llvm.org/D140507
Files:
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/cxx-attributes.cpp
Index: clang/test/Parser/cxx-attributes.cpp
===================================================================
--- clang/test/Parser/cxx-attributes.cpp
+++ clang/test/Parser/cxx-attributes.cpp
@@ -3,6 +3,8 @@
// GH#58229 - rejects-valid
__attribute__((__visibility__("default"))) [[nodiscard]] int f();
[[nodiscard]] __attribute__((__visibility__("default"))) int f();
+extern "C" __attribute__((__visibility__("default"))) [[nodiscard]]
+int g() { return 32; }
class c {
virtual void f1(const char* a, ...)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -359,8 +359,11 @@
Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
ParsedAttributes DeclAttrs(AttrFactory);
- MaybeParseCXX11Attributes(DeclAttrs);
- ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
+ ParsedAttributes DeclSpecAttrs(AttrFactory);
+
+ while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+ ;
if (Tok.isNot(tok::l_brace)) {
// Reset the source range in DS, as the leading "extern"
@@ -369,7 +372,7 @@
DS.SetRangeEnd(SourceLocation());
// ... but anyway remember that such an "extern" was seen.
DS.setExternInLinkageSpec(true);
- ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs, &DS);
+ ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
getCurScope(), LinkageSpec, SourceLocation())
: nullptr;
@@ -411,7 +414,7 @@
default:
ParsedAttributes DeclAttrs(AttrFactory);
MaybeParseCXX11Attributes(DeclAttrs);
- ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
+ ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
continue;
}
Index: clang/test/Parser/cxx-attributes.cpp
===================================================================
--- clang/test/Parser/cxx-attributes.cpp
+++ clang/test/Parser/cxx-attributes.cpp
@@ -3,6 +3,8 @@
// GH#58229 - rejects-valid
__attribute__((__visibility__("default"))) [[nodiscard]] int f();
[[nodiscard]] __attribute__((__visibility__("default"))) int f();
+extern "C" __attribute__((__visibility__("default"))) [[nodiscard]]
+int g() { return 32; }
class c {
virtual void f1(const char* a, ...)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -359,8 +359,11 @@
Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
ParsedAttributes DeclAttrs(AttrFactory);
- MaybeParseCXX11Attributes(DeclAttrs);
- ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
+ ParsedAttributes DeclSpecAttrs(AttrFactory);
+
+ while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+ ;
if (Tok.isNot(tok::l_brace)) {
// Reset the source range in DS, as the leading "extern"
@@ -369,7 +372,7 @@
DS.SetRangeEnd(SourceLocation());
// ... but anyway remember that such an "extern" was seen.
DS.setExternInLinkageSpec(true);
- ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs, &DS);
+ ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
getCurScope(), LinkageSpec, SourceLocation())
: nullptr;
@@ -411,7 +414,7 @@
default:
ParsedAttributes DeclAttrs(AttrFactory);
MaybeParseCXX11Attributes(DeclAttrs);
- ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
+ ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
continue;
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits