]> granicus.if.org Git - clang/commitdiff
Recognize 'q' as a format length modifier (from BSD).
authorDaniel Dunbar <daniel@zuster.org>
Sat, 30 Jan 2010 15:49:20 +0000 (15:49 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 30 Jan 2010 15:49:20 +0000 (15:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94894 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/PrintfFormatString.h
lib/Analysis/PrintfFormatString.cpp
test/Sema/format-strings.c

index e2c0d232fa8499436a16725592b8b7c1e2173549..0431be143ebd12188037b121fda6e341afaa12cd 100644 (file)
@@ -105,7 +105,7 @@ enum LengthModifier {
  AsChar,      // 'hh'
  AsShort,     // 'h'
  AsLong,      // 'l'
- AsLongLong,  // 'll'
+ AsLongLong,  // 'll', 'q' (BSD, deprecated)
  AsIntMax,    // 'j'
  AsSizeT,     // 'z'
  AsPtrDiff,   // 't'
index 05b5d9cceba30f9c1b2f75f269373eadaf6c4db6..d2bcbb04f9d68c0d9578727ffeb5df9d5cde5195 100644 (file)
@@ -185,6 +185,7 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
     case 'z': lm = AsSizeT;      ++I; break;
     case 't': lm = AsPtrDiff;    ++I; break;
     case 'L': lm = AsLongDouble; ++I; break;
+    case 'q': lm = AsLongLong;   ++I; break;
   }
   FS.setLengthModifier(lm);
   
index 21d7770e12cfb4ef322721d26b462657d355d5fa..02e39a426be23f26ff3b6f66dcc0fa1a6e8bc2c5 100644 (file)
@@ -144,7 +144,7 @@ void torture(va_list v8) {
   
 }
 
-void test10(int x, float f, int i) {
+void test10(int x, float f, int i, long long lli) {
   printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}}
   printf("\0"); // expected-warning{{format string contains '\0' within the string body}}
   printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}}
@@ -161,6 +161,7 @@ void test10(int x, float f, int i) {
   printf("%.d", x); // no-warning
   printf("%.", x);  // expected-warning{{incomplete format specifier}}
   printf("%f", 4); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}}
+  printf("%qd", lli);
 } 
 
 typedef struct __aslclient *aslclient;