Skip to content

Commit

Permalink
Fix C++ header regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Jan 13, 2024
1 parent 2a1f97f commit 8c68590
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dmd/dsymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ enum

/* Flags for symbol search
*/
typedef uint SearchOptFlags;
typedef unsigned SearchOptFlags;
enum class SearchOpt : SearchOptFlags
{
all = 0x00, // default
Expand Down
3 changes: 1 addition & 2 deletions dmd/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<bool> toBool();
Expand Down
2 changes: 1 addition & 1 deletion dmd/optimize.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dmd/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
7 changes: 4 additions & 3 deletions gen/asm-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions gen/pragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gen/toconstelem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 8c68590

Please sign in to comment.