]> granicus.if.org Git - clang/commitdiff
Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4
authorSunil Srivastava <sunil_srivastava@playstation.sony.com>
Tue, 26 Apr 2016 23:19:00 +0000 (23:19 +0000)
committerSunil Srivastava <sunil_srivastava@playstation.sony.com>
Tue, 26 Apr 2016 23:19:00 +0000 (23:19 +0000)
This is an addendum to r229921.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267625 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/Sema/format-strings-freebsd.c

index badc71021a12f5ecaa11c61d07c5dd6d0ba3a78d..83d08b55427fd32dffb8175bbf581ffbbd358009 100644 (file)
@@ -694,7 +694,7 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target) const {
           return true;
         case ConversionSpecifier::FreeBSDrArg:
         case ConversionSpecifier::FreeBSDyArg:
-          return Target.getTriple().isOSFreeBSD();
+          return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
         default:
           return false;
       }
@@ -727,7 +727,7 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target) const {
           return true;
         case ConversionSpecifier::FreeBSDrArg:
         case ConversionSpecifier::FreeBSDyArg:
-          return Target.getTriple().isOSFreeBSD();
+          return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
         default:
           return false;
       }
index cdf273ae10938c906593d2e51f14d8c94f9fcd63..965d7c287be650edcc0be9e6bbd411bee72709bd 100644 (file)
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
 
 // Test FreeBSD kernel printf extensions.
 int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));
 
-void check_freebsd_kernel_extensions(int i, long l, char *s)
+void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
 {
   // %b expects an int and a char *
   freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
@@ -32,6 +33,12 @@ void check_freebsd_kernel_extensions(int i, long l, char *s)
   freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
   freebsd_kernel_printf("%lr", l); // no-warning
 
+  // h modifier expects a short
+  freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hr", h); // no-warning
+  freebsd_kernel_printf("%hy", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hy", h); // no-warning
+
   // %y expects an int
   freebsd_kernel_printf("%y", i); // no-warning
   freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}