This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix handling of "%zd" format specifier in scanf
ClosedPublic

Authored by alexander-shaposhnikov on Jul 19 2017, 4:35 PM.

Details

Summary

This is a follow-up for https://reviews.llvm.org/D35427
ScanfFormatString.cpp has the same issue (incorrect handling of
the specifiers for ssize_t) and this diff fixes it and adds tests.

Test plan: make check-all

Diff Detail

Repository
rL LLVM

Event Timeline

test/Sema/format-strings-fixit-ssize_t.c
4 ↗(On Diff #107411)

c99 is necessary for "zd"

test/Sema/format-strings-scanf.c
1 ↗(On Diff #107411)

c11 is necessary for _Generic below.
I have not found a more reliable way to define ssize_t
which doesn't require a large number of #ifdef ...

aaron.ballman accepted this revision.Jul 20 2017, 7:43 AM

LGTM with a small testing nit.

test/Sema/format-strings-scanf.c
1 ↗(On Diff #107411)

Ugh, that is pretty nasty, but I cannot think of a better way to define it in a generic manner.

198 ↗(On Diff #107411)

Can you add a passing test for %zn?

This revision is now accepted and ready to land.Jul 20 2017, 7:43 AM
alexander-shaposhnikov marked an inline comment as done.Jul 20 2017, 12:44 PM
This revision was automatically updated to reflect the committed changes.