[clang] [Clang] Only non-overloaded dereference expressions are lvalues (PR #93457)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 27 04:10:36 PDT 2024
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/93457
Fix a regression introduced by #88740
Fixes #92275
>From 437558af94c8e59a98b26f23fabd4850c2da7131 Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Mon, 27 May 2024 13:07:50 +0200
Subject: [PATCH] [Clang] Only non-overloaded dereference expressions are
lvalues
Fix a regression introduced by #88740
Fixes #92275
---
clang/lib/Sema/SemaOverload.cpp | 2 +-
clang/test/SemaCXX/overloaded-operator.cpp | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 0c89fca8d38eb..4b4d4f218fbd9 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14354,7 +14354,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
if (Fn.isInvalid())
return ExprError();
return CXXOperatorCallExpr::Create(Context, Op, Fn.get(), ArgsArray,
- Context.DependentTy, VK, OpLoc,
+ Context.DependentTy, VK_PRValue, OpLoc,
CurFPFeatureOverrides());
}
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp b/clang/test/SemaCXX/overloaded-operator.cpp
index cab21d67a002f..0701a96d5d0ce 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -691,4 +691,15 @@ template <auto T> A<*T> operator *() { return {}; }
// expected-error at -1 {{overloaded 'operator*' must have at least one parameter of class or enumeration type}}
}
+namespace GH92275 {
+
+template <auto v>
+struct constant{};
+
+template <auto x>
+auto operator *(constant<x>)
+{ return constant<(*x)>{}; }
+
+}
+
#endif
More information about the cfe-commits
mailing list