================
@@ -58,3 +58,11 @@ int main() {
   my_malloc_fn_pointer_type f3 = fn2;
   my_other_malloc_fn_pointer_type f4 = fn2;
 }
+
+// Regression test for GH199407: structural equivalence of alloc_size attrs
+// with an unset optional ParamIdx must not crash.
+#define GH199407(Ty, Name) _Alignas(Ty) char Name[sizeof(Ty)]
+GH199407(struct GH199407S { float *f(long) __attribute__((alloc_size(1))); }, 
gbuf);  // expected-error 2{{field 'f' declared as a function}} 
expected-error{{redefinition of 'GH199407S'}} expected-note{{previous 
definition is here}}
+// nonnull uses a VariadicParamIdx whose elements are always valid; verify no
+// regression for the valid-ParamIdx path in equalAttrArgs<ParamIdx>.
+GH199407(struct GH199407T { void *g(void *p) __attribute__((nonnull(1))); }, 
gbuf2); // expected-error 2{{field 'g' declared as a function}} 
expected-error{{redefinition of 'GH199407T'}} expected-note{{previous 
definition is here}}
----------------
melver wrote:

this is the `alloc-size.c` test, `nonnull` doesn't belong here.

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

Reply via email to