Skip to content

Tag lookup should not find hidden declarations #24122

@rjmccall

Description

@rjmccall
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions