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

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 10:30:51 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;
+    }
----------------
sdkrystian wrote:

I added a commit which issues a diagnostic from the parser when a second declarator is encountered for templates, and then have `ParseSingleDeclarationAfterTemplate` call `ParseDeclGroup`... let me know if you guys think this approach is worth pursuing


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


More information about the cfe-commits mailing list