diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10789,13 +10789,13 @@ "matrix row and column subscripts cannot be separated by any expression">; def err_matrix_subscript_comma: Error< "comma expressions are not allowed as indices in matrix subscript expressions">; -def err_builtin_matrix_arg: Error<"first argument must be a matrix">; +def err_builtin_matrix_arg: Error<"1st argument must be a matrix">; def err_builtin_matrix_scalar_unsigned_arg: Error< "%0 argument must be a constant unsigned integer expression">; def err_builtin_matrix_pointer_arg: Error< - "%0 argument must be a pointer to a valid matrix element type">; + "%ordinal0 argument must be a pointer to a valid matrix element type">; def err_builtin_matrix_pointer_arg_mismatch: Error< - "the pointee of the second argument must match the element type of the first argument (%0 != %1)">; + "the pointee of the 2nd argument must match the element type of the 1st argument (%0 != %1)">; def err_builtin_matrix_store_to_const: Error< "cannot store matrix to read-only pointer">; def err_builtin_matrix_stride_too_small: Error< diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -15295,7 +15295,8 @@ if (checkArgCount(*this, TheCall, 4)) return ExprError(); - Expr *PtrExpr = TheCall->getArg(0); + unsigned PtrArgIdx = 0; + Expr *PtrExpr = TheCall->getArg(PtrArgIdx); Expr *RowsExpr = TheCall->getArg(1); Expr *ColumnsExpr = TheCall->getArg(2); Expr *StrideExpr = TheCall->getArg(3); @@ -15319,14 +15320,14 @@ QualType ElementTy; if (!PtrTy) { Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg) - << "first"; + << PtrArgIdx + 1; ArgError = true; } else { ElementTy = PtrTy->getPointeeType().getUnqualifiedType(); if (!ConstantMatrixType::isValidElementType(ElementTy)) { Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg) - << "first"; + << PtrArgIdx + 1; ArgError = true; } } @@ -15402,8 +15403,9 @@ if (checkArgCount(*this, TheCall, 3)) return ExprError(); + unsigned PtrArgIdx = 1; Expr *MatrixExpr = TheCall->getArg(0); - Expr *PtrExpr = TheCall->getArg(1); + Expr *PtrExpr = TheCall->getArg(PtrArgIdx); Expr *StrideExpr = TheCall->getArg(2); bool ArgError = false; @@ -15442,7 +15444,7 @@ auto *PtrTy = PtrExpr->getType()->getAs(); if (!PtrTy) { Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg) - << "second"; + << PtrArgIdx + 1; ArgError = true; } else { QualType ElementTy = PtrTy->getPointeeType(); diff --git a/clang/test/Sema/matrix-type-builtins.c b/clang/test/Sema/matrix-type-builtins.c --- a/clang/test/Sema/matrix-type-builtins.c +++ b/clang/test/Sema/matrix-type-builtins.c @@ -11,11 +11,11 @@ b = __builtin_matrix_transpose(b); // expected-error@-1 {{assigning to 'ix3x2_t' (aka 'int __attribute__((matrix_type(3, 2)))') from incompatible type 'int __attribute__((matrix_type(2, 3)))'}} __builtin_matrix_transpose(d); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} __builtin_matrix_transpose(e); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} __builtin_matrix_transpose("test"); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} ix3x3 m = __builtin_matrix_transpose(c); // expected-error@-1 {{initializing 'ix3x3' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') with an expression of incompatible type 'double __attribute__((matrix_type(3, 3)))'}} @@ -43,10 +43,10 @@ // expected-error@-1 {{stride must be greater or equal to the number of rows}} sx5x10_t a8 = __builtin_matrix_column_major_load(p3, 5, 10, 6); - // expected-error@-1 {{first argument must be a pointer to a valid matrix element type}} + // expected-error@-1 {{1st argument must be a pointer to a valid matrix element type}} sx5x10_t a9 = __builtin_matrix_column_major_load(p4, 5, 10, 6); - // expected-error@-1 {{first argument must be a pointer to a valid matrix element type}} + // expected-error@-1 {{1st argument must be a pointer to a valid matrix element type}} sx5x10_t a10 = __builtin_matrix_column_major_load(p1, 1ull << 21, 10, 6); // expected-error@-1 {{row dimension is outside the allowed range [1, 1048575}} @@ -54,13 +54,13 @@ // expected-error@-1 {{column dimension is outside the allowed range [1, 1048575}} sx5x10_t a12 = __builtin_matrix_column_major_load( - 10, // expected-error {{first argument must be a pointer to a valid matrix element type}} + 10, // expected-error {{1st argument must be a pointer to a valid matrix element type}} 1ull << 21, // expected-error {{row dimension is outside the allowed range [1, 1048575]}} 1ull << 21, // expected-error {{column dimension is outside the allowed range [1, 1048575]}} ""); // expected-warning {{incompatible pointer to integer conversion casting 'char [1]' to type 'unsigned long'}} sx5x10_t a13 = __builtin_matrix_column_major_load( - 10, // expected-error {{first argument must be a pointer to a valid matrix element type}} + 10, // expected-error {{1st argument must be a pointer to a valid matrix element type}} *p4, // expected-error {{casting 'struct Foo' to incompatible type 'unsigned long'}} "", // expected-error {{column argument must be a constant unsigned integer expression}} // expected-warning@-1 {{incompatible pointer to integer conversion casting 'char [1]' to type 'unsigned long'}} @@ -73,18 +73,18 @@ __builtin_matrix_column_major_store(*m1, p1, 0); // expected-error@-1 {{stride must be greater or equal to the number of rows}} __builtin_matrix_column_major_store(*m1, p2, 10); - // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('int' != 'float')}} + // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('int' != 'float')}} __builtin_matrix_column_major_store(p1, p2, 10); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} __builtin_matrix_column_major_store( - "", // expected-error {{first argument must be a matrix}} - 10, // expected-error {{second argument must be a pointer to a valid matrix element type}} + "", // expected-error {{1st argument must be a matrix}} + 10, // expected-error {{2nd argument must be a pointer to a valid matrix element type}} *p3); // expected-error {{casting 'struct Foo' to incompatible type 'unsigned long'}} __builtin_matrix_column_major_store( *m1, - 10, // expected-error {{second argument must be a pointer to a valid matrix element type}} + 10, // expected-error {{2nd argument must be a pointer to a valid matrix element type}} 10); *m1 = __builtin_matrix_column_major_store(*m1, p1, 10); diff --git a/clang/test/SemaCXX/matrix-type-builtins.cpp b/clang/test/SemaCXX/matrix-type-builtins.cpp --- a/clang/test/SemaCXX/matrix-type-builtins.cpp +++ b/clang/test/SemaCXX/matrix-type-builtins.cpp @@ -15,9 +15,9 @@ // expected-error@-3 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 3)))'}} __builtin_matrix_transpose(A); - // expected-error@-1 {{first argument must be a matrix}} - // expected-error@-2 {{first argument must be a matrix}} - // expected-error@-3 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} + // expected-error@-2 {{1st argument must be a matrix}} + // expected-error@-3 {{1st argument must be a matrix}} return __builtin_matrix_transpose(A.value); // expected-error@-1 {{cannot initialize return object of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 3)))') with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 2)))'}} @@ -99,13 +99,13 @@ // expected-error@-1 {{row argument must be a constant unsigned integer expression}} // expected-error@-2 {{column argument must be a constant unsigned integer expression}} (void)__builtin_matrix_column_major_load(X, 2, 2, 2); - // expected-error@-1 {{first argument must be a pointer to a valid matrix element type}} + // expected-error@-1 {{1st argument must be a pointer to a valid matrix element type}} } template void column_major_store(MyMatrix &A, PtrTy Ptr, unsigned Stride) { __builtin_matrix_column_major_store(A.value, Ptr, Stride); - // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}} + // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}} } template @@ -126,14 +126,14 @@ void column_major_store(MyMatrix &A, EltTy1 *Ptr) { __builtin_matrix_column_major_store(A.value, Ptr, 1); // expected-error@-1 3 {{stride must be greater or equal to the number of rows}} - // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}} - // expected-error@-3 {{the pointee of the second argument must match the element type of the first argument ('unsigned int' != 'float')}} + // expected-error@-2 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}} + // expected-error@-3 {{the pointee of the 2nd argument must match the element type of the 1st argument ('unsigned int' != 'float')}} char *s; return __builtin_matrix_column_major_store(A.value, s, 20); - // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}} - // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}} - // expected-error@-3 {{he pointee of the second argument must match the element type of the first argument ('char' != 'float')}} + // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'unsigned int')}} + // expected-error@-2 {{the pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'unsigned int')}} + // expected-error@-3 {{he pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'float')}} } void test_column_major_store_template(unsigned *Ptr1, float *Ptr2) { @@ -152,9 +152,9 @@ __builtin_matrix_column_major_store(M.value, Ptr, constexpr1()); // expected-error@-1 {{stride must be greater or equal to the number of rows}} __builtin_matrix_column_major_store(constexpr1(), Ptr, 1); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} __builtin_matrix_column_major_store(M.value, constexpr1(), 1); - // expected-error@-1 {{second argument must be a pointer to a valid matrix element type}} + // expected-error@-1 {{2nd argument must be a pointer to a valid matrix element type}} // expected-error@-2 {{stride must be greater or equal to the number of rows}} } @@ -162,5 +162,5 @@ __builtin_matrix_column_major_store(M.value, Ptr, W); __builtin_matrix_column_major_store(W, Ptr, W); - // expected-error@-1 {{first argument must be a matrix}} + // expected-error@-1 {{1st argument must be a matrix}} } diff --git a/clang/test/SemaObjC/matrix-type-builtins.m b/clang/test/SemaObjC/matrix-type-builtins.m --- a/clang/test/SemaObjC/matrix-type-builtins.m +++ b/clang/test/SemaObjC/matrix-type-builtins.m @@ -22,10 +22,10 @@ double test_store(MatrixValue *mv, float *Ptr) { __builtin_matrix_column_major_store(mv.value, Ptr, 1); - // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'double')}} + // expected-error@-1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'double')}} // expected-error@-2 {{stride must be greater or equal to the number of rows}} __builtin_matrix_column_major_store(mv.value, mv.value, mv.value); - // expected-error@-1 {{second argument must be a pointer to a valid matrix element type}} + // expected-error@-1 {{2nd argument must be a pointer to a valid matrix element type}} // expected-error@-2 {{casting 'double4x4' (aka 'double __attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long}} }