r242675 changed the signature for the signbit builtin but did not introduce proper semantic checking to ensure the arguments are as-expected. This lead to regressions like the one reported in PR28172 where codegen would crash. This patch addresses this by properly grouping the signbit builtins along with the other fp classification builtins.
Details
Diff Detail
Event Timeline
test/Sema/builtins.c | ||
---|---|---|
228 | I'll revert this sneaky whitespace either as part of the commit, or as an updated patch if one is required. |
The checking by itself looks sane-ish, but i don't have any reasonable knowledge in this area.
lib/Sema/SemaChecking.cpp | ||
---|---|---|
925 | The name of the function is unfortunate given that you call it for __builtin_signbit(int). | |
test/Sema/builtins.c | ||
260 | What about (void)__builtin_signbit(1.0); | |
260 | Hm, is __builtin_signbit() taking an integer, or float? | |
264 | 1 will be promoted to float? (void)__builtin_signbit(1.0); | |
268 | Same, would be good to see __builtin_signbitf(1.0);, __builtin_signbitf(1.0L);. |
Updating based on review feedback.
lib/Sema/SemaChecking.cpp | ||
---|---|---|
925 | signbit() is an FP classification macro (see C17 7.12.3 "Classification macros"), so I don't think the name is unfortunate. | |
test/Sema/builtins.c | ||
260 | It accepts a floating-point type. | |
268 | It turns out that double and long double were fine, but the promotion from float for this case was a problem. I fixed that as well. |
I've committed in r335048; if @rsmith has concerns, they can be addressed post commit.
The name of the function is unfortunate given that you call it for __builtin_signbit(int).