[clang] Reapply "[Clang][Sema] Fix crash when 'this' is used in a dependent class scope function template specialization that instantiates to a static member function (#87541)" (PR #88311)

Jordan Rupprecht via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 12 11:44:04 PDT 2024


rupprecht wrote:

Still seeing a few more failures, although the original repro is now working.

```c++
struct Base {
    int BaseFunc(int x) { return 0; }
    int val;
};

template <typename T>
struct Foo : Base {
    template <typename X>
    int bar(X x) {
        return BaseFunc(val);  // OK
    }

    template <>
    int bar(double x) {
        return BaseFunc(0);  // error: call to non-static member function without an object argument
    }

    template <>
    int bar(int x) {
        return BaseFunc(val);  // error: no matching function for call to 'BaseFunc'
        // note: candidate function not viable: no overload of 'val' matching 'int' for 1st argument
    }
};
```

https://godbolt.org/z/Yn1jbGqW3

We also see a `reference to overloaded function could not be resolved; did you mean to call it?`, but I haven't been able to reduce that yet.

https://github.com/llvm/llvm-project/pull/88311


More information about the cfe-commits mailing list