diff options
author | Timm Bäder <tbaeder@redhat.com> | 2024-04-12 10:43:14 +0200 |
---|---|---|
committer | Timm Bäder <tbaeder@redhat.com> | 2024-04-16 11:08:30 +0200 |
commit | 9141e1c24f87e5735bc4178a018eba4bdf2750aa (patch) | |
tree | 03f98455dcf95362f599e0453bd1e6df664fa948 | |
parent | 5a46123ddf62900d3dc73330f699c73038645198 (diff) |
[clang][Interp] Gracefully handle bitcasts to non-primitive types
We were calling classfiyPrim() instead of classify().
-rw-r--r-- | clang/lib/AST/Interp/ByteCodeExprGen.cpp | 2 | ||||
-rw-r--r-- | clang/test/AST/Interp/vectors.cpp | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 01ec31e4077f..5866228663dc 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -262,7 +262,7 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) { return this->discard(SubExpr); std::optional<PrimType> FromT = classify(SubExpr->getType()); - std::optional<PrimType> ToT = classifyPrim(CE->getType()); + std::optional<PrimType> ToT = classify(CE->getType()); if (!FromT || !ToT) return false; diff --git a/clang/test/AST/Interp/vectors.cpp b/clang/test/AST/Interp/vectors.cpp index 8afef3c897bf..fb5787a9eda9 100644 --- a/clang/test/AST/Interp/vectors.cpp +++ b/clang/test/AST/Interp/vectors.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s // RUN: %clang_cc1 -verify=ref,both %s -// both-no-diagnostics +// ref-no-diagnostics typedef int __attribute__((vector_size(16))) VI4; constexpr VI4 A = {1,2,3,4}; @@ -20,3 +20,9 @@ namespace Vector { } constexpr auto v2 = g(4); } + +/// FIXME: We need to support BitCasts between vector types. +namespace { + typedef float __attribute__((vector_size(16))) VI42; + constexpr VI42 A2 = A; // expected-error {{must be initialized by a constant expression}} +} |