Skip to content

Commit 9141e1c

Browse files
committed
[clang][Interp] Gracefully handle bitcasts to non-primitive types
We were calling classfiyPrim() instead of classify().
1 parent 5a46123 commit 9141e1c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
262262
return this->discard(SubExpr);
263263

264264
std::optional<PrimType> FromT = classify(SubExpr->getType());
265-
std::optional<PrimType> ToT = classifyPrim(CE->getType());
265+
std::optional<PrimType> ToT = classify(CE->getType());
266266
if (!FromT || !ToT)
267267
return false;
268268

clang/test/AST/Interp/vectors.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s
22
// RUN: %clang_cc1 -verify=ref,both %s
33

4-
// both-no-diagnostics
4+
// ref-no-diagnostics
55

66
typedef int __attribute__((vector_size(16))) VI4;
77
constexpr VI4 A = {1,2,3,4};
@@ -20,3 +20,9 @@ namespace Vector {
2020
}
2121
constexpr auto v2 = g(4);
2222
}
23+
24+
/// FIXME: We need to support BitCasts between vector types.
25+
namespace {
26+
typedef float __attribute__((vector_size(16))) VI42;
27+
constexpr VI42 A2 = A; // expected-error {{must be initialized by a constant expression}}
28+
}

0 commit comments

Comments
 (0)