xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/invalid-member-expr.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class X {};
4*f4a2713aSLionel Sambuc 
test()5*f4a2713aSLionel Sambuc void test() {
6*f4a2713aSLionel Sambuc   X x;
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc   x.int; // expected-error{{expected unqualified-id}}
9*f4a2713aSLionel Sambuc   x.~int(); // expected-error{{expected a class name}}
10*f4a2713aSLionel Sambuc   x.operator; // expected-error{{expected a type}}
11*f4a2713aSLionel Sambuc   x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
test2()14*f4a2713aSLionel Sambuc void test2() {
15*f4a2713aSLionel Sambuc   X *x;
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc   x->int; // expected-error{{expected unqualified-id}}
18*f4a2713aSLionel Sambuc   x->~int(); // expected-error{{expected a class name}}
19*f4a2713aSLionel Sambuc   x->operator; // expected-error{{expected a type}}
20*f4a2713aSLionel Sambuc   x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc // PR6327
24*f4a2713aSLionel Sambuc namespace test3 {
25*f4a2713aSLionel Sambuc   template <class A, class B> struct pair {};
26*f4a2713aSLionel Sambuc 
test0()27*f4a2713aSLionel Sambuc   void test0() {
28*f4a2713aSLionel Sambuc     pair<int, int> z = minmax({}); // expected-error {{expected expression}}
29*f4a2713aSLionel Sambuc   }
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   struct string {
32*f4a2713aSLionel Sambuc     class iterator {};
33*f4a2713aSLionel Sambuc   };
34*f4a2713aSLionel Sambuc 
test1()35*f4a2713aSLionel Sambuc   void test1() {
36*f4a2713aSLionel Sambuc     string s;
37*f4a2713aSLionel Sambuc     string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
38*f4a2713aSLionel Sambuc   }
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc // Make sure we don't crash.
43*f4a2713aSLionel Sambuc namespace rdar11293995 {
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc struct Length {
46*f4a2713aSLionel Sambuc   explicit Length(PassRefPtr<CalculationValue>); // expected-error {{unknown type name}} \
47*f4a2713aSLionel Sambuc                     expected-error {{expected ')'}} \
48*f4a2713aSLionel Sambuc                     expected-note {{to match this '('}}
49*f4a2713aSLionel Sambuc };
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc struct LengthSize {
52*f4a2713aSLionel Sambuc     Length m_width;
53*f4a2713aSLionel Sambuc     Length m_height;
54*f4a2713aSLionel Sambuc };
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc struct FillSize {
59*f4a2713aSLionel Sambuc     EFillSizeType type;
60*f4a2713aSLionel Sambuc     LengthSize size;
61*f4a2713aSLionel Sambuc };
62*f4a2713aSLionel Sambuc 
63*f4a2713aSLionel Sambuc class FillLayer {
64*f4a2713aSLionel Sambuc public:
setSize(FillSize f)65*f4a2713aSLionel Sambuc     void setSize(FillSize f) { m_sizeType = f.type;}
66*f4a2713aSLionel Sambuc private:
67*f4a2713aSLionel Sambuc     unsigned m_sizeType : 2;
68*f4a2713aSLionel Sambuc };
69*f4a2713aSLionel Sambuc 
70*f4a2713aSLionel Sambuc }
71