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