-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 23748 |
| Resolution | FIXED |
| Resolved on | Feb 10, 2016 13:27 |
| Version | trunk |
| OS | All |
| Attachments | a test case demonstrating the problem |
| CC | @DougGregor,@vgvassilev |
Extended Description
Currently, LookupResult::isHiddenDeclarationVisible() is defined as follows:
bool isHiddenDeclarationVisible() const {
return AllowHidden || LookupKind == Sema::LookupTagName;
}
This is trying to ensure that elaborated type specifiers are linked into existing declaration chains even if those declarations are hidden. This is necessary in C because we don't perform a second redeclaration lookup when the initial lookup didn't find anything. (It's not necessary in C++ because we have to perform that redeclaration lookup anyway, because of friends.)
Unfortunately, it can lead to incorrect results if the tag lookup finds something hidden in an inner scope when it should have found something non-hidden in an outer scope. That can't happen in C because there's only one open scope to which modules can add declarations, the global scope; but it can happen in C++ because of namespaces.
I've attached a simple testcase which reproduces the problem. The code should compile because the elaborated type specifier should find the non-hidden declaration ::A from Module.h instead of the hidden declaration ns::A from Submodule.h.