From 28ac016928634a469118699536b4fe56bf19fc2a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 15 Mar 2012 07:20:36 -0500 Subject: [PATCH] Fix bugs in checks for varying parameters in exported functions. In short, we inadvertently weren't checking whether pointers themselves were varying, which in turn led to an assertion later if an exported function did have a varying parameter. Issue #187. --- module.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/module.cpp b/module.cpp index 42843f6d..7b7f2e5c 100644 --- a/module.cpp +++ b/module.cpp @@ -343,8 +343,6 @@ Module::AddGlobalVariable(Symbol *sym, Expr *initExpr, bool isConst) { */ static bool lRecursiveCheckValidParamType(const Type *t) { - t = t->GetBaseType(); - const StructType *st = dynamic_cast(t); if (st != NULL) { for (int i = 0; i < st->GetElementCount(); ++i) @@ -352,15 +350,16 @@ lRecursiveCheckValidParamType(const Type *t) { return true; return false; } - else { - if (t->IsVaryingType()) - return true; - const PointerType *pt = dynamic_cast(t); - if (pt != NULL && pt->IsSlice()) - return true; - else - return false; - } + + const SequentialType *seqt = dynamic_cast(t); + if (seqt != NULL) + return lRecursiveCheckValidParamType(seqt->GetElementType()); + + const PointerType *pt = dynamic_cast(t); + if (pt != NULL) + return (pt->IsSlice() || pt->IsVaryingType()); + + return t->IsVaryingType(); }