blob: 373e44c17edad5d2c2cd16355c208d89924408e7 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor29882052008-12-10 21:26:49 +00002// PR clang/3175
3
4void bar(int*);
5
6class c {
7 int var;
8 static int svar;
9 void foo() {
10 bar(&var);
11 bar(&svar);
12 }
13
14 static void wibble() {
15 bar(&var); // expected-error{{invalid use of member 'var' in static member function}}
16 bar(&svar);
17 }
18};
19
20enum E {
21 Enumerator
22};
23
24void test() {
Richard Smith3fa3fea2013-02-02 02:14:45 +000025 (void)&Enumerator; // expected-error{{cannot take the address of an rvalue of type 'E'}}
Douglas Gregor29882052008-12-10 21:26:49 +000026}
27
28template<int N>
29void test2() {
Richard Smith3fa3fea2013-02-02 02:14:45 +000030 (void)&N; // expected-error{{cannot take the address of an rvalue of type 'int'}}
Douglas Gregor29882052008-12-10 21:26:49 +000031}
Nuno Lopes6fea8d22008-12-16 22:58:26 +000032
33// PR clang/3222
34void xpto();
35void (*xyz)(void) = &xpto;
Douglas Gregor44efed02011-10-09 19:10:41 +000036
37struct PR11066 {
38 static int foo(short);
39 static int foo(float);
40 void test();
41};
42
43void PR11066::test() {
Richard Smith3fa3fea2013-02-02 02:14:45 +000044 int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{extra '&' taking address of overloaded function}}
Douglas Gregor44efed02011-10-09 19:10:41 +000045}
46
Nick Lewyckyb7e5eec2013-02-02 00:25:55 +000047namespace test3 {
48 // emit no error
49 template<typename T> struct S {
50 virtual void f() = 0;
51 };
52 template<typename T> void S<T>::f() { T::error; }
53 void (S<int>::*p)() = &S<int>::f;
54}