Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Charles Li | 542f04c | 2015-11-11 19:34:47 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Douglas Gregor | 522fbc4 | 2009-08-31 19:52:13 +0000 | [diff] [blame] | 4 | |
| 5 | class X {}; |
| 6 | |
| 7 | void test() { |
| 8 | X x; |
| 9 | |
Douglas Gregor | 30d60cb | 2009-11-03 19:44:04 +0000 | [diff] [blame] | 10 | x.int; // expected-error{{expected unqualified-id}} |
Douglas Gregor | fe17d25 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 11 | x.~int(); // expected-error{{expected a class name}} |
Nick Lewycky | 07e97c5 | 2010-11-03 17:52:57 +0000 | [diff] [blame] | 12 | x.operator; // expected-error{{expected a type}} |
Richard Smith | c5b0552 | 2012-03-12 07:56:15 +0000 | [diff] [blame] | 13 | x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}} |
Douglas Gregor | 522fbc4 | 2009-08-31 19:52:13 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | void test2() { |
| 17 | X *x; |
| 18 | |
Douglas Gregor | 30d60cb | 2009-11-03 19:44:04 +0000 | [diff] [blame] | 19 | x->int; // expected-error{{expected unqualified-id}} |
Douglas Gregor | fe17d25 | 2010-02-16 19:09:40 +0000 | [diff] [blame] | 20 | x->~int(); // expected-error{{expected a class name}} |
Nick Lewycky | 07e97c5 | 2010-11-03 17:52:57 +0000 | [diff] [blame] | 21 | x->operator; // expected-error{{expected a type}} |
Richard Smith | c5b0552 | 2012-03-12 07:56:15 +0000 | [diff] [blame] | 22 | x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}} |
Douglas Gregor | 522fbc4 | 2009-08-31 19:52:13 +0000 | [diff] [blame] | 23 | } |
John McCall | eae5acb | 2010-03-31 02:13:20 +0000 | [diff] [blame] | 24 | |
| 25 | // PR6327 |
| 26 | namespace test3 { |
| 27 | template <class A, class B> struct pair {}; |
Charles Li | 542f04c | 2015-11-11 19:34:47 +0000 | [diff] [blame] | 28 | template <class _E> class initializer_list {}; |
| 29 | template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {}; |
John McCall | eae5acb | 2010-03-31 02:13:20 +0000 | [diff] [blame] | 30 | |
| 31 | void test0() { |
Charles Li | 542f04c | 2015-11-11 19:34:47 +0000 | [diff] [blame] | 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 |
John McCall | eae5acb | 2010-03-31 02:13:20 +0000 | [diff] [blame] | 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 | } |
Argyrios Kyrtzidis | b39399d | 2012-04-27 04:31:46 +0000 | [diff] [blame] | 50 | |
| 51 | |
| 52 | // Make sure we don't crash. |
| 53 | namespace rdar11293995 { |
| 54 | |
| 55 | struct Length { |
| 56 | explicit Length(PassRefPtr<CalculationValue>); // expected-error {{unknown type name}} \ |
| 57 | expected-error {{expected ')'}} \ |
| 58 | expected-note {{to match this '('}} |
| 59 | }; |
| 60 | |
| 61 | struct LengthSize { |
| 62 | Length m_width; |
| 63 | Length m_height; |
| 64 | }; |
| 65 | |
| 66 | enum EFillSizeType { Contain, Cover, SizeLength, SizeNone }; |
| 67 | |
| 68 | struct FillSize { |
| 69 | EFillSizeType type; |
| 70 | LengthSize size; |
| 71 | }; |
| 72 | |
| 73 | class FillLayer { |
| 74 | public: |
| 75 | void setSize(FillSize f) { m_sizeType = f.type;} |
| 76 | private: |
| 77 | unsigned m_sizeType : 2; |
| 78 | }; |
| 79 | |
| 80 | } |