[Openmp-commits] [PATCH] D108774: [OpenMP][FIX] Allow declare variant to work with reference types
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Aug 26 11:19:07 PDT 2021
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, ABataev, pdhaliwal, aaron.ballman.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108774
Files:
clang/lib/AST/ASTContext.cpp
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9680,11 +9680,16 @@
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 (LHS->getAs<ReferenceType>() && RHS->getAs<ReferenceType>())
+ return mergeTypes(LHS->getAs<ReferenceType>()->getPointeeType() , RHS->getAs<ReferenceType>()->getPointeeType(), OfBlockPointer, Unqualified, BlockReturnType);
if (LHS->getAs<ReferenceType>() || RHS->getAs<ReferenceType>())
return {};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108774.368939.patch
Type: text/x-patch
Size: 1214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210826/e7d1762e/attachment.bin>
More information about the Openmp-commits
mailing list