@@ -1849,15 +1849,10 @@ bool Sema::CheckSpanLikeType(const AttributeCommonInfo &CI,
18491849 Diag (CI.getLoc (), diag::warn_attribute_return_span_only) << CI;
18501850 return Diag (CI.getLoc (), NoteDiagID);
18511851 };
1852- if (!Ty->isDependentType ()) {
1853- // If the type is a class template specialization, it may not be
1854- // instantiated at this stage. We must force it to be complete to examine
1855- // its fields.
1856- // The returned value is discarded since the code below emits a warning
1857- // if the type keeps being incomplete.
1858- (void )isCompleteType (CI.getLoc (), Ty);
1859- }
1860- if (Ty->isIncompleteType ())
1852+ if (Ty->isDependentType ())
1853+ return false ;
1854+ // isCompleteType is used to force template class instantiation.
1855+ if (!isCompleteType (CI.getLoc (), Ty))
18611856 return emitWarning (diag::note_returned_incomplete_type);
18621857 const RecordDecl *RD = Ty->getAsRecordDecl ();
18631858 if (!RD || RD->isUnion ())
@@ -1899,11 +1894,8 @@ bool Sema::CheckSpanLikeType(const AttributeCommonInfo &CI,
18991894
19001895static void handleMallocSpanAttr (Sema &S, Decl *D, const ParsedAttr &AL) {
19011896 QualType ResultType = getFunctionOrMethodResultType (D);
1902- if (ResultType->isDependentType () || !S.CheckSpanLikeType (AL, ResultType)) {
1903- // If it's a dependent type, the attribute will be re-checked upon
1904- // instantiation.
1897+ if (!S.CheckSpanLikeType (AL, ResultType))
19051898 D->addAttr (::new (S.Context ) MallocSpanAttr (S.Context , AL));
1906- }
19071899}
19081900
19091901static void handleCPUSpecificAttr (Sema &S, Decl *D, const ParsedAttr &AL) {
0 commit comments