Revert 131347. It asserts if the specialization in within a class template:
[clang/stm8.git] / test / SemaCXX / MicrosoftExtensions.cpp
blob88e39226708c98cb7944bac6cc5fde5b4d1a1ec0
1 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions
4 // ::type_info is predeclared with forward class declartion
5 void f(const type_info &a);
8 // Microsoft doesn't validate exception specification.
9 void foo(); // expected-note {{previous declaration}}
10 void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
12 void r6() throw(...); // expected-note {{previous declaration}}
13 void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
15 struct Base {
16 virtual void f2();
17 virtual void f3() throw(...);
20 struct Derived : Base {
21 virtual void f2() throw(...);
22 virtual void f3();
26 // MSVC allows type definition in anonymous union and struct
27 struct A
29 union
31 int a;
32 struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
34 int c;
35 } d;
37 union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
39 int e;
40 int ee;
41 } f;
43 typedef int D; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
44 struct F; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
47 struct
49 int a2;
51 struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
53 int c2;
54 } d2;
56 union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
58 int e2;
59 int ee2;
60 } f2;
62 typedef int D2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
63 struct F2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
67 // __stdcall handling
68 struct M {
69 int __stdcall addP();
70 float __stdcall subtractP();
73 template<typename T> void h1(T (__stdcall M::* const )()) { }
75 void m1() {
76 h1<int>(&M::addP);
77 h1(&M::subtractP);
80 //MSVC allows forward enum declaration
81 enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
82 ENUM *var = 0;
83 ENUM var2 = (ENUM)3;
84 enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
87 enum ENUM2 {
88 ENUM2_a = (enum ENUM2) 4,
89 ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
90 ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
94 void f(long long);
95 void f(int);
97 int main()
99 // This is an ambiguous call in standard C++.
100 // This calls f(long long) in Microsoft mode because LL is always signed.
101 f(0xffffffffffffffffLL);
102 f(0xffffffffffffffffi64);
105 // Enumeration types with a fixed underlying type.
106 const int seventeen = 17;
107 typedef int Int;
109 struct X0 {
110 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
111 enum E1 : seventeen;
114 enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
115 SomeValue = 0x100000000
119 class AAA {
120 __declspec(dllimport) void f(void) { }
121 void f2(void);
124 __declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
130 template <class T>
131 class BB {
132 public:
133 void f(int g = 10 ); // expected-note {{previous definition is here}}
136 template <class T>
137 void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}}
140 namespace MissingTypename {
142 template<class T> class A {
143 public:
144 typedef int TYPE;
147 template<class T> class B {
148 public:
149 typedef int TYPE;
153 template<class T, class U>
154 class C : private A<T>, public B<U> {
155 public:
156 typedef A<T> Base1;
157 typedef B<U> Base2;
158 typedef A<U> Base3;
160 A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
161 Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
163 B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
164 Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
166 A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
167 Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
175 extern void static_func();
176 void static_func(); // expected-note {{previous declaration is here}}
179 static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
184 long function_prototype(int a);
185 long (*function_ptr)(int a);
187 void function_to_voidptr_conv() {
188 void *a1 = function_prototype;
189 void *a2 = &function_prototype;
190 void *a3 = function_ptr;
194 void pointer_to_integral_type_conv(char* ptr) {
195 char ch = (char)ptr;
196 short sh = (short)ptr;
197 ch = (char)ptr;
198 sh = (short)ptr;