Skip to content

Commit 02a153d

Browse files
committed
fixup! [clang] Ignore GCC 11 [[malloc(x)]] attribute
Move diag::warn_multiarg_malloc_attribute_ignored to `DiagnosticSemaKinds.td` and make it generic so we can use it for other attributes. Fixes #68059 (comment)
1 parent a76561f commit 02a153d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ def warn_unknown_attribute_ignored : Warning<
177177
"unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
178178
def warn_attribute_ignored : Warning<"%0 attribute ignored">,
179179
InGroup<IgnoredAttributes>;
180-
def warn_multiarg_malloc_attribute_ignored: Warning<
181-
"'malloc' attribute ignored because"
182-
" Clang does not support the one/two argument form">,
183-
InGroup<IgnoredAttributes>;
184180
def err_keyword_not_supported_on_target : Error<
185181
"%0 is not supported on this target">;
186182
def err_use_of_tag_name_without_tag : Error<

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,10 @@ def warn_auto_var_is_id : Warning<
30283028
InGroup<DiagGroup<"auto-var-id">>;
30293029

30303030
// Attributes
3031+
def warn_attribute_form_ignored : Warning<
3032+
"%0 attribute ignored because Clang does not yet support this attribute signature">,
3033+
InGroup<IgnoredAttributes>;
3034+
30313035
def warn_attribute_ignored_no_calls_in_stmt: Warning<
30323036
"%0 attribute is ignored because there exists no call expression inside the "
30333037
"statement">,

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
20842084
// FIXME: GCC uses [[malloc(my_func)]] to specify a deallocator for the
20852085
// returned pointer, but this isn't currently supported in LLVM
20862086
// see https://github.com/llvm/llvm-project/issues/51607
2087-
S.Diag(AL.getLoc(), diag::warn_multiarg_malloc_attribute_ignored);
2087+
S.Diag(AL.getLoc(), diag::warn_attribute_form_ignored) << AL;
20882088
}
20892089

20902090
static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) {

clang/test/Sema/attr-args.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inline __attribute__((const(a))) void *f4(void); // expected-error {{'const' at
88
inline __attribute__((fastcall(a))) void *f5(void); // expected-error {{'fastcall' attribute takes no arguments}}
99
inline __declspec(restrict(a)) void *f6_a(void); // expected-error {{'restrict' attribute takes no arguments}}
1010
inline __attribute__((malloc(a, 1, a))) void *f6_b(void); // expected-error {{'malloc' attribute takes no more than 2 arguments}}
11-
inline __attribute__((malloc(a, 1))) void *f6_c(void); // expected-warning {{'malloc' attribute ignored because Clang does not support the one/two argument form}}
11+
inline __attribute__((malloc(a, 1))) void *f6_c(void); // expected-warning {{'malloc' attribute ignored because Clang does not yet support this attribute signature}}
1212
inline __attribute__((nothrow(a))) void *f7(void); // expected-error {{'nothrow' attribute takes no arguments}}
1313
inline __attribute__((stdcall(a))) void *f8(void); // expected-error {{'stdcall' attribute takes no arguments}}
1414
inline __attribute__((used(a))) void *f9(void); // expected-error {{'used' attribute takes no arguments}}

0 commit comments

Comments
 (0)