]> granicus.if.org Git - clang/commitdiff
Warn about bogus protocol qualifiers.
authorSteve Naroff <snaroff@apple.com>
Sat, 21 Feb 2009 19:50:43 +0000 (19:50 +0000)
committerSteve Naroff <snaroff@apple.com>
Sat, 21 Feb 2009 19:50:43 +0000 (19:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65241 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.def
lib/Sema/SemaType.cpp
test/SemaObjC/protocol-archane.m

index cce97aa48f9dd21a09d260e207fdd0512d1b8b49..7ebb5a706cda5934b535cc6c8471bdb3bb506ff8 100644 (file)
@@ -1402,4 +1402,6 @@ DIAG(warn_objc_array_of_interfaces, WARNING,
      "array of interface %0 should probably be an array of pointers")
 DIAG(ext_c99_array_usage, EXTENSION,
      "use of C99-specific array features, accepted as an extension")
+DIAG(warn_ignoring_objc_qualifiers, WARNING,
+     "ignoring protocol qualifiers on non-ObjC type")
 
index 252cd2d533cee1c63a89d120ae322565837cf30f..acdeec6ba94dfecd055c2ee627acef9d99fc7a2c 100644 (file)
@@ -151,6 +151,9 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) {
         // id<protocol-list>
         Result = Context.getObjCQualifiedIdType((ObjCProtocolDecl**)PQ,
                                                 DS.getNumProtocolQualifiers());
+      else
+        Diag(DS.getSourceRange().getBegin(), 
+             diag::warn_ignoring_objc_qualifiers) << DS.getSourceRange();
     }
     // TypeQuals handled by caller.
     break;
index bfae348f082b22a81d24ff50052d145c16e841eb..2cba1fad051fc9cf850b7943065eef8b1dbfff38 100644 (file)
@@ -21,4 +21,9 @@ void foo(id x) {
 
 // FIXME: provide a better diagnostic (no typedef).
 - (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
-@end
\ No newline at end of file
+@end
+
+typedef int NotAnObjCObjectType;
+
+// GCC doesn't diagnose this.
+NotAnObjCObjectType <SomeProtocol> *obj; // expected-warning {{ignoring protocol qualifiers on non-ObjC type}}