Clang Project

clang_source_code/test/SemaCXX/has_unique_object_reps_member_ptr.cpp
1// RUN: %clang_cc1 -triple x86_64-linux-pc -DIS64 -fsyntax-only -verify -std=c++17 %s 
2// RUN: %clang_cc1 -triple x86_64-windows-pc -DIS64 -fsyntax-only -verify -std=c++17 %s
3// RUN: %clang_cc1 -triple i386-linux-pc -fsyntax-only -verify -std=c++17 %s
4// RUN: %clang_cc1 -triple i386-windows-pc -DW32 -fsyntax-only -verify -std=c++17 %s
5// expected-no-diagnostics
6
7struct Base {};
8struct A : virtual Base {
9  virtual void n() {}
10};
11
12auto p = &A::n;
13static_assert(__has_unique_object_representations(decltype(p)));
14
15struct B {
16  decltype(p) x;
17  int b;
18#ifdef IS64
19  // required on 64 bit to fill out the tail padding.
20  int c;
21#endif
22};
23static_assert(__has_unique_object_representations(B));
24
25struct C { // has padding on Win32, but nothing else.
26  decltype(p) x;
27};
28#ifdef W32
29static_assert(!__has_unique_object_representations(C));
30#else
31static_assert(__has_unique_object_representations(C));
32#endif
33