From: Chris Lattner Date: Tue, 14 Jun 2011 04:51:15 +0000 (+0000) Subject: fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b792b30ce3d31e3eb3cfee3321238cf3cc2165b0;p=clang fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132975 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8dc54ae553..9c47e1e1e2 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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(Source)->getElementType().getTypePtr(); Target = cast(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; diff --git a/test/Sema/conversion-64-32.c b/test/Sema/conversion-64-32.c index aa7282962f..112e995102 100644 --- a/test/Sema/conversion-64-32.c +++ b/test/Sema/conversion-64-32.c @@ -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; +}