[LLVMbugs] [Bug 23748] New: Tag lookup should not find hidden declarations

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 3 16:17:09 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: rjmccall at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150603/7591cdce/attachment.html>


More information about the llvm-bugs mailing list