diff options
Diffstat (limited to 'test/Sema')
| -rw-r--r-- | test/Sema/attr-format_arg.c | 11 | ||||
| -rw-r--r-- | test/Sema/ext_vector_casts.c | 23 | ||||
| -rw-r--r-- | test/Sema/ext_vector_components.c | 7 | ||||
| -rw-r--r-- | test/Sema/vector-cast.c | 4 |
4 files changed, 43 insertions, 2 deletions
diff --git a/test/Sema/attr-format_arg.c b/test/Sema/attr-format_arg.c new file mode 100644 index 000000000000..6f953155f8c8 --- /dev/null +++ b/test/Sema/attr-format_arg.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +const char* f(const char *s) __attribute__((format_arg(1))); + +void g(const char *s) { + printf("%d", 123); + printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}} + + printf(f("%d"), 123); + printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}} +} diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c new file mode 100644 index 000000000000..8aa762ebcf2a --- /dev/null +++ b/test/Sema/ext_vector_casts.c @@ -0,0 +1,23 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +typedef __attribute__(( ext_vector_type(2) )) float float2; +typedef __attribute__(( ext_vector_type(4) )) int int4; +typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef float t3 __attribute__ ((vector_size (16))); + +static void test() { + float2 vec2; + float4 vec4, vec4_2; + int4 ivec4; + t3 vec4_3; + + vec4 = (float4)5.0f; + vec4 = (float4)5; + vec4 = (float4)vec4_3; + + ivec4 = (int4)5.0f; + ivec4 = (int4)5; + ivec4 = (int4)vec4_3; + + vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}} +} diff --git a/test/Sema/ext_vector_components.c b/test/Sema/ext_vector_components.c index 422a9e6f2287..48903024d3c6 100644 --- a/test/Sema/ext_vector_components.c +++ b/test/Sema/ext_vector_components.c @@ -3,11 +3,15 @@ typedef __attribute__(( ext_vector_type(2) )) float float2; typedef __attribute__(( ext_vector_type(3) )) float float3; typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(16) )) float float16; + +static float4 vec4_0 = (float4)0.5f; static void test() { float2 vec2, vec2_2; float3 vec3; float4 vec4, vec4_2, *vec4p; + float16 vec16; float f; vec2.z; // expected-error {{vector component access exceeds type 'float2'}} @@ -16,6 +20,7 @@ static void test() { vec4.xyzc; // expected-error {{illegal vector component name 'c'}} vec4.s01z; // expected-error {{illegal vector component name 'z'}} vec2 = vec4.s01; // legal, shorten + vec2 = vec4.S01; // legal, shorten vec3 = vec4.xyz; // legal, shorten f = vec2.x; // legal, shorten @@ -32,6 +37,8 @@ static void test() { vec4 = (float4){ 1,2,3,4 }; vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}} vec4.s06; // expected-error {{vector component access exceeds type 'float4'}} + vec4.x = vec16.sf; + vec4.x = vec16.sF; vec4p->yz = vec4p->xy; } diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c index bd09e69800cc..9460cac6d187 100644 --- a/test/Sema/vector-cast.c +++ b/test/Sema/vector-cast.c @@ -11,9 +11,9 @@ void f() t3 v3; v2 = (t2)v1; // -expected-error {{invalid conversion between vector type \ -'t1' and 't2' of different size}} - v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \ 't2' and 't1' of different size}} + v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \ +'t1' and 't2' of different size}} v3 = (t3)v2; v1 = (t1)(char *)10; // -expected-error {{invalid conversion between vector \ |
