Skip to content

[Clang] prevent assertion failure by skipping analysis of invalid field declaration #99998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ Bug Fixes to C++ Support
- Clang now diagnoses explicit object parameters in member pointers and other contexts where they should not appear.
Fixes (#GH85992).
- Fixed a crash-on-invalid bug involving extraneous template parameter with concept substitution. (#GH73885)
- Fixed assertion failure by skipping the analysis of an invalid field declaration. (#GH99868)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ bool CXXRecordDecl::hasSubobjectAtOffsetZeroOfEmptyBaseType(
if (!IsFirstField && !FD->isZeroSize(Ctx))
continue;

if (FD->isInvalidDecl())
continue;

// -- If X is n array type, [visit the element type]
QualType T = Ctx.getBaseElementType(FD->getType());
if (auto *RD = T->getAsCXXRecordDecl())
Expand Down
10 changes: 10 additions & 0 deletions clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ X1<int, X1a> inst_x1a;
X1<long, X1b> inst_x1b;
X1<short, X1c> inst_x1c;
X1<short, X1d> inst_x1d; // expected-error{{template template argument has different template parameters than its corresponding template template paramete}}

template <int> class X2; // expected-note{{template is declared here}} \
// expected-note{{template is declared here}}
class X3 : X2<1> {}; // expected-error{{implicit instantiation of undefined template 'X2<1>'}}

template <int> class X4 : X3 {
struct {
X2<1> e; // expected-error{{implicit instantiation of undefined template 'X2<1>'}}
} f;
};
Loading