diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp index 683e916391337..4f4b122ce8c9d 100644 --- a/clang/lib/AST/ByteCode/Context.cpp +++ b/clang/lib/AST/ByteCode/Context.cpp @@ -566,10 +566,15 @@ const Function *Context::getOrCreateFunction(const FunctionDecl *FuncDecl) { // Assign descriptors to all parameters. // Composite objects are lowered to pointers. - for (const ParmVarDecl *PD : FuncDecl->parameters()) { + const auto *FuncProto = FuncDecl->getType()->getAs(); + for (auto [ParamIndex, PD] : llvm::enumerate(FuncDecl->parameters())) { bool IsConst = PD->getType().isConstQualified(); bool IsVolatile = PD->getType().isVolatileQualified(); + if (!getASTContext().hasSameType(PD->getType(), + FuncProto->getParamType(ParamIndex))) + return nullptr; + OptPrimType T = classify(PD->getType()); PrimType PT = T.value_or(PT_Ptr); Descriptor *Desc = P->createDescriptor(PD, PT, nullptr, std::nullopt, diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c index 657a920e7d02c..cfdc9d0d3dd86 100644 --- a/clang/test/AST/ByteCode/c.c +++ b/clang/test/AST/ByteCode/c.c @@ -372,3 +372,12 @@ void discardedCmp(void) /// ArraySubscriptExpr that's not an lvalue typedef unsigned char U __attribute__((vector_size(1))); void nonLValueASE(U f) { f[0] = f[((U)(U){0})[0]]; } + +static char foo_(a) // all-warning {{definition without a prototype}} + char a; +{ + return 'a'; +} +static void bar_(void) { + foo_(foo_(1)); +}