diff options
Diffstat (limited to 'test/SemaCXX/MicrosoftExtensions.cpp')
| -rw-r--r-- | test/SemaCXX/MicrosoftExtensions.cpp | 79 | 
1 files changed, 78 insertions, 1 deletions
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp index ab3ff69f27be0..c5b45a2905c8b 100644 --- a/test/SemaCXX/MicrosoftExtensions.cpp +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -167,8 +167,14 @@ void pointer_to_integral_type_conv(char* ptr) {     short sh = (short)ptr;     ch = (char)ptr;     sh = (short)ptr; -}  +   // These are valid C++. +   bool b = (bool)ptr; +   b = static_cast<bool>(ptr); + +   // This is bad. +   b = reinterpret_cast<bool>(ptr); // expected-error {{cast from pointer to smaller type 'bool' loses information}} +}  namespace friend_as_a_forward_decl { @@ -333,3 +339,74 @@ void TestSP9() {    c3.g(); // Overloaded incdec op operand    c3.h(); // Overloaded unary op operand  } + +union u { +  int *i1; +  int &i2;  // expected-warning {{union member 'i2' has reference type 'int &', which is a Microsoft extension}} +}; + +// Property getter using reference. +struct SP11 { +  __declspec(property(get=GetV)) int V; +  int _v; +  int& GetV() { return _v; } +  void UseV(); +  void TakePtr(int *) {} +  void TakeRef(int &) {} +  void TakeVal(int) {} +}; + +void SP11::UseV() { +  TakePtr(&V); +  TakeRef(V); +  TakeVal(V); +} + +struct StructWithUnnamedMember { +  __declspec(property(get=GetV)) int : 10; // expected-error {{anonymous property is not supported}} +}; + +namespace rdar14250378 { +  class Bar {}; +   +  namespace NyNamespace { +    class Foo { +    public: +      Bar* EnsureBar(); +    }; +     +    class Baz : public Foo { +    public: +      friend class Bar; +    }; +     +    Bar* Foo::EnsureBar() { +      return 0; +    } +  } +} + +// expected-error@+1 {{'sealed' keyword not permitted with interface types}} +__interface InterfaceWithSealed sealed { +}; + +struct SomeBase { +  virtual void OverrideMe(); + +  // expected-note@+2 {{overridden virtual function is here}} +  // expected-warning@+1 {{'sealed' keyword is a Microsoft extension}} +  virtual void SealedFunction() sealed; +}; + +// expected-note@+2 {{'SealedType' declared here}} +// expected-warning@+1 {{'sealed' keyword is a Microsoft extension}} +struct SealedType sealed : SomeBase { +  // expected-error@+1 {{declaration of 'SealedFunction' overrides a 'sealed' function}} +  virtual void SealedFunction(); + +  // expected-warning@+1 {{'override' keyword is a C++11 extension}} +  virtual void OverrideMe() override; +}; + +// expected-error@+1 {{base 'SealedType' is marked 'sealed'}} +struct InheritFromSealed : SealedType {};  | 
