@@ -1528,9 +1528,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
15281528 break ;
15291529 case DeclSpec::TST_half: Result = Context.HalfTy ; break ;
15301530 case DeclSpec::TST_BFloat16:
1531- if (!S.Context .getTargetInfo ().hasBFloat16Type ())
1532- S.Diag (DS.getTypeSpecTypeLoc (), diag::err_type_unsupported)
1533- << " __bf16" ;
1531+ // Disable errors for SYCL and OpenMP device since definition of __bf16 is
1532+ // being moved to a shared header and it causes new errors emitted when
1533+ // host code is compiled with device compiler for SPIR target.
1534+ // FIXME: device code specific diagnostic is probably needed.
1535+ if (!S.Context .getTargetInfo ().hasBFloat16Type () &&
1536+ !S.getLangOpts ().SYCLIsDevice && !S.getLangOpts ().OpenMPIsDevice )
1537+ S.Diag (DS.getTypeSpecTypeLoc (), diag::err_type_unsupported) << " __bf16" ;
15341538 Result = Context.BFloat16Ty ;
15351539 break ;
15361540 case DeclSpec::TST_float: Result = Context.FloatTy ; break ;
@@ -2727,8 +2731,15 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
27272731 }
27282732
27292733 if (!TypeSize || VectorSizeBits % TypeSize) {
2730- Diag (AttrLoc, diag::err_attribute_invalid_size)
2731- << SizeExpr->getSourceRange ();
2734+ // Disable errors for SYCL and OpenMP device since definition of __bf16 is
2735+ // being moved to a shared header and it causes new errors emitted when
2736+ // host code is compiled with device compiler for SPIR target.
2737+ // FIXME: device code specific diagnostic is probably needed.
2738+ if (!(!TypeSize &&
2739+ (getLangOpts ().OpenMPIsDevice || getLangOpts ().SYCLIsDevice ))) {
2740+ Diag (AttrLoc, diag::err_attribute_invalid_size)
2741+ << SizeExpr->getSourceRange ();
2742+ }
27322743 return QualType ();
27332744 }
27342745
0 commit comments