Skip to content

Commit

Permalink
replace uses of c2x with c23
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu committed Nov 6, 2023
1 parent 08bde2c commit a7f0cbd
Show file tree
Hide file tree
Showing 47 changed files with 126 additions and 125 deletions.
2 changes: 1 addition & 1 deletion include/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct {

#if __STDC_VERSION__ >= 202311L
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpre-c2x-compat"
# pragma GCC diagnostic ignored "-Wpre-c23-compat"
typedef typeof(nullptr) nullptr_t;
# pragma GCC diagnostic pop

Expand Down
8 changes: 4 additions & 4 deletions src/Attribute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ syntax: Syntax,
args: Arguments,

pub const Syntax = enum {
c2x,
c23,
declspec,
gnu,
keyword,
};

pub const Kind = enum {
c2x,
c23,
declspec,
gnu,

pub fn toSyntax(kind: Kind) Syntax {
return switch (kind) {
.c2x => .c2x,
.c23 => .c23,
.declspec => .declspec,
.gnu => .gnu,
};
Expand Down Expand Up @@ -684,7 +684,7 @@ pub fn fromString(kind: Kind, namespace: ?[]const u8, name: []const u8) ?Tag {
tag: Tag,
gnu: bool = false,
declspec: bool = false,
c2x: bool = false,
c23: bool = false,
};
const attribute_names = @import("Attribute/names.def").with(Properties);

Expand Down
16 changes: 8 additions & 8 deletions src/Attribute/names.def
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# multiple
deprecated
.tag = .deprecated
.c2x = true
.c23 = true
.gnu = true
.declspec = true

fallthrough
.tag = .fallthrough
.c2x = true
.c23 = true
.gnu = true

noreturn
.tag = .@"noreturn"
.c2x = true
.c23 = true
.gnu = true
.declspec = true

Expand All @@ -26,22 +26,22 @@ noinline
.gnu = true
.declspec = true

# c2x only
# c23 only
nodiscard
.tag = .nodiscard
.c2x = true
.c23 = true

reproducible
.tag = .reproducible
.c2x = true
.c23 = true

unsequenced
.tag = .unsequenced
.c2x = true
.c23 = true

maybe_unused
.tag = .unused
.c2x = true
.c23 = true

# gnu only
access
Expand Down
56 changes: 28 additions & 28 deletions src/Diagnostics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub const Options = struct {
@"array-bounds": Kind = .default,
@"int-conversion": Kind = .default,
@"pointer-type-mismatch": Kind = .default,
@"c2x-extensions": Kind = .default,
@"c23-extensions": Kind = .default,
@"incompatible-pointer-types": Kind = .default,
@"excess-initializers": Kind = .default,
@"division-by-zero": Kind = .default,
Expand Down Expand Up @@ -164,7 +164,7 @@ pub const Options = struct {
@"keyword-macro": Kind = .default,
@"pointer-arith": Kind = .default,
@"sizeof-array-argument": Kind = .default,
@"pre-c2x-compat": Kind = .default,
@"pre-c23-compat": Kind = .default,
@"pointer-bool-conversion": Kind = .default,
@"string-conversion": Kind = .default,
@"gnu-auto-type": Kind = .default,
Expand Down Expand Up @@ -384,7 +384,7 @@ const messages = struct {
const kind = .warning;
const all = true;
};
pub const missing_type_specifier_c2x = struct {
pub const missing_type_specifier_c23 = struct {
const msg = "a type specifier is required for all declarations";
const kind = .@"error";
};
Expand Down Expand Up @@ -1137,17 +1137,17 @@ const messages = struct {
const kind = .@"error";
};
pub const static_assert_missing_message = struct {
const msg = "static_assert with no message is a C2X extension";
const opt = "c2x-extensions";
const msg = "static_assert with no message is a C23 extension";
const opt = "c23-extensions";
const kind = .warning;
const suppress_version = .c2x;
const suppress_version = .c23;
};
pub const pre_c2x_compat = struct {
const msg = "{s} is incompatible with C standards before C2x";
pub const pre_c23_compat = struct {
const msg = "{s} is incompatible with C standards before C23";
const extra = .str;
const kind = .off;
const suppress_unless_version = .c2x;
const opt = "pre-c2x-compat";
const suppress_unless_version = .c23;
const opt = "pre-c23-compat";
};
pub const unbound_vla = struct {
const msg = "variable length array must be bound in function definition";
Expand Down Expand Up @@ -1450,10 +1450,10 @@ const messages = struct {
const pedantic = true;
};
pub const omitting_parameter_name = struct {
const msg = "omitting the parameter name in a function definition is a C2x extension";
const opt = "c2x-extensions";
const msg = "omitting the parameter name in a function definition is a C23 extension";
const opt = "c23-extensions";
const kind = .warning;
const suppress_version = .c2x;
const suppress_version = .c23;
};
pub const non_int_bitfield = struct {
const msg = "bit-field has non-integer type '{s}'";
Expand Down Expand Up @@ -2227,7 +2227,7 @@ const messages = struct {
const kind = .off;
const pedantic = true;
const opt = "bit-int-extension";
const suppress_version = .c2x;
const suppress_version = .c23;
};
pub const unsigned_bit_int_too_small = struct {
const msg = "{s} must have a bit size of at least 1";
Expand Down Expand Up @@ -2306,10 +2306,10 @@ const messages = struct {
const kind = .@"error";
};
pub const bitint_suffix = struct {
const msg = "'_BitInt' suffix for literals is a C2x extension";
const opt = "c2x-extensions";
const msg = "'_BitInt' suffix for literals is a C23 extension";
const opt = "c23-extensions";
const kind = .warning;
const suppress_version = .c2x;
const suppress_version = .c23;
};
pub const auto_type_extension = struct {
const msg = "'__auto_type' is a GNU extension";
Expand Down Expand Up @@ -2469,21 +2469,21 @@ const messages = struct {
const extra = .ascii;
};
pub const ucn_basic_char_warning = struct {
const msg = "specifying character '{c}' with a universal character name is incompatible with C standards before C2x";
const msg = "specifying character '{c}' with a universal character name is incompatible with C standards before C23";
const kind = .off;
const extra = .ascii;
const suppress_unless_version = .c2x;
const opt = "pre-c2x-compat";
const suppress_unless_version = .c23;
const opt = "pre-c23-compat";
};
pub const ucn_control_char_error = struct {
const msg = "universal character name refers to a control character";
const kind = .@"error";
};
pub const ucn_control_char_warning = struct {
const msg = "universal character name referring to a control character is incompatible with C standards before C2x";
const msg = "universal character name referring to a control character is incompatible with C standards before C23";
const kind = .off;
const suppress_unless_version = .c2x;
const opt = "pre-c2x-compat";
const suppress_unless_version = .c23;
const opt = "pre-c23-compat";
};
pub const c89_ucn_in_literal = struct {
const msg = "universal character names are only valid in C99 or later";
Expand Down Expand Up @@ -2548,12 +2548,12 @@ const messages = struct {
const kind = .@"error";
};
pub const def_no_proto_deprecated = struct {
const msg = "a function definition without a prototype is deprecated in all versions of C and is not supported in C2x";
const msg = "a function definition without a prototype is deprecated in all versions of C and is not supported in C23";
const kind = .warning;
const opt = "deprecated-non-prototype";
};
pub const passing_args_to_kr = struct {
const msg = "passing arguments to without a prototype is deprecated in all versions of C and is not supported in C2x";
const msg = "passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C23";
const kind = .warning;
const opt = "deprecated-non-prototype";
};
Expand All @@ -2563,10 +2563,10 @@ const messages = struct {
const extra = .str;
};
pub const label_compound_end = struct {
const msg = "label at end of compound statement is a C2x extension";
const opt = "c2x-extensions";
const msg = "label at end of compound statement is a C23 extension";
const opt = "c23-extensions";
const kind = .warning;
const suppress_version = .c2x;
const suppress_version = .c23;
};
};

Expand Down
4 changes: 2 additions & 2 deletions src/Driver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pub const usage =
\\ -c, --compile Only run preprocess, compile, and assemble steps
\\ -D <macro>=<value> Define <macro> to <value> (defaults to 1)
\\ -E Only run the preprocessor
\\ -fchar8_t Enable char8_t (enabled by default in C2X and later)
\\ -fno-char8_t Disable char8_t (disabled by default for pre-C2X)
\\ -fchar8_t Enable char8_t (enabled by default in C23 and later)
\\ -fno-char8_t Disable char8_t (disabled by default for pre-C23)
\\ -fcolor-diagnostics Enable colors in diagnostics
\\ -fno-color-diagnostics Disable colors in diagnostics
\\ -fdeclspec Enable support for __declspec attributes
Expand Down
29 changes: 15 additions & 14 deletions src/LangOpts.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ pub const Standard = enum {
default,
/// ISO C 2017 with GNU extensions
gnu17,
/// Working Draft for ISO C2x
c2x,
/// Working Draft for ISO C2x with GNU extensions
gnu2x,
/// Working Draft for ISO C23
c23,
/// Working Draft for ISO C23 with GNU extensions
gnu23,

const NameMap = std.ComptimeStringMap(Standard, .{
.{ "c89", .c89 }, .{ "c90", .c89 }, .{ "iso9899:1990", .c89 },
.{ "iso9899:199409", .iso9899 }, .{ "gnu89", .gnu89 }, .{ "gnu90", .gnu89 },
.{ "c99", .c99 }, .{ "iso9899:1999", .c99 }, .{ "gnu99", .gnu99 },
.{ "c11", .c11 }, .{ "iso9899:2011", .c11 }, .{ "gnu11", .gnu11 },
.{ "c17", .c17 }, .{ "iso9899:2017", .c17 }, .{ "c18", .c17 },
.{ "iso9899:2018", .c17 }, .{ "gnu17", .gnu17 }, .{ "gnu18", .gnu17 },
.{ "c2x", .c2x }, .{ "gnu2x", .gnu2x },
.{ "c99", .c99 }, .{ "iso9899:1999", .c99 }, .{ "c9x", .c99 },
.{ "iso9899:199x", .c99 }, .{ "gnu99", .gnu99 }, .{ "gnu9x", .gnu99 },
.{ "c11", .c11 }, .{ "iso9899:2011", .c11 }, .{ "c1x", .c11 },
.{ "iso9899:201x", .c11 }, .{ "gnu11", .gnu11 }, .{ "c17", .c17 },
.{ "iso9899:2017", .c17 }, .{ "c18", .c17 }, .{ "iso9899:2018", .c17 },
.{ "gnu17", .gnu17 }, .{ "gnu18", .gnu17 }, .{ "c23", .c23 },
.{ "gnu23", .gnu23 }, .{ "c2x", .c23 }, .{ "gnu2x", .gnu23 },
});

pub fn atLeast(self: Standard, other: Standard) bool {
Expand All @@ -65,7 +67,7 @@ pub const Standard = enum {

pub fn isGNU(standard: Standard) bool {
return switch (standard) {
.gnu89, .gnu99, .gnu11, .default, .gnu17, .gnu2x => true,
.gnu89, .gnu99, .gnu11, .default, .gnu17, .gnu23 => true,
else => false,
};
}
Expand All @@ -82,8 +84,7 @@ pub const Standard = enum {
.c99, .gnu99 => "199901L",
.c11, .gnu11 => "201112L",
.default, .c17, .gnu17 => "201710L",
// todo: subject to change, verify once c23 finalized
.c2x, .gnu2x => "202311L",
.c23, .gnu23 => "202311L",
};
}

Expand Down Expand Up @@ -119,7 +120,7 @@ allow_half_args_and_returns: bool = false,
fp_eval_method: ?FPEvalMethod = null,
/// If set, use specified signedness for `char` instead of the target's default char signedness
char_signedness_override: ?std.builtin.Signedness = null,
/// If set, override the default availability of char8_t (by default, enabled in C2X and later; disabled otherwise)
/// If set, override the default availability of char8_t (by default, enabled in C23 and later; disabled otherwise)
has_char8_t_override: ?bool = null,

/// Whether to allow GNU-style inline assembly
Expand All @@ -145,7 +146,7 @@ pub fn disableMSExtensions(self: *LangOpts) void {
}

pub fn hasChar8_T(self: *const LangOpts) bool {
return self.has_char8_t_override orelse self.standard.atLeast(.c2x);
return self.has_char8_t_override orelse self.standard.atLeast(.c23);
}

pub fn hasDigraphs(self: *const LangOpts) bool {
Expand Down
Loading

0 comments on commit a7f0cbd

Please sign in to comment.