Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -8836,13 +8836,22 @@ void FixedPointValueToString(SmallVectorImpl<char> &Str, llvm::APSInt Val,
unsigned Scale);

inline FunctionEffectsRef FunctionEffectsRef::get(QualType QT) {
const Type *TypePtr = QT.getTypePtr();
while (true) {
QualType Pointee = QT->getPointeeType();
if (Pointee.isNull())
// Note that getPointeeType() seems to successfully navigate some constructs
// for which isAnyPointerType() returns false (e.g.
// pointer-to-member-function).
QualType Pointee = TypePtr->getPointeeType();
if (Pointee.isNull()) {
if (TypePtr->isArrayType()) {
TypePtr = TypePtr->getBaseElementTypeUnsafe();
continue;
}
break;
QT = Pointee;
}
TypePtr = Pointee.getTypePtr();
}
if (const auto *FPT = QT->getAs<FunctionProtoType>())
if (const auto *FPT = TypePtr->getAs<FunctionProtoType>())
return FPT->getFunctionEffects();
return {};
}
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Sema/attr-nonblocking-constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ void PTMFTester::convert() [[clang::nonblocking]]
(this->*mConvertFunc)();
}

// Allow implicit conversion from array to pointer.
void nb14(unsigned idx) [[clang::nonblocking]]
{
using FP = void (*)() [[clang::nonblocking]];
using FPArray = FP[2];
auto nb = +[]() [[clang::nonblocking]] {};

FPArray src{ nb, nullptr };
FP f = src[idx]; // This should not generate a warning.
}

// Block variables
void nb17(void (^blk)() [[clang::nonblocking]]) [[clang::nonblocking]] {
blk();
Expand Down
Loading