summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C
new file mode 100644
index 00000000000..8bb24cb2775
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-complex1.C
@@ -0,0 +1,24 @@
+// PR c++/88174
+// { dg-do compile { target c++14 } }
+
+constexpr bool
+foo (double x, double y, double z, double w)
+{
+ __complex__ double a = 0;
+ __real__ a = x;
+ __imag__ a = y;
+#if __cpp_constexpr >= 201907L
+ __complex__ double b;
+ __real__ b = z;
+#else
+ __complex__ double b = z;
+#endif
+ __imag__ b = w;
+ a += b;
+ a -= b;
+ a *= b;
+ a /= b;
+ return __real__ a == x && __imag__ a == y;
+}
+
+static_assert (foo (1.0, 2.0, 3.0, 4.0), "");