[cfe-commits] r148026 - in /cfe/trunk: lib/Analysis/FormatString.cpp test/Sema/format-strings-c90.c test/Sema/format-strings-scanf.c
Hans Wennborg
hans at hanshq.net
Thu Jan 12 07:07:16 PST 2012
Author: hans
Date: Thu Jan 12 09:07:16 2012
New Revision: 148026
URL: http://llvm.org/viewvc/llvm-project?rev=148026&view=rev
Log:
scanf analysis: the 'a' length modifier is valid with a scanlist
Before r148025 we (accidentally) didn't check whether a length modifier is
appropriate for a scanlist, but now we do.
Modified:
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/test/Sema/format-strings-c90.c
cfe/trunk/test/Sema/format-strings-scanf.c
Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=148026&r1=148025&r2=148026&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Thu Jan 12 09:07:16 2012
@@ -550,6 +550,7 @@
switch (CS.getKind()) {
case ConversionSpecifier::sArg:
case ConversionSpecifier::SArg:
+ case ConversionSpecifier::ScanListArg:
return true;
default:
return false;
Modified: cfe/trunk/test/Sema/format-strings-c90.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-c90.c?rev=148026&r1=148025&r2=148026&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings-c90.c (original)
+++ cfe/trunk/test/Sema/format-strings-c90.c Thu Jan 12 09:07:16 2012
@@ -7,6 +7,7 @@
void foo(char **sp, float *fp, int *ip) {
/* TODO: Warn that the 'a' length modifier is an extension. */
scanf("%as", sp);
+ scanf("%a[abc]", sp);
/* TODO: Warn that the 'a' conversion specifier is a C99 feature. */
scanf("%a", fp);
Modified: cfe/trunk/test/Sema/format-strings-scanf.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-scanf.c?rev=148026&r1=148025&r2=148026&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings-scanf.c (original)
+++ cfe/trunk/test/Sema/format-strings-scanf.c Thu Jan 12 09:07:16 2012
@@ -68,8 +68,9 @@
vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
}
-void test_scanlist(int *ip) {
+void test_scanlist(int *ip, char *sp) {
scanf("%[abc]", ip); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int *'}}
+ scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}}
}
void test_alloc_extension(char **sp, wchar_t **lsp) {
More information about the cfe-commits
mailing list