[clang] [Clang][Parse] Diagnose member template declarations with multiple declarators (PR #78243)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 08:00:43 PST 2024


================
@@ -3167,6 +3167,15 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
 
     DeclaratorInfo.complete(ThisDecl);
 
+    if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
+      if (Tok.is(tok::comma)) {
+        Diag(Tok, diag::err_multiple_template_declarators)
+            << (int)TemplateInfo.Kind;
+        SkipUntil(tok::semi, StopBeforeMatch);
+      }
+      break;
+    }
----------------
erichkeane wrote:

The 'later' we do these sort of diagnostics, the better we are at recovering from them, and the better the diagnostics can be.  IMO, if this is possible, putting this in FinalizeDeclaratorGroup makes a lot more sense here. 

At least that way, we could recover and pretend one of those are the 'right' template that we intend to declare.

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


More information about the cfe-commits mailing list