This revision was automatically updated to reflect the committed changes. Closed by commit rL341309: [OpenCL] Traverse vector types for ocl extensions support (authored by AlexeySotkin, committed by ). Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D51296?vs=163287&id=163691#toc Repository: rL LLVM https://reviews.llvm.org/D51296 Files: cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/test/SemaOpenCL/extensions.cl Index: cfe/trunk/test/SemaOpenCL/extensions.cl =================================================================== --- cfe/trunk/test/SemaOpenCL/extensions.cl +++ cfe/trunk/test/SemaOpenCL/extensions.cl @@ -70,6 +70,13 @@ // expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}} #endif + typedef double double4 __attribute__((ext_vector_type(4))); + double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f}; +#ifdef NOFP64 +// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}} +// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}} +#endif + (void) 1.0; #ifdef NOFP64 Index: cfe/trunk/lib/Sema/Sema.cpp =================================================================== --- cfe/trunk/lib/Sema/Sema.cpp +++ cfe/trunk/lib/Sema/Sema.cpp @@ -1889,6 +1889,14 @@ if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr())) Decl = TagT->getDecl(); auto Loc = DS.getTypeSpecTypeLoc(); + + // Check extensions for vector types. + // e.g. double4 is not allowed when cl_khr_fp64 is absent. + if (QT->isExtVectorType()) { + auto TypePtr = QT->castAs<ExtVectorType>()->getElementType().getTypePtr(); + return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap); + } + if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap)) return true;
Index: cfe/trunk/test/SemaOpenCL/extensions.cl =================================================================== --- cfe/trunk/test/SemaOpenCL/extensions.cl +++ cfe/trunk/test/SemaOpenCL/extensions.cl @@ -70,6 +70,13 @@ // expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}} #endif + typedef double double4 __attribute__((ext_vector_type(4))); + double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f}; +#ifdef NOFP64 +// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}} +// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}} +#endif + (void) 1.0; #ifdef NOFP64 Index: cfe/trunk/lib/Sema/Sema.cpp =================================================================== --- cfe/trunk/lib/Sema/Sema.cpp +++ cfe/trunk/lib/Sema/Sema.cpp @@ -1889,6 +1889,14 @@ if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr())) Decl = TagT->getDecl(); auto Loc = DS.getTypeSpecTypeLoc(); + + // Check extensions for vector types. + // e.g. double4 is not allowed when cl_khr_fp64 is absent. + if (QT->isExtVectorType()) { + auto TypePtr = QT->castAs<ExtVectorType>()->getElementType().getTypePtr(); + return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap); + } + if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap)) return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits