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

    <tr>
        <th>Summary</th>
        <td>
            Warnings in templates should be triggered based on flags of instantiating module, not instantiated module
        </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>
    Given a.cpp:

```cpp
export module a;

export template<typename T>
void a(T y) {
        unsigned x = 0;
        x = x + y;
}
```

compiled with

`clang++ -std=c++20 -Werror -Wshorten-64-to-32 -x c++-module a.cpp --precompile -o a.pcm`

and b.cpp:

```cpp
export module b;

import a;

void b() {
        a(static_cast<unsigned long>(1));
}
```

compiled with

`clang++ -std=c++20 -Wno-error -Wno-shorten-64-to-32 b.cpp -fprebuilt-module-path=. a.pcm -o /dev/null`

fails with

```shell
In file included from b.cpp:3:
a.cpp:6:8: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        x = x + y;
          ~ ~~^~~
b.cpp:6:2: note: in instantiation of function template specialization 'a<unsigned long>' requested here
 a(static_cast<unsigned long>(1));
        ^
1 error generated.
```

So to summarize, I compile b.cpp with "warnings not as errors, and don't warn me about this thing anyway", and clang warns me about it and makes it an error, because I happened to compile a.cpp with a different set of warning flags.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lU2PozgTxz-NuZSIiAkhHDh0dyaP-vyM1MdVgQvwrrFZ26Q7c-jPvjIvSSbT2sNIixCBqrL516-qCDonW01UsuyZZccIR98ZWwo8S-G80RRVRlzK_8kzacBNPQwsfWLJkSXrdZ_MZ3BNFvoYjPXQGzEqAmTp83384vXUDwo9sfTFXwbS2BN8Z-m3OehspABk_PAdLowXwPLrHsWoJ8UCPoClR0ju9i9m0wcw_gyXmyM_P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