[PATCH] D36773: Fix for internal compiler error when calling __builtin_signbit with invalid arguments

Josh Seba via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 16:21:56 PDT 2017


jseba created this revision.
jseba added a project: clang.

Clang has had a regression since version 3.8 where calls to __builtin_signbit (and friends signbitf & signbitl) without passing any arguments would cause it to segfault because it didn't abort compilation, even though it would properly flag the function call as having too few arguments passed in. This patch fixes the issue by including signbit in the checks for floating point parameters during semantic checks for builtin functions, same as isnan or isinf.

This addresses https://bugs.llvm.org/show_bug.cgi?id=28653 and https://bugs.llvm.org/show_bug.cgi?id=28653


https://reviews.llvm.org/D36773

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/builtin-unary-fp.c


Index: test/Sema/builtin-unary-fp.c
===================================================================
--- test/Sema/builtin-unary-fp.c
+++ test/Sema/builtin-unary-fp.c
@@ -9,6 +9,9 @@
   check(__builtin_isfinite(1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_isinf()); // expected-error{{too few arguments}}
   check(__builtin_isnan(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit()); // expected-error{{too few arguments}}
+  check(__builtin_signbit(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit(1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0));
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 4.5 to 4}}
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -839,6 +839,9 @@
   case Builtin::BI__builtin_isinf_sign:
   case Builtin::BI__builtin_isnan:
   case Builtin::BI__builtin_isnormal:
+  case Builtin::BI__builtin_signbit:
+  case Builtin::BI__builtin_signbitf:
+  case Builtin::BI__builtin_signbitl:
     if (SemaBuiltinFPClassification(TheCall, 1))
       return ExprError();
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36773.111279.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170815/7d3c8428/attachment.bin>


More information about the cfe-commits mailing list