Skip to content

Commit

Permalink
[OpenMP][FIX] Allow declare variant to work with reference types
Browse files Browse the repository at this point in the history
Reference types in the return or parameter position did cause the OpenMP
declare variant overload reasoning to give up. We should allow them as
we allow any other type.

This should fix the bug reported on the mailing list:
https://lists.llvm.org/pipermail/openmp-dev/2021-August/004094.html

Reviewed By: ABataev, pdhaliwal

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

(cherry picked from commit 2930c83)
  • Loading branch information
jdoerfert authored and tstellar committed Sep 2, 2021
1 parent bcb4361 commit 73c36a9
Show file tree
Hide file tree
Showing 2 changed files with 422 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9653,11 +9653,19 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET,
QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
bool OfBlockPointer,
bool Unqualified, bool BlockReturnType) {
// For C++ we will not reach this code with reference types (see below),
// for OpenMP variant call overloading we might.
//
// C++ [expr]: If an expression initially has the type "reference to T", the
// type is adjusted to "T" prior to any further analysis, the expression
// designates the object or function denoted by the reference, and the
// expression is an lvalue unless the reference is an rvalue reference and
// the expression is a function call (possibly inside parentheses).
if (LangOpts.OpenMP && LHS->getAs<ReferenceType>() &&
RHS->getAs<ReferenceType>() && LHS->getTypeClass() == RHS->getTypeClass())
return mergeTypes(LHS->getAs<ReferenceType>()->getPointeeType(),
RHS->getAs<ReferenceType>()->getPointeeType(),
OfBlockPointer, Unqualified, BlockReturnType);
if (LHS->getAs<ReferenceType>() || RHS->getAs<ReferenceType>())
return {};

Expand Down
Loading

0 comments on commit 73c36a9

Please sign in to comment.