[PATCH v2 12/16] struct-attr: prepare to handle attributes at the end of struct definitions (3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Type attributes for struct can be placed either just after the
keyword 'struct' or after the '}' ending its definition but this
later case is currently ignored.

Prepare the handling of this by having the 3 following cases in sequence:
1) a tag is present
2) no tag present but is followed by an opening brace
3) neither of these, so it's an error.
---
 parse.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/parse.c b/parse.c
index a90dcf7f7e4a..a67d567145d0 100644
--- a/parse.c
+++ b/parse.c
@@ -747,18 +747,15 @@ static struct token *struct_union_enum_specifier(enum type type,
 		if (sym->symbol_list)
 			error_die(token->pos, "redefinition of %s", show_typename (sym));
 		sym->pos = *repos;
-		goto end;
-	}
-
-	// private struct/union/enum type
-	if (!match_op(token, '{')) {
+	} else if (match_op(token, '{')) {
+		// private struct/union/enum type
+		sym = alloc_symbol(token->pos, type);
+	} else {
 		sparse_error(token->pos, "expected declaration");
 		ctx->ctype.base_type = &bad_ctype;
 		return token;
 	}
 
-	sym = alloc_symbol(token->pos, type);
-end:
 	set_current_scope(sym);		// used by dissect
 	token = parse(token->next, sym);
 	ctx->ctype.base_type = sym;
-- 
2.29.2




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux