[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
This revision was automatically updated to reflect the committed changes. Closed by commit rL316016: [OpenCL] Restrict swizzle length check to OpenCL mode (authored by bruno). Changed prior to commit: https://reviews.llvm.org/D38868?vs=118966=119351#toc Repository: rL LLVM https://reviews.llvm.org/D38868 Files: cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/test/Sema/vector_swizzle_length.c cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Index: cfe/trunk/test/Sema/vector_swizzle_length.c === --- cfe/trunk/test/Sema/vector_swizzle_length.c +++ cfe/trunk/test/Sema/vector_swizzle_length.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only +// expected-no-diagnostics + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +(void)f2.s01234; +(void)f2.xyzxy; +} Index: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl === --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); Index: cfe/trunk/lib/Sema/SemaExprMember.cpp === --- cfe/trunk/lib/Sema/SemaExprMember.cpp +++ cfe/trunk/lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) Index: cfe/trunk/test/Sema/vector_swizzle_length.c === --- cfe/trunk/test/Sema/vector_swizzle_length.c +++ cfe/trunk/test/Sema/vector_swizzle_length.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only +// expected-no-diagnostics + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +(void)f2.s01234; +(void)f2.xyzxy; +} Index: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl === --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); Index: cfe/trunk/lib/Sema/SemaExprMember.cpp === --- cfe/trunk/lib/Sema/SemaExprMember.cpp +++ cfe/trunk/lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Comment at: test/SemaOpenCL/vector_swizzle_length.cl:7 void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; bruno wrote: > Anastasia wrote: > > Even though this works in Clang, ideally OpenCL vector literal is with > > parenthesis (see s6.1.6). > Ok. I changed this to avoid warnings in C mode. Gonna change it back, Can you undo this change please before committing. Thanks! https://reviews.llvm.org/D38868 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
bruno updated this revision to Diff 118966. bruno marked 2 inline comments as done. bruno added a comment. Update patch after Anastasia's suggestions https://reviews.llvm.org/D38868 Files: lib/Sema/SemaExprMember.cpp test/Sema/vector_swizzle_length.c test/SemaOpenCL/vector_swizzle_length.cl Index: test/SemaOpenCL/vector_swizzle_length.cl === --- test/SemaOpenCL/vector_swizzle_length.cl +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -1,9 +1,9 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} f2.xyzxy; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} Index: test/Sema/vector_swizzle_length.c === --- /dev/null +++ test/Sema/vector_swizzle_length.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only +// expected-no-diagnostics + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +(void)f2.s01234; +(void)f2.xyzxy; +} Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) Index: test/SemaOpenCL/vector_swizzle_length.cl === --- test/SemaOpenCL/vector_swizzle_length.cl +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -1,9 +1,9 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} f2.xyzxy; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} Index: test/Sema/vector_swizzle_length.c === --- /dev/null +++ test/Sema/vector_swizzle_length.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only +// expected-no-diagnostics + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +(void)f2.s01234; +(void)f2.xyzxy; +} Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
bruno marked 2 inline comments as done. bruno added inline comments. Comment at: test/SemaOpenCL/vector_swizzle_length.cl:7 void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; Anastasia wrote: > Even though this works in Clang, ideally OpenCL vector literal is with > parenthesis (see s6.1.6). Ok. I changed this to avoid warnings in C mode. Gonna change it back, Comment at: test/SemaOpenCL/vector_swizzle_length.cl:13 +#else +// expected-no-diagnostics +(void)f2.s01234; Anastasia wrote: > I am not sure it's good idea to test C mode here since this is intended for > OpenCL only functionality. I think it might be better to separate C > functionality and keep under regular Sema tests. We could keep the same test > name to be able to identify similar functionality. Ok! https://reviews.llvm.org/D38868 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
Anastasia added inline comments. Comment at: test/SemaOpenCL/vector_swizzle_length.cl:7 void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; Even though this works in Clang, ideally OpenCL vector literal is with parenthesis (see s6.1.6). Comment at: test/SemaOpenCL/vector_swizzle_length.cl:13 +#else +// expected-no-diagnostics +(void)f2.s01234; I am not sure it's good idea to test C mode here since this is intended for OpenCL only functionality. I think it might be better to separate C functionality and keep under regular Sema tests. We could keep the same test name to be able to identify similar functionality. https://reviews.llvm.org/D38868 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode
bruno created this revision. Herald added a subscriber: yaxunl. Change behavior introduced in r298369 and only error out on vector component invalid length access on OpenCL mode. https://reviews.llvm.org/D38868 Files: lib/Sema/SemaExprMember.cpp test/SemaOpenCL/vector_swizzle_length.cl Index: test/SemaOpenCL/vector_swizzle_length.cl === --- test/SemaOpenCL/vector_swizzle_length.cl +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -1,10 +1,17 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +#if defined(__OPENCL_C_VERSION__) f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} f2.xyzxy; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +#else +// expected-no-diagnostics +(void)f2.s01234; +(void)f2.xyzxy; +#endif } Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) Index: test/SemaOpenCL/vector_swizzle_length.cl === --- test/SemaOpenCL/vector_swizzle_length.cl +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -1,10 +1,17 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only typedef float float8 __attribute__((ext_vector_type(8))); void foo() { -float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); +float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0}; +#if defined(__OPENCL_C_VERSION__) f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} f2.xyzxy; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +#else +// expected-no-diagnostics +(void)f2.s01234; +(void)f2.xyzxy; +#endif } Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -384,7 +384,9 @@ } } - if (!HalvingSwizzle) { + // OpenCL mode requires swizzle length to be in accordance with accepted + // sizes. Clang however supports arbitrary lengths for other languages. + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { unsigned SwizzleLength = CompName->getLength(); if (HexSwizzle) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits