Skip to content

Commit

Permalink
[clang][Interp] Only check ComparisonCategoryInfo in C++ (#80131)
Browse files Browse the repository at this point in the history
Binary operators are also of struct type in C, when assigning. Don't try to get the ComparisonCategoryInfo in that case.
  • Loading branch information
tbaederr committed Feb 6, 2024
1 parent 92b3382 commit cc55af7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
// Special case for C++'s three-way/spaceship operator <=>, which
// returns a std::{strong,weak,partial}_ordering (which is a class, so doesn't
// have a PrimType).
if (!T) {
if (!T && Ctx.getLangOpts().CPlusPlus) {
if (DiscardResult)
return true;
const ComparisonCategoryInfo *CmpInfo =
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/struct-cast.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify
// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter -verify
// expected-no-diagnostics

struct S {
Expand Down

0 comments on commit cc55af7

Please sign in to comment.