Skip to content

Commit 98c7c28

Browse files
author
huqizhi
committed
[Clang][Sema] set declaration invalid earlier to prevent crash in calculating record layout
1 parent 9525841 commit 98c7c28

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ Bug Fixes to C++ Support
465465
following the first `::` were ignored).
466466
- Fix an out-of-bounds crash when checking the validity of template partial specializations. (part of #GH86757).
467467
- Fix an issue caused by not handling invalid cases when substituting into the parameter mapping of a constraint. Fixes (#GH86757).
468+
- Fix a crash caused by defined struct in a type alias template when the structure
469+
has fields with dependent type. Fixes (#GH75221).
468470

469471
Bug Fixes to AST Handling
470472
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,6 +3899,9 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
38993899
SemaRef.Diag(OwnedTagDecl->getLocation(), DiagID)
39003900
<< SemaRef.Context.getTypeDeclType(OwnedTagDecl);
39013901
D.setInvalidType(true);
3902+
OwnedTagDecl->setCompleteDefinition(false);
3903+
OwnedTagDecl->setInvalidDecl();
3904+
OwnedTagDecl->setCompleteDefinition();
39023905
}
39033906
}
39043907

clang/test/SemaCXX/PR75221.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -verify -std=c++11 -fsyntax-only %s
2+
// expected-no-diagnostics
3+
4+
template <class T> using foo = struct foo {
5+
T size = 0;
6+
};
7+
foo a;

0 commit comments

Comments
 (0)