[clang] [Clang] Fixed an assertion in constant evaluation of EmbedExpr inside array initializers. (PR #182257)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 19 10:18:32 PST 2026
================
@@ -13,3 +14,37 @@ int *p2 = (int[]){
int *p3 = (int[30]){
#embed __FILE__ limit(30)
};
+
+
+#ifdef NEGATIVE
+
+// Pointer element type
+char *bad_ptr = (int (*[5]) 0){ // expected-error {{expected ')'}}
+ // expected-note at -1 {{to match this '('}}
+// expected-error at -2 {{incompatible pointer types initializing}}
+// expected-error at -3 {{initializer element is not a compile-time constant}}
+#embed __FILE__
+// expected-error at -1 {{incompatible integer to pointer conversion}}
+// expected-warning at -2 {{excess elements in array initializer}}
+};
+
+
+// Struct element type
+struct S { int x; };
+struct S bad_struct = (struct S[5]){ // expected-error {{initializing 'struct S'}}
----------------
shafik wrote:
Should we also test unions and `_Bitint`?
https://github.com/llvm/llvm-project/pull/182257
More information about the cfe-commits
mailing list