From 844b78330c64f32c07ba8f1b44200bcf35fad401 Mon Sep 17 00:00:00 2001 From: John Birrell Date: Tue, 20 Nov 2007 01:46:12 +0000 Subject: [PATCH] Generate code that doesn't fail gcc 4.2's strict aliasing test. --- usr.bin/rpcgen/rpc_cout.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index c72edc6fe94..8bbd5d3c578 100644 --- a/usr.bin/rpcgen/rpc_cout.c +++ b/usr.bin/rpcgen/rpc_cout.c @@ -200,11 +200,13 @@ print_ifsizeof(int indent, const char *prefix, const char *type) } static void -print_ifclose(int indent) +print_ifclose(int indent, int brace) { f_print(fout, "))\n"); tabify(fout, indent); f_print(fout, "\treturn (FALSE);\n"); + if (brace) + f_print(fout, "\t}\n"); } static void @@ -212,12 +214,16 @@ print_ifstat(int indent, const char *prefix, const char *type, relation rel, const char *amax, const char *objname, const char *name) { const char *alt = NULL; + int brace = 0; switch (rel) { case REL_POINTER: + brace = 1; + f_print(fout, "\t{\n"); + f_print(fout, "\t%s **pp = %s;\n", type, objname); print_ifopen(indent, "pointer"); print_ifarg("(char **)"); - f_print(fout, "%s", objname); + f_print(fout, "pp"); print_ifsizeof(0, prefix, type); break; case REL_VECTOR: @@ -274,7 +280,7 @@ print_ifstat(int indent, const char *prefix, const char *type, relation rel, print_ifarg(objname); break; } - print_ifclose(indent); + print_ifclose(indent, brace); } /* ARGSUSED */ @@ -283,7 +289,7 @@ emit_enum(definition *def __unused) { print_ifopen(1, "enum"); print_ifarg("(enum_t *)objp"); - print_ifclose(1); + print_ifclose(1, 0); } static void