From 8c685903cc962934c38202ed43a6d08394351738 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 10 Jan 2024 04:53:48 +0100 Subject: [PATCH] Fix C++ header regressions --- dmd/dsymbol.h | 2 +- dmd/expression.h | 3 +-- dmd/optimize.d | 2 +- dmd/scope.h | 2 +- gen/asm-x86.h | 7 ++++--- gen/pragma.cpp | 6 +++--- gen/toconstelem.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index 9c15ea368b3..025400499d6 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -149,7 +149,7 @@ enum /* Flags for symbol search */ -typedef uint SearchOptFlags; +typedef unsigned SearchOptFlags; enum class SearchOpt : SearchOptFlags { all = 0x00, // default diff --git a/dmd/expression.h b/dmd/expression.h index 93ee693ff66..463f8af6eb4 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -65,6 +65,7 @@ Expression *resolveLoc(Expression *exp, const Loc &loc, Scope *sc); MATCH implicitConvTo(Expression *e, Type *t); Expression *toLvalue(Expression *_this, Scope *sc, const char* action); Expression *modifiableLvalue(Expression* exp, Scope *sc); +Expression *optimize(Expression *exp, int result, bool keepLvalue = false); typedef unsigned char OwnedBy; enum @@ -123,8 +124,6 @@ class Expression : public ASTNode Expression *addressOf(); Expression *deref(); - Expression *optimize(int result, bool keepLvalue = false); - int isConst(); virtual bool isIdentical(const Expression *e) const; virtual Optional toBool(); diff --git a/dmd/optimize.d b/dmd/optimize.d index f86abde5c3e..5eb5429eaae 100644 --- a/dmd/optimize.d +++ b/dmd/optimize.d @@ -272,7 +272,7 @@ package void setLengthVarIfKnown(VarDeclaration lengthVar, Type type) * Returns: * Constant folded version of `e` */ -Expression optimize(Expression e, int result, bool keepLvalue = false) +extern (C++) Expression optimize(Expression e, int result, bool keepLvalue = false) { //printf("optimize() e: %s result: %d keepLvalue %d\n", e.toChars(), result, keepLvalue); Expression ret = e; diff --git a/dmd/scope.h b/dmd/scope.h index b79665ec8b4..936896b970b 100644 --- a/dmd/scope.h +++ b/dmd/scope.h @@ -133,5 +133,5 @@ struct Scope AliasDeclaration *aliasAsg; // if set, then aliasAsg is being assigned a new value, // do not set wasRead for it - Dsymbol *search(const Loc &loc, Identifier *ident, Dsymbol **pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all); + Dsymbol *search(const Loc &loc, Identifier *ident, Dsymbol *&pscopesym, SearchOptFlags flags = (SearchOptFlags)SearchOpt::all); }; diff --git a/gen/asm-x86.h b/gen/asm-x86.h index 16d9e790db1..00a7129436c 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -3743,7 +3743,7 @@ struct AsmProcessor { // DMD uses labels secondarily to other symbols, so check // if IdentifierExp::semantic won't find anything. Dsymbol *scopesym; - if (!sc->search(stmt->loc, ident, &scopesym)) { + if (!sc->search(stmt->loc, ident, scopesym)) { if (LabelDsymbol *labelsym = sc->func->searchLabel(ident, stmt->loc)) { e = createDsymbolExp(stmt->loc, labelsym); if (opTakesLabel()) { @@ -3755,11 +3755,12 @@ struct AsmProcessor { } e = expressionSemantic(e, sc); - e = e->optimize(WANTvalue); + e = optimize(e, WANTvalue); // Special case for floating point constant declarations. if (e->op == EXP::float64) { - Dsymbol *sym = sc->search(stmt->loc, ident, nullptr); + Dsymbol *scopesym; + Dsymbol *sym = sc->search(stmt->loc, ident, scopesym); if (sym) { VarDeclaration *v = sym->isVarDeclaration(); if (v) { diff --git a/gen/pragma.cpp b/gen/pragma.cpp index b90f96de18d..7afb4bca275 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -24,7 +24,7 @@ namespace { bool parseStringExp(Expression *e, const char *&res) { - e = e->optimize(WANTvalue); + e = optimize(e, WANTvalue); if (e->op != EXP::string_) { return false; } @@ -37,7 +37,7 @@ bool parseStringExp(Expression *e, const char *&res) { } bool parseIntExp(Expression *e, dinteger_t &res) { - e = e->optimize(WANTvalue); + e = optimize(e, WANTvalue); if (auto i = e->isIntegerExp()) { res = i->getInteger(); return true; @@ -46,7 +46,7 @@ bool parseIntExp(Expression *e, dinteger_t &res) { } bool parseBoolExp(Expression *e, bool &res) { - e = e->optimize(WANTvalue); + e = optimize(e, WANTvalue); if (auto i = e->isIntegerExp()) { if (e->type->equals(Type::tbool)) { res = (i->toInteger() != 0); diff --git a/gen/toconstelem.cpp b/gen/toconstelem.cpp index 6fa299da083..c681804af33 100644 --- a/gen/toconstelem.cpp +++ b/gen/toconstelem.cpp @@ -709,7 +709,7 @@ class ToConstElemVisitor : public Visitor { const auto elementCount = llvm::ElementCount(elemCount, false); #endif result = llvm::ConstantVector::getSplat( - elementCount, toConstElem(e->e1->optimize(WANTvalue), p)); + elementCount, toConstElem(optimize(e->e1, WANTvalue), p)); } }