diff mbox series

[v2,11/16] struct-attr: prepare to handle attributes at the end of struct definitions (2)

Message ID 20201226175129.9621-12-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series support __packed struct | expand

Commit Message

Luc Van Oostenryck Dec. 26, 2020, 5:51 p.m. UTC
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 restructuring the code handling
struct specifiers, namely inverting the condition so that the
function can return early to make next patch's job easier.
---
 parse.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/parse.c b/parse.c
index 99d810910dab..a90dcf7f7e4a 100644
--- a/parse.c
+++ b/parse.c
@@ -738,16 +738,16 @@  static struct token *struct_union_enum_specifier(enum type type,
 		ctx->ctype.base_type = sym;
 		repos = &token->pos;
 		token = token->next;
-		if (match_op(token, '{')) {
-			// The following test is actually wrong for empty
-			// structs, but (1) they are not C99, (2) gcc does
-			// the same thing, and (3) it's easier.
-			if (sym->symbol_list)
-				error_die(token->pos, "redefinition of %s", show_typename (sym));
-			sym->pos = *repos;
-			goto end;
-		}
-		return token;
+		if (!match_op(token, '{'))
+			return token;
+
+		// The following test is actually wrong for empty
+		// structs, but (1) they are not C99, (2) gcc does
+		// the same thing, and (3) it's easier.
+		if (sym->symbol_list)
+			error_die(token->pos, "redefinition of %s", show_typename (sym));
+		sym->pos = *repos;
+		goto end;
 	}
 
 	// private struct/union/enum type