[Clang][Sema] Diagnose function/variable templates that shadow their own...
[Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (#78274) Previously, we skipped through template parameter scopes (until we hit a declaration scope) prior to redeclaration lookup for declarators. For template declarations, the meant that their template parameters would not be found and shadowing would not be diagnosed. With these changes applied, the following declarations are correctly diagnosed: ```cpp template<typename T> void T(); // error: declaration of 'T' shadows template parameter template<typename U> int U; // error: declaration of 'U' shadows template parameter ``` The reason for skipping past non-declaration & template parameter scopes prior to lookup appears to have been because `GetTypeForDeclarator` needed this adjusted scope... but it doesn't actually use this parameter anymore. The scope adjustment now happens prior to calling `ActOnFunctionDeclarator`/`ActOnVariableDeclarator`/`ActOnTypedefDeclarator` (just in case they depend on this behavior... I didn't check in depth).
Loading
Please sign in to comment