Use standard attribute syntax instead of IBM __attribute__

Move format attrs to proper standard location

For some reason, GCC 13 is more lax than earlier versions...
This commit is contained in:
ISSOtm
2024-03-28 00:47:58 +01:00
committed by Rangi42
parent 506911d7d0
commit cae7b5dcf6
11 changed files with 36 additions and 42 deletions

View File

@@ -45,7 +45,7 @@ void FormatSpec::useCharacter(int c) {
case '0':
if (state < FORMAT_WIDTH)
padZero = true;
// fallthrough
[[fallthrough]];
case '1':
case '2':
case '3':

View File

@@ -864,7 +864,7 @@ static void discardBlockComment() {
case '\r':
// Handle CRLF before nextLine() since shiftChar updates colNo
handleCRLF(c);
// fallthrough
[[fallthrough]];
case '\n':
if (lexerState->expansions.empty())
nextLine();
@@ -879,7 +879,7 @@ static void discardBlockComment() {
shiftChar();
return;
}
// fallthrough
[[fallthrough]];
default:
continue;
}
@@ -1216,7 +1216,7 @@ static void appendEscapedSubstring(std::string &yylval, std::string const &str)
case '"':
case '{':
yylval += '\\';
// fallthrough
[[fallthrough]];
default:
yylval += c;
break;
@@ -1515,7 +1515,7 @@ static Token yylex_NORMAL() {
case ';':
discardComment();
// fallthrough
[[fallthrough]];
case ' ':
case '\t':
break;
@@ -1729,7 +1729,7 @@ static Token yylex_NORMAL() {
case '\r':
handleCRLF(c);
// fallthrough
[[fallthrough]];
case '\n':
return Token(T_(NEWLINE));
@@ -1751,7 +1751,7 @@ static Token yylex_NORMAL() {
shiftChar();
return Token(T_(STRING), readString(true));
}
// fallthrough
[[fallthrough]];
// Handle identifiers... or report garbage characters
@@ -1846,7 +1846,7 @@ static Token yylex_RAW() {
case ';': // Comments inside macro args
discardComment();
c = peek();
// fallthrough
[[fallthrough]];
case '\r': // End of line
case '\n':
case EOF:
@@ -1920,7 +1920,7 @@ backslash:
error("Illegal character escape %s\n", printChar(c));
break;
}
// fallthrough
[[fallthrough]];
default: // Regular characters will just get copied
append:

View File

@@ -198,7 +198,7 @@ int main(int argc, char *argv[]) {
// introduced to better match the `-I dir` option of gcc and clang.
case 'i':
warning(WARNING_OBSOLETE, "`-i` is deprecated; use `-I`\n");
// fallthrough
[[fallthrough]];
case 'I':
fstk_AddIncludePath(musl_optarg);
break;

View File

@@ -47,7 +47,7 @@ std::optional<std::string> currentLoadScope = std::nullopt;
int32_t loadOffset; // Offset into the LOAD section's parent (see sect_GetOutputOffset)
// A quick check to see if we have an initialized section
attr_(warn_unused_result) static bool checksection() {
[[nodiscard]] static bool checksection() {
if (currentSection)
return true;
@@ -57,7 +57,7 @@ attr_(warn_unused_result) static bool checksection() {
// A quick check to see if we have an initialized section that can contain
// this much initialized data
attr_(warn_unused_result) static bool checkcodesection() {
[[nodiscard]] static bool checkcodesection() {
if (!checksection())
return false;
@@ -71,7 +71,7 @@ attr_(warn_unused_result) static bool checkcodesection() {
return false;
}
attr_(warn_unused_result) static bool checkSectionSize(Section const &sect, uint32_t size) {
[[nodiscard]] static bool checkSectionSize(Section const &sect, uint32_t size) {
uint32_t maxSize = sectionTypeInfo[sect.type].size;
// If the new size is reasonable, keep going
@@ -88,7 +88,7 @@ attr_(warn_unused_result) static bool checkSectionSize(Section const &sect, uint
}
// Check if the section has grown too much.
attr_(warn_unused_result) static bool reserveSpace(uint32_t delta_size) {
[[nodiscard]] static bool reserveSpace(uint32_t delta_size) {
// This check is here to trap broken code that generates sections that are too big and to
// prevent the assembler from generating huge object files or trying to allocate too much
// memory.

View File

@@ -76,7 +76,7 @@ static void printUsage() {
static uint8_t nbErrors;
static format_(printf, 1, 2) void report(char const *fmt, ...) {
[[gnu::format(printf, 1, 2)]] static void report(char const *fmt, ...) {
va_list ap;
va_start(ap, fmt);
@@ -465,7 +465,7 @@ static MbcType parseMBC(char const *name) {
static_assert(MBC1 + 2 == MBC1_RAM_BATTERY, "Enum sanity check failed!");
static_assert(MMM01 + 1 == MMM01_RAM, "Enum sanity check failed!");
static_assert(MMM01 + 2 == MMM01_RAM_BATTERY, "Enum sanity check failed!");
// fallthrough
[[fallthrough]];
case MBC1:
case MMM01:
if (features == RAM)

View File

@@ -50,11 +50,11 @@ retry:
do {
firstChar = getc(file);
} while (firstChar != EOF && firstChar != '\r' && firstChar != '\n');
// fallthrough
[[fallthrough]];
case '\r':
if (firstChar == '\r' && getc(file) != '\n')
consumeLF(where, lineNo, file);
// fallthrough
[[fallthrough]];
case '\n':
goto retry;
}
@@ -65,7 +65,7 @@ retry:
switch (c) {
case '\r':
consumeLF(where, lineNo, file);
// fallthrough
[[fallthrough]];
case '\n':
case EOF:
lineBuf.push_back('\0'); // Terminate the string (space was ensured above)