Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions |
Francois Pichet | 1c98d62 | 2011-09-18 21:37:37 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | |
| 5 | namespace ms_conversion_rules { |
| 6 | |
| 7 | void f(float a); |
| 8 | void f(int a); |
| 9 | |
| 10 | void test() |
| 11 | { |
| 12 | long a = 0; |
| 13 | f((long)0); |
| 14 | f(a); |
| 15 | } |
| 16 | |
| 17 | } |
| 18 | |
Francois Pichet | 8b3c99e | 2011-09-18 21:48:27 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | namespace ms_protected_scope { |
| 22 | struct C { C(); }; |
| 23 | |
| 24 | int jump_over_variable_init(bool b) { |
| 25 | if (b) |
| 26 | goto foo; // expected-warning {{illegal goto into protected scope}} |
| 27 | C c; // expected-note {{jump bypasses variable initialization}} |
| 28 | foo: |
| 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | struct Y { |
| 33 | ~Y(); |
| 34 | }; |
| 35 | |
| 36 | void jump_over_var_with_dtor() { |
| 37 | goto end; // expected-warning{{goto into protected scope}} |
| 38 | Y y; // expected-note {{jump bypasses variable initialization}} |
| 39 | end: |
| 40 | ; |
| 41 | } |
| 42 | |
| 43 | void jump_over_variable_case(int c) { |
| 44 | switch (c) { |
| 45 | case 0: |
| 46 | int x = 56; // expected-note {{jump bypasses variable initialization}} |
| 47 | case 1: // expected-error {{switch case is in protected scope}} |
| 48 | x = 10; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void exception_jump() { |
| 54 | goto l2; // expected-error {{illegal goto into protected scope}} |
| 55 | try { // expected-note {{jump bypasses initialization of try block}} |
| 56 | l2: ; |
| 57 | } catch(int) { |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | int jump_over_indirect_goto() { |
| 62 | static void *ps[] = { &&a0 }; |
| 63 | goto *&&a0; // expected-warning {{goto into protected scope}} |
| 64 | int a = 3; // expected-note {{jump bypasses variable initialization}} |
| 65 | a0: |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |
| 71 | |
| 72 | |
Francois Pichet | cc6306e | 2011-09-20 22:08:26 +0000 | [diff] [blame] | 73 | namespace ms_using_declaration_bug {
|
| 74 |
|
| 75 | class A {
|
| 76 | public:
|
| 77 | int f();
|
| 78 | };
|
| 79 |
|
| 80 | class B : public A {
|
| 81 | private:
|
| 82 | using A::f;
|
| 83 | };
|
| 84 |
|
| 85 | class C : public B {
|
| 86 | private:
|
| 87 | using B::f; // expected-warning {{using declaration refers to inaccessible member 'ms_using_declaration_bug::B::f', which refers to accessible member 'ms_using_declaration_bug::A::f', accepted for Microsoft compatibility}}
|
| 88 | };
|
| 89 |
|
| 90 | }
|
| 91 |
|
| 92 |
|