47 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unreachable-code %s2 3typedef __attribute__(( ext_vector_type(4) )) int int4;4 5static int4 test1(void) {6 int4 vec, rv;7 8 // comparisons to self...9 return vec == vec; // expected-warning{{self-comparison always evaluates to true}}10 return vec != vec; // expected-warning{{self-comparison always evaluates to false}}11 return vec < vec; // expected-warning{{self-comparison always evaluates to false}}12 return vec <= vec; // expected-warning{{self-comparison always evaluates to true}}13 return vec > vec; // expected-warning{{self-comparison always evaluates to false}}14 return vec >= vec; // expected-warning{{self-comparison always evaluates to true}}15}16 17 18typedef __attribute__(( ext_vector_type(4) )) float float4;19 20static int4 test2(void) {21 float4 vec, rv;22 23 // comparisons to self. no warning, they're floats24 return vec == vec; // no-warning25 return vec != vec; // no-warning26 return vec < vec; // no-warning27 return vec <= vec; // no-warning28 return vec > vec; // no-warning29 return vec >= vec; // no-warning30}31 32static int4 test3(void) {33 int4 i0, i1;34 35 return i0 > i1 ? i0 : i1; // no-error36 return i0 ? i0 : i1; // no-error37}38 39static float4 test4(void) {40 float4 f0, f1;41 42 // This would actually generate implicit casting warning43 // under Weverything flag but we don't really care here44 return f0 > f1 ? f0 : f1; // no-error45 return f0 ? f0 : f1; // expected-error {{used type 'float4' (vector of 4 'float' values) where floating point type is not allowed}}46}47