Skip to content

Commit

Permalink
[OpenMP][SYCL] Do not crash on attempt to diagnose unsupported type use
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Fznamznon authored and bader committed May 30, 2020
1 parent 81b50a7 commit bd85b7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &&
Expand Down
11 changes: 11 additions & 0 deletions clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit bd85b7d

Please sign in to comment.