Remove now-unnecessary enum keyword (#1338)

C++ does not need it
This commit is contained in:
Sylvie
2024-03-08 19:40:41 -05:00
committed by GitHub
parent 1b97297d63
commit 53537cf9af
27 changed files with 95 additions and 127 deletions

View File

@@ -49,7 +49,7 @@
#include <winbase.h> // CreateFileMappingA
#include <memoryapi.h> // MapViewOfFile
#include <handleapi.h> // CloseHandle
// clang-format on
// clang-format on
#define MAP_FAILED nullptr
@@ -491,7 +491,7 @@ void lexer_CleanupState(LexerState &state) {
);
}
void lexer_SetMode(enum LexerMode mode) {
void lexer_SetMode(LexerMode mode) {
lexerState->mode = mode;
}
@@ -1825,9 +1825,8 @@ static Token yylex_NORMAL() {
// Local symbols cannot be string expansions
if (token.type == T_(ID) && lexerState->expandStrings) {
// Attempt string expansion
Symbol const *sym = sym_FindExactSymbol(
std::get<std::string>(token.value).c_str()
);
Symbol const *sym =
sym_FindExactSymbol(std::get<std::string>(token.value).c_str());
if (sym && sym->type == SYM_EQUS) {
char const *str = sym->getEqus()->c_str();

View File

@@ -28,7 +28,7 @@ struct OptStackEntry {
bool warnOnLdOpt;
bool warningsAreErrors;
size_t maxRecursionDepth;
enum WarningState warningStates[numWarningStates];
WarningState warningStates[numWarningStates];
};
static std::stack<OptStackEntry> stack;

View File

@@ -295,7 +295,7 @@ void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32
// Creates an assert that will be written to the object file
void out_CreateAssert(
enum AssertionType type, Expression const &expr, char const *message, uint32_t ofs
AssertionType type, Expression const &expr, char const *message, uint32_t ofs
) {
Assertion &assertion = assertions.emplace_front();

View File

@@ -78,9 +78,9 @@
char *dest, size_t destLen, char const *spec,
std::vector<std::variant<uint32_t, std::string>> &args
);
static void compoundAssignment(const char *symName, enum RPNCommand op, int32_t constValue);
static void failAssert(enum AssertionType type);
static void failAssertMsg(enum AssertionType type, char const *msg);
static void compoundAssignment(const char *symName, RPNCommand op, int32_t constValue);
static void failAssert(AssertionType type);
static void failAssertMsg(AssertionType type, char const *msg);
void yyerror(char const *str);
// The CPU encodes instructions in a logical way, so most instructions actually follow patterns.
@@ -838,7 +838,7 @@ shift:
load:
POP_LOAD sectmod string COMMA sectiontype sectorg sectattrs {
sect_SetLoadSection($3.string, (enum SectionType)$5, $6, $7, $2);
sect_SetLoadSection($3.string, (SectionType)$5, $6, $7, $2);
}
| POP_ENDL {
sect_EndLoadSection();
@@ -1402,10 +1402,10 @@ relocexpr_no_str:
rpn_StartOfSection($$, $3.string);
}
| OP_SIZEOF LPAREN sectiontype RPAREN {
rpn_SizeOfSectionType($$, (enum SectionType)$3);
rpn_SizeOfSectionType($$, (SectionType)$3);
}
| OP_STARTOF LPAREN sectiontype RPAREN {
rpn_StartOfSectionType($$, (enum SectionType)$3);
rpn_StartOfSectionType($$, (SectionType)$3);
}
| OP_DEF {
lexer_ToggleStringExpansion(false);
@@ -1611,7 +1611,7 @@ strfmt_va_args:
section:
POP_SECTION sectmod string COMMA sectiontype sectorg sectattrs {
sect_NewSection($3.string, (enum SectionType)$5, $6, $7, $2);
sect_NewSection($3.string, (SectionType)$5, $6, $7, $2);
}
;
@@ -2730,7 +2730,7 @@ static void strfmt(
dest[i] = '\0';
}
static void compoundAssignment(const char *symName, enum RPNCommand op, int32_t constValue) {
static void compoundAssignment(const char *symName, RPNCommand op, int32_t constValue) {
Expression oldExpr, constExpr, newExpr;
int32_t newValue;
@@ -2741,7 +2741,7 @@ static void compoundAssignment(const char *symName, enum RPNCommand op, int32_t
sym_AddVar(symName, newValue);
}
static void failAssert(enum AssertionType type) {
static void failAssert(AssertionType type) {
switch (type) {
case ASSERT_FATAL:
fatalerror("Assertion failed\n");
@@ -2754,7 +2754,7 @@ static void failAssert(enum AssertionType type) {
}
}
static void failAssertMsg(enum AssertionType type, char const *msg) {
static void failAssertMsg(AssertionType type, char const *msg) {
switch (type) {
case ASSERT_FATAL:
fatalerror("Assertion failed: %s\n", msg);

View File

@@ -198,7 +198,7 @@ void rpn_StartOfSection(Expression &expr, char const *sectionName) {
}
}
void rpn_SizeOfSectionType(Expression &expr, enum SectionType type) {
void rpn_SizeOfSectionType(Expression &expr, SectionType type) {
initExpression(expr);
makeUnknown(expr, "Section type's size is not known");
@@ -209,7 +209,7 @@ void rpn_SizeOfSectionType(Expression &expr, enum SectionType type) {
*ptr++ = type;
}
void rpn_StartOfSectionType(Expression &expr, enum SectionType type) {
void rpn_StartOfSectionType(Expression &expr, SectionType type) {
initExpression(expr);
makeUnknown(expr, "Section type's start is not known");
@@ -343,9 +343,7 @@ static int32_t tryConstMask(Expression const &lhs, Expression const &rhs) {
return (symbolOfs + sect.alignOfs) & ~unknownBits;
}
void rpn_BinaryOp(
enum RPNCommand op, Expression &expr, const Expression &src1, const Expression &src2
) {
void rpn_BinaryOp(RPNCommand op, Expression &expr, const Expression &src1, const Expression &src2) {
initExpression(expr);
expr.isSymbol = false;
int32_t constMaskVal;

View File

@@ -128,7 +128,7 @@ Section *sect_FindSectionByName(char const *name) {
} while (0)
static unsigned int mergeSectUnion(
Section &sect, enum SectionType type, uint32_t org, uint8_t alignment, uint16_t alignOffset
Section &sect, SectionType type, uint32_t org, uint8_t alignment, uint16_t alignOffset
) {
assert(alignment < 16); // Should be ensured by the caller
unsigned int nbSectErrors = 0;
@@ -240,12 +240,12 @@ static unsigned int
static void mergeSections(
Section &sect,
enum SectionType type,
SectionType type,
uint32_t org,
uint32_t bank,
uint8_t alignment,
uint16_t alignOffset,
enum SectionModifier mod
SectionModifier mod
) {
unsigned int nbSectErrors = 0;
@@ -296,12 +296,12 @@ static void mergeSections(
// Create a new section, not yet in the list.
static Section *createSection(
char const *name,
enum SectionType type,
SectionType type,
uint32_t org,
uint32_t bank,
uint8_t alignment,
uint16_t alignOffset,
enum SectionModifier mod
SectionModifier mod
) {
// Add the new section to the list (order doesn't matter)
Section &sect = sectionList.emplace_front();
@@ -326,11 +326,7 @@ static Section *createSection(
// Find a section by name and type. If it doesn't exist, create it.
static Section *getSection(
char const *name,
enum SectionType type,
uint32_t org,
SectionSpec const &attrs,
enum SectionModifier mod
char const *name, SectionType type, uint32_t org, SectionSpec const &attrs, SectionModifier mod
) {
uint32_t bank = attrs.bank;
uint8_t alignment = attrs.alignment;
@@ -445,11 +441,7 @@ bool Section::isSizeKnown() const {
// Set the current section by name and type
void sect_NewSection(
char const *name,
enum SectionType type,
uint32_t org,
SectionSpec const &attrs,
enum SectionModifier mod
char const *name, SectionType type, uint32_t org, SectionSpec const &attrs, SectionModifier mod
) {
if (currentLoadSection)
fatalerror("Cannot change the section within a `LOAD` block\n");
@@ -469,11 +461,7 @@ void sect_NewSection(
// Set the current section by name and type
void sect_SetLoadSection(
char const *name,
enum SectionType type,
uint32_t org,
SectionSpec const &attrs,
enum SectionModifier mod
char const *name, SectionType type, uint32_t org, SectionSpec const &attrs, SectionModifier mod
) {
// Important info: currently, UNION and LOAD cannot interact, since UNION is prohibited in
// "code" sections, whereas LOAD is restricted to them.
@@ -612,7 +600,7 @@ static void writelong(uint32_t b) {
writebyte(b >> 24);
}
static void createPatch(enum PatchType type, Expression const &expr, uint32_t pcShift) {
static void createPatch(PatchType type, Expression const &expr, uint32_t pcShift) {
out_CreatePatch(type, expr, sect_GetOutputOffset(), pcShift);
}

View File

@@ -19,7 +19,7 @@
unsigned int nbErrors = 0;
unsigned int maxErrors = 0;
static const enum WarningState defaultWarnings[ARRAY_SIZE(warningStates)] = {
static const WarningState defaultWarnings[ARRAY_SIZE(warningStates)] = {
WARNING_ENABLED, // WARNING_ASSERT
WARNING_DISABLED, // WARNING_BACKWARDS_FOR
WARNING_DISABLED, // WARNING_BUILTIN_ARG
@@ -45,17 +45,17 @@ static const enum WarningState defaultWarnings[ARRAY_SIZE(warningStates)] = {
WARNING_DISABLED, // WARNING_UNMAPPED_CHAR_2
};
enum WarningState warningStates[ARRAY_SIZE(warningStates)];
WarningState warningStates[ARRAY_SIZE(warningStates)];
bool warningsAreErrors; // Set if `-Werror` was specified
static enum WarningState warningState(enum WarningID id) {
static WarningState warningState(WarningID id) {
// Check if warnings are globally disabled
if (!warnings)
return WARNING_DISABLED;
// Get the actual state
enum WarningState state = warningStates[id];
WarningState state = warningStates[id];
if (state == WARNING_DEFAULT)
// The state isn't set, grab its default state
@@ -109,8 +109,8 @@ static const struct {
{"unmapped-char", 2, 1},
};
static bool tryProcessParamWarning(char const *flag, uint8_t param, enum WarningState state) {
enum WarningID baseID = PARAM_WARNINGS_START;
static bool tryProcessParamWarning(char const *flag, uint8_t param, WarningState state) {
WarningID baseID = PARAM_WARNINGS_START;
for (size_t i = 0; i < ARRAY_SIZE(paramWarnings); i++) {
uint8_t maxParam = paramWarnings[i].nbLevels;
@@ -142,7 +142,7 @@ static bool tryProcessParamWarning(char const *flag, uint8_t param, enum Warning
return true;
}
baseID = (enum WarningID)(baseID + maxParam);
baseID = (WarningID)(baseID + maxParam);
}
return false;
}
@@ -214,7 +214,7 @@ void processWarningFlag(char const *flag) {
static bool setError = false;
// First, try to match against a "meta" warning
for (enum WarningID id : EnumSeq(META_WARNINGS_START, NB_WARNINGS)) {
for (WarningID id : EnumSeq(META_WARNINGS_START, NB_WARNINGS)) {
// TODO: improve the matching performance?
if (!strcmp(flag, warningFlags[id])) {
// We got a match!
@@ -256,10 +256,10 @@ void processWarningFlag(char const *flag) {
// Well, it's either a normal warning or a mistake
enum WarningState state = setError ? WARNING_ERROR
// Not an error, then check if this is a negation
: strncmp(flag, "no-", strlen("no-")) ? WARNING_ENABLED
: WARNING_DISABLED;
WarningState state = setError ? WARNING_ERROR
// Not an error, then check if this is a negation
: strncmp(flag, "no-", strlen("no-")) ? WARNING_ENABLED
: WARNING_DISABLED;
char const *rootFlag = state == WARNING_DISABLED ? flag + strlen("no-") : flag;
// Is this a "parametric" warning?
@@ -312,7 +312,7 @@ void processWarningFlag(char const *flag) {
}
// Try to match the flag against a "normal" flag
for (enum WarningID id : EnumSeq(NB_PLAIN_WARNINGS)) {
for (WarningID id : EnumSeq(NB_PLAIN_WARNINGS)) {
if (!strcmp(rootFlag, warningFlags[id])) {
// We got a match!
warningStates[id] = state;
@@ -368,7 +368,7 @@ void error(char const *fmt, ...) {
exit(1);
}
void warning(enum WarningID id, char const *fmt, ...) {
void warning(WarningID id, char const *fmt, ...) {
char const *flag = warningFlags[id];
va_list args;