Rewrite attributes#1048
Conversation
|
For anyone interested in taking a look this is now mostly ready with 21 integration tests failing with |
|
I'm away from my main computer until the weekend but thank you for taking this on, the old attribute implementation had a bit too much comptime :) |
| syntax | ||
| _BitInt change size.c:1:17: warning: implicit conversion from 'double' to 'signed _BitInt(10)' changes value from 1.2 to 1 [-Wfloat-conversion] | ||
| _BitInt change size.c:2:35: warning: implicit conversion from 'double' to '_Complex unsigned _BitInt(10)' changes value from 1.2 to 1 [-Wfloat-conversion] |
There was a problem hiding this comment.
did you intend to remove this test? seems helpful and like it shouldn't be removed
There was a problem hiding this comment.
I made _Complex _BitInt an error as it is in gcc and clang.
| maybe_unused, | ||
| nodiscard, | ||
| noreturn, | ||
| _Noreturn, // Deprecated |
There was a problem hiding this comment.
mind moving this comment and others below to be doc-comments?
| _Noreturn, // Deprecated | |
| /// Deprecated in c23 | |
| _Noreturn, |
| inline for (.{ "gnu", "clang", "aro" }) |vendor_name| { | ||
| if (std.meta.stringToEnum(@FieldType(Namespaced, vendor_name), name)) |tag| { | ||
| return @unionInit(Namespaced, vendor_name, tag); | ||
| } | ||
| } |
There was a problem hiding this comment.
IMO this should match the compiler being emulated
| inline for (.{ "gnu", "clang", "aro" }) |vendor_name| { | |
| if (std.meta.stringToEnum(@FieldType(Namespaced, vendor_name), name)) |tag| { | |
| return @unionInit(Namespaced, vendor_name, tag); | |
| } | |
| } | |
| switch (comp.langopts.emulate) { | |
| .msvc => {}, // TODO | |
| inline .clang, .gcc => |vendor| if (std.meta.stringToEnum(@FieldType(Namespaced, vendor_name), name)) |tag| { | |
| return @unionInit(Namespaced, vendor_name, tag); | |
| }, | |
| .no => if (std.meta.stringToEnum(Namespaced.Aro, name)) |tag| { | |
| return @unionInit(Namespaced, "aro", tag); | |
| }, | |
| } |
There was a problem hiding this comment.
If we were to go that route then we should also check which specific attributes each compiler supports but seeing as attributes are an extension and unknown ones are ignored I don't really want to do that.
| if (max_requested == null or max_requested.? < requested) { | ||
| max_requested = requested; | ||
| } | ||
| } |
There was a problem hiding this comment.
it seems most attributes will be using the last attribute present (by using getAttribute). is this implementation the same behavior of clang/gcc/msvc, or can this be simplified/removed to follow the conforming behavior?
There was a problem hiding this comment.
The biggest specified alignment is used so this logic needs to exist either when applying attributes or when fetching them.
Will close #944
Will close #367