| 2984 | } |
| 2985 | |
| 2986 | void FunctionParameterDefault(const char* pos) |
| 2987 | { |
| 2988 | FunctionInfo &lastFunc = *currDefinedFunc.back(); |
| 2989 | |
| 2990 | TypeInfo *left = lastFunc.lastParam->varType; |
| 2991 | |
| 2992 | ConvertFunctionToPointer(pos, left); |
| 2993 | if(left) |
| 2994 | HandlePointerToObject(pos, left); |
| 2995 | |
| 2996 | TypeInfo *right = CodeInfo::nodeList.back()->typeInfo; |
| 2997 | |
| 2998 | if(!lastFunc.lastParam->varType) |
| 2999 | { |
| 3000 | left = lastFunc.lastParam->varType = right; |
| 3001 | lastFunc.allParamSize += right->size < 4 ? 4 : right->size; |
| 3002 | } |
| 3003 | if(left == typeVoid) |
| 3004 | ThrowError(pos, "ERROR: function parameter cannot be a void type", right->GetFullTypeName(), left->GetFullTypeName()); |
| 3005 | |
| 3006 | // If types don't match and it it is not built-in basic types or if pointers point to different types |
| 3007 | if(right == typeVoid || (left != right && (left->type == TypeInfo::TYPE_COMPLEX || right->type == TypeInfo::TYPE_COMPLEX || left->subType != right->subType)) && |
| 3008 | !(left->arrLevel == right->arrLevel && left->arrSize == TypeInfo::UNSIZED_ARRAY && right->arrSize != TypeInfo::UNSIZED_ARRAY)) |
| 3009 | ThrowError(pos, "ERROR: cannot convert from '%s' to '%s'", right->GetFullTypeName(), left->GetFullTypeName()); |
| 3010 | |
| 3011 | lastFunc.lastParam->defaultValue = CodeInfo::nodeList.back(); |
| 3012 | CodeInfo::nodeList.pop_back(); |
| 3013 | |
| 3014 | // Restore function arguments so that typeof could be taken |
| 3015 | for(VariableInfo *curr = lastFunc.firstParam; curr; curr = curr->next) |
| 3016 | varMap.insert(curr->nameHash, curr); |
| 3017 | } |
| 3018 | |
| 3019 | void FunctionPrototype(const char* pos) |
| 3020 | { |
no test coverage detected