<div dir="ltr">ping.<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 30, 2016 at 7:32 PM, Mayur Pandey <span dir="ltr"><<a href="mailto:mayurthebond@gmail.com" target="_blank">mayurthebond@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">mayurpandey updated this revision to Diff 69674.<br>
<span class="">mayurpandey added a comment.<br>
<br>
Hi,<br>
<br>
</span>Updated the patch to add a template based testcase. As suggested by you, I tried updating the error diagnostic to err_typecheck_cond_expect_<wbr>float and to issue diagnostic in similar fashion to err_typecheck_cond_expect_int_<wbr>float, something like this :<br>
def err_typecheck_cond_expect_<wbr>float : Error<<br>
<br>
"used type %0 where floating point type is required">;<br>
<br>
But on updating this clang was crashing with the following message:<br>
clang-3.9: llvm/tools/clang/include/<wbr>clang/Basic/Diagnostic.h:1167: clang::DiagnosticsEngine::<wbr>ArgumentKind clang::Diagnostic::getArgKind(<wbr>unsigned int) const: Assertion `Idx < getNumArgs() && "Argument index out of range!"' failed.<br>
<br>
So reverted it to as it was earlier and similar to other builtin error err_builtin_annotation_first_<wbr>arg.<br>
<br>
Please review the changes and let me know if any other change is needed.<br>
<span class=""><br>
Thanks,<br>
Mayur<br>
<br>
<br>
<a href="https://reviews.llvm.org/D22334" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D22334</a><br>
<br>
Files:<br>
include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
lib/Sema/SemaChecking.cpp<br>
test/Sema/builtins.c<br>
</span> test/SemaCXX/builtins.cpp<br>
<br>
Index: test/SemaCXX/builtins.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/SemaCXX/builtins.cpp<br>
+++ test/SemaCXX/builtins.cpp<br>
@@ -44,3 +44,10 @@<br>
__noop(1); // expected-error {{use of undeclared}}<br>
__debugbreak(); // expected-error {{use of undeclared}}<br>
}<br>
+<br>
+template <typename T><br>
+int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{Argument type mismatch}}<br>
+<br>
+int test_signbit_call () {<br>
+return test_signbit("1"); // expected-note {{instantiation of function template specialization}}<br>
+}<br>
<span class="">Index: test/Sema/builtins.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/Sema/builtins.c<br>
+++ test/Sema/builtins.c<br>
</span>@@ -248,3 +248,11 @@<br>
<span class=""><br>
return buf;<br>
}<br>
+<br>
+int test21(double a) {<br>
+ return __builtin_signbit(); // expected-error {{too few arguments}}<br>
+}<br>
</span><span class="">+<br>
+int test22(void) {<br>
+ return __builtin_signbit("1"); // expected-error {{Argument type mismatch}}<br>
</span><span class="">+}<br>
Index: lib/Sema/SemaChecking.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/Sema/SemaChecking.cpp<br>
+++ lib/Sema/SemaChecking.cpp<br>
</span><span class="">@@ -99,6 +99,22 @@<br>
return false;<br>
}<br>
<br>
+static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) {<br>
</span>+ if (checkArgCount(S, TheCall, 1))<br>
+ return true;<br>
+<br>
<span class="">+ // Argument should be an float, double or long double.<br>
+ Expr *ValArg = TheCall->getArg(0);<br>
+ QualType Ty = ValArg->getType();<br>
+ if (!Ty->isRealFloatingType()) {<br>
+ S.Diag(ValArg->getLocStart(), diag::err_builtin_signbit_<wbr>wrong_argument)<br>
+ << ValArg->getSourceRange();<br>
+ return true;<br>
+ }<br>
+<br>
+ return false;<br>
+}<br>
+<br>
/// Check that the argument to __builtin_addressof is a glvalue, and set the<br>
/// result type to the corresponding pointer type.<br>
static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) {<br>
</span>@@ -763,6 +779,10 @@<br>
<span class="im HOEnZb"> }<br>
break;<br>
}<br>
+ case Builtin::BI__builtin_signbit:<br>
</span><span class="im HOEnZb">+ if (SemaBuiltinSignbit(*this, TheCall))<br>
+ return ExprError();<br>
</span><span class="im HOEnZb">+ break;<br>
case Builtin::BI__builtin_<wbr>isgreater:<br>
case Builtin::BI__builtin_<wbr>isgreaterequal:<br>
case Builtin::BI__builtin_isless:<br>
</span><span class="im HOEnZb">Index: include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
==============================<wbr>==============================<wbr>=======<br>
--- include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
+++ include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
@@ -7398,6 +7398,9 @@<br>
def err_builtin_annotation_second_<wbr>arg : Error<<br>
"second argument to __builtin_annotation must be a non-wide string constant">;<br>
<br>
</span><span class="im HOEnZb">+def err_builtin_signbit_wrong_<wbr>argument : Error<<br>
+ "Argument type mismatch, must be float, double or long double">;<br>
+<br>
// CFString checking<br>
</span><div class="HOEnZb"><div class="h5"> def err_cfstring_literal_not_<wbr>string_constant : Error<<br>
"CFString literal is not a string constant">;<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Thanx & Regards <br></div>
<div><b>Mayur Pandey </b><br></div>
<div style="color:rgb(0,0,0)"><span style="font-size:12.8000001907349px;color:rgb(34,34,34)">+91-9742959541</span><br></div><div><font color="#3333ff"></font><font color="#3333ff"> <br></font></div>
<div> </div>
<div> </div></div></div></div></div>
</div></div>