Support "<p>" as a short-hand for "id<p>". Here's a comment from GCC (the only documentation I could find on it).

/* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" - nisse@lysator.liu.se.  */

This commit adds the parser magic. The type associated with <p> is still incorrect. Will discuss with Chris.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51972 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index f20c72e..46246e6 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -323,7 +323,7 @@
   
   // Validate declspec for type-name.
   unsigned Specs = DS.getParsedSpecifiers();
-  if (Specs == DeclSpec::PQ_None)
+  if (Specs == DeclSpec::PQ_None && !DS.getNumProtocolQualifiers())
     Diag(Tok, diag::err_typename_requires_specqual);
   
   // Issue diagnostic and remove storage class if present.
@@ -548,6 +548,21 @@
     case tok::kw_inline:
       isInvalid = DS.SetFunctionSpecInline(Loc, PrevSpec);
       break;
+      
+    // Gross GCC-ism that we are forced support. FIXME: make an extension?
+    case tok::less:
+      if (!DS.hasTypeSpecifier()) {
+        SourceLocation endProtoLoc;
+        llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
+        ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc);
+        llvm::SmallVector<DeclTy *, 8> *ProtocolDecl = 
+                new llvm::SmallVector<DeclTy *, 8>;
+        DS.setProtocolQualifiers(ProtocolDecl);
+        Actions.FindProtocolDeclaration(Loc, 
+                  &ProtocolRefs[0], ProtocolRefs.size(),
+                  *ProtocolDecl);
+      }
+      continue;
     }
     // If the specifier combination wasn't legal, issue a diagnostic.
     if (isInvalid) {
@@ -872,6 +887,8 @@
   case tok::kw___attribute:
     // GNU typeof support.
   case tok::kw_typeof:
+    // GNU bizarre protocol extension. FIXME: make an extension?
+  case tok::less:
   
     // type-specifiers
   case tok::kw_short:
@@ -962,6 +979,9 @@
     
     // GNU attributes.
   case tok::kw___attribute:
+  
+    // GNU bizarre protocol extension. FIXME: make an extension?
+  case tok::less:
     return true;
     
     // typedef-name