@@ -1528,9 +1528,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
1528
1528
break ;
1529
1529
case DeclSpec::TST_half: Result = Context.HalfTy ; break ;
1530
1530
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" ;
1534
1538
Result = Context.BFloat16Ty ;
1535
1539
break ;
1536
1540
case DeclSpec::TST_float: Result = Context.FloatTy ; break ;
@@ -2727,8 +2731,15 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
2727
2731
}
2728
2732
2729
2733
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
+ }
2732
2743
return QualType ();
2733
2744
}
2734
2745
0 commit comments