Bug 39699 - No error reporting when function and variable have the same name
Summary: No error reporting when function and variable have the same name
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-09 16:24 UTC by BRULE Herman
Modified: 2011-09-25 16:04 UTC (History)
0 users

See Also:
Host: linux x86_64
Target: linux x86_64
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description BRULE Herman 2009-04-09 16:24:33 UTC
Hello, no error reporting when function and variable have the same name in class.
Please do this check and show this error.
Comment 1 Richard Biener 2009-04-09 21:17:02 UTC
We need a testcase.
Comment 2 BRULE Herman 2009-04-10 04:47:25 UTC
class toto
{
      enum e {a,b};
      e test_example();
      e test_example;
};
Comment 3 Dodji Seketeli 2009-04-10 11:46:51 UTC
Subject: Re:  No error reporting when function and variable
 have the same name

alpha dot super-one at laposte dot net a écrit :
> ------- Comment #2 from alpha dot super-one at laposte dot net  2009-04-10 04:47 -------

So I compiled this program:

     1  class toto
     2  {
     3        enum e {a,b};
     4        e test_example();
     5        e test_example;
     6  };
     7
     8  toto t;

with the -Wall option of g++ 4.3.2, I got:

test.cc:5: error: declaration of 'toto::e toto::test_example'
test.cc:4: error: conflicts with previous declaration 'toto::e toto::test_example()'

So that does what you want I guess.

Comment 4 BRULE Herman 2009-04-10 15:42:57 UTC
I have not that's in lot of version, my code tested is here:
http://www.developpez.net/forums/m4191192-3/
Comment 5 Paolo Carlini 2011-09-25 16:04:24 UTC
Works everywhere.