[PATCH] Fix g++.dg/cpp2a/lambda-this3.C (Re: PATCH to enable testing C++17 by default)
Jakub Jelinek
jakub@redhat.com
Tue Oct 23 09:02:00 GMT 2018
On Wed, Oct 17, 2018 at 03:31:43PM -0400, Marek Polacek wrote:
> As discussed in <https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00752.html> it
> seems to be a high time we turned on testing C++17 by default.
>
> The only interesting part is at the very end, otherwise most of the changes is
> just using { target c++17 } instead of explicit dg-options. Removing
> dg-options has the effect that DEFAULT_CXXFLAGS comes in play, so I've removed
> a bunch of stray semicolons to fix -Wpedantic errors.
>
> I wonder if we also want to enable 2a, but the overhead could be too much. Or
> use 2a instead of 17?
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-10-17 Marek Polacek <polacek@redhat.com>
>
> * g++.dg/*.C: Use target c++17 instead of explicit dg-options.
> * lib/g++-dg.exp: Don't test C++11 by default. Add C++17 to
> the list of default stds to test.
> diff --git gcc/testsuite/g++.dg/cpp2a/lambda-this3.C gcc/testsuite/g++.dg/cpp2a/lambda-this3.C
> index 5e5c8b3d50f..d1738ea7d17 100644
> --- gcc/testsuite/g++.dg/cpp2a/lambda-this3.C
> +++ gcc/testsuite/g++.dg/cpp2a/lambda-this3.C
> @@ -1,6 +1,6 @@
> // P0806R2
> -// { dg-do compile }
> -// { dg-options "-std=c++17" }
> +// { dg-do compile { target c++17 } }
> +// { dg-options "" }
>
> struct X {
> int x;
This test now fails with -std=gnu++2a:
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C: In lambda function:
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:8:15: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated]
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:8:15: note: add explicit 'this' or '*this' capture
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C: In lambda function:
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:16:15: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated]
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:16:15: note: add explicit 'this' or '*this' capture
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:17:16: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated]
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:17:16: note: add explicit 'this' or '*this' capture
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:18:13: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated]
/.../gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this3.C:18:13: note: add explicit 'this' or '*this' capture
FAIL: g++.dg/cpp2a/lambda-this3.C -std=gnu++2a (test for bogus messages, line 8)
FAIL: g++.dg/cpp2a/lambda-this3.C -std=gnu++2a (test for bogus messages, line 16)
FAIL: g++.dg/cpp2a/lambda-this3.C -std=gnu++2a (test for bogus messages, line 17)
FAIL: g++.dg/cpp2a/lambda-this3.C -std=gnu++2a (test for bogus messages, line 18)
PASS: g++.dg/cpp2a/lambda-this3.C -std=gnu++2a (test for excess errors)
The following patch fixes this, tested on x86_64-linux with
make check-c++-all RUNTESTFLAGS=dg.exp=lambda-this3.C
Ok for trunk?
2018-10-23 Jakub Jelinek <jakub@redhat.com>
* g++.dg/cpp2a/lambda-this3.C: Limit dg-bogus directives to c++17_down only.
Add expected warnings and messages for c++2a.
--- gcc/testsuite/g++.dg/cpp2a/lambda-this3.C.jj 2018-10-22 09:28:06.807650016 +0200
+++ gcc/testsuite/g++.dg/cpp2a/lambda-this3.C 2018-10-23 10:48:13.992577673 +0200
@@ -5,7 +5,9 @@
struct X {
int x;
void foo (int n) {
- auto a1 = [=] { x = n; }; // { dg-bogus "implicit capture" }
+ auto a1 = [=] { x = n; }; // { dg-bogus "implicit capture" "" { target c++17_down } }
+ // { dg-warning "implicit capture of 'this' via '\\\[=\\\]' is deprecated" "" { target c++2a } .-1 }
+ // { dg-message "add explicit 'this' or '\\\*this' capture" "" { target c++2a } .-2 }
auto a2 = [=, this] { x = n; };
// { dg-warning "explicit by-copy capture" "" { target c++17_down } .-1 }
auto a3 = [=, *this]() mutable { x = n; };
@@ -13,9 +15,15 @@ struct X {
auto a5 = [&, this] { x = n; };
auto a6 = [&, *this]() mutable { x = n; };
- auto a7 = [=] { // { dg-bogus "implicit capture" }
- auto a = [=] { // { dg-bogus "implicit capture" }
- auto a2 = [=] { x = n; }; // { dg-bogus "implicit capture" }
+ auto a7 = [=] { // { dg-bogus "implicit capture" "" { target c++17_down } }
+ // { dg-warning "implicit capture of 'this' via '\\\[=\\\]' is deprecated" "" { target c++2a } .-1 }
+ // { dg-message "add explicit 'this' or '\\\*this' capture" "" { target c++2a } .-2 }
+ auto a = [=] { // { dg-bogus "implicit capture" "" { target c++17_down } }
+ // { dg-warning "implicit capture of 'this' via '\\\[=\\\]' is deprecated" "" { target c++2a } .-1 }
+ // { dg-message "add explicit 'this' or '\\\*this' capture" "" { target c++2a } .-2 }
+ auto a2 = [=] { x = n; }; // { dg-bogus "implicit capture" "" { target c++17_down } }
+ // { dg-warning "implicit capture of 'this' via '\\\[=\\\]' is deprecated" "" { target c++2a } .-1 }
+ // { dg-message "add explicit 'this' or '\\\*this' capture" "" { target c++2a } .-2 }
};
};
Jakub
More information about the Gcc-patches
mailing list