Clang Project

clang_source_code/test/SemaCXX/invalid-member-expr.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
5class X {};
6
7void test() {
8  X x;
9
10  x.int; // expected-error{{expected unqualified-id}}
11  x.~int(); // expected-error{{expected a class name}}
12  x.operator; // expected-error{{expected a type}}
13  x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
14}
15
16void test2() {
17  X *x;
18
19  x->int; // expected-error{{expected unqualified-id}}
20  x->~int(); // expected-error{{expected a class name}}
21  x->operator; // expected-error{{expected a type}}
22  x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
23}
24
25// PR6327
26namespace test3 {
27  template <class A, class B> struct pair {};
28  template <class _E> class initializer_list {};
29  template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {};
30
31  void test0() {
32    pair<int, int> z = minmax({});
33#if __cplusplus <= 199711L // C++03 or earlier modes
34    // expected-error@-2 {{expected expression}}
35#else
36    // expected-error@-4 {{no matching function for call to 'minmax'}}
37    // expected-note@-8 {{candidate template ignored: couldn't infer template argument '_Tp'}}
38#endif
39  }
40
41  struct string {
42    class iterator {};
43  };
44
45  void test1() {
46    string s;
47    string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
48  }
49}
50
51
52// Make sure we don't crash.
53namespace rdar11293995 {
54
55struct Length {
56  explicit Length(PassRefPtr<CalculationValue>); // expected-error {{no template named 'PassRefPtr}} expected-error {{undeclared identifier 'CalculationValue'}}
57};
58
59struct LengthSize {
60    Length m_width;
61    Length m_height;
62};
63
64enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
65
66struct FillSize {
67    EFillSizeType type;
68    LengthSize size;
69};
70
71class FillLayer {
72public:
73    void setSize(FillSize f) { m_sizeType = f.type;}
74private:
75    unsigned m_sizeType : 2;
76};
77
78}
79