[PATCH] D64811: Warn when NumParams overflows

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 21:43:56 PDT 2019


rjmccall added inline comments.


================
Comment at: clang/lib/Parse/ParseDecl.cpp:6233
+
+  } else if (RequiresArg)
       Diag(Tok, diag::err_argument_required_after_attribute);
----------------
The re-indentation here is wrong.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:304
+
+  Diag(ParamInfo[FunctionType::getMaxNumParams() - 1].IdentLoc,
+       diag::err_number_of_function_parameters_exceeded)
----------------
This is off by one: if the maximum number of parameters is 2, you want the diagnostic to appear on the parameter at index 2, not the parameter at index 1.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:6794
+    return;
+  }
+
----------------
Unfortunately, you can't do this: a call can have more arguments than parameters because of variadic arguments.  We probably *also* need to enforce an implementation limit on arguments, but it's not obvious that it should be the same limit.


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

https://reviews.llvm.org/D64811





More information about the cfe-commits mailing list