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

    <tr>
        <th>Summary</th>
        <td>
            lang does not warn about redeclaration of type aliases within lambda-like construct
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          starbugs-qurong
      </td>
    </tr>
</table>

<pre>
    When compiling the following C++ code with Clang, the compiler issues a warning about an unused expression result but does not warn about the redeclaration of the same type alias within the same scope. According to C++ standards, redeclaring the same name within the same scope should either be allowed (if it's the same declaration) or result in a compilation error/warning.

Steps to Reproduce:

Compile the following code with Clang:

 ```cpp  
   template <typename T>  
   struct Test { 
       int f() {  
           int x = 0;  
           [x = x, &r = x] { 
               using ty1 = int;         // First definition  
 using ty1 = decltype(x); // Redefinition (invalid)  
           };  
 return 0;  
       }  
   };  

   int main() {  
       Test<int> obj;  
       obj.f();  
       return 0;  
   }  

Expected Behavior:
Clang should issue a warning or error about the redeclaration of ty1 and ty2 within the same scope.

Actual Behavior:
Clang only issues a warning about an unused expression result.

Compiler Version:
Clang 19.0.0

Additional Information:
The use of based-range initializer lists in this manner might not be standard-compliant. However, even if the code is invalid, Clang should still provide a meaningful diagnostic about the redeclaration issue.

Compiler Explorer link: https://godbolt.org/z/Mf7c1zP4v




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