<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 4, 2014, at 5:58 PM, Steve Canon <<a href="mailto:scanon@apple.com">scanon@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I added a warning with r205521, for this and some other scalar->vector conversions.<br><br></blockquote><div><br></div>Great, thanks. I reverted my patch in r<span style="font-family: Menlo; font-size: 11px;">205718.</span></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font></div><div><font face="Menlo"><span style="font-size: 11px;">- Fariborz</span></font></div><div><font face="Menlo"><span style="font-size: 11px;"><br></span></font><blockquote type="cite">-- Steve<br><br>Sent from my iPhone<br><br><blockquote type="cite">On Apr 4, 2014, at 8:14 PM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><br>This is strange. Before my patch, there was no warning for my test. This was the reason behind the patch.<br>If my patch is no longer needed due to other changes which took place while I was fixing this,  I can take it out.<br><br>- Fariborz<br><br><br><blockquote type="cite">On Apr 4, 2014, at 3:05 PM, Stephen Canon <<a href="mailto:scanon@apple.com">scanon@apple.com</a>> wrote:<br><br>Hi Fariborz --<br><br>Before this patch, we were generating the following warning for your test case:<br><br>   implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'ushort16'<br><br>with your patch, we get the following instead:<br><br>   implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'unsigned short'<br><br>I have a slight preference for the warning we used to issue, as it refers to the conversion that actually takes place conceptually (scalar -> vector), rather than the "subconversion" that changes the value (scalar -> vector element).  Reasonable people may disagree, of course.<br><br>– Steve<br><br><blockquote type="cite">On Apr 4, 2014, at 3:33 PM, Fariborz Jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><br>Author: fjahanian<br>Date: Fri Apr  4 14:33:39 2014<br>New Revision: 205646<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=205646&view=rev">http://llvm.org/viewvc/llvm-project?rev=205646&view=rev</a><br>Log:<br>Vector [Sema]. Vector "splats" which are truncated should have a warning<br>with -Wconversion. // <a href="rdar://16502418">rdar://16502418</a><br><br>Modified:<br> cfe/trunk/lib/Sema/SemaChecking.cpp<br> cfe/trunk/test/Sema/conversion.c<br><br>Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=205646&r1=205645&r2=205646&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=205646&r1=205645&r2=205646&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Apr  4 14:33:39 2014<br>@@ -6113,11 +6113,20 @@ void CheckConditionalOperator(Sema &S, C<br>/// implicit conversions in the given expression.  There are a couple<br>/// of competing diagnostics here, -Wconversion and -Wsign-compare.<br>void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {<br>-  QualType T = OrigE->getType();<br>Expr *E = OrigE->IgnoreParenImpCasts();<br><br>if (E->isTypeDependent() || E->isValueDependent())<br>  return;<br>+  <br>+  QualType T = OrigE->getType();<br>+  // Check for conversion from an arithmetic type to a vector of arithmetic<br>+  // type elements. Warn if this results in truncation of each vector element.<br>+  if (isa<ExtVectorElementExpr>(E)) {<br>+    if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(OrigE))<br>+      if ((ICE->getCastKind() == CK_VectorSplat) &&<br>+          !T.isNull() && T->isExtVectorType())<br>+        T = cast<ExtVectorType>(T.getCanonicalType())->getElementType();<br>+  }<br><br>// For conditional operators, we analyze the arguments as if they<br>// were being fed directly into the output.<br><br>Modified: cfe/trunk/test/Sema/conversion.c<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conversion.c?rev=205646&r1=205645&r2=205646&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conversion.c?rev=205646&r1=205645&r2=205646&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Sema/conversion.c (original)<br>+++ cfe/trunk/test/Sema/conversion.c Fri Apr  4 14:33:39 2014<br>@@ -417,3 +417,15 @@ void test26(int si, long sl) {<br>si = si / sl;<br>si = sl / si; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}<br>}<br>+<br>+// <a href="rdar://16502418">rdar://16502418</a><br>+typedef unsigned short uint16_t;<br>+typedef unsigned int uint32_t;<br>+typedef __attribute__ ((ext_vector_type(16),__aligned__(32))) uint16_t ushort16;<br>+typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) uint32_t uint8;<br>+<br>+void test27(ushort16 constants) {<br>+    uint8 pairedConstants = (uint8) constants;<br>+    ushort16 crCbScale = pairedConstants.s4; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'unsigned short'}}<br>+    ushort16 brBias = pairedConstants.s6; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'unsigned short'}}<br>+}<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote></blockquote><br></blockquote></blockquote></div><br></body></html>