diff --git a/src/lang/modes/opencl.cpp b/src/lang/modes/opencl.cpp index ee9caaadb..4e8c97fce 100644 --- a/src/lang/modes/opencl.cpp +++ b/src/lang/modes/opencl.cpp @@ -242,8 +242,13 @@ namespace occa { statementExprMap::iterator it = exprMap.begin(); while (it != exprMap.end()) { declarationStatement &declSmnt = *((declarationStatement*) it->first); - declSmnt.removeFromParent(); - kernelSmnt.addFirst(declSmnt); + + variable_t *var = declSmnt.declarations[0].variable; + + if (var->hasAttribute("shared")) { + declSmnt.removeFromParent(); + kernelSmnt.addFirst(declSmnt); + } ++it; } }