Skip to content

Conversation

mizvekov
Copy link
Contributor

@mizvekov mizvekov commented Sep 19, 2025

This fixes a regression reported here: #159463 (comment)

Since this regression was never released, there are no release notes.

@mizvekov mizvekov requested a review from erichkeane September 19, 2025 17:26
@mizvekov mizvekov self-assigned this Sep 19, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 19, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2025

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

Changes

This fixes a regression reported here: #159463 (comment) Since this regression was never released, there are no release notes.


Full diff: https://github.com/llvm/llvm-project/pull/159819.diff

2 Files Affected:

  • (modified) clang/lib/AST/ExprClassification.cpp (+7)
  • (modified) clang/test/SemaTemplate/temp_arg_template.cpp (+6)
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index ad66335138a42..efe72137631a2 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -601,6 +601,13 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) {
 static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) {
   assert(Ctx.getLangOpts().CPlusPlus &&
          "This is only relevant for C++.");
+
+  // For binary operators which are unknown due to type dependence, the convention
+  // is to classify them as a prvalue. This does not matter much, but it needs
+  // to agree with how they are created.
+  if (E->getType() == Ctx.DependentTy)
+    return Cl::CL_PRValue;
+
   // C++ [expr.ass]p1: All [...] return an lvalue referring to the left operand.
   // Except we override this for writes to ObjC properties.
   if (E->isAssignmentOp())
diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp
index 431e19741ece9..c9576e2057e53 100644
--- a/clang/test/SemaTemplate/temp_arg_template.cpp
+++ b/clang/test/SemaTemplate/temp_arg_template.cpp
@@ -149,6 +149,12 @@ namespace CheckDependentNonTypeParamTypes {
   };
   // FIXME: This should be rejected, as there are no valid instantiations for E<char>::F
   template struct E<char>;
+
+#if __cplusplus >= 201703L
+  template<template<auto> class TT, class V> struct G {
+    using type = TT<((void)0, V::value)>;
+  };
+#endif
 }
 
 namespace PR32185 {

Copy link

github-actions bot commented Sep 19, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

This fixes a regression reported here: #159463 (comment)
Since this regression was never released, there are no release notes.
@mizvekov mizvekov force-pushed the users/mizvekov/GH159463-regression-1 branch from 21d07e4 to 9216ca7 Compare September 19, 2025 17:31
@mizvekov mizvekov merged commit bbf657d into main Sep 19, 2025
9 checks passed
@mizvekov mizvekov deleted the users/mizvekov/GH159463-regression-1 branch September 19, 2025 18:12
Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants