[cfe-commits] r99212 - in /cfe/trunk/test/Sema: attr-format.c format-attr-pr4470.c format-attribute-printf0.c
Chris Lattner
sabre at nondot.org
Mon Mar 22 14:05:16 PDT 2010
Author: lattner
Date: Mon Mar 22 16:05:15 2010
New Revision: 99212
URL: http://llvm.org/viewvc/llvm-project?rev=99212&view=rev
Log:
merge some tests.
Removed:
cfe/trunk/test/Sema/format-attr-pr4470.c
cfe/trunk/test/Sema/format-attribute-printf0.c
Modified:
cfe/trunk/test/Sema/attr-format.c
Modified: cfe/trunk/test/Sema/attr-format.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-format.c?rev=99212&r1=99211&r2=99212&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-format.c (original)
+++ cfe/trunk/test/Sema/attr-format.c Mon Mar 22 16:05:15 2010
@@ -32,3 +32,39 @@
int rdar6623513_aux(int len, const char* s) {
rdar6623513(0, "hello", "%.*s", len, s);
}
+
+
+
+// same as format(printf(...))...
+void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
+void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
+
+// FreeBSD usage
+#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
+void null(int i, const char *a, ...) __printf0like(2,0); // no-error
+void null(int i, const char *a, ...) {
+ if (a)
+ (void)0/* vprintf(...) would go here */;
+}
+
+void callnull(void){
+ null(0, 0); // no error
+ null(0, (char*)0); // no error
+ null(0, (void*)0); // no error
+ null(0, (int*)0); // expected-warning {{incompatible pointer types}}
+}
+
+
+
+// PR4470
+int xx_vprintf(const char *, va_list);
+
+const char *foo(const char *format) __attribute__((format_arg(1)));
+
+void __attribute__((format(printf, 1, 0)))
+foo2(const char *fmt, va_list va) {
+ xx_vprintf(foo(fmt), va);
+}
Removed: cfe/trunk/test/Sema/format-attr-pr4470.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-attr-pr4470.c?rev=99211&view=auto
==============================================================================
--- cfe/trunk/test/Sema/format-attr-pr4470.c (original)
+++ cfe/trunk/test/Sema/format-attr-pr4470.c (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat=2 %s
-
-#include <stdarg.h>
-int vprintf(const char *, va_list);
-
-const char *foo(const char *format) __attribute__((format_arg(1)));
-
-void __attribute__((format(printf, 1, 0)))
-foo2(const char *fmt, va_list va)
-{
- vprintf(foo(fmt), va);
-}
Removed: cfe/trunk/test/Sema/format-attribute-printf0.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-attribute-printf0.c?rev=99211&view=auto
==============================================================================
--- cfe/trunk/test/Sema/format-attribute-printf0.c (original)
+++ cfe/trunk/test/Sema/format-attribute-printf0.c (removed)
@@ -1,26 +0,0 @@
-//RUN: %clang_cc1 -fsyntax-only -verify %s
-
-#include <stdarg.h>
-
-// same as format(printf(...))...
-void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
-void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
-void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
-void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
-void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
-
-// FreeBSD usage
-#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
-void null(int i, const char *a, ...) __printf0like(2,0); // no-error
-void null(int i, const char *a, ...) {
- if (a)
- (void)0/* vprintf(...) would go here */;
-}
-
-void callnull(void){
- null(0, 0); // no error
- null(0, (char*)0); // no error
- null(0, (void*)0); // no error
- null(0, (int*)0); // expected-warning {{incompatible pointer types}}
-}
-
More information about the cfe-commits
mailing list