[clang] Reapply "[Clang][Sema] Diagnose function/variable templates that shadow their own template parameters (#78274)" (PR #79683)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 15 09:33:47 PST 2024


================
@@ -885,16 +885,19 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
 /// that the template parameter 'PrevDecl' is being shadowed by a new
 /// declaration at location Loc. Returns true to indicate that this is
 /// an error, and false otherwise.
-void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
+void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl,
+                                           bool IssueWarning) {
----------------
AaronBallman wrote:

> @AaronBallman In VS20222 the javadocs show up even when they are attached to the definition... but I'll move them to the declaration to be on the safe side :)

For me, that only happens if the definition is in the same TU as the use. When I tried outside of SemaTemplate.cpp (such as the uses in SemaDecl.cpp), no docs appeared in the tooltip.

> While I mostly agree with changing the name to SupportedAsExtension, I don't think the change to the diagnostic selection logic is quite right. When MSVC compatibility is enabled, template parameter shadowing is always allowed (read: there are no cases where shadowing would be an error with MSVC compatibility enabled), so we should issue the MSVC specific diagnostic regardless of SupportedAsExtension.

Good point!

> Perhaps we name it SupportedForCompatibility instead?

I could be okay with that; @cor3ntin WDYT?

https://github.com/llvm/llvm-project/pull/79683


More information about the cfe-commits mailing list