diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
| commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
| tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/SemaCXX/complex-conversion.cpp | |
| parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) | |
Notes
Diffstat (limited to 'test/SemaCXX/complex-conversion.cpp')
| -rw-r--r-- | test/SemaCXX/complex-conversion.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/SemaCXX/complex-conversion.cpp b/test/SemaCXX/complex-conversion.cpp new file mode 100644 index 000000000000..e8f09958165c --- /dev/null +++ b/test/SemaCXX/complex-conversion.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template<typename T> void take(T); + +void func(float Real, _Complex float Complex) { + Real += Complex; // expected-error {{assigning to 'float' from incompatible type '_Complex float'}} + Real += (float)Complex; + + Real = Complex; // expected-error {{implicit conversion from '_Complex float' to 'float' is not permitted in C++}} + Real = (float)Complex; + + take<float>(Complex); // expected-error {{implicit conversion from '_Complex float' to 'float' is not permitted in C++}} + take<double>(1.0i); // expected-error {{implicit conversion from '_Complex double' to 'double' is not permitted in C++}} + take<_Complex float>(Complex); + + // Conversion to bool doesn't actually discard the imaginary part. + take<bool>(Complex); +} |
