xref: /llvm-project/clang/test/CXX/over/over.oper/p7.cpp (revision ba15d186e5cef2620d562c6c9d9a6d570382cd0a)
1 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx11
2 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,cxx23
3 // RUN: %clang_cc1 -std=c++23 -Wpre-c++23-compat %s -verify=expected,precxx23
4 
5 
6 struct Functor {
7   static int operator()(int a, int b);
8   static int operator[](int a1);
9   // cxx11-warning@-2 {{declaring overloaded 'operator()' as 'static' is a C++23 extension}}
10   // cxx11-warning@-2 {{declaring overloaded 'operator[]' as 'static' is a C++23 extension}}
11   // precxx23-warning@-4 {{incompatible with C++ standards before C++23}}
12   // precxx23-warning@-4 {{incompatible with C++ standards before C++23}}
13 };
14 
15 struct InvalidParsing1 {
16   extern int operator()(int a, int b);  // expected-error {{storage class specified}}
17   extern int operator[](int a1);  // expected-error {{storage class specified}}
18 };
19 
20 struct InvalidParsing2 {
21   extern static int operator()(int a, int b);  // expected-error {{storage class specified}} // expected-error {{cannot combine with previous 'extern' declaration specifier}}
22   extern static int operator[](int a);  // expected-error {{storage class specified}} // expected-error {{cannot combine with previous 'extern' declaration specifier}}
23 };
24