[Openmp-commits] [PATCH] D77918: [OpenMP] Avoid crash in preparation for diagnose of unsupported type
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Apr 10 16:09:57 PDT 2020
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() ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77918.256698.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200410/042df821/attachment.bin>
More information about the Openmp-commits
mailing list