Skip to content

Commit 5410d0a

Browse files
committed
[libcxx] Silence -Wformat-nonliteral warnings in the Windows support code
This brings the mingw build back to zero build warnings as it was at some earlier time. Differential Revision: https://reviews.llvm.org/D119134 (cherry picked from commit 8cffea0)
1 parent 97fdb3a commit 5410d0a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

libcxx/src/support/win32/locale_win32.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
9797
ret, n, format, loc, ap);
9898
#else
9999
__libcpp_locale_guard __current(loc);
100+
#pragma clang diagnostic push
101+
#pragma clang diagnostic ignored "-Wformat-nonliteral"
100102
int result = vsnprintf( ret, n, format, ap );
103+
#pragma clang diagnostic pop
101104
#endif
102105
va_end(ap);
103106
return result;

libcxx/src/support/win32/support.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
2323
// Query the count required.
2424
va_list ap_copy;
2525
va_copy(ap_copy, ap);
26+
#pragma clang diagnostic push
27+
#pragma clang diagnostic ignored "-Wformat-nonliteral"
2628
int count = vsnprintf( NULL, 0, format, ap_copy );
29+
#pragma clang diagnostic pop
2730
va_end(ap_copy);
2831
if (count < 0)
2932
return count;
@@ -33,7 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
3336
return -1;
3437
// If we haven't used exactly what was required, something is wrong.
3538
// Maybe bug in vsnprintf. Report the error and return.
39+
#pragma clang diagnostic push
40+
#pragma clang diagnostic ignored "-Wformat-nonliteral"
3641
if (vsnprintf(p, buffer_size, format, ap) != count) {
42+
#pragma clang diagnostic pop
3743
free(p);
3844
return -1;
3945
}

0 commit comments

Comments
 (0)