Clang Project

clang_source_code/test/Parser/cxx-reference.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
5extern char *bork;
6char *& bar = bork;
7
8int val;
9
10void foo(int &a) {
11}
12
13typedef int & A;
14
15void g(const A aref) { // expected-warning {{'const' qualifier on reference type 'A' (aka 'int &') has no effect}}
16}
17
18int & const X = val; // expected-error {{'const' qualifier may not be applied to a reference}}
19int & volatile Y = val; // expected-error {{'volatile' qualifier may not be applied to a reference}}
20int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \
21                           expected-error {{'volatile' qualifier may not be applied}} */
22
23typedef int && RV; 
24#if __cplusplus <= 199711L
25// expected-warning@-2 {{rvalue references are a C++11 extension}}
26#endif
27