Skip to content

Commit 6c9f484

Browse files
committed
Don't use an implicit attribute so that it'll be passed on to the function definition.
1 parent ffdb7db commit 6c9f484

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,8 +6767,6 @@ def err_counted_by_attr_pointee_unknown_size : Error<
67676767
""
67686768
"}2">;
67696769
def err_count_attr_func_cannot_be_a_call : Error<"function must not be a call">;
6770-
def err_count_attr_func_must_be_pure_or_const
6771-
: Error<"function must be either 'pure' or 'const'">;
67726770
def err_count_attr_func_must_have_one_param
67736771
: Error<"function must have only one parameter">;
67746772

clang/lib/Sema/SemaBoundsSafety.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,17 @@ bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
162162
// Check a function argument.
163163
bool Ret = false;
164164

165-
if (!CountFD->hasAttr<PureAttr>() && !CountFD->hasAttr<ConstAttr>()) {
166-
Diag(E->getBeginLoc(), diag::err_count_attr_func_must_be_pure_or_const)
167-
<< CountDecl << E->getSourceRange();
168-
Ret = true;
169-
}
165+
// FIXME: We should check that the function is either pure or const.
170166

171167
if (CountFD->getNumParams() != 1) {
172168
Diag(E->getBeginLoc(), diag::err_count_attr_func_must_have_one_param)
173169
<< CountDecl << E->getSourceRange();
174170
Ret = true;
175171
}
176172

173+
if (!Ret && !CountFD->hasAttr<UsedAttr>())
174+
CountFD->addAttr(UsedAttr::Create(Context, CountFD->getSourceRange()));
175+
177176
return Ret;
178177
}
179178

0 commit comments

Comments
 (0)