================
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Foo {};
+
+struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}}
+
+void test(int a, Foo b, void *c, int *d, Foo *e, const Foo *f, Incomplete *g) {
+ __builtin_clear_padding(a); // expected-error {{passing 'int' to parameter
of incompatible type pointer: type mismatch at 1st parameter ('int' vs
pointer)}}
----------------
huixie90 wrote:
I added Sema tests for
- no arguments
- too many arguments
- non trivially copyable type
- pointer to member types where the member is a struct pointer
- function pointer
Added codegen tests for
- template types
- atomic types
- non trivially copyable types
These tests were already covered
- no_unique_address members
For `_Atomic` type, gcc does not support it. I think we need to support it as
our libcxx's `std::atomic` implementation actually uses `_Atomic`
Btw, gcc's trivially copyable check logic is a bit complex and I am trying the
match the behaviour. here is the behaviour
```cpp
struct A {
A(){}
A(const A&) {}
~A(){}
};
void test(A& a0, A a1) {
A a2 {};
A& a3 = a2;
__builtin_clear_padding(&a0); // Error
__builtin_clear_padding(&a1); // OK
__builtin_clear_padding(&a2); // OK
__builtin_clear_padding(&a3); // Error
}
struct D : A {};
void test1(D& d0, D d1) {
__builtin_clear_padding((D*)&d0); // Error
__builtin_clear_padding((D*)&d1); // OK
__builtin_clear_padding((A*)&d1); // Error
}
```
https://github.com/llvm/llvm-project/pull/75371
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits