[PATCH] D79800: [Sema] Remove default values for arguments prior to a parameter pack if the pack is used

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 21 22:45:54 PDT 2020


rjmccall added a comment.

I wrote this comment but apparently never submitted it on Phabricator, sorry.



================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:1987
+
+    if (Function->getNumParams() >= NumTemplatedParams) {
+      unsigned FirstDefault = 0;
----------------
I don't think this simple comparison works; the relationship can be complicated because there might be multiple packs in play.  By the same token, I think it's possible that there can be multiple interleavings of defaultable parameters with packs.  I think you need to scan backwards looking for a parameter without a default argument that was instantiated from a pack expansion and then remove any earlier parameters with defaults.

That is, assuming this is a reasonable implementation approach at all compared to just teaching other parts of the compiler about this case, which I think Richard needs to weigh in on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79800





More information about the cfe-commits mailing list