[cfe-commits] r65333 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaType.cpp test/SemaObjC/protocol-archane.m test/SemaObjC/protocol-atttribute-1.m

Steve Naroff snaroff at apple.com
Mon Feb 23 10:53:24 PST 2009


Author: snaroff
Date: Mon Feb 23 12:53:24 2009
New Revision: 65333

URL: http://llvm.org/viewvc/llvm-project?rev=65333&view=rev
Log:
- Generate error for protocol qualifiers on 'Class'.
- Generate error for protocol qualifiers on non-ObjC types.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaObjC/protocol-archane.m
    cfe/trunk/test/SemaObjC/protocol-atttribute-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=65333&r1=65332&r2=65333&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Mon Feb 23 12:53:24 2009
@@ -1400,6 +1400,8 @@
      "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")
+DIAG(err_invalid_protocol_qualifiers, ERROR,
+     "invalid protocol qualifiers on non-ObjC type")
+DIAG(err_qualified_class_unsupported, ERROR,
+     "protocol qualified 'Class' is unsupported")
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=65333&r1=65332&r2=65333&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Feb 23 12:53:24 2009
@@ -151,9 +151,13 @@
         // id<protocol-list>
         Result = Context.getObjCQualifiedIdType((ObjCProtocolDecl**)PQ,
                                                 DS.getNumProtocolQualifiers());
-      else
+      else if (Result == Context.getObjCClassType())
+        // Class<protocol-list>
         Diag(DS.getSourceRange().getBegin(), 
-             diag::warn_ignoring_objc_qualifiers) << DS.getSourceRange();
+             diag::err_qualified_class_unsupported) << DS.getSourceRange();
+      else
+        Diag(DS.getSourceRange().getBegin(),
+             diag::err_invalid_protocol_qualifiers) << DS.getSourceRange();
     }
     // TypeQuals handled by caller.
     break;

Modified: cfe/trunk/test/SemaObjC/protocol-archane.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-archane.m?rev=65333&r1=65332&r2=65333&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-archane.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-archane.m Mon Feb 23 12:53:24 2009
@@ -26,4 +26,10 @@
 typedef int NotAnObjCObjectType;
 
 // GCC doesn't diagnose this.
-NotAnObjCObjectType <SomeProtocol> *obj; // expected-warning {{ignoring protocol qualifiers on non-ObjC type}}
+NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
+
+// Decided not to support the following GCC extension. Found while researching rdar://6497631
+typedef struct objc_class *Class;
+
+Class <SomeProtocol> UnfortunateGCCExtension; // expected-error {{protocol qualified 'Class' is unsupported}}
+

Modified: cfe/trunk/test/SemaObjC/protocol-atttribute-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-atttribute-1.m?rev=65333&r1=65332&r2=65333&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-atttribute-1.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-atttribute-1.m Mon Feb 23 12:53:24 2009
@@ -3,7 +3,7 @@
 __attribute ((unavailable))
 @protocol FwProto; // expected-note{{marked unavailable}}
 
-Class <FwProto> cFw = 0;  // expected-warning {{'FwProto' is unavailable}} expected-warning{{ignoring protocol qualifiers on non-ObjC type}}
+Class <FwProto> cFw = 0;  // expected-warning {{'FwProto' is unavailable}} expected-error{{protocol qualified 'Class' is unsupported}}
 
 
 __attribute ((deprecated)) @protocol MyProto1
@@ -31,7 +31,7 @@
 
 
 
-Class <MyProto1> clsP1 = 0;  // expected-warning {{'MyProto1' is deprecated}} expected-warning{{ignoring protocol qualifiers on non-ObjC type}}
+Class <MyProto1> clsP1 = 0;  // expected-warning {{'MyProto1' is deprecated}} expected-error{{protocol qualified 'Class' is unsupported}}
 
 @protocol FwProto @end // expected-note{{marked unavailable}}
 





More information about the cfe-commits mailing list