From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14603 invoked by alias); 22 May 2011 22:25:59 -0000 Received: (qmail 14589 invoked by uid 22791); 22 May 2011 22:25:58 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 May 2011 22:25:43 +0000 Received: by qwh5 with SMTP id 5so2892808qwh.20 for ; Sun, 22 May 2011 15:25:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.118.72 with SMTP id u8mr1216996qcq.1.1306103141854; Sun, 22 May 2011 15:25:41 -0700 (PDT) Received: by 10.229.11.143 with HTTP; Sun, 22 May 2011 15:25:41 -0700 (PDT) In-Reply-To: References: <1268945454.2219.13.camel@janis-laptop> <20110522193335.GA9729@bromo.med.uc.edu> Date: Mon, 23 May 2011 08:34:00 -0000 Message-ID: Subject: Re: [PATCH][4.6] detect C++ errors to fix 2288 and 18770 From: "H.J. Lu" To: Gerald Pfeifer Cc: Jack Howarth , Janis Johnson , gcc-patches@gcc.gnu.org, Richard Guenther Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01587.txt.bz2 On Sun, May 22, 2011 at 2:29 PM, Gerald Pfeifer wrote: > On Sun, 22 May 2011, Jack Howarth wrote: >>> 2010-03-18 =A0Janis Johnson =A0 >>> >>> gcc/cp >>> =A0 =A0 =A0PR c++/2288 >>> =A0 =A0 =A0PR c++/18770 >>> =A0 =A0 =A0* name-lookup.h (enum scope_kind): Add sk_cond. >>> =A0 =A0 =A0* name-lookup.c (pushdecl_maybe_friend): Get scope of shadow= ed local. >>> =A0 =A0 =A0Detect and report error for redeclaration from for-init or if >>> =A0 =A0 =A0or switch condition. >>> =A0 =A0 =A0(begin_scope): Handle sk_cond. >>> =A0 =A0 =A0* semantics.c (begin_if_stmt): Use sk_cond. >>> =A0 =A0 =A0(begin switch_stmt): Ditto. >>> >>> gcc/testsuite/ >>> =A0 =A0 =A0PR c++/2288 >>> =A0 =A0 =A0PR c++/18770 >>> =A0 =A0 =A0* g++.old-deja/g++.jason/cond.C: Remove xfails. >>> =A0 =A0 =A0* g++.dg/parse/pr18770.C: New test. >> Any chance we can get this committed to gcc trunk while in 4.7 stage 1 >> (since it was already approved for 4.6 stage 1 and never applied... >> http://gcc.gnu.org/ml/gcc-patches/2010-05/msg00264.html). It would be >> nice to have in gcc 4.7 so that other open source projects that only >> build against g++ would be alerted to fix their sources. > > It's my understanding that an approved patch can be committed by anyone > with write access unless it is retracted or there is some other reason > not to. Customary that is left to the submitter if she has write access, > of course. > FWIW, I tried Janis's patch on 4.6 branch and I got /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C: In function 'void e1()':^M /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C:29:11: error: redeclaration of 'int k'^M /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C:27:12: error: 'int k' previously declared here^M /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C: In function 'void e4()':^M /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C:63:11: error: redeclaration of 'int i'^M /export/gnu/import/git/gcc/gcc/testsuite/g++.dg/parse/pr18770.C:61:14: error: 'int i' previously declared here^M FAIL: g++.dg/parse/pr18770.C prev (test for errors, line 14) FAIL: g++.dg/parse/pr18770.C redecl (test for errors, line 17) PASS: g++.dg/parse/pr18770.C prev (test for errors, line 27) PASS: g++.dg/parse/pr18770.C redecl (test for errors, line 29) FAIL: g++.dg/parse/pr18770.C prev (test for errors, line 37) FAIL: g++.dg/parse/pr18770.C redecl (test for errors, line 39) FAIL: g++.dg/parse/pr18770.C prev (test for errors, line 47) FAIL: g++.dg/parse/pr18770.C redecl (test for errors, line 53) PASS: g++.dg/parse/pr18770.C prev (test for errors, line 61) PASS: g++.dg/parse/pr18770.C redecl (test for errors, line 63) FAIL: g++.dg/parse/pr18770.C prev (test for errors, line 71) FAIL: g++.dg/parse/pr18770.C redecl (test for errors, line 73) PASS: g++.dg/parse/pr18770.C (test for excess errors) /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C: In function 'int main()':^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:22:1= 1: error: redeclaration of 'int i'^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:20:1= 4: error: 'int i' previously declared here^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:27:1= 1: error: redeclaration of 'int i'^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:25:1= 4: error: 'int i' previously declared here^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:36:1= 6: error: types may not be defined in conditions^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:39:3: error: 'A' was not declared in this scope^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:39:5: error: expected ';' before 'bar'^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:42:1= 2: error: types may not be defined in conditions^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:42:4= 0: error: 'one' was not declared in this scope^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:51:1= 4: warning: declaration of 'int f()' has 'extern' and is initialized [enabled by default]^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:51:1= 8: error: function 'int f()' is initialized like a variable^M /export/gnu/import/git/gcc/gcc/testsuite/g++.old-deja/g++.jason/cond.C:55:2= 3: error: extended initializer lists only available with -std=3Dc++0x or -std=3Dgnu++0x^M FAIL: g++.old-deja/g++.jason/cond.C (test for errors, line 9) FAIL: g++.old-deja/g++.jason/cond.C (test for errors, line 11) FAIL: g++.old-deja/g++.jason/cond.C (test for errors, line 16) PASS: g++.old-deja/g++.jason/cond.C (test for errors, line 20) PASS: g++.old-deja/g++.jason/cond.C (test for errors, line 22) PASS: g++.old-deja/g++.jason/cond.C (test for errors, line 25) PASS: g++.old-deja/g++.jason/cond.C (test for errors, line 27) FAIL: g++.old-deja/g++.jason/cond.C (test for errors, line 30) FAIL: g++.old-deja/g++.jason/cond.C (test for errors, line 33) PASS: g++.old-deja/g++.jason/cond.C (test for errors, line 36) PASS: g++.old-deja/g++.jason/cond.C decl (test for errors, line 39) PASS: g++.old-deja/g++.jason/cond.C exp (test for errors, line 39) PASS: g++.old-deja/g++.jason/cond.C def (test for errors, line 42) PASS: g++.old-deja/g++.jason/cond.C expected (test for errors, line 42) PASS: g++.old-deja/g++.jason/cond.C extern (test for warnings, line 51) The patch no longer catches all problems. --=20 H.J.