From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10748 invoked by alias); 1 Aug 2002 17:46:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10728 invoked by uid 71); 1 Aug 2002 17:46:02 -0000 Resent-Date: 1 Aug 2002 17:46:02 -0000 Resent-Message-ID: <20020801174602.10727.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, ben@timing.com Received: (qmail 6530 invoked by uid 61); 1 Aug 2002 17:36:39 -0000 Message-Id: <20020801173639.6529.qmail@sources.redhat.com> Date: Thu, 01 Aug 2002 10:46:00 -0000 From: ben@timing.com Reply-To: ben@timing.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7467: method & class w/same name gives unhelpful error. X-SW-Source: 2002-08/txt/msg00004.txt.bz2 List-Id: >Number: 7467 >Category: c++ >Synopsis: method & class w/same name gives unhelpful error. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Aug 01 10:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: ben@timing.com >Release: gcc version 2.95.3 [FreeBSD] 20010315 (release) >Organization: >Environment: piglet.ttyp3.0$ uname -a FreeBSD piglet.timing.com 4.3-RELEASE-TSC FreeBSD 4.3-RELEASE-TSC #1: Mon Aug 20 16:03:52 MDT 2001 root@piglet.timing.com:/home/ben/newpig/FreeBSD-tsc-4/sys/compile/SMPIGLET i386 >Description: When a class is given the same name as a method in your inheritance hierarchy, g++ emits the same error as if the class name were undefined. Example: If you have a class, A, with a method A::foo() and then also define a class foo, if you attempt to use a variable of type foo within class A, you get the error "syntax error before `;'" from g++. This is the same error you would get if you mistyped foo as f00. This error can be easy to reproduce if you have a complex inheritance lattice (perhaps from a third party library) and you accidentally name a class in a program to have the same name as a method in the inheritance lattice. You then end up with the puzzling situation where your newly defined class can be used in some instances, and not in others. I request a clarification of the syntax error in this case to emit a more particular error message. Since in the scope of the class with the method name that clashes with the class name you are attempting to define a variable of type "method name", the error message should indicate that there is such a clash, or at least that the compiler thinks you're a dummy for trying to declare a variable with a type that has the same name as a method in that classes inheritance hierarchy. >How-To-Repeat: Simple test case to reproduce: #include class A { public: A() {}; void foo() {}; foo bar; }; class foo { public: foo() {}; }; main() { A oink; // gives same error as: // B oink; // (B not defn'd) } >Fix: >Release-Note: >Audit-Trail: >Unformatted: