saghir updated this revision to Diff 374529. saghir added a comment. Changed approach for Sema checks.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106550/new/ https://reviews.llvm.org/D106550 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/ppc-pair-mma-types.c Index: clang/test/Sema/ppc-pair-mma-types.c =================================================================== --- clang/test/Sema/ppc-pair-mma-types.c +++ clang/test/Sema/ppc-pair-mma-types.c @@ -335,3 +335,23 @@ __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}} __builtin_vsx_stxvp(vp, ll, s); // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}} } + +void testRestrictQualifiedPointer1(int *__restrict acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}} +} + +void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); +} + +void testVolatileQualifiedPointer1(int *__volatile acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}} +} + +void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); +} Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -7436,10 +7436,15 @@ Expr *Arg = TheCall->getArg(ArgNum); QualType ArgType = Arg->getType(); + bool IsRestrictOrVolatile = + ArgType.isRestrictQualified() || ArgType.isVolatileQualified(); if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) || (!ExpectedType->isVoidPointerType() && - ArgType.getCanonicalType() != ExpectedType)) + ((IsRestrictOrVolatile && + ArgType.getCanonicalType().getUnqualifiedType() != ExpectedType) || + (!IsRestrictOrVolatile && + ArgType.getCanonicalType() != ExpectedType)))) return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible) << ArgType << ExpectedType << 1 << 0 << 0;
Index: clang/test/Sema/ppc-pair-mma-types.c =================================================================== --- clang/test/Sema/ppc-pair-mma-types.c +++ clang/test/Sema/ppc-pair-mma-types.c @@ -335,3 +335,23 @@ __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}} __builtin_vsx_stxvp(vp, ll, s); // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}} } + +void testRestrictQualifiedPointer1(int *__restrict acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}} +} + +void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); +} + +void testVolatileQualifiedPointer1(int *__volatile acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}} +} + +void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) { + vector float arr[4]; + __builtin_mma_disassemble_acc((void*)arr, acc); +} Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -7436,10 +7436,15 @@ Expr *Arg = TheCall->getArg(ArgNum); QualType ArgType = Arg->getType(); + bool IsRestrictOrVolatile = + ArgType.isRestrictQualified() || ArgType.isVolatileQualified(); if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) || (!ExpectedType->isVoidPointerType() && - ArgType.getCanonicalType() != ExpectedType)) + ((IsRestrictOrVolatile && + ArgType.getCanonicalType().getUnqualifiedType() != ExpectedType) || + (!IsRestrictOrVolatile && + ArgType.getCanonicalType() != ExpectedType)))) return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible) << ArgType << ExpectedType << 1 << 0 << 0;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits