From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21977 invoked by alias); 12 Mar 2012 16:25:28 -0000 Received: (qmail 21968 invoked by uid 22791); 12 Mar 2012 16:25:26 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Mar 2012 16:25:13 +0000 From: "shihjr at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly Date: Mon, 12 Mar 2012 16:25:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shihjr at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2012-03/txt/msg00907.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566 Bug #: 52566 Summary: #include in c++ namespace scope doesn't work properly Classification: Unclassified Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor AssignedTo: unassigned@gcc.gnu.org ReportedBy: shihjr@gmail.com # gcc --version gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 3 source files: ns1.h ns2.h test.cpp --------------------------------------------------------- ns1.h: #pragma once class A { }; --------------------------------------------------------- ns2.h: #pragma once class A { }; --------------------------------------------------------- test.cpp: namespace NS1 { #include "ns1.h" } namespace NS2 { #include "ns2.h" } int main() { NS2::A a; return 0; } --------------------------------------------------------- # touch * // important step, let ns1.h and ns2.h have same modification time # gcc test.cpp test.cpp: In function 'int main()': test.cpp:11: error: 'A' is not a member of 'NS2' test.cpp:11: error: expected ';' before 'a' # gcc -c -E test.cpp # 1 "test.cpp" # 1 "" # 1 "" # 1 "test.cpp" namespace NS1 { # 1 "ns1.h" 1 class A { }; # 4 "test.cpp" 2 } namespace NS2 { } int main() { NS2::A a; return 0; } ---------------------------------------------------- The NS2::A declaration isn't included in namespace NS2