// typedef struct objc_object *id;
const PointerType *ptr = TD->getUnderlyingType()->getAsPointerType();
- assert(ptr && "'id' incorrectly typed");
+ // User error - caller will issue diagnostics.
+ if (!ptr)
+ return;
const RecordType *rec = ptr->getPointeeType()->getAsStructureType();
- assert(rec && "'id' incorrectly typed");
+ // User error - caller will issue diagnostics.
+ if (!rec)
+ return;
IdStructType = rec;
}
// typedef struct objc_selector *SEL;
const PointerType *ptr = TD->getUnderlyingType()->getAsPointerType();
- assert(ptr && "'SEL' incorrectly typed");
+ if (!ptr)
+ return;
const RecordType *rec = ptr->getPointeeType()->getAsStructureType();
- assert(rec && "'SEL' incorrectly typed");
+ if (!rec)
+ return;
SelStructType = rec;
}
/// situation, merging decls or emitting diagnostics as appropriate.
///
TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
+ bool objc_types = false;
// Allow multiple definitions for ObjC built-in typedefs.
// FIXME: Verify the underlying types are equivalent!
if (getLangOptions().ObjC1) {
if (!TypeID->isStr("id"))
break;
Context.setObjCIdType(New);
- return New;
+ objc_types = true;
+ break;
case 5:
if (!TypeID->isStr("Class"))
break;
Context.setObjCClassType(New);
+ objc_types = true;
return New;
case 3:
if (!TypeID->isStr("SEL"))
break;
Context.setObjCSelType(New);
+ objc_types = true;
return New;
case 8:
if (!TypeID->isStr("Protocol"))
break;
Context.setObjCProtoType(New->getUnderlyingType());
+ objc_types = true;
return New;
}
// Fall through - the typedef name was not a builtin type.
if (!Old) {
Diag(New->getLocation(), diag::err_redefinition_different_kind)
<< New->getDeclName();
- Diag(OldD->getLocation(), diag::note_previous_definition);
+ if (!objc_types)
+ Diag(OldD->getLocation(), diag::note_previous_definition);
return New;
}
Context.getCanonicalType(New->getUnderlyingType())) {
Diag(New->getLocation(), diag::err_redefinition_different_typedef)
<< New->getUnderlyingType() << Old->getUnderlyingType();
- Diag(Old->getLocation(), diag::note_previous_definition);
+ if (!objc_types)
+ Diag(Old->getLocation(), diag::note_previous_definition);
return New;
}
-
+ if (objc_types) return New;
if (getLangOptions().Microsoft) return New;
// C++ [dcl.typedef]p2: