llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/188917.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+3) 
- (modified) clang/test/AST/ByteCode/builtins.c (+12) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 214013396e885..e7b3ef6ce1510 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -283,6 +283,9 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr 
OpPC,
     return false;
   if (!A.isBlockPointer() || !B.isBlockPointer())
     return false;
+  if (!A.getFieldDesc()->isPrimitiveArray() ||
+      !B.getFieldDesc()->isPrimitiveArray())
+    return false;
 
   bool IsWide = ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp ||
                 ID == Builtin::BI__builtin_wcscmp ||
diff --git a/clang/test/AST/ByteCode/builtins.c 
b/clang/test/AST/ByteCode/builtins.c
index 2d19ccb51de03..ecaafd6ce1282 100644
--- a/clang/test/AST/ByteCode/builtins.c
+++ b/clang/test/AST/ByteCode/builtins.c
@@ -22,3 +22,15 @@ _Static_assert(__atomic_is_lock_free(4, (void*)2), ""); // 
both-error {{not an i
 
 _Static_assert(__builtin_strlen((void*)0 + 1) == 2, ""); // both-error {{not 
an integral constant expression}} \
                                                          // both-note {{cannot 
perform pointer arithmetic on null pointer}}
+
+
+int strcmp(const char *, const char *);
+#define S "\x01\x02"
+
+const char _str[] = {S[0], S[1]};
+const union u {
+  int a;
+  char b[2];
+} _str2[] = {S[0], S[1]};
+
+const int compared = strcmp(_str, (const char *)_str2); // both-error 
{{initializer element is not a compile-time constant}}

``````````

</details>


https://github.com/llvm/llvm-project/pull/188917
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to