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 {};
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 {};
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits