[clang] 5b4ed49 - [PowerPC] Remove the lax warning for explicit casts
Maryam Moghadas via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 20 12:23:58 PST 2023
Author: Maryam Moghadas
Date: 2023-01-20T14:23:54-06:00
New Revision: 5b4ed4905017a052501becfde8dd1fca1e476ee3
URL: https://github.com/llvm/llvm-project/commit/5b4ed4905017a052501becfde8dd1fca1e476ee3
DIFF: https://github.com/llvm/llvm-project/commit/5b4ed4905017a052501becfde8dd1fca1e476ee3.diff
LOG: [PowerPC] Remove the lax warning for explicit casts
This patch is to remove the erroneous lax vector conversion warning for CStyle; explicit; casts
that was added as part of D126540.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D142222
Added:
clang/test/Parser/lax-conv.cpp
Modified:
clang/lib/Sema/SemaOverload.cpp
clang/test/Parser/cxx-altivec.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 251895076432b..89b5e29ffd614 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1726,7 +1726,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
/// conversion.
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
ImplicitConversionKind &ICK, Expr *From,
- bool InOverloadResolution) {
+ bool InOverloadResolution, bool CStyle) {
// We need at least one of these types to be a vector type to have a vector
// conversion.
if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1771,7 +1771,7 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
if (S.isLaxVectorConversion(FromType, ToType) &&
S.anyAltivecTypes(FromType, ToType) &&
!S.areSameVectorElemTypes(FromType, ToType) &&
- !InOverloadResolution) {
+ !InOverloadResolution && !CStyle) {
S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
<< FromType << ToType;
}
@@ -2024,7 +2024,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
// Pointer to member conversions (4.11).
SCS.Second = ICK_Pointer_Member;
} else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
- InOverloadResolution)) {
+ InOverloadResolution, CStyle)) {
SCS.Second = SecondICK;
FromType = ToType.getUnqualifiedType();
} else if (!S.getLangOpts().CPlusPlus &&
diff --git a/clang/test/Parser/cxx-altivec.cpp b/clang/test/Parser/cxx-altivec.cpp
index d1aaadc8899c5..11ac15ef46097 100644
--- a/clang/test/Parser/cxx-altivec.cpp
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
#include <altivec.h>
__vector char vv_c;
diff --git a/clang/test/Parser/lax-conv.cpp b/clang/test/Parser/lax-conv.cpp
new file mode 100644
index 0000000000000..b3b6112649288
--- /dev/null
+++ b/clang/test/Parser/lax-conv.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,nonaix %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,novsx %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,aix %s
+
+void dummy(vector unsigned int a);
+template <typename VEC> VEC __attribute__((noinline)) test(vector unsigned char a, vector unsigned char b) {
+ return (VEC)(a * b);
+}
+vector unsigned int test1(vector unsigned char RetImplicitConv) {
+ return RetImplicitConv; // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+vector unsigned int test2(vector unsigned char RetImplicitConvAddConst) {
+ return RetImplicitConvAddConst + 5; // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+vector unsigned int test3(vector unsigned char RetExplicitConv) {
+ return (vector unsigned int)RetExplicitConv;
+}
+vector unsigned int test4(vector unsigned char RetExplicitConvAddConst) {
+ return (vector unsigned int)RetExplicitConvAddConst + 5;
+}
+vector unsigned int test5(vector unsigned char RetImplicitConvAddSame1,
+ vector unsigned char RetImplicitConvAddSame2) {
+ return RetImplicitConvAddSame1 + RetImplicitConvAddSame2; // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+vector unsigned int test6(vector unsigned char RetExplicitConvAddSame1,
+ vector unsigned char RetExplicitConvAddSame2) {
+ return (vector unsigned int)RetExplicitConvAddSame1 +
+ (vector unsigned int)RetExplicitConvAddSame2;
+}
+vector unsigned int test7(vector unsigned char RetExplicitConvAddSame1Full,
+ vector unsigned char RetExplicitConvAddSame2Full) {
+ return (vector unsigned int)(RetExplicitConvAddSame1Full +
+ RetExplicitConvAddSame2Full);
+}
+vector unsigned char test8(vector unsigned char a, vector unsigned char b) {
+ return test<vector unsigned char>(a, b);
+}
+
+vector unsigned long long test9(vector unsigned char a, vector unsigned char b) {
+ return test<vector unsigned long long>(a, b);
+}
+void test1a(vector unsigned char ArgImplicitConv) {
+ return dummy(ArgImplicitConv); // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+void test2a(vector unsigned char ArgImplicitConvAddConst) {
+ return dummy(ArgImplicitConvAddConst + 5); // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+void test3a(vector unsigned char ArgExplicitConv) {
+ return dummy((vector unsigned int)ArgExplicitConv);
+}
+void test4a(vector unsigned char ArgExplicitConvAddConst) {
+ return dummy((vector unsigned int)ArgExplicitConvAddConst + 5);
+}
+void test5a(vector unsigned char ArgImplicitConvAddSame1,
+ vector unsigned char ArgImplicitConvAddSame2) {
+ return dummy(ArgImplicitConvAddSame1 + ArgImplicitConvAddSame2); // expected-warning {{Implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.}}
+}
+void test6a(vector unsigned char ArgExplicitConvAddSame1,
+ vector unsigned char ArgExplicitConvAddSame2) {
+ return dummy((vector unsigned int)ArgExplicitConvAddSame1 +
+ (vector unsigned int)ArgExplicitConvAddSame2);
+}
+void test7a(vector unsigned char ArgExplicitConvAddSame1Full,
+ vector unsigned char ArgExplicitConvAddSame2Full) {
+ return dummy((vector unsigned int)(ArgExplicitConvAddSame1Full +
+ ArgExplicitConvAddSame2Full));
+}
More information about the cfe-commits
mailing list