]> granicus.if.org Git - clang/commitdiff
(re)implement PR6542, accepting and discarding the __gcc_tdiag__
authorChris Lattner <sabre@nondot.org>
Mon, 22 Mar 2010 21:08:50 +0000 (21:08 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 22 Mar 2010 21:08:50 +0000 (21:08 +0000)
format attribute specifier.

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

lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-format.c

index 73a34f8107e0d64791b829e8f51743244e6bbf24..5a7a3c31fe8c43bc320a5ca33b8fc58ffcccdff3 100644 (file)
@@ -1115,6 +1115,7 @@ enum FormatAttrKind {
   NSStringFormat,
   StrftimeFormat,
   SupportedFormat,
+  IgnoredFormat,
   InvalidFormat
 };
 
@@ -1136,6 +1137,9 @@ static FormatAttrKind getFormatAttrKind(llvm::StringRef Format) {
       Format == "zcmn_err")
     return SupportedFormat;
 
+  if (Format == "gcc_tdiag")
+    return IgnoredFormat;
+  
   return InvalidFormat;
 }
 
@@ -1171,6 +1175,10 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
 
   // Check for supported formats.
   FormatAttrKind Kind = getFormatAttrKind(Format);
+  
+  if (Kind == IgnoredFormat)
+    return;
+  
   if (Kind == InvalidFormat) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
       << "format" << Attr.getParameterName()->getName();
index 594e590e6bad83687cd9cb0afac68f47cef31ea3..34102c660373150713f5d79d8f27f8cc22313129 100644 (file)
@@ -68,3 +68,7 @@ void __attribute__((format(printf, 1, 0)))
 foo2(const char *fmt, va_list va) {
   xx_vprintf(foo(fmt), va);
 }
+
+// PR6542
+extern void gcc_format (const char *, ...)
+  __attribute__ ((__format__(__gcc_tdiag__, 1, 2)));