From 61b7add1470c00346685fa2ddb47947e681beac8 Mon Sep 17 00:00:00 2001 From: "Vladimir N. Makarov" Date: Tue, 8 Aug 2023 13:08:44 -0400 Subject: [PATCH] Fix issue #362. --- c-tests/new/issue362.c | 4 ++++ c-tests/new/issue362.c.expectrc | 1 + c2mir/c2mir.c | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 c-tests/new/issue362.c create mode 100644 c-tests/new/issue362.c.expectrc diff --git a/c-tests/new/issue362.c b/c-tests/new/issue362.c new file mode 100644 index 0000000000..1f17c6a4f9 --- /dev/null +++ b/c-tests/new/issue362.c @@ -0,0 +1,4 @@ +n () { + char* p; + int m = {}; +} diff --git a/c-tests/new/issue362.c.expectrc b/c-tests/new/issue362.c.expectrc new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/c-tests/new/issue362.c.expectrc @@ -0,0 +1 @@ +1 diff --git a/c2mir/c2mir.c b/c2mir/c2mir.c index dd26b5a025..17caa638c6 100644 --- a/c2mir/c2mir.c +++ b/c2mir/c2mir.c @@ -7578,7 +7578,10 @@ static void check_initializer (c2m_ctx_t c2m_ctx, decl_t member_decl, struct typ } return; } - if (init == NULL) return; + if (init == NULL) { + if (scalar_type_p (type)) error (c2m_ctx, POS (initializer), "empty scalar initializer"); + return; + } assert (init->code == N_INIT); des_list = NL_HEAD (init->u.ops); assert (des_list->code == N_LIST);