[OpenMP][SYCL] Do not crash on attempt to diagnose unsupported type use
authorMariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Sat, 30 May 2020 09:27:47 +0000 (12:27 +0300)
committerAlexey Bader <alexey.bader@intel.com>
Sat, 30 May 2020 09:27:58 +0000 (12:27 +0300)
Summary:
Do not ask size of type if it is dependent. ASTContext doesn't seem expecting
this.

Reviewers: jdoerfert, ABataev, bader

Reviewed By: ABataev

Subscribers: yaxunl, guansong, ebevhan, Anastasia, sstefan1, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80829

clang/lib/Sema/Sema.cpp
clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

index 8c11a1a..ffe2e4d 100644 (file)
@@ -1725,6 +1725,9 @@ void Sema::checkDeviceDecl(const ValueDecl *D, SourceLocation Loc) {
   }
 
   auto CheckType = [&](QualType Ty) {
+    if (Ty->isDependentType())
+      return;
+
     if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) ||
         ((Ty->isFloat128Type() ||
           (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128)) &&
index 22ce817..e56105a 100644 (file)
@@ -120,3 +120,14 @@ void hostFoo() {
 long double qa, qb;
 decltype(qa + qb) qc;
 double qd[sizeof(-(-(qc * 2)))];
+
+struct A { };
+
+template <bool>
+struct A_type { typedef A type; };
+
+template <class Sp, class Tp>
+struct B {
+  enum { value = bool(Sp::value) || bool(Tp::value) };
+  typedef typename A_type<value>::type type;
+};