[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / address-of.cpp
blob373e44c17edad5d2c2cd16355c208d89924408e7
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // PR clang/3175
4 void bar(int*);
6 class c {
7 int var;
8 static int svar;
9 void foo() {
10 bar(&var);
11 bar(&svar);
14 static void wibble() {
15 bar(&var); // expected-error{{invalid use of member 'var' in static member function}}
16 bar(&svar);
20 enum E {
21 Enumerator
24 void test() {
25 (void)&Enumerator; // expected-error{{cannot take the address of an rvalue of type 'E'}}
28 template<int N>
29 void test2() {
30 (void)&N; // expected-error{{cannot take the address of an rvalue of type 'int'}}
33 // PR clang/3222
34 void xpto();
35 void (*xyz)(void) = &xpto;
37 struct PR11066 {
38 static int foo(short);
39 static int foo(float);
40 void test();
43 void PR11066::test() {
44 int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{extra '&' taking address of overloaded function}}
47 namespace test3 {
48 // emit no error
49 template<typename T> struct S {
50 virtual void f() = 0;
52 template<typename T> void S<T>::f() { T::error; }
53 void (S<int>::*p)() = &S<int>::f;