xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/cxx-reference.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc extern char *bork;
4f4a2713aSLionel Sambuc char *& bar = bork;
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc int val;
7f4a2713aSLionel Sambuc 
foo(int & a)8f4a2713aSLionel Sambuc void foo(int &a) {
9f4a2713aSLionel Sambuc }
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc typedef int & A;
12f4a2713aSLionel Sambuc 
g(const A aref)13*0a6a1f1dSLionel Sambuc void g(const A aref) { // expected-warning {{'const' qualifier on reference type 'A' (aka 'int &') has no effect}}
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc int & const X = val; // expected-error {{'const' qualifier may not be applied to a reference}}
17f4a2713aSLionel Sambuc int & volatile Y = val; // expected-error {{'volatile' qualifier may not be applied to a reference}}
18f4a2713aSLionel Sambuc int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \
19f4a2713aSLionel Sambuc                            expected-error {{'volatile' qualifier may not be applied}} */
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc typedef int && RV; // expected-warning {{rvalue references are a C++11 extension}}
22