Skip to content
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 @@ -931,6 +931,7 @@ Bug Fixes to C++ Support
- Improved handling of variables with ``consteval`` constructors, to
consistently treat the initializer as manifestly constant-evaluated.
(#GH135281)
- Fix a crash in the presence of invalid base classes. (#GH147186)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ void Parser::ParseBaseClause(Decl *ClassDecl) {
while (true) {
// Parse a base-specifier.
BaseResult Result = ParseBaseSpecifier(ClassDecl);
if (Result.isInvalid()) {
if (!Result.isUsable()) {
// Skip the rest of this base specifier, up until the comma or
// opening brace.
SkipUntil(tok::comma, tok::l_brace, StopAtSemi | StopBeforeMatch);
Expand Down
16 changes: 16 additions & 0 deletions clang/test/SemaCXX/invalid-base-inheritance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Tests that invalid base-specifiers no longer crash the compiler.
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

namespace GH147186 {

class X; // expected-note {{forward declaration of 'GH147186::X'}} expected-note {{forward declaration of 'GH147186::X'}}

class A : X { // expected-error {{base class has incomplete type}}
};

class Y : int { // expected-error {{expected class name}}
};

class Z : X*, virtual int { // expected-error {{base class has incomplete type}} expected-error {{expected class name}}
};
}