Skip to content

Commit af6c0e2

Browse files
committed
Improving the DuplicateAttribute reassignment
1 parent 3054433 commit af6c0e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,14 +2987,13 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
29872987
// Normal access control attribute.
29882988
AttrRange = Loc;
29892989

2990-
29912990
if (!DiscardAttribute) {
29922991
Attributes.add(new (Context) AccessControlAttr(AtLoc, Loc, access));
29932992
break;
29942993
}
29952994

29962995
if (access != cast<AccessControlAttr>(*DuplicateAttribute).getAccess()) {
2997-
// Diagnose if there is already an access control attribute on
2996+
// Diagnose if there's already an access control attribute on
29982997
// this declaration with a different access level.
29992998
diagnose(Loc, diag::multiple_access_level_modifiers)
30002999
.highlight(AttrRange);
@@ -3036,15 +3035,17 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
30363035
return makeParserSuccess();
30373036
}
30383037

3038+
// Check for duplicate setter access control attributes.
30393039
DuplicateAttribute = Attributes.getAttribute<SetterAccessAttr>();
3040-
3041-
if (!DuplicateAttribute) {
3040+
DiscardAttribute = DuplicateAttribute != nullptr;
3041+
3042+
if (!DiscardAttribute) {
30423043
Attributes.add(new (Context) SetterAccessAttr(AtLoc, AttrRange, access));
30433044
break;
30443045
}
30453046

30463047
if (access != cast<SetterAccessAttr>(*DuplicateAttribute).getAccess()) {
3047-
// Diagnose if there is already an access control attribute on
3048+
// Diagnose if there's already an access control attribute on
30483049
// this declaration with a different access level.
30493050
diagnose(Loc, diag::multiple_access_level_modifiers)
30503051
.highlight(AttrRange);

0 commit comments

Comments
 (0)