aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-11-29 15:29:41 -0800
committerAndrew Pinski <quic_apinski@quicinc.com>2024-11-29 23:11:49 -0800
commit1701efd5c848f56cf9a469c5bf42dd0bca675e0a (patch)
tree7c03048a34b59fd3f8354950acbdd0f0278ca207 /gcc/c
parenteb9f1baf2a50f2f1ebe23c5ad62b035d5bcfc14b (diff)
downloadgcc-1701efd5c848f56cf9a469c5bf42dd0bca675e0a.zip
gcc-1701efd5c848f56cf9a469c5bf42dd0bca675e0a.tar.gz
gcc-1701efd5c848f56cf9a469c5bf42dd0bca675e0a.tar.bz2
gimplefe: Error recovery for invalid declarations [PR117749]
c_parser_declarator can return null if there was an error, but c_parser_gimple_declaration was not ready for that. This fixes that oversight so we don't get an ICE after the error. Bootstrapped and tested on x86_64-linux-gnu. PR c/117749 gcc/c/ChangeLog: * gimple-parser.cc (c_parser_gimple_declaration): Check declarator to be non-null. gcc/testsuite/ChangeLog: * gcc.dg/gimplefe-55.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/gimple-parser.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 4763cf2..78e85d9 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -2208,7 +2208,12 @@ c_parser_gimple_declaration (gimple_parser &parser)
specs->typespec_kind != ctsk_none,
C_DTR_NORMAL, &dummy);
- if (c_parser_next_token_is (parser, CPP_SEMICOLON))
+ if (!c_parser_next_token_is (parser, CPP_SEMICOLON))
+ {
+ c_parser_error (parser, "expected %<;%>");
+ return;
+ }
+ if (declarator)
{
/* Handle SSA name decls specially, they do not go into the identifier
table but we simply build the SSA name for later lookup. */
@@ -2253,11 +2258,6 @@ c_parser_gimple_declaration (gimple_parser &parser)
NULL_TREE);
}
}
- else
- {
- c_parser_error (parser, "expected %<;%>");
- return;
- }
}
/* Parse gimple goto statement. */