blob: 094b5e05238b3f76485906c9fa45cbb28090acda [file] [log] [blame]
John McCall018591f2011-03-02 02:04:40 +00001// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions
Douglas Gregor5c0ca522010-08-30 14:44:26 +00002
3
4// ::type_info is predeclared with forward class declartion
5void f(const type_info &a);
6
Francois Picheteedd4672011-03-19 23:05:18 +00007
8// Microsoft doesn't validate exception specification.
Douglas Gregor5b6f7692010-08-30 15:04:51 +00009void foo(); // expected-note {{previous declaration}}
Francois Picheteedd4672011-03-19 23:05:18 +000010void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
Douglas Gregor5c0ca522010-08-30 14:44:26 +000011
Francois Picheteedd4672011-03-19 23:05:18 +000012void r6() throw(...); // expected-note {{previous declaration}}
13void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
Douglas Gregor5b6f7692010-08-30 15:04:51 +000014
15struct Base {
16 virtual void f2();
17 virtual void f3() throw(...);
18};
19
20struct Derived : Base {
21 virtual void f2() throw(...);
22 virtual void f3();
23};
Douglas Gregorafac01d2010-09-01 16:29:03 +000024
Francois Pichet538e0d02010-09-08 11:32:25 +000025
26// MSVC allows type definition in anonymous union and struct
27struct A
28{
29 union
30 {
31 int a;
32 struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
33 {
34 int c;
35 } d;
36
37 union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
38 {
39 int e;
40 int ee;
41 } f;
42
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}}
45 };
46
47 struct
48 {
49 int a2;
50
51 struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
52 {
53 int c2;
54 } d2;
55
56 union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
57 {
58 int e2;
59 int ee2;
60 } f2;
61
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}}
64 };
65};
66
Douglas Gregorafac01d2010-09-01 16:29:03 +000067// __stdcall handling
68struct M {
69 int __stdcall addP();
70 float __stdcall subtractP();
71};
72
73template<typename T> void h1(T (__stdcall M::* const )()) { }
74
75void m1() {
76 h1<int>(&M::addP);
77 h1(&M::subtractP);
78}
Francois Pichet8dc3abc2010-09-12 05:06:55 +000079
80//MSVC allows forward enum declaration
81enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
Francois Pichet842e7a22010-10-18 15:01:13 +000082ENUM *var = 0;
83ENUM var2 = (ENUM)3;
84enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
85
86
87enum 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'}}
91};
Francois Pichet5be38be2011-01-17 01:08:01 +000092
93
94void f(long long);
95void f(int);
96
97int main()
98{
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);
103}
Douglas Gregor86f208c2011-02-22 20:32:04 +0000104
105// Enumeration types with a fixed underlying type.
106const int seventeen = 17;
107typedef int Int;
108
109struct X0 {
110 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
111 enum E1 : seventeen;
112};
113
Douglas Gregor1756ce42011-02-22 21:42:31 +0000114enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
Douglas Gregor86f208c2011-02-22 20:32:04 +0000115 SomeValue = 0x100000000
116};
Francois Pichetb613cd62011-03-29 10:39:17 +0000117
118
119class AAA {
120__declspec(dllimport) void f(void) { }
121void f2(void);
122};
123
124__declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
125
126}
127
128
129