8000 gh-112301: Add -Wformat=2 compiler option to NODIST by nohlson · Pull Request #122474 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112301: Add -Wformat=2 compiler option to NODIST #122474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
8000 Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into add-format-level-2
  • Loading branch information
nohlson committed Sep 30, 2024
commit b62d15560e41b4f16d6712ecfb13a1c90c3bcbb1
35 changes: 35 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2863,30 +2863,65 @@
case 'o': case 'u': case 'x': case 'X':
{
char buffer[MAX_INTMAX_CHARS];
<<<<<<< HEAD

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

syntax error: missing ';' before '<<' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

syntax error: missing ';' before '<<' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

version control conflict marker in file

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

version control conflict marker in file

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

version control conflict marker in file

Check failure on line 2866 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

version control conflict marker in file
const char *fmt = NULL;
switch (*f) {
case 'o': fmt = formats_o[sizemod]; break;

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'formats_o': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'formats_o': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘fmt’ undeclared (first use in this function); did you mean ‘fma’?

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘formats_o’ undeclared (first use in this function)

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘fmt’ undeclared (first use in this function); did you mean ‘fma’?

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘formats_o’ undeclared (first use in this function)

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘fmt’ undeclared (first use in this function); did you mean ‘fma’?

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘formats_o’ undeclared (first use in this function)

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘fmt’ undeclared (first use in this function); did you mean ‘fma’?

Check failure on line 2869 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘formats_o’ undeclared (first use in this function)
case 'u': fmt = formats_u[sizemod]; break;

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'formats_u': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'formats_u': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘formats_u’ undeclared (first use in this function)

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘formats_u’ undeclared (first use in this function)

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘formats_u’ undeclared (first use in this function)

Check failure on line 2870 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘formats_u’ undeclared (first use in this function)
case 'x': fmt = formats_x[sizemod]; break;

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'formats_x': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'fmt': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'formats_x': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

subscript requires array or pointer type [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘formats_x’ undeclared (first use in this function)

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘formats_x’ undeclared (first use in this function)

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘formats_x’ undeclared (first use in this function)

Check failure on line 2871 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘formats_x’ undeclared (first use in this function)
case 'X': fmt = formats_X[sizemod]; break;

Check failure on line 2872 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘formats_X’ undeclared (first use in this function)

Check failure on line 2872 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘formats_X’ undeclared (first use in this function)

Check failure on line 2872 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘formats_X’ undeclared (first use in this function)

Check failure on line 2872 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘formats_X’ undeclared (first use in this function)
default: fmt = formats[sizemod]; break;

Check failure on line 2873 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘formats’ undeclared (first use in this function)

Check failure on line 2873 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

‘formats’ undeclared (first use in this function)

Check failure on line 2873 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

‘formats’ undeclared (first use in this function)

Check failure on line 2873 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

‘formats’ undeclared (first use in this function)
}
int issigned = (*f == 'd' || *f == 'i');

Check warning on line 2875 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

unused variable ‘issigned’ [-Wunused-variable]

Check warning on line 2875 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

unused variable ‘issigned’ [-Wunused-variable]

Check warning on line 2875 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

unused variable ‘issigned’ [-Wunused-variable]

Check warning on line 2875 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

unused variable ‘issigned’ [-Wunused-variable]
// Format strings for sprintf are selected from constant arrays of
// constant strings, and the variable used to index into the arrays
// is only assigned known constant values. Ignore warnings related
// to the format string not being a string literal.
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_FORMAT_NONLITERAL
=======

Check failure on line 2882 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

version control conflict marker in file

Check failure on line 2882 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer

version control conflict marker in file

Check failure on line 2882 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-22.04)

version control conflict marker in file

Check failure on line 2882 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-22.04)

version control conflict marker in file

// Fill buffer using sprinf, with one of many possible format
// strings, like "%llX" for `long long` in hexadecimal.
// The type/size is in `sizemod`; the format is in `*f`.

// Use macros with nested switches to keep the sprintf format strings
// as compile-time literals, avoiding warnings and maybe allowing
// optimizations.

// `SPRINT` macro does one sprintf
// Example usage: SPRINT("l", "X", unsigned long) expands to
// sprintf(buffer, "%" "l" "X", va_arg(*vargs, unsigned long))
#define SPRINT(SIZE_SPEC, FMT_CHAR, TYPE) \
sprintf(buffer, "%" SIZE_SPEC FMT_CHAR, va_arg(*vargs, TYPE))

// One inner switch to handle all format variants
#define DO_SPRINTS(SIZE_ A3D4 SPEC, SIGNED_TYPE, UNSIGNED_TYPE) \
switch (*f) { \
case 'o': len = SPRINT(SIZE_SPEC, "o", UNSIGNED_TYPE); break; \
case 'u': len = SPRINT(SIZE_SPEC, "u", UNSIGNED_TYPE); break; \
case 'x': len = SPRINT(SIZE_SPEC, "x", UNSIGNED_TYPE); break; \
case 'X': len = SPRINT(SIZE_SPEC, "X", UNSIGNED_TYPE); break; \
default: len = SPRINT(SIZE_SPEC, "d", SIGNED_TYPE); break; \
}

// Outer switch to handle all the sizes/types
>>>>>>> main
switch (sizemod) {
case F_LONG: DO_SPRINTS("l", long, unsigned long); break;
case F_LONGLONG: DO_SPRINTS("ll", long long, unsigned long long); break;

Check warning on line 2912 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2912 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2912 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2912 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
case F_SIZE: DO_SPRINTS("z", Py_ssize_t, size_t); break;

Check warning on line 2913 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2913 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2913 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2913 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
case F_PTRDIFF: DO_SPRINTS("t", ptrdiff_t, ptrdiff_t); break;

Check warning on line 2914 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2914 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2914 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2914 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
case F_INTMAX: DO_SPRINTS("j", intmax_t, uintmax_t); break;

Check warning on line 2915 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2915 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2915 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2915 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
default: DO_SPRINTS("", int, unsigned int); break;

Check warning on line 2916 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2916 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2916 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'function': 'char *const ' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 2916 in Objects/unicodeobject.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'sprintf': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
}
<<<<<<< HEAD
_Py_COMP_DIAG_POP
=======
#undef SPRINT
#undef DO_SPRINTS

>>>>>>> main
assert(len >= 0);

int sign = (buffer[0] == '-');
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0