Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20743,7 +20743,7 @@ static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
if (MD->getType().isNull())
continue;

const auto *Ty = cast<FunctionProtoType>(MD->getType());
const auto *Ty = MD->getType()->getAs<FunctionProtoType>();
if (!Ty || !MD->isExplicitObjectMemberFunction() ||
!Ty->getParamType(0)->isDependentType())
continue;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ void Sema::MarkThisReferenced(CXXThisExpr *This) {
if (MD->getType().isNull())
return false;

const auto *Ty = cast<FunctionProtoType>(MD->getType());
const auto *Ty = MD->getType()->getAs<FunctionProtoType>();
return Ty && MD->isExplicitObjectMemberFunction() &&
Ty->getParamType(0)->isDependentType();
}
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaCXX/cxx2b-deducing-this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ void TestMutationInLambda() {
l1();
l2();
}

// Check that we don't crash if the lambda has type sugar.
const auto l15 = [=](this auto&&) [[clang::annotate_type("foo")]] [[clang::annotate_type("bar")]] {
return x;
};

const auto l16 = [=]() [[clang::annotate_type("foo")]] [[clang::annotate_type("bar")]] {
return x;
};

l15();
l16();
}

struct Over_Call_Func_Example {
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaCXX/lambda-expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,12 @@ template auto t::operator()<int>(int a) const; // expected-note {{in instantiati

}
#endif

namespace GH84473_bug {
void f1() {
int b;
(void) [=] [[gnu::regcall]] () { // expected-warning {{an attribute specifier sequence in this position is a C++23 extension}}
(void) b;
};
}
}