aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2022-03-10 07:32:06 +0000
committerRoger Sayle <roger@nextmovesoftware.com>2022-03-10 07:32:06 +0000
commit2185c9734ad977b88c519a4579187a91b3f71edd (patch)
treebf785bb78f3b940d20847443d4a315c136da05f8 /gcc
parent8cc4f9cd824d195178632569c749f96b306475f9 (diff)
downloadgcc-2185c9734ad977b88c519a4579187a91b3f71edd.zip
gcc-2185c9734ad977b88c519a4579187a91b3f71edd.tar.gz
gcc-2185c9734ad977b88c519a4579187a91b3f71edd.tar.bz2
PR c++/39751: ICE-on-invalid parsing regression.
This is a fix for PR c++/39751 which is an ICE-on-invalid regression in the C++ parser after encountering the end of file. The one line change is to check that the tokens cached in DECL_PENDING_INLINE_INFO haven't been purged before processing them in cp_parser_late_parsing_for_member. 2022-03-10 Roger Sayle <roger@nextmovesoftware.com> gcc/cp/ChangeLog PR c++/39751 * parser.cc (cp_parser_late_parsing_for_member): Confirm the token stream hasn't been purged before processing DECL_PENDING_INLINE. gcc/testsuite/ChangeLog PR c++/39751 * g++.dg/parse/pr39751.C: New test case.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/parser.cc5
-rw-r--r--gcc/testsuite/g++.dg/parse/pr39751.C10
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 5c342ca..18db9d4 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -32119,8 +32119,9 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function)
maybe_begin_member_template_processing (member_function);
/* If the body of the function has not yet been parsed, parse it
- now. */
- if (DECL_PENDING_INLINE_P (member_function))
+ now. Except if the tokens have been purged (PR c++/39751). */
+ if (DECL_PENDING_INLINE_P (member_function)
+ && !DECL_PENDING_INLINE_INFO (member_function)->first->purged_p)
{
tree function_scope;
cp_token_cache *tokens;
diff --git a/gcc/testsuite/g++.dg/parse/pr39751.C b/gcc/testsuite/g++.dg/parse/pr39751.C
new file mode 100644
index 0000000..cfe803c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr39751.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+template < typename >
+struct A
+{
+A < struct
+{
+f () :
+
+// { dg-excess-errors "" }