]> granicus.if.org Git - clang/commitdiff
Add support for differentiating between attributes ignored when handled and
authorChandler Carruth <chandlerc@gmail.com>
Thu, 8 Jul 2010 09:42:26 +0000 (09:42 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 8 Jul 2010 09:42:26 +0000 (09:42 +0000)
unknown attributes that we discard. Add a diagnostic group for unknown
attribute warnings to allow turning these off when we don't care. Also
consolidates the tests for this case.

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

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-deprecated.c
test/Sema/attr-unknown.c [new file with mode: 0644]

index 566fc9b96491b50d37eb0a51737161bf3c191c41..8572c62e4bbe420e85795a4c2aa093bcd0257e16 100644 (file)
@@ -116,6 +116,7 @@ def Trigraphs      : DiagGroup<"trigraphs">;
 def : DiagGroup<"type-limits">;
 def Uninitialized  : DiagGroup<"uninitialized">;
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
+def UnknownAttributes : DiagGroup<"unknown-attributes">;
 def UnusedArgument : DiagGroup<"unused-argument">;
 def UnusedExceptionParameter : DiagGroup<"unused-exception-parameter">;
 def UnusedFunction : DiagGroup<"unused-function">;
index 0883eab0034bc16299fcef56622db1b6d40da237..578fe8c724db38a07cab17e1fd76348a17d0f8a7 100644 (file)
@@ -875,6 +875,8 @@ def err_attribute_aligned_not_power_of_two : Error<
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "'%0' redeclared without %1 attribute: previous %1 ignored">;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">;
+def warn_unknown_attribute_ignored : Warning<
+  "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
 def warn_attribute_precede_definition : Warning<
   "attribute declaration must precede definition">;
 def warn_attribute_void_function_method : Warning<
index b7e275a9d4b31b64473e8c31838ada49d871af7d..3b82f58be43edf619c11f2cc4356f33c6c6db0e5 100644 (file)
@@ -2069,7 +2069,8 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D,
     // Ask target about the attribute.
     const TargetAttributesSema &TargetAttrs = S.getTargetAttributesSema();
     if (!TargetAttrs.ProcessDeclAttribute(scope, D, Attr, S))
-      S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+      S.Diag(Attr.getLoc(), diag::warn_unknown_attribute_ignored)
+        << Attr.getName();
     break;
   }
 }
index e723255c0cfa60887888cd6d523ff5c8237296a3..e7c997f3ee23d9761ce582c8197c136d24e9e103 100644 (file)
@@ -4,8 +4,6 @@ int f() __attribute__((deprecated));
 void g() __attribute__((deprecated));
 void g();
 
-void z() __attribute__((bogusattr)); // expected-warning {{'bogusattr' attribute ignored}}
-
 extern int var __attribute__((deprecated));
 
 int a() {
@@ -45,7 +43,7 @@ typedef struct foo foo_dep __attribute__((deprecated));
 foo_dep *test2;    // expected-warning {{'foo_dep' is deprecated}}
 
 struct bar_dep __attribute__((deprecated, 
-                              invalid_attribute));  // expected-warning {{'invalid_attribute' attribute ignored}}
+                              invalid_attribute));  // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
 
 struct bar_dep *test3;   // expected-warning {{'bar_dep' is deprecated}}
 
diff --git a/test/Sema/attr-unknown.c b/test/Sema/attr-unknown.c
new file mode 100644 (file)
index 0000000..bec2e29
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunknown-attributes %s
+
+int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}}
+void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}