@@ -5291,10 +5291,8 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
52915291 // UNION_TYPE; <- where UNION_TYPE is a typedef union.
52925292 if ((Tag && Tag->getDeclName()) ||
52935293 DS.getTypeSpecType() == DeclSpec::TST_typename) {
5294- RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag);
5295- if (!Record)
5296- Record = DS.getRepAsType().get()->getAsRecordDecl();
5297-
5294+ RecordDecl *Record = Tag ? dyn_cast<RecordDecl>(Tag)
5295+ : DS.getRepAsType().get()->getAsRecordDecl();
52985296 if (Record && getLangOpts().MicrosoftExt) {
52995297 Diag(DS.getBeginLoc(), diag::ext_ms_anonymous_record)
53005298 << Record->isUnion() << DS.getSourceRange();
@@ -18571,8 +18569,14 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1857118569 if (PrevDecl)
1857218570 CheckRedeclarationInModule(New, PrevDecl);
1857318571
18574- if (TUK == TagUseKind::Definition && (!SkipBody || !SkipBody->ShouldSkip))
18575- New->startDefinition();
18572+ if (TUK == TagUseKind::Definition) {
18573+ if (!SkipBody || !SkipBody->ShouldSkip) {
18574+ New->startDefinition();
18575+ } else {
18576+ New->setCompleteDefinition();
18577+ New->demoteThisDefinitionToDeclaration();
18578+ }
18579+ }
1857618580
1857718581 ProcessDeclAttributeList(S, New, Attrs);
1857818582 AddPragmaAttributes(S, New);
0 commit comments