mirror of https://github.com/microsoft/clang.git
[Sema] Handle errors during rewriteBuiltinFunctionDecl
rewriteBuiltinFunctionDecl can encounter errors when performing DefaultFunctionArrayLvalueConversion. These errors were not handled which led to a null pointer dereference. This fixes PR28651. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276352 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
540a73bdd3
commit
2f94b4c80e
|
@ -5051,7 +5051,11 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
|
|||
for (QualType ParamType : FT->param_types()) {
|
||||
|
||||
// Convert array arguments to pointer to simplify type lookup.
|
||||
Expr *Arg = Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]).get();
|
||||
ExprResult ArgRes =
|
||||
Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]);
|
||||
if (ArgRes.isInvalid())
|
||||
return nullptr;
|
||||
Expr *Arg = ArgRes.get();
|
||||
QualType ArgType = Arg->getType();
|
||||
if (!ParamType->isPointerType() ||
|
||||
ParamType.getQualifiers().hasAddressSpace() ||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
|
||||
// expected-no-diagnostics
|
||||
|
||||
kernel void test(global float *out, global float *in, global int* in2) {
|
||||
out[0] = __builtin_nanf("");
|
||||
__builtin_memcpy(out, in, 32);
|
||||
out[0] = __builtin_frexpf(in[0], in2);
|
||||
}
|
||||
|
||||
void pr28651() {
|
||||
__builtin_alloca(value); // expected-error{{use of undeclared identifier}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue