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/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: 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}}