[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Parser / cxx-reference.cpp
blob58bd7ab607276edd646b7104bc5b1c7a654ba322
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
5 extern char *bork;
6 char *& bar = bork;
8 int val;
10 void foo(int &a) {
13 typedef int & A;
15 void g(const A aref) { // expected-warning {{'const' qualifier on reference type 'A' (aka 'int &') has no effect}}
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}} \
21 expected-error {{'volatile' qualifier may not be applied}} */
23 typedef int && RV;
24 #if __cplusplus <= 199711L
25 // expected-warning@-2 {{rvalue references are a C++11 extension}}
26 #endif