[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / invalid-member-expr.cpp
blob6ef33ea575a12817db9d800ff30c6048145f29a1
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 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
6 class X {};
8 void test() {
9 X x;
11 x.int; // expected-error{{expected unqualified-id}}
12 x.~int(); // expected-error{{expected a class name}}
13 x.operator; // expected-error{{expected a type}}
14 x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
17 void test2() {
18 X *x;
20 x->int; // expected-error{{expected unqualified-id}}
21 x->~int(); // expected-error{{expected a class name}}
22 x->operator; // expected-error{{expected a type}}
23 x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
26 // PR6327
27 namespace test3 {
28 template <class A, class B> struct pair {};
29 template <class _E> class initializer_list {};
30 template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {};
32 void test0() {
33 pair<int, int> z = minmax({});
34 #if __cplusplus <= 199711L // C++03 or earlier modes
35 // expected-error@-2 {{expected expression}}
36 #else
37 // expected-error@-4 {{no matching function for call to 'minmax'}}
38 // expected-note@-8 {{candidate template ignored: couldn't infer template argument '_Tp'}}
39 #endif
42 struct string {
43 class iterator {};
46 void test1() {
47 string s;
48 string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
53 // Make sure we don't crash.
54 namespace rdar11293995 {
56 struct Length {
57 explicit Length(PassRefPtr<CalculationValue>); // expected-error {{undeclared identifier 'CalculationValue'}}
60 struct LengthSize {
61 Length m_width;
62 Length m_height;
65 enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
67 struct FillSize {
68 EFillSizeType type;
69 LengthSize size;
72 class FillLayer {
73 public:
74 void setSize(FillSize f) { m_sizeType = f.type;}
75 private:
76 unsigned m_sizeType : 2;