[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
Doug Wyatt via cfe-commits
cfe-commits at lists.llvm.org
Sat May 18 13:25:06 PDT 2024
================
@@ -1870,6 +1870,28 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
FromFn = QT->getAs<FunctionType>();
Changed = true;
}
+
+ // For C, when called from checkPointerTypesForAssignment,
+ // we need not to alter FromFn, or else even an innocuous cast
+ // like dropping effects will fail. In C++ however we do want to
+ // alter FromFn. TODO: Is this correct?
----------------
dougsonos wrote:
The test case which exposes a need for this kind of logic is:
```
void nonblocking() [[clang::nonblocking]];
void type_conversions() {
void (*fp_plain)();
fp_plain = nonblocking;
}
```
The call chain to `IsFunctionConversion` is:
```
CheckSingleAssignmentConversion
PerformImplicitConversion (in C++ only, not plain C)
TryImplicitConversion
IsStandardConversion
IsFunctionConversion
```
`IsFunctionConversion` drops `noreturn` and `noexcept` from the function type very similarly to what this code does for effects. If this code is disabled, then an implicit conversion between the two canonically different types fails. Then `TryUserDefinedConversion` fails too.
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list