annotate clang/test/Sema/ext_vector_comparisons.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children
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
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
5 static int4 test1(void) {
150
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
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
20 static int4 test2(void) {
150
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 }
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
31
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
32 static int4 test3(void) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
33 int4 i0, i1;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
34
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 return i0 > i1 ? i0 : i1; // no-error
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
36 return i0 ? i0 : i1; // no-error
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
37 }
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
38
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
39 static float4 test4(void) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 float4 f0, f1;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
41
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
42 // This would actually generate implicit casting warning
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
43 // under Weverything flag but we don't really care here
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
44 return f0 > f1 ? f0 : f1; // no-error
79ff65ed7e25 LLVM12 Original
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}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
46 }