[PATCH] D148372: [clang] add diagnose when member function contains invalid default argument

Congcong Cai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 17 16:18:30 PDT 2023


HerrCai0907 marked an inline comment as done.
HerrCai0907 added inline comments.


================
Comment at: clang/lib/Parse/ParseDecl.cpp:7385
           if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
             DefArgToks.reset();
+            Diag(ArgStartLoc, diag::err_expected) << "initializer";
----------------
rsmith wrote:
> I think we should just remove this `reset` call. That way, the tokens we've accumulated will get parsed when we come to later process the default argument, and we can produce the proper error at that time, such as diagnosing a missing `:`. That's what we do for default member initializers.
Only remove `reset` does not work. I think it doesn't need to issue diagnose here. We can add it as a unparsedDefaultArgument and issue it when parsing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148372



More information about the cfe-commits mailing list