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

    <tr>
        <th>Summary</th>
        <td>
            [clang++] template nested class declaration works unexpectedly
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    (clang++, version=19.1.7, platform=MacOS)
See this code below

```cpp
template < class T >
concept my_concept = true;

template < class T >
struct my_class
{
    template < my_concept U >
    struct my_nested_class;
};

template < class T >
template < my_concept U >
#if defined(__GNUC__) and not defined(__clang__)
    struct my_class<T>::my_nested_class // *** Expected way, which works on gcc ***
#elifdef __clang__
    struct my_class<T>::my_nested_class<U> // *** In clang++ we must write in this way ***
#endif
    {

    };
```

When we declare as the first way in clang++, we get a compile-error like this:
```text
main.cpp:12:12: error: type constraint differs in template redeclaration
   12 | template < my_concept type2 >
      | ^
main.cpp:7:16: note: previous template declaration is here
    7 | template < my_concept type2 >
      |        
```
while declare as the second way is accepted in clang++.


However ***the first way is expected***, because when we declare a ***non-concept*** template nested class, it should be written like this:
```cpp

template < class T >
struct your_class
{
    template < class U >
    struct your_nested_class;
};

template < class T >
template < class U >
struct your_class<T>::your_nested_class /* clang++ requires no <U> here. Same do g++ */; 
```
and it should be along with the one with ***concept*** -constrained nested class.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2TozYQ_TXypWtcIBmzPnBg7HGSQz6qZqdynBJSY5QVEpHEsP73KQEef-1mN6l1qcyX-vVr3uuGe68OBrEg2SPJdgveh8a6ojTWHFvb-z-2i8rKY0HoB6G5ORD6OK4tvKHzyhrCdulmmS7zeK_TPNTWtYTtfuXi92dCNyQpnxEhNMqDsBKhQm0HkpRxrZNpia4jSRmwjQAIhG1BaO49fATCnkhSCmsEdgHa4-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