llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> To match the diagnostic output of the current interpreter. --- Full diff: https://github.com/llvm/llvm-project/pull/118460.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+4-3) - (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+4) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index c5473322ecb280..b788656f9484fc 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1813,9 +1813,6 @@ static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC, bool Move = (ID == Builtin::BI__builtin_memmove || ID == Builtin::BImemmove); - if (DestPtr.isDummy() || SrcPtr.isDummy()) - return false; - // If the size is zero, we treat this as always being a valid no-op. if (Size.isZero()) { S.Stk.push<Pointer>(DestPtr); @@ -1830,6 +1827,10 @@ static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC, return false; } + // As a last resort, reject dummy pointers. + if (DestPtr.isDummy() || SrcPtr.isDummy()) + return false; + if (!DoBitCastPtr(S, OpPC, SrcPtr, DestPtr)) return false; diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 211ca6e164cbfb..b951c04dde5980 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1169,6 +1169,10 @@ namespace BuiltinMemcpy { static_assert(__builtin_memcpy(null_incomplete, null_incomplete, sizeof(wchar_t))); // both-error {{not an integral constant expression}} \ // both-note {{source of 'memcpy' is nullptr}} + wchar_t global; + constexpr wchar_t *null = 0; + static_assert(__builtin_memcpy(&global, null, sizeof(wchar_t))); // both-error {{not an integral constant expression}} \ + // both-note {{source of 'memcpy' is nullptr}} constexpr int simpleMove() { int a = 12; `````````` </details> https://github.com/llvm/llvm-project/pull/118460 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits