Skip to content

Commit bbf657d

Browse files
authored
[clang] fix expression classification for dependent binary operators (#159819)
This fixes a regression reported here: #159463 (comment) Since this regression was never released, there are no release notes.
1 parent 2d503b9 commit bbf657d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/AST/ExprClassification.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,13 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) {
601601
static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) {
602602
assert(Ctx.getLangOpts().CPlusPlus &&
603603
"This is only relevant for C++.");
604+
605+
// For binary operators which are unknown due to type dependence, the
606+
// convention is to classify them as a prvalue. This does not matter much, but
607+
// it needs to agree with how they are created.
608+
if (E->getType() == Ctx.DependentTy)
609+
return Cl::CL_PRValue;
610+
604611
// C++ [expr.ass]p1: All [...] return an lvalue referring to the left operand.
605612
// Except we override this for writes to ObjC properties.
606613
if (E->isAssignmentOp())

clang/test/SemaTemplate/temp_arg_template.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ namespace CheckDependentNonTypeParamTypes {
149149
};
150150
// FIXME: This should be rejected, as there are no valid instantiations for E<char>::F
151151
template struct E<char>;
152+
153+
#if __cplusplus >= 201703L
154+
template<template<auto> class TT, class V> struct G {
155+
using type = TT<((void)0, V::value)>;
156+
};
157+
#endif
152158
}
153159

154160
namespace PR32185 {

0 commit comments

Comments
 (0)