https://llvm.org/bugs/show_bug.cgi?id=23748

            Bug ID: 23748
           Summary: Tag lookup should not find hidden declarations
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Created attachment 14432
  --> https://llvm.org/bugs/attachment.cgi?id=14432&action=edit
a test case demonstrating the problem

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to