Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang will ignore using declarations from qualified name lookups when handling declarators #62174

Closed
ChuanqiXu9 opened this issue Apr 17, 2023 · 4 comments
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@ChuanqiXu9
Copy link
Member

ChuanqiXu9 commented Apr 17, 2023

See https://godbolt.org/z/8eef5nsEs and the text form is:

namespace lib {
    namespace impl {
        template <class>
        inline constexpr bool test = false;
    }
    using impl::test;
}

struct foo {};

template <>
inline constexpr bool lib::test<foo> = true;

static_assert(lib::test<foo>);

GCC will accept this but Clang will reject this.

@ChuanqiXu9 ChuanqiXu9 added the c++ label Apr 17, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 17, 2023

@llvm/issue-subscribers-c-1

@ChuanqiXu9
Copy link
Member Author

I sent https://reviews.llvm.org/D148506 as a ad-hoc patch.

@ChuanqiXu9 ChuanqiXu9 changed the title Clang will ignore using declarations from qualified names when handling declarators Clang will ignore using declarations from qualified name lookups when handling declarators Apr 17, 2023
@Endilll
Copy link
Contributor

Endilll commented Apr 17, 2023

I think GCC behaves correctly, and Clang doesn't:

  1. test on line 12 is a qualified name (basicl.lookup.qual/2.4.5).
  2. test has to undergo a qualified name lookup in the lookup context of lib from the point where it appears (basicl.lookup.qual/3).
  3. Qualified name lookup is a search in associated scope (basicl.lookup.qual/3).
  4. Search is a single search, because lib is not a class or class template (class.member.lookup/1).
  5. Single search finds all declarations in lib that precede the point where test appears, taking into account using declarations whose terminal name is not dependent (basic.lookup.general/3).
  6. Name test on line 6 is not dependent (temp.dep.type/5), which means it should be found.

Most of this wording comes from P1787R6. I hope this helps!

@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Apr 17, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 17, 2023

@llvm/issue-subscribers-clang-frontend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants