[PATCH] D47435: Add __builtin_signbit semantic checking

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 12 09:22:48 PDT 2018


aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaChecking.cpp:925
+  case Builtin::BI__builtin_signbitl:
     if (SemaBuiltinFPClassification(TheCall, 1))
       return ExprError();
----------------
lebedev.ri wrote:
> The name of the function is unfortunate given that you call it for `__builtin_signbit(int)`.
signbit() is an FP classification macro (see C17 7.12.3 "Classification macros"), so I don't think the name is unfortunate.


================
Comment at: test/Sema/builtins.c:260
+  (void)__builtin_signbit(1.0, 2.0, 3.0); // expected-error{{too many arguments to function call, expected 1, have 3}}
+  (void)__builtin_signbit(1); // expected-error {{floating point classification requires argument of floating point type (passed in 'int')}}
+
----------------
lebedev.ri wrote:
> lebedev.ri wrote:
> > What about
> > ```
> > (void)__builtin_signbit(1.0);
> > ```
> Hm, is `__builtin_signbit()` taking an integer, or float?
> If integer, the comment about `floating point classification` is slightly misleading.
> 
It accepts a floating-point type.


================
Comment at: test/Sema/builtins.c:268
+  (void)__builtin_signbitl(1.0, 2.0, 3.0); // expected-error{{too many arguments to function call, expected 1, have 3}}
+  (void)__builtin_signbitl(1);
+}
----------------
lebedev.ri wrote:
> Same, would be good to see `__builtin_signbitf(1.0);`, `__builtin_signbitf(1.0L);`.
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.


https://reviews.llvm.org/D47435





More information about the cfe-commits mailing list