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 5 6 class X {}; 7 test()8void test() { 9 X x; 10 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}} 15 } 16 test2()17void test2() { 18 X *x; 19 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}} 24 } 25 26 // PR6327 27 namespace test3 { 28 template <class A, class B> struct pair {}; 29 template <class _E> class initializer_list {}; minmax(initializer_list<_Tp> __l)30 template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {}; 31 test0()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 40 } 41 42 struct string { 43 class iterator {}; 44 }; 45 test1()46 void test1() { 47 string s; 48 string::iterator i = s.foo(); // expected-error {{no member named 'foo'}} 49 } 50 } 51 52 53 // Make sure we don't crash. 54 namespace rdar11293995 { 55 56 struct Length { 57 explicit Length(PassRefPtr<CalculationValue>); // expected-error {{undeclared identifier 'CalculationValue'}} 58 }; 59 60 struct LengthSize { 61 Length m_width; 62 Length m_height; 63 }; 64 65 enum EFillSizeType { Contain, Cover, SizeLength, SizeNone }; 66 67 struct FillSize { 68 EFillSizeType type; 69 LengthSize size; 70 }; 71 72 class FillLayer { 73 public: setSize(FillSize f)74 void setSize(FillSize f) { m_sizeType = f.type;} 75 private: 76 unsigned m_sizeType : 2; 77 }; 78 79 } 80