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 // FIXME: We try to annotate the template-id here during tentative parsing, 58 // and fail, then try again during the actual parse. This results in the same 59 // diagnostic being produced twice. :( 60 explicit Length(PassRefPtr<CalculationValue>); // expected-error 2{{undeclared identifier 'CalculationValue'}} 61 }; 62 63 struct LengthSize { 64 Length m_width; 65 Length m_height; 66 }; 67 68 enum EFillSizeType { Contain, Cover, SizeLength, SizeNone }; 69 70 struct FillSize { 71 EFillSizeType type; 72 LengthSize size; 73 }; 74 75 class FillLayer { 76 public: setSize(FillSize f)77 void setSize(FillSize f) { m_sizeType = f.type;} 78 private: 79 unsigned m_sizeType : 2; 80 }; 81 82 } 83