public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20293] New: namespace name lost
@ 2005-03-02 22:19 igodard at pacbell dot net
  2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-03-02 22:19 UTC (permalink / raw)
  To: gcc-bugs

In:
namespace hide {
    int k;
    }

namespace {
    int i;
    namespace hide {
        int j;
        }
    }

void F(int) {}

int main() {
    F(i);
    F(hide::j);
    }

you get:

~/ootbc/members/src$ g++ foo.cc
foo.cc: In function `int main()':
foo.cc:16: error: `hide' has not been declared
foo.cc:16: error: `j' undeclared (first use this function)
foo.cc:16: error: (Each undeclared identifier is reported only once for each
function it appears in.)

i.e. the lookup for "hide" fails whereas a simple variable "i" is found.

My (probably erroneous) understanding is that the anonymous namespace has no 
impact on name scope; exports all names declared within it to filescope; and 
simply replaces the old "static" to prevent cluttering the linker namespace. 
That seems to be the case with "i". However, if that rule were applied to "hide" 
then the two "hide"s would be at the same level and would merge as namespaces 
do, rather than the inner one being hidden as happened. This problem arose 
because I was trying to declare a filescope name ("j") in a way that *neither* 
cluttered the compiler's space nor the linkers. 

If this is in fact an error, please change this report to a complaint about the 
diagnostic.

Ivan

-- 
           Summary: namespace name lost
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
@ 2005-03-02 23:01 ` pinskia at gcc dot gnu dot org
  2005-03-02 23:03 ` [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access bangerth at dealii dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-02 23:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-02 23:01 -------
Confirmed, this is invalid code as the namespace hide is ambiguous but the diagnostic is just plainly 
bogus. Related to both PR 100 and bug 12272.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |100, 12272
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2005-03-02 23:01:37
               date|                            |
            Summary|namespace name lost         |ambiguous namespace and
                   |                            |diagnostic, unamed namespace


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
  2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
@ 2005-03-02 23:03 ` bangerth at dealii dot org
  2005-03-02 23:24 ` giovannibajo at libero dot it
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-03-02 23:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-03-02 23:03 -------
This is indeed a diagnostic problem: the access is ambiguous, but instead 
of saying so gcc chooses to mention that there is no such name at all. This 
happens in many places, and I believe that there must be at least half 
a dozen PRs about this. 
 
This is in fact also a regression, since before the new parser we got this: 
 
g/x> /home/bangerth/bin/gcc-3.3*/bin/c++ -c x.cc 
x.cc: In function `int main()': 
x.cc:16: error: use of `hide' is ambiguous 
x.cc:1: error:   first declared as `hide' here 
x.cc:7: error:   also declared as `<unnamed>::hide' here 
x.cc:16: error: parse error before `::' token 
 
icc says this: 
g/x> icc -c x.cc 
x.cc(16): error: "hide" is ambiguous 
      F(hide::j); 
        ^ 
 
compilation aborted for x.cc (code 2) 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|100, 12272                  |
           Severity|enhancement                 |normal
      Known to fail|                            |3.4.3 4.0.0 4.1.0
      Known to work|                            |2.95 3.2 3.3
   Last reconfirmed|2005-03-02 23:01:37         |2005-03-02 23:03:15
               date|                            |
            Summary|ambiguous namespace and     |[3.4/4.0/4.1 regression]
                   |diagnostic, unamed namespace|Wrong diagnostic for
                   |                            |ambiguous access
   Target Milestone|---                         |3.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
  2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
  2005-03-02 23:03 ` [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access bangerth at dealii dot org
@ 2005-03-02 23:24 ` giovannibajo at libero dot it
  2005-03-08  2:31 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2005-03-02 23:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-03-02 23:24 -------
(merging bugzilla conflicts...)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |100, 12272


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2005-03-02 23:24 ` giovannibajo at libero dot it
@ 2005-03-08  2:31 ` pinskia at gcc dot gnu dot org
  2005-03-11 16:27 ` lerdsuwa at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-08  2:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-08 02:31 -------
The diagnostic changed when the new parser was merged in (between 20021213 and 20021228).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2005-03-08  2:31 ` pinskia at gcc dot gnu dot org
@ 2005-03-11 16:27 ` lerdsuwa at gcc dot gnu dot org
  2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-11 16:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lerdsuwa at gcc dot gnu dot org  2005-03-11 16:27 -------
The diagnostic is missing due to calling lookup_name_real inside
cp_parser_lookup_name without the LOOKUP_COMPLAIN flag.  Too bad
we cannot just add this flag because this will cause duplicate
error messages.  cp_parser_lookup_name are called multiple times
during tentative parse.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2005-03-11 16:27 ` lerdsuwa at gcc dot gnu dot org
@ 2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org
  2005-07-22 21:17 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:35 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.4                       |3.4.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (5 preceding siblings ...)
  2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org
@ 2005-07-22 21:17 ` pinskia at gcc dot gnu dot org
  2005-09-11  1:51 ` bangerth at dealii dot org
  2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-22 21:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-22 21:13 -------
Moving to 4.0.2 pre Mark.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.5                       |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (6 preceding siblings ...)
  2005-07-22 21:17 ` pinskia at gcc dot gnu dot org
@ 2005-09-11  1:51 ` bangerth at dealii dot org
  2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-09-11  1:51 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 20293 depends on bug 100, which changed state.

Bug 100 Summary: confusing name lookup diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=100

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
  2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
                   ` (7 preceding siblings ...)
  2005-09-11  1:51 ` bangerth at dealii dot org
@ 2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:13 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
       [not found] <bug-20293-6594@http.gcc.gnu.org/bugzilla/>
  2005-10-31  2:49 ` mmitchel at gcc dot gnu dot org
  2005-11-14  1:32 ` mmitchel at gcc dot gnu dot org
@ 2005-11-14  1:45 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-11-14  1:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mmitchel at gcc dot gnu dot org  2005-11-14 01:45 -------
Subject: Bug 20293

Author: mmitchel
Date: Mon Nov 14 01:45:19 2005
New Revision: 106879

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106879
Log:
        PR c++/20293
        * cxx-pretty-print.c (pp_cxx_statement): Print qualifying scopes
        for namespaces.
        (pp_cxx_original_namespace_definition): Likewise.
        * name-lookup.c (ambiguous_decl): Don't issue error messages;
        instead return lists of ambiguous candidates.
        (select_decl): Handle ambiguous namespace lookups.
        * parser.c (cp_token): Add ambiguous_p.
        (cp_lexer_get_preprocessor_token): Set it.
        (cp_parser_diagnose_invalid_type_name): Avoid duplicate messages
        when a qualified name uses an invalid scope. 
        (cp_parser_primary_expression): Print ambiguous candidates.
        (cp_parser_type_parameter): Adjust comment to reflect new
        parameter name for cp_parser_lookup_name.
        (cp_parser_template_argument): Likewise.
        (cp_parser_elaborated_type_specifier): Likewise.
        (cp_parser_namespace_name): Likewise.
        (cp_parser_class_name): Print ambiguous candidates.
        (cp_parser_lookup_name): Rename ambiguous_p parameter to
        ambiguous_decls.  Use it to return a list of ambiguous candiates
        when a lookup is ambiguous.
        (cp_parser_lookup_name_simple): Adjust comment to reflect new
        parameter name for cp_parser_lookup_name.

        PR c++/20293
        * g++.dg/parse/ambig4.C: New test.
        * g++.dg/tc1/dr101.C: Adjust error markers.
        * g++.dg/lookup/strong-using-2.C: Likewise.
        * g++.dg/lookup/ambig5.C: Likewise.
        * g++.dg/lookup/ambig4.C: Likewise.
        * g++.dg/parse/crash22.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/parse/ambig4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cxx-pretty-print.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/lookup/ambig4.C
    trunk/gcc/testsuite/g++.dg/lookup/ambig5.C
    trunk/gcc/testsuite/g++.dg/lookup/strong-using-2.C
    trunk/gcc/testsuite/g++.dg/parse/crash22.C
    trunk/gcc/testsuite/g++.dg/tc1/dr101.C


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
       [not found] <bug-20293-6594@http.gcc.gnu.org/bugzilla/>
  2005-10-31  2:49 ` mmitchel at gcc dot gnu dot org
@ 2005-11-14  1:32 ` mmitchel at gcc dot gnu dot org
  2005-11-14  1:45 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-11-14  1:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access
       [not found] <bug-20293-6594@http.gcc.gnu.org/bugzilla/>
@ 2005-10-31  2:49 ` mmitchel at gcc dot gnu dot org
  2005-11-14  1:32 ` mmitchel at gcc dot gnu dot org
  2005-11-14  1:45 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-31  2:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mmitchel at gcc dot gnu dot org  2005-10-31 02:49 -------
Leaving as P2; we should try to fix this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-11-14  1:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
2005-03-02 23:03 ` [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access bangerth at dealii dot org
2005-03-02 23:24 ` giovannibajo at libero dot it
2005-03-08  2:31 ` pinskia at gcc dot gnu dot org
2005-03-11 16:27 ` lerdsuwa at gcc dot gnu dot org
2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org
2005-07-22 21:17 ` pinskia at gcc dot gnu dot org
2005-09-11  1:51 ` bangerth at dealii dot org
2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-20293-6594@http.gcc.gnu.org/bugzilla/>
2005-10-31  2:49 ` mmitchel at gcc dot gnu dot org
2005-11-14  1:32 ` mmitchel at gcc dot gnu dot org
2005-11-14  1:45 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).