]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add test for C++23 auto(x)
authorMarek Polacek <polacek@redhat.com>
Fri, 10 Dec 2021 18:07:19 +0000 (13:07 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 10 Dec 2021 18:09:13 +0000 (13:09 -0500)
I was curious if our auto(x) works in contexts like bit-field width
and similar.  It appears that it does.  Might be worth adding a test
for it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/auto-fncast10.C: New test.

gcc/testsuite/g++.dg/cpp23/auto-fncast10.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp23/auto-fncast10.C b/gcc/testsuite/g++.dg/cpp23/auto-fncast10.C
new file mode 100644 (file)
index 0000000..29c779b
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile { target c++23 } }
+
+struct S {
+  int i1 : auto(12);
+  int i2 : auto{12};
+  static constexpr auto x = auto(12);
+  static constexpr auto y = auto{12};
+};
+
+struct R {
+  int i;
+};
+
+static constexpr R r1 = { auto(23) };
+static constexpr R r2 = { auto{23} };
+enum E { X = auto(12), Y = auto{1u} };
+static_assert (auto(true));
+static_assert (auto{true});