Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 2988205 | 2008-12-10 21:26:49 +0000 | [diff] [blame] | 2 | // PR clang/3175 |
| 3 | |
| 4 | void bar(int*); |
| 5 | |
| 6 | class 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 | |
| 20 | enum E { |
| 21 | Enumerator |
| 22 | }; |
| 23 | |
| 24 | void test() { |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 25 | (void)&Enumerator; // expected-error{{cannot take the address of an rvalue of type 'E'}} |
Douglas Gregor | 2988205 | 2008-12-10 21:26:49 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | template<int N> |
| 29 | void test2() { |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 30 | (void)&N; // expected-error{{cannot take the address of an rvalue of type 'int'}} |
Douglas Gregor | 2988205 | 2008-12-10 21:26:49 +0000 | [diff] [blame] | 31 | } |
Nuno Lopes | 6fea8d2 | 2008-12-16 22:58:26 +0000 | [diff] [blame] | 32 | |
| 33 | // PR clang/3222 |
| 34 | void xpto(); |
| 35 | void (*xyz)(void) = &xpto; |
Douglas Gregor | 44efed0 | 2011-10-09 19:10:41 +0000 | [diff] [blame] | 36 | |
| 37 | struct PR11066 { |
| 38 | static int foo(short); |
| 39 | static int foo(float); |
| 40 | void test(); |
| 41 | }; |
| 42 | |
| 43 | void PR11066::test() { |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 44 | int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{extra '&' taking address of overloaded function}} |
Douglas Gregor | 44efed0 | 2011-10-09 19:10:41 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Nick Lewycky | b7e5eec | 2013-02-02 00:25:55 +0000 | [diff] [blame] | 47 | namespace 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 | } |