From patchwork Thu May 9 03:55:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 242707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 125472C00D8 for ; Thu, 9 May 2013 13:55:29 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=yBocTcwjr26n/09M599VPwEdx51rTJ6sFBqYTAwsWC3zH6 c2/v7Fhd4p0X2/bL65eyUcTfV0+7FsX1jTiNDV214y7zJHsth6/KgQrLqvTSYKNW n222mX3YsOEdwj4y5b63tgZ264hrEEqctUUX3MqjxT3H3jh6eWn0730byIaNs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=69V+D4Mz2xWegq2UbI71oodlkm4=; b=WJ3qfxXZW/SGWJIBCAhM uhxWxHAGaa7UWw1Jmn64yhfIEQDmcTHVNhdmmEE6+0y6kYzHHRcpZJW/0+Kx5HhY 3CPtA2NQ0dvax+J3macqRxTtGH+iuw3dggZnqTB+TGoHQdYfed3nwr9ECwryRNRI XfQXkpYlLYlnfEdSrmtYLqo= Received: (qmail 7768 invoked by alias); 9 May 2013 03:55:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7749 invoked by uid 89); 9 May 2013 03:55:21 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 09 May 2013 03:55:20 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r493tIF4017987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 May 2013 23:55:18 -0400 Received: from [10.3.113.33] (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r493tHRu005943 for ; Wed, 8 May 2013 23:55:18 -0400 Message-ID: <518B1E25.4090404@redhat.com> Date: Wed, 08 May 2013 23:55:17 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Thunderbird/22.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/57068 (wrong ref-qualifier error) X-Virus-Found: No A case of giving an error during tentative parsing; we need to wait until we know for sure that we're doing something dodgy. Tested x86_64-pc-linux-gnu, applying to trunk and 4.8. commit 4d01649f80e76af9be37b35d166a00990defa978 Author: Jason Merrill Date: Wed May 8 12:33:26 2013 -0400 PR c++/57068 * decl.c (grokdeclarator): Warn about ref-qualifiers here. * parser.c (cp_parser_ref_qualifier_seq_opt): Not here. * error.c (maybe_warn_cpp0x): s/0x/11/. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a3250a2..bd9afc8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9577,6 +9577,7 @@ grokdeclarator (const cp_declarator *declarator, if (rqual) { + maybe_warn_cpp0x (CPP0X_REF_QUALIFIER); error ((flags == DTOR_FLAG) ? "destructors may not be ref-qualified" : "constructors may not be ref-qualified"); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 48327dd..a75fc4e 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -3404,7 +3404,7 @@ maybe_warn_cpp0x (cpp0x_warn_str str) break; case CPP0X_AUTO: pedwarn (input_location, 0, - "C++0x auto only available with -std=c++11 or -std=gnu++11"); + "C++11 auto only available with -std=c++11 or -std=gnu++11"); break; case CPP0X_SCOPED_ENUMS: pedwarn (input_location, 0, @@ -3453,7 +3453,7 @@ maybe_warn_cpp0x (cpp0x_warn_str str) case CPP0X_REF_QUALIFIER: pedwarn (input_location, 0, "ref-qualifiers " - "only available with -std=c++0x or -std=gnu++0x"); + "only available with -std=c++11 or -std=gnu++11"); break; default: gcc_unreachable (); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6de8e1a..8d3f6c7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17199,9 +17199,6 @@ cp_parser_ref_qualifier_opt (cp_parser* parser) } } - if (ref_qual) - maybe_warn_cpp0x (CPP0X_REF_QUALIFIER); - return ref_qual; } diff --git a/gcc/testsuite/g++.dg/parse/ref-qual1.C b/gcc/testsuite/g++.dg/parse/ref-qual1.C new file mode 100644 index 0000000..e3f60c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ref-qual1.C @@ -0,0 +1,29 @@ +// PR c++/57068 + +enum Enums { + Enum1 = 0x00000000, + Enum2 = 0x00000001 +}; + +class Flags { +public: + Flags() : i(0) {} + Flags(int i): i(i) {} + Flags operator&(Enums f) { return Flags(Enums(i & f)); } + + operator bool() { return i; } +private: + int i; +}; + +Flags windowState() +{ + return Flags(); +} + +int main() +{ + if (bool(windowState() & Enum1) == true) + return 1; + return 0; +}