]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix checking assert upon invalid class definition [PR116740]
authorSimon Martin <simon@nasilyan.com>
Wed, 5 Mar 2025 08:08:57 +0000 (09:08 +0100)
committerSimon Martin <simon@nasilyan.com>
Wed, 5 Mar 2025 08:11:13 +0000 (09:11 +0100)
commitb3d078220d202094a2b4eaef9b4a5ad1b84d30e6
treed97a3d91ed2b6d513ae6b51d2720fd738fb76a07
parentddeb70548c81f5dba91f281290584698897151d8
c++: Fix checking assert upon invalid class definition [PR116740]

A checking assert triggers upon the following invalid code since
GCC 11:

=== cut here ===
class { a (struct b;
} struct b
=== cut here ===

The problem is that during error recovery, we call
set_identifier_type_value_with_scope for B in the global namespace, and
the checking assert added via r11-7228-g8f93e1b892850b fails.

This patch relaxes that assert to not fail if we've seen a parser error
(it a generalization of another fix done to that checking assert via
r11-7266-g24bf79f1798ad1).

PR c++/116740

gcc/cp/ChangeLog:

* name-lookup.cc (set_identifier_type_value_with_scope): Don't
fail assert with ill-formed input.

gcc/testsuite/ChangeLog:

* g++.dg/parse/crash80.C: New test.
gcc/cp/name-lookup.cc
gcc/testsuite/g++.dg/parse/crash80.C [new file with mode: 0644]