From aad8da82a5cfd9b7602ee3adbff340c9c15d9165 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Sat, 29 Aug 2026 17:09:01 -0600 Subject: [PATCH] translate-c: Fix "error: attribute argument is invalid" The recent change (ba74ad55) to `@hasDecl` requiring public declarations caused a regression in the vendored `translate-c`: ```c //example.h #define EXPORT __attribute__((visibility("default"))) EXPORT void example(void); ``` Running `zig translate-c example.h` yields: ``` error: translation failure src/example.h:2:1: error: attribute argument is invalid, expected a string but got a string EXPORT void repro_function(void); ^ src/example.h:1:42: note: expanded from here ``` The bug occurred because `Attribute.zig:319` has a branch condition of `@hasDecl(Wanted, "opts")`. The `opts` declarations exist in the same file and are not public. After the `@hasDecl` behavior change, the condition that may have previously been true is now false. The simple fix is to add `pub` to those `opts` declarations. I looked at the upstream Aro code and it seems significantly different. This particular branch condition no longer exists. --- lib/compiler/aro/aro/Attribute.zig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/compiler/aro/aro/Attribute.zig b/lib/compiler/aro/aro/Attribute.zig index 706eb65945223bd274ac8b3ee89e34127b896094..4142da8a88d8f5103fc42264839406e45309053a 100644 --- a/lib/compiler/aro/aro/Attribute.zig +++ b/lib/compiler/aro/aro/Attribute.zig @@ -383,7 +383,7 @@ const attributes = struct { write_only, none, - const opts = struct { + pub const opts = struct { const enum_kind = .identifier; }; }, @@ -454,7 +454,7 @@ const attributes = struct { strftime, strfmon, - const opts = struct { + pub const opts = struct { const enum_kind = .identifier; }; }, @@ -500,7 +500,7 @@ const attributes = struct { BND32, BND64, // zig fmt: on - const opts = struct { + pub const opts = struct { const enum_kind = .identifier; }; }, @@ -560,7 +560,7 @@ const attributes = struct { @"little-endian", @"big-endian", - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; }, @@ -577,7 +577,7 @@ const attributes = struct { notinbranch, inbranch, - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; } = null, @@ -587,7 +587,7 @@ const attributes = struct { arg: enum { nomitigation, - const opts = struct { + pub const opts = struct { const enum_kind = .identifier; }; }, @@ -613,7 +613,7 @@ const attributes = struct { @"initial-exec", @"local-exec", - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; }, @@ -642,7 +642,7 @@ const attributes = struct { internal, protected, - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; }, @@ -671,7 +671,7 @@ const attributes = struct { @"all-arg", @"all-gpr-arg", - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; }, @@ -689,7 +689,7 @@ const attributes = struct { nullable_result, unspecified, - const opts = struct { + pub const opts = struct { const enum_kind = .identifier; }; }, @@ -700,7 +700,7 @@ const attributes = struct { aapcs, @"aapcs-vfp", - const opts = struct { + pub const opts = struct { const enum_kind = .string; }; }, -- 2.54.0