Skip to content

Commit def038b

Browse files
authored
Revert "[clang] Fix crash when declaring invalid lambda member" (#84615)
Reverts #74110 Fails on many bots: https://lab.llvm.org/buildbot/#/builders/5/builds/41633
1 parent ba13fa2 commit def038b

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ Bug Fixes in This Version
258258
operator.
259259
Fixes (#GH83267).
260260

261-
- Fixes an assertion failure on invalid code when trying to define member
262-
functions in lambdas.
263-
264261
Bug Fixes to Compiler Builtins
265262
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
266263

@@ -411,7 +408,7 @@ RISC-V Support
411408
CUDA/HIP Language Changes
412409
^^^^^^^^^^^^^^^^^^^^^^^^^
413410

414-
- PTX is no longer included by default when compiling for CUDA. Using
411+
- PTX is no longer included by default when compiling for CUDA. Using
415412
``--cuda-include-ptx=all`` will return the old behavior.
416413

417414
CUDA Support

clang/lib/AST/DeclCXX.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,9 +1567,10 @@ bool CXXRecordDecl::isGenericLambda() const {
15671567

15681568
#ifndef NDEBUG
15691569
static bool allLookupResultsAreTheSame(const DeclContext::lookup_result &R) {
1570-
return llvm::all_of(R, [&](NamedDecl *D) {
1571-
return D->isInvalidDecl() || declaresSameEntity(D, R.front());
1572-
});
1570+
for (auto *D : R)
1571+
if (!declaresSameEntity(D, R.front()))
1572+
return false;
1573+
return true;
15731574
}
15741575
#endif
15751576

clang/test/SemaCXX/lambda-expressions.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify=expected,expected-cxx14,cxx11 -fblocks %s
21
// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -verify=expected-cxx14 -fblocks %s
32
// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify -ast-dump -fblocks %s | FileCheck %s
43

@@ -559,8 +558,8 @@ struct B {
559558
int x;
560559
A a = [&] { int y = x; };
561560
A b = [&] { [&] { [&] { int y = x; }; }; };
562-
A d = [&](auto param) { int y = x; }; // cxx11-error {{'auto' not allowed in lambda parameter}}
563-
A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; }; // cxx11-error 2 {{'auto' not allowed in lambda parameter}}
561+
A d = [&](auto param) { int y = x; };
562+
A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
564563
};
565564

566565
B<int> b;
@@ -590,7 +589,6 @@ struct S1 {
590589
void foo1() {
591590
auto s0 = S1{[name=]() {}}; // expected-error 2 {{expected expression}}
592591
auto s1 = S1{[name=name]() {}}; // expected-error {{use of undeclared identifier 'name'; did you mean 'name1'?}}
593-
// cxx11-warning@-1 {{initialized lambda captures are a C++14 extension}}
594592
}
595593
}
596594

@@ -606,7 +604,7 @@ namespace PR25627_dont_odr_use_local_consts {
606604

607605
namespace ConversionOperatorDoesNotHaveDeducedReturnType {
608606
auto x = [](int){};
609-
auto y = [](auto &v) -> void { v.n = 0; }; // cxx11-error {{'auto' not allowed in lambda parameter}} cxx11-note {{candidate function not viable}} cxx11-note {{conversion candidate}}
607+
auto y = [](auto &v) -> void { v.n = 0; };
610608
using T = decltype(x);
611609
using U = decltype(y);
612610
using ExpectedTypeT = void (*)(int);
@@ -626,22 +624,22 @@ namespace ConversionOperatorDoesNotHaveDeducedReturnType {
626624
template<typename T>
627625
friend constexpr U::operator ExpectedTypeU<T>() const noexcept;
628626
#else
629-
friend auto T::operator()(int) const; // cxx11-error {{'auto' return without trailing return type; deduced return types are a C++14 extension}}
627+
friend auto T::operator()(int) const;
630628
friend T::operator ExpectedTypeT() const;
631629

632630
template<typename T>
633-
friend void U::operator()(T&) const; // cxx11-error {{friend declaration of 'operator()' does not match any declaration}}
631+
friend void U::operator()(T&) const;
634632
// FIXME: This should not match, as above.
635633
template<typename T>
636-
friend U::operator ExpectedTypeU<T>() const; // cxx11-error {{friend declaration of 'operator void (*)(type-parameter-0-0 &)' does not match any declaration}}
634+
friend U::operator ExpectedTypeU<T>() const;
637635
#endif
638636

639637
private:
640638
int n;
641639
};
642640

643-
// Should be OK in C++14 and later: lambda's call operator is a friend.
644-
void use(X &x) { y(x); } // cxx11-error {{no matching function for call to object}}
641+
// Should be OK: lambda's call operator is a friend.
642+
void use(X &x) { y(x); }
645643

646644
// This used to crash in return type deduction for the conversion opreator.
647645
struct A { int n; void f() { +[](decltype(n)) {}; } };

0 commit comments

Comments
 (0)