From patchwork Sun Sep 11 14:22:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 15508 Received: (qmail 45475 invoked by alias); 11 Sep 2016 14:22:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 45457 invoked by uid 89); 11 Sep 2016 14:22:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=BG, $B!G, $b!g X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Sep 2016 14:22:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 953FEC049D59 for ; Sun, 11 Sep 2016 14:22:51 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8BEMmap008388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 11 Sep 2016 10:22:50 -0400 Date: Sun, 11 Sep 2016 16:22:48 +0200 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp Message-ID: <20160911142248.GA12817@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.0 (2016-08-17) X-IsSubscribed: yes Hi, gcc-6.2.1-1.fc26.x86_64 g++ -std=c++03: no warnings g++: In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:0: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:34: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float gnu_obj_4::somewhere’ of non-integral type [-fpermissive] static const float somewhere = 3.14159; ^~~~~~~ clang++: In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init] static const float somewhere = 3.14159; ^ ~~~~~~~ 1 warning generated. clang++ -std=c++11: In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: error: in-class initializer for static data member of type 'const float' requires 'constexpr' specifier [-Wstatic-float-init] static const float somewhere = 3.14159; ^ ~~~~~~~ /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:3: note: add 'constexpr' static const float somewhere = 3.14159; ^ constexpr 1 error generated. OK for check-in? After the fix out of the 4 combinations above only this one remains non-empty: clang++: In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init] static const float somewhere = 3.14159; ^ ~~~~~~~ 1 warning generated. Jan gdb/testsuite/ChangeLog 2016-09-11 Jan Kratochvil * gdb.cp/m-static.h (gnu_obj_4::somewhere): Use constexpr for C++11. diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h index bcedfff..2992463 100644 --- a/gdb/testsuite/gdb.cp/m-static.h +++ b/gdb/testsuite/gdb.cp/m-static.h @@ -6,6 +6,9 @@ class gnu_obj_4 static const int elsewhere; static const int nowhere; static const int everywhere = 317; +#if __cplusplus >= 201103L + constexpr +#endif static const float somewhere = 3.14159; // try to ensure test4 is actually allocated