+2019-11-22 Jakub Jelinek <jakub@redhat.com>
+
+ Implement P1920R1, Missing feature-test macros 2017-2019.
+ * c-cppbuiltin.c (c_cpp_builtins): Bump __cpp_init_captures
+ and __cpp_generic_lambdas for -std=c++2a. Define
+ __cpp_designated_initializers, __cpp_constexpr_in_decltype and
+ __cpp_consteval for -std=c++2a. Remove a FIXME comment about
+ __cpp_concepts for -std=c++2a.
+
2019-11-22 Martin Sebor <msebor@redhat.com>
PR middle-end/83859
{
/* Set feature test macros for C++14. */
cpp_define (pfile, "__cpp_return_type_deduction=201304L");
- cpp_define (pfile, "__cpp_init_captures=201304L");
- cpp_define (pfile, "__cpp_generic_lambdas=201304L");
+ if (cxx_dialect <= cxx17)
+ {
+ cpp_define (pfile, "__cpp_init_captures=201304L");
+ cpp_define (pfile, "__cpp_generic_lambdas=201304L");
+ }
if (cxx_dialect <= cxx14)
cpp_define (pfile, "__cpp_constexpr=201304L");
cpp_define (pfile, "__cpp_decltype_auto=201304L");
if (cxx_dialect > cxx17)
{
/* Set feature test macros for C++2a. */
+ cpp_define (pfile, "__cpp_init_captures=201803L");
+ cpp_define (pfile, "__cpp_generic_lambdas=201707L");
+ cpp_define (pfile, "__cpp_designated_initializers=201707L");
+ cpp_define (pfile, "__cpp_constexpr_in_decltype=201711L");
cpp_define (pfile, "__cpp_conditional_explicit=201806L");
+ cpp_define (pfile, "__cpp_consteval=201811L");
cpp_define (pfile, "__cpp_constinit=201907L");
cpp_define (pfile, "__cpp_nontype_template_parameter_class=201806L");
cpp_define (pfile, "__cpp_impl_destroying_delete=201806L");
if (flag_concepts)
{
if (cxx_dialect >= cxx2a)
- /* FIXME: Update this to the value required by the IS. */
cpp_define (pfile, "__cpp_concepts=201907L");
else
cpp_define (pfile, "__cpp_concepts=201507L");
2019-11-22 Jakub Jelinek <jakub@redhat.com>
+ Implement P1920R1, Missing feature-test macros 2017-2019.
+ * g++.dg/cpp1z/feat-cxx1z.C: Only compile with -std=c++17.
+ * g++.dg/cpp2a/feat-cxx2a.C: Adjust for P1920R1 changes.
+ * g++.dg/cpp2a/desig15.C: New test.
+ * g++.dg/cpp2a/lambda-pack-init3.C: New test.
+ * g++.dg/cpp2a/lambda-generic6.C: New test.
+ * g++.dg/cpp2a/consteval15.C: New test.
+
PR tree-optimization/92618
* gcc.c-torture/compile/pr92618.c: New test.
* gcc.c-torture/execute/pr92618.c: New test.
-// { dg-do compile { target c++17 } }
-// { dg-options "-I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
+// { dg-do compile }
+// { dg-options "-std=c++17 -I${srcdir}/g++.dg/cpp1y -I${srcdir}/g++.dg/cpp1y/testinc" }
// C++98 features:
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+#if __cpp_consteval >= 201811L
+consteval
+#else
+constexpr
+#endif
+int
+foo (int x)
+{
+ return x * x * x * x;
+}
+
+auto a = foo (2);
--- /dev/null
+// { dg-do run }
+// { dg-options "-pedantic" }
+
+struct A { int a; };
+struct B { int b; A c; int d; };
+A a = { 1 };
+B c = { 3, { 4 }, 5 };
+#if __cpp_designated_initializers >= 201707L
+A b = { .a = 2 };
+B d = { .b = 6, .c { 7 }, .d = 8 };
+B e = { .c = { .a = 9 } };
+#else
+A b = { 2 };
+B d = { 6, { 7 }, 8 };
+B e = { 0, { 9 } };
+#endif
+
+int
+main ()
+{
+ if (a.a != 1 || b.a != 2
+ || c.b != 3 || c.c.a != 4 || c.d != 5
+ || d.b != 6 || d.c.a != 7 || d.d != 8
+ || e.b != 0 || e.c.a != 9 || e.d != 0)
+ __builtin_abort ();
+ return 0;
+}
#ifndef __cpp_init_captures
# error "__cpp_init_captures"
-#elif __cpp_init_captures != 201304
-# error "__cpp_init_captures != 201304"
+#elif __cpp_init_captures != 201803
+# error "__cpp_init_captures != 201803"
#endif
#ifndef __cpp_generic_lambdas
# error "__cpp_generic_lambdas"
-#elif __cpp_generic_lambdas != 201304
-# error "__cpp_generic_lambdas != 201304"
+#elif __cpp_generic_lambdas != 201707
+# error "__cpp_generic_lambdas != 201707"
#endif
#ifndef __cpp_constexpr
#elif __cpp_char8_t != 201811
# error "__cpp_char8_t != 201811"
#endif
+
+#ifndef __cpp_designated_initializers
+# error "__cpp_designated_initializers"
+#elif __cpp_designated_initializers != 201707
+# error "__cpp_designated_initializers != 201707"
+#endif
+
+#ifndef __cpp_constexpr_in_decltype
+# error "__cpp_constexpr_in_decltype"
+#elif __cpp_constexpr_in_decltype != 201711
+# error "__cpp_constexpr_in_decltype != 201711"
+#endif
+
+#ifndef __cpp_consteval
+# error "__cpp_consteval"
+#elif __cpp_consteval != 201811
+# error "__cpp_consteval != 201811"
+#endif
+
+#ifndef __cpp_concepts
+# error "__cpp_concepts"
+#elif __cpp_concepts != 201907
+# error "__cpp_concepts != 201907"
+#endif
--- /dev/null
+// P0428R2
+// { dg-do compile { target c++14 } }
+
+struct S { int s; };
+
+auto x =
+#if __cpp_generic_lambdas >= 201707
+ []<class T = S>(T &&t) { return t.s; } ({ 2 });
+#else
+ [](auto &&t) { return t.s; } (S { 2 });
+#endif
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+void bar();
+void bar(int);
+
+template <typename... Args>
+void foo(Args... args) {
+#if __cpp_init_captures >= 201803
+ auto f = [...xs=args]{
+ bar(xs...);
+ };
+#endif
+}
+
+int main()
+{
+ foo();
+ foo(1);
+}