Skip to content

Commit cc55af7

Browse files
authored
[clang][Interp] Only check ComparisonCategoryInfo in C++ (#80131)
Binary operators are also of struct type in C, when assigning. Don't try to get the ComparisonCategoryInfo in that case.
1 parent 92b3382 commit cc55af7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ bool ByteCodeExprGen<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
464464
// Special case for C++'s three-way/spaceship operator <=>, which
465465
// returns a std::{strong,weak,partial}_ordering (which is a class, so doesn't
466466
// have a PrimType).
467-
if (!T) {
467+
if (!T && Ctx.getLangOpts().CPlusPlus) {
468468
if (DiscardResult)
469469
return true;
470470
const ComparisonCategoryInfo *CmpInfo =

clang/test/Sema/struct-cast.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only %s -verify
2+
// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter -verify
23
// expected-no-diagnostics
34

45
struct S {

0 commit comments

Comments
 (0)