llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.39k stars 11.73k forks source link

Clang fails to resolve some names inside templates/lambdas under -fdelayed-template-parsing or --driver-mode=cl #94585

Open higher-performance opened 4 months ago

higher-performance commented 4 months ago

Repro:

struct Outer
{
    template<class = void>
    static void foo()
    {
        struct S
        {
        };
        auto const g = []()
        {
            struct H
            {
                static void f()
                {
                    typedef S S;  // error: unknown type name 'S'
                }
            };
        };
    }
};

int main()
{
    Outer().foo();
}

Both Clang and MSVC compile this fine with eager template parsing, but clang-cl fails to compile it due to delayed template parsing.

This makes clang-cl incompatible with MSVC.

Note that MSVC always handles this fine, regardless of /permissive[-] or /Zc:twoPhase[-].

llvmbot commented 4 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (higher-performance)

[Repro](https://godbolt.org/z/fM8rdcG4d): ``` struct Outer { template<class = void> static void foo() { struct S { }; auto const g = []() { struct H { static void f() { typedef S S; // error: unknown type name 'S' } }; }; } }; int main() { Outer().foo(); } ``` Both Clang and MSVC compile this fine with eager template parsing, but clang-cl fails to compile it due to delayed template parsing. This makes clang-cl incompatible with MSVC. Note that MSVC always handles this fine, regardless of `/permissive[-]` or `/Zc:twoPhase[-]`.