www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12613] New: Diagnostic for calling convention mismatch when


          Issue ID: 12613
           Summary: Diagnostic for calling convention mismatch when
                    implementing/overriding methods should improve
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: andrej.mitrovich gmail.com
          Reporter: andrej.mitrovich gmail.com

import core.sys.windows.windows;
import std.c.windows.com;

interface IFoo
    void foo();

abstract class Foo : IFoo
    void foo_impl() { }

class C : Foo, IUnknown
    void foo() { }

    override void foo_impl() { }

    HRESULT QueryInterface(const(IID)*, void**) { return typeof(return).init; }
    uint AddRef() { return typeof(return).init; }
    uint Release() { return typeof(return).init; }

void main()

Note that COM classes by default have the extern(System) calling convention,
hence why the above neither implements 'foo' nor overrides 'foo_impl'. The
diagnostics are:

test.d(14): Error: class test.C interface function 'void foo()' is not
test.d(18): Error: function test.C.foo_impl does not override any function, did
you mean to override 'test.Foo.foo_impl'?

The compiler should emit the calling convention of the two methods if they
don't match.

Apr 22 2014