Skip to content

Commit 6fa72ec

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd0a038296ea7' from llvm.org/main into next
2 parents 6300457 + d0a0382 commit 6fa72ec

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ Bug Fixes to C++ Support
935935
- Improved handling of variables with ``consteval`` constructors, to
936936
consistently treat the initializer as manifestly constant-evaluated.
937937
(#GH135281)
938+
- Fix a crash in the presence of invalid base classes. (#GH147186)
938939

939940
Bug Fixes to AST Handling
940941
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,7 @@ void Parser::ParseBaseClause(Decl *ClassDecl) {
22522252
while (true) {
22532253
// Parse a base-specifier.
22542254
BaseResult Result = ParseBaseSpecifier(ClassDecl);
2255-
if (Result.isInvalid()) {
2255+
if (!Result.isUsable()) {
22562256
// Skip the rest of this base specifier, up until the comma or
22572257
// opening brace.
22582258
SkipUntil(tok::comma, tok::l_brace, StopAtSemi | StopBeforeMatch);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Tests that invalid base-specifiers no longer crash the compiler.
2+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3+
4+
namespace GH147186 {
5+
6+
class X; // expected-note {{forward declaration of 'GH147186::X'}} expected-note {{forward declaration of 'GH147186::X'}}
7+
8+
class A : X { // expected-error {{base class has incomplete type}}
9+
};
10+
11+
class Y : int { // expected-error {{expected class name}}
12+
};
13+
14+
class Z : X*, virtual int { // expected-error {{base class has incomplete type}} expected-error {{expected class name}}
15+
};
16+
}

0 commit comments

Comments
 (0)