fix several problems with the protocol qualified id handling where id was implicit.
First, fix canonical type handling of these, since protocol qualified id's are always
canonical. Next, enhance SemaType to actually make these when used (instead of int)
allowing them to actually be used when appropriate. Finally remove a bunch of logic
relating to the mishandling of canonical types with protocol-qual id's. This fixes
rdar://5986251
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54083 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 4bee2de..85a457b 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -43,6 +43,14 @@
}
break;
case DeclSpec::TST_unspecified:
+ // "<proto1,proto2>" is an objc qualified ID with a missing id.
+ if (llvm::SmallVector<Action::DeclTy *, 8> *PQ=DS.getProtocolQualifiers()) {
+ Action::DeclTy **PPDecl = &(*PQ)[0];
+ Result = Context.getObjCQualifiedIdType((ObjCProtocolDecl**)(PPDecl),
+ DS.getNumProtocolQualifiers());
+ break;
+ }
+
// Unspecified typespec defaults to int in C90. However, the C90 grammar
// [C90 6.5] only allows a decl-spec if there was *some* type-specifier,
// type-qualifier, or storage-class-specifier. If not, emit an extwarn.
@@ -128,13 +136,12 @@
reinterpret_cast<ObjCProtocolDecl**>(PPDecl),
DS.getNumProtocolQualifiers());
break;
- }
- else if (TypedefDecl *typeDecl = dyn_cast<TypedefDecl>(D)) {
+ } else if (TypedefDecl *typeDecl = dyn_cast<TypedefDecl>(D)) {
if (Context.getObjCIdType() == Context.getTypedefType(typeDecl)
&& DS.getProtocolQualifiers()) {
// id<protocol-list>
Action::DeclTy **PPDecl = &(*DS.getProtocolQualifiers())[0];
- Result = Context.getObjCQualifiedIdType(typeDecl->getUnderlyingType(),
+ Result = Context.getObjCQualifiedIdType(
reinterpret_cast<ObjCProtocolDecl**>(PPDecl),
DS.getNumProtocolQualifiers());
break;