[clang] 103cdd4 - [Matrix] Add test showing unintended implicit sign conversion warning.

Florian Hahn via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 04:24:54 PDT 2024


Author: Florian Hahn
Date: 2024-08-13T12:18:38+01:00
New Revision: 103cdd45fcdb8024f73f43bddf1764e26bfa0053

URL: https://github.com/llvm/llvm-project/commit/103cdd45fcdb8024f73f43bddf1764e26bfa0053
DIFF: https://github.com/llvm/llvm-project/commit/103cdd45fcdb8024f73f43bddf1764e26bfa0053.diff

LOG: [Matrix] Add test showing unintended implicit sign conversion warning.

Added: 
    clang/test/SemaCXX/matrix-index-operator-sign-conversion.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang/test/SemaCXX/matrix-index-operator-sign-conversion.cpp b/clang/test/SemaCXX/matrix-index-operator-sign-conversion.cpp
new file mode 100644
index 00000000000000..4254780651c5f5
--- /dev/null
+++ b/clang/test/SemaCXX/matrix-index-operator-sign-conversion.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple arm64-apple-macosx -std=c++11 -fenable-matrix -fsyntax-only -verify -Wsign-conversion %s
+
+template <typename T, int R, int C> using m __attribute__((__matrix_type__(R,C))) = T;
+
+// FIXME: should not warn here.
+double index1(m<double,3,1> X, int      i) { return X[i][0]; }
+// expected-warning at -1 {{implicit conversion changes signedness: 'int' to 'unsigned long'}}
+
+double index2(m<double,3,1> X, unsigned i) { return X[i][0]; }
+
+double index3(m<double,3,1> X, char     i) { return X[i][0]; }
+// expected-warning at -1 {{implicit conversion changes signedness: 'char' to 'unsigned long'}}
+
+double index4(m<double,3,1> X, int      i) { return X[0][i]; }
+// expected-warning at -1 {{implicit conversion changes signedness: 'int' to 'unsigned long'}}
+
+double index5(m<double,3,1> X, unsigned i) { return X[0][i]; }
+
+double index6(m<double,3,1> X, char     i) { return X[0][i]; }
+// expected-warning at -1 {{implicit conversion changes signedness: 'char' to 'unsigned long'}}


        


More information about the cfe-commits mailing list