2012-11-02 09:34:28 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions
|
2010-08-30 22:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
// ::type_info is predeclared with forward class declartion
|
|
|
|
void f(const type_info &a);
|
|
|
|
|
2010-08-30 23:04:51 +08:00
|
|
|
|
2011-03-20 07:05:18 +08:00
|
|
|
// Microsoft doesn't validate exception specification.
|
2011-05-24 10:11:43 +08:00
|
|
|
namespace microsoft_exception_spec {
|
|
|
|
|
2011-03-20 07:05:18 +08:00
|
|
|
void foo(); // expected-note {{previous declaration}}
|
|
|
|
void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
|
2010-08-30 23:04:51 +08:00
|
|
|
|
2011-03-20 07:05:18 +08:00
|
|
|
void r6() throw(...); // expected-note {{previous declaration}}
|
|
|
|
void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
|
2010-08-30 23:04:51 +08:00
|
|
|
|
|
|
|
struct Base {
|
|
|
|
virtual void f2();
|
|
|
|
virtual void f3() throw(...);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Derived : Base {
|
|
|
|
virtual void f2() throw(...);
|
|
|
|
virtual void f3();
|
|
|
|
};
|
2010-09-02 00:29:03 +08:00
|
|
|
|
2011-05-24 10:11:43 +08:00
|
|
|
class A {
|
|
|
|
virtual ~A() throw(); // expected-note {{overridden virtual function is here}}
|
|
|
|
};
|
|
|
|
|
|
|
|
class B : public A {
|
|
|
|
virtual ~B(); // expected-warning {{exception specification of overriding function is more lax than base version}}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2010-09-08 19:32:25 +08:00
|
|
|
|
|
|
|
// MSVC allows type definition in anonymous union and struct
|
|
|
|
struct A
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
} d;
|
|
|
|
|
|
|
|
union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
|
|
|
|
{
|
|
|
|
int e;
|
|
|
|
int ee;
|
|
|
|
} f;
|
|
|
|
|
|
|
|
typedef int D; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
|
|
|
|
struct F; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int a2;
|
|
|
|
|
|
|
|
struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
|
|
|
|
{
|
|
|
|
int c2;
|
|
|
|
} d2;
|
|
|
|
|
|
|
|
union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
|
|
|
|
{
|
|
|
|
int e2;
|
|
|
|
int ee2;
|
|
|
|
} f2;
|
|
|
|
|
|
|
|
typedef int D2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
|
|
|
|
struct F2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2010-09-02 00:29:03 +08:00
|
|
|
// __stdcall handling
|
|
|
|
struct M {
|
|
|
|
int __stdcall addP();
|
|
|
|
float __stdcall subtractP();
|
|
|
|
};
|
|
|
|
|
2011-08-18 17:59:55 +08:00
|
|
|
// __unaligned handling
|
|
|
|
typedef char __unaligned *aligned_type;
|
|
|
|
|
|
|
|
|
2010-09-02 00:29:03 +08:00
|
|
|
template<typename T> void h1(T (__stdcall M::* const )()) { }
|
|
|
|
|
|
|
|
void m1() {
|
|
|
|
h1<int>(&M::addP);
|
|
|
|
h1(&M::subtractP);
|
|
|
|
}
|
2010-09-12 13:06:55 +08:00
|
|
|
|
2010-10-18 23:01:13 +08:00
|
|
|
|
|
|
|
|
2011-01-17 09:08:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
void f(long long);
|
|
|
|
void f(int);
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// This is an ambiguous call in standard C++.
|
|
|
|
// This calls f(long long) in Microsoft mode because LL is always signed.
|
|
|
|
f(0xffffffffffffffffLL);
|
|
|
|
f(0xffffffffffffffffi64);
|
|
|
|
}
|
2011-02-23 04:32:04 +08:00
|
|
|
|
|
|
|
// Enumeration types with a fixed underlying type.
|
|
|
|
const int seventeen = 17;
|
|
|
|
typedef int Int;
|
|
|
|
|
|
|
|
struct X0 {
|
2012-11-02 09:34:28 +08:00
|
|
|
enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
|
2011-02-23 04:32:04 +08:00
|
|
|
enum E1 : seventeen;
|
|
|
|
};
|
|
|
|
|
2012-11-02 09:34:28 +08:00
|
|
|
enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
|
2011-02-23 04:32:04 +08:00
|
|
|
SomeValue = 0x100000000
|
|
|
|
};
|
2011-03-29 18:39:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
class AAA {
|
|
|
|
__declspec(dllimport) void f(void) { }
|
|
|
|
void f2(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
__declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-10 11:03:52 +08:00
|
|
|
template <class T>
|
|
|
|
class BB {
|
|
|
|
public:
|
|
|
|
void f(int g = 10 ); // expected-note {{previous definition is here}}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}}
|
|
|
|
|
2011-04-13 10:38:49 +08:00
|
|
|
|
2011-04-22 16:14:00 +08:00
|
|
|
|
|
|
|
extern void static_func();
|
|
|
|
void static_func(); // expected-note {{previous declaration is here}}
|
|
|
|
|
|
|
|
|
|
|
|
static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
|
|
|
|
{
|
|
|
|
|
2011-05-09 06:52:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
long function_prototype(int a);
|
|
|
|
long (*function_ptr)(int a);
|
|
|
|
|
|
|
|
void function_to_voidptr_conv() {
|
|
|
|
void *a1 = function_prototype;
|
|
|
|
void *a2 = &function_prototype;
|
2011-05-09 07:15:10 +08:00
|
|
|
void *a3 = function_ptr;
|
2011-05-09 06:52:41 +08:00
|
|
|
}
|
2011-05-12 06:13:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
void pointer_to_integral_type_conv(char* ptr) {
|
|
|
|
char ch = (char)ptr;
|
|
|
|
short sh = (short)ptr;
|
|
|
|
ch = (char)ptr;
|
|
|
|
sh = (short)ptr;
|
|
|
|
}
|
2011-05-23 11:43:44 +08:00
|
|
|
|
2011-06-01 12:14:20 +08:00
|
|
|
|
|
|
|
namespace friend_as_a_forward_decl {
|
|
|
|
|
|
|
|
class A {
|
|
|
|
class Nested {
|
|
|
|
friend class B;
|
|
|
|
B* b;
|
|
|
|
};
|
|
|
|
B* b;
|
|
|
|
};
|
|
|
|
B* global_b;
|
|
|
|
|
|
|
|
|
|
|
|
void f()
|
|
|
|
{
|
|
|
|
class Local {
|
|
|
|
friend class Z;
|
|
|
|
Z* b;
|
|
|
|
};
|
|
|
|
Z* b;
|
|
|
|
}
|
|
|
|
|
2011-09-13 18:26:51 +08:00
|
|
|
}
|
|
|
|
|
2011-10-18 01:09:53 +08:00
|
|
|
struct PR11150 {
|
|
|
|
class X {
|
|
|
|
virtual void f() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
int array[__is_abstract(X)? 1 : -1];
|
|
|
|
};
|
2011-10-21 11:57:52 +08:00
|
|
|
|
|
|
|
void f() { int __except = 0; }
|
|
|
|
|
2012-09-14 04:16:20 +08:00
|
|
|
void ::f(); // expected-warning{{extra qualification on member 'f'}}
|
2013-02-13 01:27:41 +08:00
|
|
|
|
|
|
|
class C {
|
|
|
|
C::C(); // expected-warning{{extra qualification on member 'C'}}
|
|
|
|
};
|