================
@@ -930,12 +928,26 @@ CIRGenTypes::arrangeFunctionDeclaration(const 
FunctionDecl *fd) {
   // TODO: setCUDAKernelCallingConvention
   assert(!cir::MissingFeatures::cudaSupport());
 
-  // When declaring a function without a prototype, always use a non-variadic
-  // type.
+  // Handle C89/gnu89 no-prototype functions (FunctionNoProtoType).
+  //
+  // In C89, a function declared without a prototype does not type-check
+  // arguments and may legally be called with additional arguments.
+  // If we model such functions as non-variadic, the first observed call-site
+  // would freeze the function signature to that arity, causing later calls
+  // with different argument counts to fail CIR verification.
+  //
+  // When the target ABI permits variadic no-proto calls, model the function
+  // as variadic with zero fixed parameters to preserve C semantics and keep
+  // the CIR function type stable across call sites.
   if (CanQual<FunctionNoProtoType> noProto =
           funcTy.getAs<FunctionNoProtoType>()) {
     assert(!cir::MissingFeatures::opCallCIRGenFuncInfoExtParamInfo());
     assert(!cir::MissingFeatures::opCallFnInfoOpts());
+
+    if (cgm.getTargetCIRGenInfo().isNoProtoCallVariadic(noProto.getTypePtr())) 
{
----------------
andykaylor wrote:

This doesn't look right, and I don't think it's needed here.

https://github.com/llvm/llvm-project/pull/182718
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to