mirror of https://github.com/microsoft/clang.git
Ensure we evaluate VLA bounds if a variably-modified type is used as the
argument to __builtin_va_arg. Patch by Rahul Jain, some test massaging and IR emission order changes by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206223 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9cb9774199
commit
ad1bdc0fa1
|
@ -3199,6 +3199,10 @@ Value *ScalarExprEmitter::VisitChooseExpr(ChooseExpr *E) {
|
|||
}
|
||||
|
||||
Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
|
||||
QualType Ty = VE->getType();
|
||||
if (Ty->isVariablyModifiedType())
|
||||
CGF.EmitVariablyModifiedType(Ty);
|
||||
|
||||
llvm::Value *ArgValue = CGF.EmitVAListRef(VE->getSubExpr());
|
||||
llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType());
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// PR6433 - Don't crash on va_arg(typedef).
|
||||
typedef double gdouble;
|
||||
|
@ -15,3 +14,10 @@ void function_as_vararg() {
|
|||
// CHECK-NOT: llvm.trap
|
||||
vararg(0, focus_changed_cb);
|
||||
}
|
||||
|
||||
void vla(int n, ...)
|
||||
{
|
||||
__builtin_va_list ap;
|
||||
void *p;
|
||||
p = __builtin_va_arg(ap, typeof (int (*)[++n])); // CHECK: add nsw i32 {{.*}}, 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue