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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] [Modules] consteval function existing in global module fragment causes `if consteval` to be assumed to be true in template
        </td>
    </tr>

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

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

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

<pre>
    The following valid set of C++ source files:

```cpp
module;

consteval void f() {}

export module a;

export template<typename T>
void a() {
        if consteval {
                typename T::type x;
        }
}
```

```cpp
module;

consteval void f() {}

export module b;

import a;

void b() {
        a<int>();
}
```

When compiled with

```shell
clang++ -std=c++2b -x c++-module a.cpp --precompile -o a.pcm
clang++ -std=c++2b -x c++-module b.cpp --precompile -o b.pcm -fmodule-file=a.pcm
```

fails with

```
a.cpp:10:12: error: type 'int' cannot be used prior to '::' because it has no members
 typename T::type x;
 ^
b.cpp:10:2: note: in instantiation of function template specialization 'a<int>' requested here
        a<int>();
        ^
1 error generated.
```

Note that `-Wredundant-consteval-if` also fires if `a.cpp` is changed to:

```cpp
module;

consteval void f() {}

export module a;

void aa() {}

export template<typename>
auto a() {
        if consteval {
                aa();
        }
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVU-vozYQ_zTOZUTkmATCgUPy0tza00p7NngAV8am9pD3tp--MpAEPWV32x7aKCJMPP7Nv9_MyBB0axFLdjizw2UjR-qcL5W8aRXIWdxUTn0rv3QIjTPGvWvbwk0arSAggWvgjYkzE2cIbvQ1QqMNBpaeGL8wfn9mfP7WwzD_0zs1GmTpea1WOxsIb9LAzWkFDRNHJgpg-Znll7UifgzOE8wgID_BLKeE_WAkIUvf6NuAVvYIX1j6y6w0WZArCwtAoRt4-rE-YLxY45xYeooyfKzMF09HHy_32P-7hFSfYHQ_nX7O04R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