Bug 48489 - Invalid error message 'has no member named' when referring directly to the base class
Summary: Invalid error message 'has no member named' when referring directly to the ba...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.1
: P3 minor
Target Milestone: 4.7.0
Assignee: Paolo Carlini
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2011-04-07 11:59 UTC by Michal Malecki
Modified: 2011-10-17 09:50 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-04-07 13:02:52


Attachments
Short C++ code that reproduces the problem. (468 bytes, application/octet-stream)
2011-04-07 11:59 UTC, Michal Malecki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Malecki 2011-04-07 11:59:17 UTC
Created attachment 23908 [details]
Short C++ code that reproduces the problem.

There is one case, having that:

struct Base { };
struct Concrete: Base { void setValue( string, string ); };

and using:

v->BaseType::setValue( this->name, this->value );

[with template parameter BaseType = Base]

generates the following error:

newmpl.cc:37:35: error: ‘struct Concrete’ has no member named ‘setValue’

which is a lie, because Concrete::setValue exists. The mistaken here is the name of the class that does not have given member, which should be ‘struct Base’ here, because this call refers directly to the given class (not to the 'v' pointer's class).

Please find the reproduction example in attachment (no dependencies but C++ standard library). You can see that the 'Base' class has 'setValue' commented out in order to make this error occur.

The same behavior is with the latest version, gcc 4.7.0.
Comment 1 Jonathan Wakely 2011-04-07 13:02:52 UTC
The attachment can be simplified to:

struct Base{ };

struct Concrete : Base
{
    void setValue();
};

int main()
{
    Concrete d;
    d.Base::setValue();
}


which gives the error:
error: 'struct Concrete' has no member named 'setValue'

expected:
error: 'struct Base' has no member named 'setValue'
Comment 2 Paolo Carlini 2011-10-16 18:24:48 UTC
On it.
Comment 3 paolo@gcc.gnu.org 2011-10-17 09:48:06 UTC
Author: paolo
Date: Mon Oct 17 09:48:02 2011
New Revision: 180080

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180080
Log:
/cp
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48489
	* typeck.c (finish_class_member_access_expr): Fix error call
	for TREE_CODE (access_path) == TREE_BINFO.

/testsuite
2011-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48489
	* g++.dg/inherit/error5.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/error5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2011-10-17 09:50:18 UTC
Fixed for 4.7.0.