[clang] cc55af7 - [clang][Interp] Only check ComparisonCategoryInfo in C++ (#80131)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 13:02:02 PST 2024
Author: Timm Baeder
Date: 2024-02-06T22:01:59+01:00
New Revision: cc55af777a19b69f466875683655810f5d485386
URL: https://github.com/llvm/llvm-project/commit/cc55af777a19b69f466875683655810f5d485386
DIFF: https://github.com/llvm/llvm-project/commit/cc55af777a19b69f466875683655810f5d485386.diff
LOG: [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.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/Sema/struct-cast.c
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index f31755e72e8de..79d44842d8319 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -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 =
diff --git a/clang/test/Sema/struct-cast.c b/clang/test/Sema/struct-cast.c
index 74d00c42c295e..05e5fa4f92ca7 100644
--- a/clang/test/Sema/struct-cast.c
+++ b/clang/test/Sema/struct-cast.c
@@ -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 {
More information about the cfe-commits
mailing list