[clang] [clang] Add support for [[clang::diagnose_if(...)]] and [[clang::enable_if(...)]] syntax (PR #225900)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 14:49:23 PDT 2026
================
@@ -1938,7 +1902,7 @@ def EnableIf : InheritableAttr {
// Does not have a [[]] spelling because this attribute requires the ability
// to parse function arguments but the attribute is not written in the type
// position.
- let Spellings = [GNU<"enable_if">];
+ let Spellings = [Clang<"enable_if">];
----------------
AaronBallman wrote:
The comment is not wrong; we intentionally do not support it with the `[[]]` spelling because more often than not the parameters are used for the `diagnose_if` or `enable_if` condition and that means the attribute has to be after the parameter list. However, with `[[]]` attributes, where you put the attribute list determines what it appertains to and trailing after the parameter list makes it a type attribute which would impact the function type. However, these have always been declaration attributes, not type attributes (and we do not want to break the standard model for appertainment). That's why we only support the `__attribute__` spelling for these -- that has no strict appertainment rules and can slide the attribute around to whatever makes sense.
So while you're right that *some* uses can be in declaration form because they don't mention parameter names, most uses cannot and we don't want to support the `[[]]` spelling until we have a solution for that.
https://github.com/llvm/llvm-project/pull/225900
More information about the cfe-commits
mailing list