xref: /aosp_15_r20/external/clang/test/SemaCXX/alignof-sizeof-reference.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li struct s0; // expected-note {{forward declaration}}
4*67e74705SXin Li char ar[sizeof(s0&)]; // expected-error {{invalid application of 'sizeof' to an incomplete type}}
test()5*67e74705SXin Li void test() {
6*67e74705SXin Li   char &r = ar[0];
7*67e74705SXin Li   static_assert(alignof(r) == 1, "bad alignment"); // expected-warning {{GNU extension}}
8*67e74705SXin Li   static_assert(alignof(char&) == 1, "bad alignment");
9*67e74705SXin Li   static_assert(sizeof(r) == 1, "bad size");
10*67e74705SXin Li   static_assert(sizeof(char&) == 1, "bad size");
11*67e74705SXin Li }
12*67e74705SXin Li 
13*67e74705SXin Li int f();  // expected-note{{possible target for call}}
14*67e74705SXin Li int f(int);  // expected-note{{possible target for call}}
g()15*67e74705SXin Li void g() {
16*67e74705SXin Li   sizeof(&f); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} \
17*67e74705SXin Li   // expected-warning{{expression result unused}}
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li template<typename T> void f_template(); // expected-note{{possible target for call}}
21*67e74705SXin Li template<typename T> void f_template(T*); // expected-note{{possible target for call}}
rdar9659191()22*67e74705SXin Li void rdar9659191() {
23*67e74705SXin Li   (void)alignof(f_template<int>); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} expected-warning {{GNU extension}}
24*67e74705SXin Li }
25