annotate clang/test/SemaCXX/complex-conversion.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
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 %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 template<typename T> void take(T);
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 void func(float Real, _Complex float Complex) {
anatofuz
parents:
diff changeset
6 Real += Complex; // expected-error {{assigning to 'float' from incompatible type '_Complex float'}}
anatofuz
parents:
diff changeset
7 Real += (float)Complex;
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 Real = Complex; // expected-error {{implicit conversion from '_Complex float' to 'float' is not permitted in C++}}
anatofuz
parents:
diff changeset
10 Real = (float)Complex;
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 take<float>(Complex); // expected-error {{implicit conversion from '_Complex float' to 'float' is not permitted in C++}}
anatofuz
parents:
diff changeset
13 take<double>(1.0i); // expected-error {{implicit conversion from '_Complex double' to 'double' is not permitted in C++}}
anatofuz
parents:
diff changeset
14 take<_Complex float>(Complex);
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 // Conversion to bool doesn't actually discard the imaginary part.
anatofuz
parents:
diff changeset
17 take<bool>(Complex);
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
18
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
19 using B = _Complex double;
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
20 B c;
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
21 c *= double();
150
anatofuz
parents:
diff changeset
22 }