]> granicus.if.org Git - clang/commitdiff
fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.
authorChris Lattner <sabre@nondot.org>
Tue, 14 Jun 2011 04:51:15 +0000 (04:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Jun 2011 04:51:15 +0000 (04:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/Sema/conversion-64-32.c

index 8dc54ae55311be62973a9842e467efa16b6f1de3..9c47e1e1e26a778d1ba728943dcfac24bb059e95 100644 (file)
@@ -2895,6 +2895,11 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
         return;
       return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar);
     }
+    
+    // If the vector cast is cast between two vectors of the same size, it is
+    // a bitcast, not a conversion.
+    if (S.Context.getTypeSize(Source) == S.Context.getTypeSize(Target))
+      return;
 
     Source = cast<VectorType>(Source)->getElementType().getTypePtr();
     Target = cast<VectorType>(Target)->getElementType().getTypePtr();
@@ -2989,9 +2994,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
       return;
     }
 
-    // People want to build with -Wshorten-64-to-32 and not -Wconversion
-    // and by god we'll let them.
-    
+    // People want to build with -Wshorten-64-to-32 and not -Wconversion.
     if (isFromSystemMacro(S, CC))
       return;
     
index aa7282962f8e698d4aeeccee6e6ef081658d7480..112e995102c59e6aac0ab9e1842136934ae31e66 100644 (file)
@@ -3,3 +3,13 @@
 int test0(long v) {
   return v; // expected-warning {{implicit conversion loses integer precision}}
 }
+
+
+// rdar://9546171
+typedef int  int4  __attribute__ ((vector_size(16)));
+typedef long long long2 __attribute__((__vector_size__(16)));
+
+int4 test1(long2 a) {
+  int4  v127 = a;  // no warning.
+  return v127; 
+}