Skip to content

Commit

Permalink
Merge pull request #679 from ehaas/bad-attribute
Browse files Browse the repository at this point in the history
Fix error message when complex float value given for attribute value
  • Loading branch information
Vexu authored Apr 15, 2024
2 parents e863887 + 60f1f14 commit bac4f24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/aro/Attribute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub const ArgumentType = enum {
int,
alignment,
float,
complex_float,
expression,
nullptr_t,

Expand All @@ -54,6 +55,7 @@ pub const ArgumentType = enum {
.int, .alignment => "an integer constant",
.nullptr_t => "nullptr",
.float => "a floating point number",
.complex_float => "a complex floating point number",
.expression => "an expression",
};
}
Expand Down Expand Up @@ -278,8 +280,19 @@ fn diagnoseField(
.int => .int,
.bytes => .string,
.float => .float,
.complex => .complex_float,
.null => .nullptr_t,
else => unreachable,
.int_ty,
.float_ty,
.complex_ty,
.ptr_ty,
.noreturn_ty,
.void_ty,
.func_ty,
.array_ty,
.vector_ty,
.record_ty,
=> unreachable,
});
}

Expand Down
3 changes: 3 additions & 0 deletions test/cases/attribute errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct S {

int __thiscall bar(int);
int big __attribute__((vector_size(4294967296)));
typedef float f2v __attribute__((vector_size(8.0i)));

#define EXPECTED_ERRORS "attribute errors.c:4:24: error: 'access' attribute takes at least 2 argument(s)" \
"attribute errors.c:5:31: error: Unknown `access` argument. Possible values are: 'read_only', 'read_write', 'write_only', 'none'" \
Expand All @@ -52,3 +53,5 @@ int big __attribute__((vector_size(4294967296)));
"attribute errors.c:28:24: warning: attribute 'cold' ignored on fields [-Wignored-attributes]" \
"attribute errors.c:31:5: warning: '__thiscall' calling convention is not supported for this target [-Wignored-attributes]" \
"attribute errors.c:32:36: error: attribute value '4294967296' out of range" \
"attribute errors.c:33:46: error: Attribute argument is invalid, expected an integer constant but got a complex floating point number" \

0 comments on commit bac4f24

Please sign in to comment.