Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Bill Wendling | cbf4709 | 2007-06-03 09:02:28 +0000 | [diff] [blame] | 4 | |
Bill Wendling | 6811c0b | 2007-05-27 10:16:12 +0000 | [diff] [blame] | 5 | extern char *bork; |
| 6 | char *& bar = bork; |
| 7 | |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 8 | int val; |
| 9 | |
Bill Wendling | 6811c0b | 2007-05-27 10:16:12 +0000 | [diff] [blame] | 10 | void foo(int &a) { |
| 11 | } |
Bill Wendling | cbf4709 | 2007-06-03 09:02:28 +0000 | [diff] [blame] | 12 | |
| 13 | typedef int & A; |
| 14 | |
Richard Smith | 4025944 | 2014-02-19 00:13:27 +0000 | [diff] [blame] | 15 | void g(const A aref) { // expected-warning {{'const' qualifier on reference type 'A' (aka 'int &') has no effect}} |
Bill Wendling | cbf4709 | 2007-06-03 09:02:28 +0000 | [diff] [blame] | 16 | } |
| 17 | |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 18 | int & const X = val; // expected-error {{'const' qualifier may not be applied to a reference}} |
| 19 | int & volatile Y = val; // expected-error {{'volatile' qualifier may not be applied to a reference}} |
| 20 | int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \ |
Bill Wendling | eb2def6 | 2007-06-27 04:30:12 +0000 | [diff] [blame] | 21 | expected-error {{'volatile' qualifier may not be applied}} */ |
Sebastian Redl | 3b27be6 | 2009-03-23 00:00:23 +0000 | [diff] [blame] | 22 | |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 23 | typedef int && RV; |
| 24 | #if __cplusplus <= 199711L |
| 25 | // expected-warning@-2 {{rvalue references are a C++11 extension}} |
| 26 | #endif |