jdoerfert created this revision. jdoerfert added reviewers: hfinkel, ABataev, JonChesterfield. Herald added subscribers: guansong, bollu, yaxunl. Herald added a project: clang.
This was reported as PR45231 but occurs even without `cmath` in C++17 mode if we have an expression involving unsupported types outside of a function. For now we just avoid to create a diagnose builder in this case as it might be valid anyway. A proper solution to handle unsupported types has to be found. Discussion is ongoing in D74387 <https://reviews.llvm.org/D74387>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D77918 Files: clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/nvptx_unsupported_type_messages.cpp Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp =================================================================== --- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -56,3 +56,8 @@ T1 t = bar1(); } #pragma omp end declare target + +// Do not crash on these expressions during device compilation. +long double qa, qb; +decltype(qa + qb) qc; +double qd[sizeof(-(-(qc * 2)))]; Index: clang/lib/Sema/SemaOpenMP.cpp =================================================================== --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -1828,6 +1828,10 @@ void Sema::checkOpenMPDeviceExpr(const Expr *E) { assert(getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice && "OpenMP device compilation mode is expected."); + // TODO: Do not check outside of functions for now as the targetDiag below + // requires one. + if (!getCurFunctionDecl()) + return; QualType Ty = E->getType(); if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) || ((Ty->isFloat128Type() ||
Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp =================================================================== --- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -56,3 +56,8 @@ T1 t = bar1(); } #pragma omp end declare target + +// Do not crash on these expressions during device compilation. +long double qa, qb; +decltype(qa + qb) qc; +double qd[sizeof(-(-(qc * 2)))]; Index: clang/lib/Sema/SemaOpenMP.cpp =================================================================== --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -1828,6 +1828,10 @@ void Sema::checkOpenMPDeviceExpr(const Expr *E) { assert(getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice && "OpenMP device compilation mode is expected."); + // TODO: Do not check outside of functions for now as the targetDiag below + // requires one. + if (!getCurFunctionDecl()) + return; QualType Ty = E->getType(); if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) || ((Ty->isFloat128Type() ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits