Skip to content

Commit 9c073cc

Browse files
committed
Undo previous changes, keeping the release note and tests
1 parent 9ec229d commit 9c073cc

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ Bug Fixes to C++ Support
457457
containing outer unexpanded parameters were not correctly expanded. (#GH101754)
458458
- Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly
459459
in certain friend declarations. (#GH93099)
460+
- Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
461+
parameter pack. (#GH109148)
460462

461463
Bug Fixes to AST Handling
462464
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16379,6 +16379,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
1637916379
if (getCurFunction())
1638016380
getCurFunction()->addBlock(BD);
1638116381

16382+
// This can happen if the block's return type is deduced, but
16383+
// the return expression is invalid.
1638216384
if (BD->isInvalidDecl())
1638316385
return CreateRecoveryExpr(Result->getBeginLoc(), Result->getEndLoc(),
1638416386
{Result}, Result->getType());
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify %s -frecovery-ast -frecovery-ast-type
3+
4+
// This checks that when a block is discarded, the enclosing lambda’s
5+
// unexpanded parameter pack flag is reset to what it was before the
6+
// block is parsed so we don't crash when trying to diagnose unexpanded
7+
// parameter packs in the lambda.
8+
9+
template <typename ...Ts>
10+
void gh109148() {
11+
(^Ts); // expected-error {{expected expression}} expected-error {{unexpanded parameter pack 'Ts'}}
12+
13+
[] {
14+
(^Ts); // expected-error {{expected expression}}
15+
^Ts; // expected-error {{expected expression}}
16+
^(Ts); // expected-error {{expected expression}}
17+
^ Ts); // expected-error {{expected expression}}
18+
};
19+
20+
([] {
21+
(^Ts); // expected-error {{expected expression}}
22+
^Ts; // expected-error {{expected expression}}
23+
^(Ts); // expected-error {{expected expression}}
24+
^ Ts); // expected-error {{expected expression}}
25+
}, ...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
26+
27+
[] { // expected-error {{unexpanded parameter pack 'Ts'}}
28+
^ (Ts) {};
29+
};
30+
31+
[] { // expected-error {{unexpanded parameter pack 'Ts'}}
32+
(void) ^ { Ts x; };
33+
};
34+
35+
[] { // expected-error {{unexpanded parameter pack 'Ts'}}
36+
Ts s;
37+
(^Ts); // expected-error {{expected expression}}
38+
};
39+
40+
([] {
41+
Ts s;
42+
(^Ts); // expected-error {{expected expression}}
43+
}, ...);
44+
45+
[] { // expected-error {{unexpanded parameter pack 'Ts'}}
46+
^ { Ts s; return not_defined; }; // expected-error {{use of undeclared identifier 'not_defined'}}
47+
};
48+
}

0 commit comments

Comments
 (0)