Skip to content

Commit

Permalink
Bug fixes while compiling are-we-fast-yet test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
LADSoft committed Jul 21, 2024
1 parent e198f15 commit 15f37a6
Show file tree
Hide file tree
Showing 60 changed files with 7,581 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/clibs/cpp/libextra/cregex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct iregex : public std::regex
bool inosubs;
};

static void errmap(std::regex_error& e)
static int errmap(std::regex_error& e)
{
switch (e.code())
{
Expand Down
1 change: 1 addition & 0 deletions src/clibs/io/fopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ FILE* __basefopen(const wchar_t* restrict name, const wchar_t* restrict mode, FI
return file;
}
FILE* _RTL_FUNC _wfopen(const wchar_t* restrict name, const wchar_t* restrict mode) { return __basefopen(name, mode, 0, -1, SH_COMPAT); }
FILE* _RTL_FUNC _wfsopen(const wchar_t* restrict name, const wchar_t* restrict mode, int __shmode) { return __basefopen(name, mode, 0, -1, __shmode); }
FILE* _RTL_FUNC fopen(const char* restrict name, const char* restrict mode)
{
wchar_t buf[260], buf1[64], *p = buf, *q = buf1;
Expand Down
1 change: 1 addition & 0 deletions src/clibs/stdinc/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ extern "C"
char* ZSTR _RTL_FUNC _IMPORT _strerror(const char* ZSTR __s);

FILE * _RTL_FUNC _IMPORT _wfopen(const wchar_t * restrict, const wchar_t * restrict);
FILE * _RTL_FUNC _IMPORT _wfsopen(const wchar_t * restrict, const wchar_t * restrict, int __shflag);
FILE * _RTL_FUNC _IMPORT _wfreopen(const wchar_t * restrict, const wchar_t * restrict, FILE * restrict);
FILE * _RTL_FUNC _IMPORT _wfdopen(int, const wchar_t *);
int _RTL_FUNC _IMPORT _wremove(const wchar_t *);
Expand Down
2 changes: 1 addition & 1 deletion src/occopt/ilstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ static void NumberTypes()
{
s->typeIndex = 2 * i++ + 1;
// static members
if (s->storage_class != scc_external && s->storage_class != scc_global && s->storage_class != scc_constant)
if (s->storage_class != scc_external && s->storage_class != scc_global && s->storage_class != scc_constant && s->storage_class != scc_enumconstant)
{
s->fileIndex = s->typeIndex;
}
Expand Down
7 changes: 6 additions & 1 deletion src/occparse/constopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,10 @@ int opt0(EXPRESSION** node)
{
*node = exprNode(ExpressionNode::uminus_, ep->right, 0);
}
*node = ep->right;
else
{
*node = ep->right;
}
}
else
dooper(node, mode);
Expand All @@ -1645,7 +1648,9 @@ int opt0(EXPRESSION** node)
*node = ep->left;
}
else
{
dooper(node, mode);
}
rv = true;
break;
case 22:
Expand Down
41 changes: 34 additions & 7 deletions src/occparse/declare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,7 @@ SYMBOL* calculateStructAbstractness(SYMBOL* top, SYMBOL* sp)
{
for (auto pq1 : *pq->tp->syms)
{
const char* p1 = strrchr(pq1->sb->decoratedName, '@');
const char* p2 = strrchr(pi->sb->decoratedName, '@');
if (p1 && p2 && !strcmp(p1, p2))
if (strcmp(pq1->name, pi->name) == 0 && matchOverload(pq1->tp, pi->tp, false))
{
if (!pq1->sb->ispure)
{
Expand Down Expand Up @@ -1242,8 +1240,11 @@ LEXLIST* innerDeclStruct(LEXLIST* lex, SYMBOL* funcsp, SYMBOL* sp, bool inTempla
bool* defd, SymbolTable<SYMBOL>* anonymousTable)
{
int oldParsingTemplateArgs;
int oldExpressionParsing;
oldParsingTemplateArgs = parsingDefaultTemplateArgs;
oldExpressionParsing = inFunctionExpressionParsing;
parsingDefaultTemplateArgs = 0;
inFunctionExpressionParsing = false;
bool hasBody = (Optimizer::cparams.prm_cplusplus && KW(lex) == Keyword::colon_) || KW(lex) == Keyword::begin_;
SYMBOL* injected = nullptr;

Expand Down Expand Up @@ -1305,6 +1306,7 @@ LEXLIST* innerDeclStruct(LEXLIST* lex, SYMBOL* funcsp, SYMBOL* sp, bool inTempla
TemplateGetDeferred(sp);
}
--structLevel;
inFunctionExpressionParsing = oldExpressionParsing;
parsingDefaultTemplateArgs = oldParsingTemplateArgs;
return lex;
}
Expand Down Expand Up @@ -1414,7 +1416,6 @@ static LEXLIST* declstruct(LEXLIST* lex, SYMBOL* funcsp, TYPE** tp, bool inTempl
strcpy(newName, tagname);
if (inTemplate)
inTemplateSpecialization++;

lex = tagsearch(lex, newName, &sp, &table, &strSym, &nsv, storage_class);

if (inTemplate)
Expand Down Expand Up @@ -1456,6 +1457,16 @@ static LEXLIST* declstruct(LEXLIST* lex, SYMBOL* funcsp, TYPE** tp, bool inTempl
lex = backupsym();
}
}
if (funcsp && !inFunctionExpressionParsing && (MATCHKW(lex, Keyword::colon_) || MATCHKW(lex, Keyword::begin_)))
{
sp = nullptr;
nsv = nullptr;
if (localNameSpace->front()->tags)
{
sp = localNameSpace->front()->tags->Lookup(newName);
}
table = localNameSpace->front()->tags;
}
if (!sp)
{
addedNew = true;
Expand All @@ -1475,13 +1486,17 @@ static LEXLIST* declstruct(LEXLIST* lex, SYMBOL* funcsp, TYPE** tp, bool inTempl
sp->sb->declfile = sp->sb->origdeclfile = lex->data->errfile;
sp->sb->declfilenum = lex->data->linedata->fileindex;
sp->sb->attribs = basisAttribs;
if ((storage_class == StorageClass::member_ || storage_class == StorageClass::mutable_) &&
if ((storage_class == StorageClass::member_ || storage_class == StorageClass::mutable_ || storage_class == StorageClass::auto_) &&
(MATCHKW(lex, Keyword::begin_) || MATCHKW(lex, Keyword::colon_) || MATCHKW(lex, Keyword::try_) || MATCHKW(lex, Keyword::semicolon_)))
sp->sb->parentClass = getStructureDeclaration();
if (storage_class == StorageClass::auto_)
sp->sb->parentClass = theCurrentFunc->sb->parentClass;
else
sp->sb->parentClass = getStructureDeclaration();
if (nsv)
sp->sb->parentNameSpace = nsv->front()->name;
else
sp->sb->parentNameSpace = globalNameSpace->front()->name;
sp->sb->parent = funcsp;
if (nsv && nsv->front()->name && !strcmp(sp->name, "initializer_list") && !strcmp(nsv->front()->name->name, "std"))
sp->sb->initializer_list = true;
if (inTemplate)
Expand Down Expand Up @@ -1867,8 +1882,20 @@ static LEXLIST* declenum(LEXLIST* lex, SYMBOL* funcsp, TYPE** tp, StorageClass s
}

strcpy(newName, tagname);

lex = tagsearch(lex, newName, &sp, &table, &strSym, &nsv, storage_class);

ParseAttributeSpecifiers(&lex, funcsp, true);
if (funcsp && (MATCHKW(lex, Keyword::colon_) || MATCHKW(lex, Keyword::begin_)))
{
sp = nullptr;
nsv = nullptr;
if (localNameSpace->front()->tags)
{
sp = localNameSpace->front()->tags->Lookup(newName);
}
table = localNameSpace->front()->tags;
}
if (KW(lex) == Keyword::colon_)
{
RequiresDialect::Feature(Dialect::c2x, "Underlying type");
Expand Down Expand Up @@ -3288,7 +3315,7 @@ LEXLIST* getBasicType(LEXLIST* lex, SYMBOL* funcsp, TYPE** tp, SYMBOL** strSym_o
((strSym && ((strSym->sb->mainsym && strSym->sb->mainsym == sp->sb->mainsym) ||
strSym == sp->sb->mainsym || sameTemplate(strSym->tp, sp->tp))) ||
(!strSym && (storage_class == StorageClass::member_ || storage_class == StorageClass::mutable_) && ssp &&
ssp == sp->sb->mainsym)))
(ssp == sp || ssp == sp->sb->mainsym))))
{
if (destructor)
{
Expand Down
18 changes: 8 additions & 10 deletions src/occparse/declcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,15 +1333,16 @@ static void shimDefaultConstructor(SYMBOL* sp, SYMBOL* cons)
++it1;
if (it1 != itend && ((*it1)->sb->init || (*it1)->sb->deferredCompile))
{
if (sp->templateParams == nullptr)
if (sp->templateParams == nullptr || (!templateNestingCount || instantiatingTemplate))
{
// will match a default constructor but has defaulted args
SYMBOL* consfunc = declareConstructor(sp, true, false); // default
consfunc->sb->defaulted = false;
SymbolTable<SYMBOL>* syms;
BLOCKDATA bd = {};
std::list<BLOCKDATA*> b = { &bd };
STATEMENT* st;
EXPRESSION* thisptr = varNode(ExpressionNode::auto_, *it);
EXPRESSION* thisptr = varNode(ExpressionNode::auto_, consfunc->tp->syms->front());
EXPRESSION* e1;
FUNCTIONCALL* params = Allocate<FUNCTIONCALL>();
(*it)->sb->offset = Optimizer::chosenAssembler->arch->retblocksize;
Expand All @@ -1366,13 +1367,10 @@ static void shimDefaultConstructor(SYMBOL* sp, SYMBOL* cons)
}
e1 = varNode(ExpressionNode::func_, nullptr);
e1->v.func = params;
if (e1) // could probably remove this, only null if ran out of memory.
{
e1 = exprNode(ExpressionNode::thisref_, e1, nullptr);
e1->v.t.thisptr = params->thisptr;
e1->v.t.tp = sp->tp;
// hasXCInfo = true;
}
e1 = exprNode(ExpressionNode::thisref_, e1, nullptr);
e1->v.t.thisptr = params->thisptr;
e1->v.t.tp = sp->tp;
// hasXCInfo = true;
st = stmtNode(nullptr, b, StatementNode::return_);
st->select = e1;
consfunc->sb->xcMode = cons->sb->xcMode;
Expand Down Expand Up @@ -1472,7 +1470,7 @@ void createDefaultConstructors(SYMBOL* sp)
err |= s->sb->isConstructor && !s->sb->defaulted;
err |= s->sb->deleted;
err |= s->sb->access != AccessLevel::public_;
err |= s->sb->isConstructor && s->sb->isExplicit;
err |= s->sb->isConstructor && s->sb->isExplicit && !s->sb->defaulted;
if (s->sb->isDestructor && !s->sb->defaulted)
trivialDest = false;
}
Expand Down
8 changes: 7 additions & 1 deletion src/occparse/declcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,17 @@ void deferredCompileOne(SYMBOL* cur)
}
oldLambdas = lambdas;
lambdas.clear();
int oldStructLevel = structLevel;
structLevel = 0;
auto oldOpen = openStructs;
openStructs = nullptr;
cur->sb->deferredCompile = nullptr;
lex = body(lex, cur);
SetAlternateLex(nullptr);
dontRegisterTemplate--;
lambdas = oldLambdas;
openStructs = oldOpen;
structLevel = oldStructLevel;
while (count--)
{
dropStructureDeclaration();
Expand Down Expand Up @@ -1144,7 +1150,7 @@ void warnCPPWarnings(SYMBOL* sym, bool localClassWarnings)
if (localClassWarnings)
{
if (isfunction(cur1->tp))
if (!basetype(cur1->tp)->sp->sb->inlineFunc.stmt)
if (basetype(cur1->tp)->sp && !basetype(cur1->tp)->sp->sb->inlineFunc.stmt && !basetype(cur1->tp)->sp->sb->deferredCompile)
errorsym(ERR_LOCAL_CLASS_FUNCTION_NEEDS_BODY, cur1);
}
if (cur1->sb->isfinal || cur1->sb->isoverride || cur1->sb->ispure)
Expand Down
15 changes: 14 additions & 1 deletion src/occparse/expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8124,7 +8124,20 @@ static LEXLIST* expression_hook(LEXLIST* lex, SYMBOL* funcsp, TYPE* atp, TYPE**
}
if (Optimizer::cparams.prm_cplusplus && (isstructured(tpc) || isstructured(tph)) && (!tpc->lref || !tph->lref))
{
if ( ! isstructured(tpc) || !isstructured(tph) || (comparetypes(tph, tpc, false) && !sameTemplate(tph, tpc, false)) || epc->type == ExpressionNode::thisref_ || epc->type == ExpressionNode::func_ || eph->type == ExpressionNode::thisref_ || eph->type == ExpressionNode::func_)
if (atp && !isstructured(atp) && (!isref(atp) || !isstructured(basetype(atp)->btp)))
{
if (isstructured(tpc))
{
if (!castToArithmeticInternal(true, &tpc, &epc, Keyword::plus_, atp, false))
errorConversionOrCast(true, tpc, atp);
}
if (isstructured(tph))
{
if (!castToArithmeticInternal(true, &tph, &eph, Keyword::plus_, atp, false))
errorConversionOrCast(true, tph, atp);
}
}
else if ( ! isstructured(tpc) || !isstructured(tph) || (comparetypes(tph, tpc, false) && !sameTemplate(tph, tpc, false)) || epc->type == ExpressionNode::thisref_ || epc->type == ExpressionNode::func_ || eph->type == ExpressionNode::thisref_ || eph->type == ExpressionNode::func_)
{
// structure is result of constructor or return value
// at this point we want to check that both sides
Expand Down
1 change: 1 addition & 0 deletions src/occparse/iinline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ static bool hasaincdec(EXPRESSION* exp)
}
return false;
}
int count3;
Optimizer::IMODE* gen_inline(SYMBOL* funcsp, EXPRESSION* node, int flags)
/*
* generate a function call node and return the address mode
Expand Down
Loading

0 comments on commit 15f37a6

Please sign in to comment.