Skip to content

Commit bd1b0b2

Browse files
committed
Fix error recovery while PTU cleanup
1 parent 1e83d97 commit bd1b0b2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clang/lib/Interpreter/IncrementalParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
176176
// FIXME: We should de-allocate MostRecentTU
177177
for (Decl *D : MostRecentTU->decls()) {
178178
auto *ND = dyn_cast<NamedDecl>(D);
179-
if (!ND)
179+
if (!ND || ND->getDeclName().isEmpty())
180180
continue;
181181
// Check if we need to clean up the IdResolver chain.
182182
if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&

clang/test/Interpreter/lambda.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// REQUIRES: host-supports-jit
22
// UNSUPPORTED: system-aix
33
// RUN: cat %s | clang-repl | FileCheck %s
4-
// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
4+
// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck %s
5+
56
extern "C" int printf(const char *, ...);
67

78
auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +15,10 @@ auto r2 = l2();
1415
auto r3 = l2();
1516
// CHECK: TWO
1617

17-
%quit
18+
// Verify non-local lambda capture error is correctly reported
19+
int x = 42;
20+
21+
// expected-error@+1 {{non-local lambda expression cannot have a capture-default}}
22+
auto capture = [&]() { return x * 2; };
23+
24+
%quit

0 commit comments

Comments
 (0)