Francois Pichet | 6b6fb4f | 2012-01-21 23:26:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions |
Francois Pichet | 1c98d62 | 2011-09-18 21:37:37 +0000 | [diff] [blame] | 2 | |
| 3 | |
Francois Pichet | dfd110c | 2012-07-22 11:32:41 +0000 | [diff] [blame] | 4 | typedef unsigned short char16_t; |
| 5 | typedef unsigned int char32_t; |
Francois Pichet | 1c98d62 | 2011-09-18 21:37:37 +0000 | [diff] [blame] | 6 | |
Francois Pichet | b67e7fc | 2012-07-22 15:10:57 +0000 | [diff] [blame^] | 7 | typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}} |
| 8 | |
Francois Pichet | 1c98d62 | 2011-09-18 21:37:37 +0000 | [diff] [blame] | 9 | namespace ms_conversion_rules { |
| 10 | |
| 11 | void f(float a); |
| 12 | void f(int a); |
| 13 | |
| 14 | void test() |
| 15 | { |
| 16 | long a = 0; |
| 17 | f((long)0); |
| 18 | f(a); |
| 19 | } |
| 20 | |
| 21 | } |
| 22 | |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 23 | |
| 24 | |
| 25 | namespace ms_protected_scope { |
| 26 | struct C { C(); }; |
| 27 | |
| 28 | int jump_over_variable_init(bool b) { |
| 29 | if (b) |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 30 | goto foo; // expected-warning {{goto into protected scope}} |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 31 | C c; // expected-note {{jump bypasses variable initialization}} |
| 32 | foo: |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | struct Y { |
| 37 | ~Y(); |
| 38 | }; |
| 39 | |
| 40 | void jump_over_var_with_dtor() { |
| 41 | goto end; // expected-warning{{goto into protected scope}} |
Richard Smith | 0e9e981 | 2011-10-20 21:42:12 +0000 | [diff] [blame] | 42 | Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}} |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 43 | end: |
| 44 | ; |
| 45 | } |
| 46 | |
| 47 | void jump_over_variable_case(int c) { |
| 48 | switch (c) { |
| 49 | case 0: |
| 50 | int x = 56; // expected-note {{jump bypasses variable initialization}} |
| 51 | case 1: // expected-error {{switch case is in protected scope}} |
| 52 | x = 10; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | void exception_jump() { |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 58 | goto l2; // expected-error {{goto into protected scope}} |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 59 | try { // expected-note {{jump bypasses initialization of try block}} |
| 60 | l2: ; |
| 61 | } catch(int) { |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | int jump_over_indirect_goto() { |
| 66 | static void *ps[] = { &&a0 }; |
| 67 | goto *&&a0; // expected-warning {{goto into protected scope}} |
| 68 | int a = 3; // expected-note {{jump bypasses variable initialization}} |
| 69 | a0: |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | } |
| 74 | |
Nico Weber | 2897660 | 2012-01-23 04:01:33 +0000 | [diff] [blame] | 75 | namespace PR11826 { |
| 76 | struct pair { |
| 77 | pair(int v) { } |
| 78 | void operator=(pair&& rhs) { } |
| 79 | }; |
| 80 | void f() { |
| 81 | pair p0(3); |
| 82 | pair p = p0; |
| 83 | } |
| 84 | } |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 85 | |
Nico Weber | 2897660 | 2012-01-23 04:01:33 +0000 | [diff] [blame] | 86 | namespace PR11826_for_symmetry { |
| 87 | struct pair { |
| 88 | pair(int v) { } |
| 89 | pair(pair&& rhs) { } |
| 90 | }; |
| 91 | void f() { |
| 92 | pair p0(3); |
| 93 | pair p(4); |
| 94 | p = p0; |
| 95 | } |
| 96 | } |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 97 | |
Nico Weber | c14ec5a | 2012-01-23 04:08:13 +0000 | [diff] [blame] | 98 | namespace ms_using_declaration_bug { |
| 99 | |
| 100 | class A { |
| 101 | public: |
| 102 | int f(); |
| 103 | }; |
| 104 | |
| 105 | class B : public A { |
| 106 | private: |
| 107 | using A::f; |
| 108 | }; |
| 109 | |
| 110 | class C : public B { |
| 111 | private: |
| 112 | using B::f; // expected-warning {{using declaration referring to inaccessible member 'ms_using_declaration_bug::B::f' (which refers to accessible member 'ms_using_declaration_bug::A::f') is a Microsoft compatibility extension}} |
| 113 | }; |
| 114 | |
| 115 | } |
| 116 | |
| 117 | |
| 118 | namespace MissingTypename { |
| 119 | |
| 120 | template<class T> class A { |
| 121 | public: |
| 122 | typedef int TYPE; |
| 123 | }; |
| 124 | |
| 125 | template<class T> class B { |
| 126 | public: |
| 127 | typedef int TYPE; |
| 128 | }; |
| 129 | |
| 130 | |
| 131 | template<class T, class U> |
| 132 | class C : private A<T>, public B<U> { |
| 133 | public: |
| 134 | typedef A<T> Base1; |
| 135 | typedef B<U> Base2; |
| 136 | typedef A<U> Base3; |
| 137 | |
| 138 | A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}} |
| 139 | Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}} |
| 140 | |
| 141 | B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}} |
| 142 | Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}} |
| 143 | |
| 144 | A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}} |
| 145 | Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}} |
| 146 | }; |
| 147 | |
| 148 | class D { |
| 149 | public: |
| 150 | typedef int Type; |
| 151 | }; |
| 152 | |
| 153 | template <class T> |
| 154 | void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}} |
| 155 | { |
| 156 | const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}} |
| 157 | } |
| 158 | |
| 159 | template void function_missing_typename<D>(const D::Type param); |
| 160 | |
| 161 | } |
| 162 | |
Francois Pichet | 6b6fb4f | 2012-01-21 23:26:50 +0000 | [diff] [blame] | 163 | enum ENUM2 { |
| 164 | ENUM2_a = (enum ENUM2) 4, |
| 165 | ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} |
| 166 | ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} |
| 167 | }; |
Nico Weber | c14ec5a | 2012-01-23 04:08:13 +0000 | [diff] [blame] | 168 | |
| 169 | |
Nico Weber | df1be86 | 2012-01-23 05:50:57 +0000 | [diff] [blame] | 170 | namespace PR11791 { |
| 171 | template<class _Ty> |
| 172 | void del(_Ty *_Ptr) { |
| 173 | _Ptr->~_Ty(); // expected-warning {{pseudo-destructors on type void are a Microsoft extension}} |
| 174 | } |
| 175 | |
| 176 | void f() { |
| 177 | int* a = 0; |
| 178 | del((void*)a); // expected-note {{in instantiation of function template specialization}} |
| 179 | } |
| 180 | } |