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