annotate clang/test/Sema/ext_vector_comparisons.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unreachable-code %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 typedef __attribute__(( ext_vector_type(4) )) int int4;
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 static int4 test1() {
anatofuz
parents:
diff changeset
6 int4 vec, rv;
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 // comparisons to self...
anatofuz
parents:
diff changeset
9 return vec == vec; // expected-warning{{self-comparison always evaluates to true}}
anatofuz
parents:
diff changeset
10 return vec != vec; // expected-warning{{self-comparison always evaluates to false}}
anatofuz
parents:
diff changeset
11 return vec < vec; // expected-warning{{self-comparison always evaluates to false}}
anatofuz
parents:
diff changeset
12 return vec <= vec; // expected-warning{{self-comparison always evaluates to true}}
anatofuz
parents:
diff changeset
13 return vec > vec; // expected-warning{{self-comparison always evaluates to false}}
anatofuz
parents:
diff changeset
14 return vec >= vec; // expected-warning{{self-comparison always evaluates to true}}
anatofuz
parents:
diff changeset
15 }
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 typedef __attribute__(( ext_vector_type(4) )) float float4;
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 static int4 test2() {
anatofuz
parents:
diff changeset
21 float4 vec, rv;
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 // comparisons to self. no warning, they're floats
anatofuz
parents:
diff changeset
24 return vec == vec; // no-warning
anatofuz
parents:
diff changeset
25 return vec != vec; // no-warning
anatofuz
parents:
diff changeset
26 return vec < vec; // no-warning
anatofuz
parents:
diff changeset
27 return vec <= vec; // no-warning
anatofuz
parents:
diff changeset
28 return vec > vec; // no-warning
anatofuz
parents:
diff changeset
29 return vec >= vec; // no-warning
anatofuz
parents:
diff changeset
30 }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
32 static int4 test3() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
33 int4 i0, i1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
34
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 return i0 > i1 ? i0 : i1; // no-error
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
36 return i0 ? i0 : i1; // no-error
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
37 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
38
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
39 static float4 test4() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 float4 f0, f1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
41
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
42 // This would actually generate implicit casting warning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
43 // under Weverything flag but we don't really care here
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
44 return f0 > f1 ? f0 : f1; // no-error
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
45 return f0 ? f0 : f1; // expected-error {{used type 'float4' (vector of 4 'float' values) where floating point type is not allowed}}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
46 }