[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
aloisklink wrote: I've fixed reviewer comments! Sorry for the delay! I didn't have much time, and my PC isn't the fastest, so building Clang + regression tests takes a while! As recommended by https://github.com/llvm/llvm-project/pull/68059#discussion_r1355449108, I added type checking for

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
@@ -1,12 +1,14 @@ -// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only %s +// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only -fdeclspec %s int a; inline __attribute__((noreturn(a))) void

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
@@ -289,6 +289,11 @@ Bug Fixes to Compiler Builtins Bug Fixes to Attribute Support ^^ +- Clang now emits a warning instead of an error when using the one or two + argument form of GCC 11's ``__attribute__((malloc(deallocator)))`` + or

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
@@ -1629,6 +1629,8 @@ def IFunc : Attr, TargetSpecificAttr { def Restrict : InheritableAttr { let Spellings = [Declspec<"restrict">, GCC<"malloc">]; + let Args = [IdentifierArgument<"Deallocator", /*opt*/ 1>, + ParamIdxArgument<"DeallocatorPtrArgIndex",

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
@@ -177,6 +177,10 @@ def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; def warn_attribute_ignored : Warning<"%0 attribute ignored">, InGroup; +def warn_multiarg_malloc_attribute_ignored: Warning< + "'malloc' attribute ignored because"

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-11-01 Thread Alois Klink via cfe-commits
https://github.com/aloisklink updated https://github.com/llvm/llvm-project/pull/68059 >From a76561f522f628b0882572f8dabee6f7e4abd5f5 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Mon, 2 Oct 2023 19:59:06 +0100 Subject: [PATCH 1/5] [clang] Ignore GCC 11 [[malloc(x)]] attribute Ignore the

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-31 Thread Erich Keane via cfe-commits
erichkeane wrote: > Hi, yes the really bad choice here is by gcc to have the same name for > basically two different attributes. For the value, they also missed the > opportunity to do something sensible when moving to C++ attributes, what a > pitty. For a concrete guideline in that jungle,

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-31 Thread Jens Gustedt via cfe-commits
gustedt wrote: Hi, yes the really bad choice here is by gcc to have the same name for basically two different attributes. For the value, they also missed the opportunity to do something sensible when moving to C++ attributes, what a pitty. For a concrete guideline in that jungle, when (=

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-31 Thread Erich Keane via cfe-commits
erichkeane wrote: > > I see that the fix is almost ready, good. But generally it would also have > > helped if the `__has_c_attribute` feature test for this type of borrowed > > attributes would provide means to distinguish different versions. Here gcc > > as well as clang only have the value

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-31 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > I see that the fix is almost ready, good. But generally it would also have > helped if the `__has_c_attribute` feature test for this type of borrowed > attributes would provide means to distinguish different versions. Here gcc as > well as clang only have the value 1. So

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-31 Thread Jens Gustedt via cfe-commits
gustedt wrote: I see that the fix is almost ready, good. But generally it would also have helped if the `__has_c_attribute` feature test for this type of borrowed attributes would provide means to distinguish different versions. Here gcc as well as clang only have the value 1. So if the patch

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-11 Thread Aaron Ballman via cfe-commits
@@ -289,6 +289,11 @@ Bug Fixes to Compiler Builtins Bug Fixes to Attribute Support ^^ +- Clang now emits a warning instead of an error when using the one or two + argument form of GCC 11's ``__attribute__((malloc(deallocator)))`` + or

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-11 Thread Aaron Ballman via cfe-commits
@@ -1,12 +1,14 @@ -// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only %s +// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -fsyntax-only -fdeclspec %s int a; inline __attribute__((noreturn(a))) void

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-11 Thread Aaron Ballman via cfe-commits
@@ -177,6 +177,10 @@ def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; def warn_attribute_ignored : Warning<"%0 attribute ignored">, InGroup; +def warn_multiarg_malloc_attribute_ignored: Warning< + "'malloc' attribute ignored because"

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-09 Thread Shafik Yaghmour via cfe-commits
@@ -1629,6 +1629,8 @@ def IFunc : Attr, TargetSpecificAttr { def Restrict : InheritableAttr { let Spellings = [Declspec<"restrict">, GCC<"malloc">]; + let Args = [IdentifierArgument<"Deallocator", /*opt*/ 1>, + ParamIdxArgument<"DeallocatorPtrArgIndex",

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-09 Thread Shafik Yaghmour via cfe-commits
@@ -1629,6 +1629,8 @@ def IFunc : Attr, TargetSpecificAttr { def Restrict : InheritableAttr { let Spellings = [Declspec<"restrict">, GCC<"malloc">]; + let Args = [IdentifierArgument<"Deallocator", /*opt*/ 1>, + ParamIdxArgument<"DeallocatorPtrArgIndex",

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-09 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Just a nit https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-09 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-07 Thread Alois Klink via cfe-commits
@@ -2064,13 +2064,26 @@ static void handleTLSModelAttr(Sema , Decl *D, const ParsedAttr ) { static void handleRestrictAttr(Sema , Decl *D, const ParsedAttr ) { QualType ResultType = getFunctionOrMethodResultType(D); - if (ResultType->isAnyPointerType() ||

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-07 Thread Alois Klink via cfe-commits
aloisklink wrote: > We generally want ignored attributes to be diagnosed as being ignored; > otherwise users have a much harder time determining whether the attribute is > working or not. I think we should issue an "attribute ignored" warning when > we're dropping the attribute in the AST.

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-07 Thread Alois Klink via cfe-commits
https://github.com/aloisklink updated https://github.com/llvm/llvm-project/pull/68059 >From a76561f522f628b0882572f8dabee6f7e4abd5f5 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Mon, 2 Oct 2023 19:59:06 +0100 Subject: [PATCH] [clang] Ignore GCC 11 [[malloc(x)]] attribute Ignore the

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thank you for the fix! We generally want ignored attributes to be diagnosed as being ignored; otherwise users have a much harder time determining whether the attribute is working or not. I think we should issue an "attribute ignored" warning when

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-05 Thread Erich Keane via cfe-commits
@@ -2064,13 +2064,26 @@ static void handleTLSModelAttr(Sema , Decl *D, const ParsedAttr ) { static void handleRestrictAttr(Sema , Decl *D, const ParsedAttr ) { QualType ResultType = getFunctionOrMethodResultType(D); - if (ResultType->isAnyPointerType() ||

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-03 Thread Alois Klink via cfe-commits
@@ -4122,6 +4122,9 @@ def RestrictDocs : Documentation { The ``malloc`` attribute indicates that the function acts like a system memory allocation function, returning a pointer to allocated storage disjoint from the storage for any other object accessible to the caller. + +The

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-02 Thread Timm Baeder via cfe-commits
@@ -4122,6 +4122,9 @@ def RestrictDocs : Documentation { The ``malloc`` attribute indicates that the function acts like a system memory allocation function, returning a pointer to allocated storage disjoint from the storage for any other object accessible to the caller. + +The

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2023-10-02 Thread Alois Klink via cfe-commits
https://github.com/aloisklink created https://github.com/llvm/llvm-project/pull/68059 Ignore the `[[malloc(x)]]` or `[[malloc(x, 1)]]` function attribute syntax added in [GCC 11][1]. Unlike `[[malloc]]` with no arguments (which is supported by Clang), GCC uses the one or two argument form to