<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/128657>128657</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            False positive warning `warning: instantiation of variable 'declvar<A>' required here, but no definition is available`, when the definition is not required
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          HolyBlackCat
      </td>
    </tr>
</table>

<pre>
    Consider the following code:
```cpp
#include <utility>

struct A {explicit constexpr operator bool() const {return true;}};
struct B {int x = 1; explicit constexpr operator bool() const {return x;}};

template <typename T>
extern T declvar;

template <typename T>
concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};

static_assert(C<A>);
static_assert(!C<B>);
```
This works correctly on all 3 bug compilers including Clang (and seems to be the only good way of doing this).

But Clang emits a useless warning:
```none
<source>:10:50: warning: instantiation of variable 'declvar<A>' required here, but no definition is available [-Wundefined-var-template]
   10 | concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};
      | ^
<source>:7:10: note: forward declaration of template entity is here
    7 | extern T declvar;
      | ^
<source>:10:50: note: add an explicit instantiation declaration to suppress this warning if 'declvar<A>' is explicitly instantiated in another translation unit
   10 | concept C = requires{typename std::bool_constant<declvar<T> ? true : false>;};
      | ^
```
The variable definition isn't needed here, so it shouldn't warn.


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVcGOozgQ_ZrKpdQtMA0kBw5AT7QfMNIeR8auBO84NmsXSefvV4ZOOj070q72MNoIBSE_v6p67xlkjOboiBooOyhfN3Lm0YfmN2-vnZXqey95M3h9bXrvotEUkEfCg7fWX4w7ovKaoGgha6HK1ktNU3oUhXHKzpoQin5mYw1fofiSlrI2cpgVY4tQd_Q2WaMMo_IuMr1NAf1EQbIPOHhvQWxB7NbVhA_Ec3DIYSYoOqhf01V0H6xdQhnH-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