From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18273 invoked by alias); 8 Jul 2007 22:41:05 -0000 Received: (qmail 18220 invoked by uid 48); 8 Jul 2007 22:40:56 -0000 Date: Sun, 08 Jul 2007 22:41:00 -0000 Message-ID: <20070708224056.18219.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/30917] [4.1/4.2/4.3 Regression] ICE with friend in local class (to a function) In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mmitchel at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg00984.txt.bz2 ------- Comment #5 from mmitchel at gcc dot gnu dot org 2007-07-08 22:40 ------- Simon -- It took me a while to decide that this patch was OK -- but it is. :-) I will suggest a few changes to make it more obviously correct. First, minor coding style nit: drop the else after the return that you've introduced. Second, we need some chapter-and-verse in here. Please avoid references like "11.4.8" as the numbers tend to move around as the standard changes. (For example, I don't think 11.4.8 is the right reference in either the published standard or the current WP.) For the comment on the gcc_asert, I would say: /* A non namespace-scope binding can only be hidden if we are in a local class, due to friend declarations. In particular, consider: void f() { struct A { friend struct B; void g() { B* b; } // error: B is hidden } struct B {}; } The standard says that "B" is a local class in "f" (but not nested within "A") -- but that name lookup for "B" does not find this declaration until it is declared directly with "f". In particular: [class.friend] If a friend declaration appears in a local class and the name specified is an unqualified name, a prior declaration is looked up without considering scopes that are outside the innermost enclosing non-class scope.... For a friend class declaration, if there is no prior declaration, the class that is specified belongs to the innermost enclosing non-class scope, but if it is subsequently referenced, its name is not found by name lookup until a matching declaration is provided in the innermost enclosing nonclass scope. */ OK with that change. Thanks, -- Mark -- mmitchel at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simartin at users dot | |sourceforge dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30917