Esempio n. 1
0
bool
VarDeclSpecHelper::receiveConstQualifier(CompileContext &cc, const SourceLocation &constLoc, Type *type)
{
  VariableSymbol *sym = decl_->sym();
  if (sym->isArgument()) {
    if (!!(sym->storage_flags() & StorageFlags::byref)) {
      cc.report(constLoc, rmsg::const_ref_has_no_meaning) << type;
      return true;
    }
    if (!type->passesByReference()) {
      cc.report(constLoc, rmsg::const_has_no_meaning) << type;
      return true;
    }
  } else if (TypeSupportsCompileTimeInterning(type)) {
    sym->storage_flags() |= StorageFlags::constval;
  }

  sym->storage_flags() |= StorageFlags::readonly;
  return true;
}