www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14407] New: No protection and attributes check for

https://issues.dlang.org/show_bug.cgi?id=14407

          Issue ID: 14407
           Summary: No protection and attributes check for class/struct
                    allocator in NewExp
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

Test case:

a.d: --------------------------------

deprecated class C
{
    private deprecated new (size_t, string)
    {
        return null;
    }
    private this(int) {}
}

deprecated struct S
{
    private deprecated new (size_t, string)
    {
        return null;
    }
    private this(int) {}
}

b.d: --------------------------------

import a;

void main() pure nothrow  safe  nogc
{
//    auto c = new("arg") C(0);
// Deprecation: class a.C is deprecated
// Deprecation: class a.C is deprecated     <-- duplicated message
// <-- no attribute errors for allocator
// <-- no access error for allocator
// Error: pure function 'D main' cannot call impure function 'a.C.this'
// Error: safe function 'D main' cannot call system function 'a.C.this'
// Error:  nogc function 'D main' cannot call non- nogc function 'a.C.this'
// Error: class a.C member this is not accessible
// Deprecation: class a.C is deprecated
// Error: constructor this is not nothrow
// Error: function 'D main' is nothrow yet may throw

    auto s = new("arg") S(0);
// Same with class new
}

--
Apr 04 2015