[PATCH] D111175: [Clang] Extend init-statement to allow alias-declaration

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 7 09:39:55 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:552-553
   "extraneous ')' after condition, expected a statement">;
+def ext_alias_in_init_statement : ExtWarn<
+  "alias declaration in this context is a C++2b extension">,
+  InGroup<CXX2b>;
----------------
Can you also add the "incompatible with standards before C++2b" variant of this diagnostic?


================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:720-722
+  if (InInitStatement && Tok.isNot(tok::identifier)) {
+    return nullptr;
+  }
----------------



================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:1927-1930
+  if (!getLangOpts().CPlusPlus2b) {
+    Diag(DeclStart, diag::ext_alias_in_init_statement)
+        << SourceRange(DeclStart, DeclEnd);
+  }
----------------
Though I suspect this will change somewhat when you add the precompat warning.


================
Comment at: clang/lib/Parse/ParseExprCXX.cpp:2047-2050
+    else {
+      DG = ParseSimpleDeclaration(DeclaratorContext::SelectionInit, DeclEnd,
+                                  attrs, /*RequireSemi=*/true);
+    }
----------------



================
Comment at: clang/lib/Parse/ParseTentative.cpp:486-488
+  if (CanBeInitStatement && Tok.is(tok::kw_using)) {
+    return ConditionOrInitStatement::InitStmtDecl;
+  } else if (State.update(isCXXDeclarationSpecifier()))
----------------
No `else` after a `return`, and can drop the curly braces, per coding standard.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111175/new/

https://reviews.llvm.org/D111175



More information about the cfe-commits mailing list