blob: 172be6b8266d699abe4773dfa236d7810ecbed6f [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Charles Li542f04c2015-11-11 19:34:47 +00002// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Douglas Gregor522fbc42009-08-31 19:52:13 +00004
5class X {};
6
7void test() {
8 X x;
9
Douglas Gregor30d60cb2009-11-03 19:44:04 +000010 x.int; // expected-error{{expected unqualified-id}}
Douglas Gregorfe17d252010-02-16 19:09:40 +000011 x.~int(); // expected-error{{expected a class name}}
Nick Lewycky07e97c52010-11-03 17:52:57 +000012 x.operator; // expected-error{{expected a type}}
Richard Smithc5b05522012-03-12 07:56:15 +000013 x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
Douglas Gregor522fbc42009-08-31 19:52:13 +000014}
15
16void test2() {
17 X *x;
18
Douglas Gregor30d60cb2009-11-03 19:44:04 +000019 x->int; // expected-error{{expected unqualified-id}}
Douglas Gregorfe17d252010-02-16 19:09:40 +000020 x->~int(); // expected-error{{expected a class name}}
Nick Lewycky07e97c52010-11-03 17:52:57 +000021 x->operator; // expected-error{{expected a type}}
Richard Smithc5b05522012-03-12 07:56:15 +000022 x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
Douglas Gregor522fbc42009-08-31 19:52:13 +000023}
John McCalleae5acb2010-03-31 02:13:20 +000024
25// PR6327
26namespace test3 {
27 template <class A, class B> struct pair {};
Charles Li542f04c2015-11-11 19:34:47 +000028 template <class _E> class initializer_list {};
29 template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {};
John McCalleae5acb2010-03-31 02:13:20 +000030
31 void test0() {
Charles Li542f04c2015-11-11 19:34:47 +000032 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
John McCalleae5acb2010-03-31 02:13:20 +000039 }
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}
Argyrios Kyrtzidisb39399d2012-04-27 04:31:46 +000050
51
52// Make sure we don't crash.
53namespace rdar11293995 {
54
55struct Length {
56 explicit Length(PassRefPtr<CalculationValue>); // expected-error {{unknown type name}} \
57 expected-error {{expected ')'}} \
58 expected-note {{to match this '('}}
59};
60
61struct LengthSize {
62 Length m_width;
63 Length m_height;
64};
65
66enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
67
68struct FillSize {
69 EFillSizeType type;
70 LengthSize size;
71};
72
73class FillLayer {
74public:
75 void setSize(FillSize f) { m_sizeType = f.type;}
76private:
77 unsigned m_sizeType : 2;
78};
79
80}