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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 16 15:47:34 PDT 2023


rsmith added inline comments.


================
Comment at: clang/lib/Parse/ParseDecl.cpp:7385
           if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
             DefArgToks.reset();
+            Diag(ArgStartLoc, diag::err_expected) << "initializer";
----------------
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.


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