Skip to content

Commit 44311a6

Browse files
a-tarasyukAlexisPerry
authored andcommitted
[Clang] skip alignment checks on incomplete types to avoid an assertion failure while parsing lambda used as default argument (llvm#94542)
Fixes llvm#93512
1 parent e9e25ee commit 44311a6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ Bug Fixes to C++ Support
912912
between the addresses of two labels (a GNU extension) to a pointer within a constant expression. (#GH95366).
913913
- Fix immediate escalation bugs in the presence of dependent call arguments. (#GH94935)
914914
- Clang now diagnoses explicit specializations with storage class specifiers in all contexts.
915-
915+
- Fix an assertion failure caused by parsing a lambda used as a default argument for the value of a
916+
forward-declared class. (#GH93512).
916917

917918
Bug Fixes to AST Handling
918919
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3355,7 +3355,7 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(const VarDecl *VD) {
33553355

33563356
// Variables with higher required alignment than their type's ABI
33573357
// alignment cannot use NRVO.
3358-
if (!VD->hasDependentAlignment() &&
3358+
if (!VD->hasDependentAlignment() && !VDType->isIncompleteType() &&
33593359
Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
33603360
Info.S = NamedReturnInfo::MoveEligible;
33613361

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2+
3+
struct a; // expected-note {{forward declaration of 'a'}} \
4+
expected-note {{forward declaration of 'a'}}
5+
void b(a c = [] { return c; }); // expected-error {{initialization of incomplete type 'a'}} \
6+
expected-error {{variable has incomplete type 'a'}}

0 commit comments

Comments
 (0)