Thread overview
[Issue 5105] New: Member function template cannot be synchronized
Oct 23, 2010
Shin Fujishiro
Jan 29, 2011
Don
Feb 06, 2011
Don
October 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5105

           Summary: Member function template cannot be synchronized
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: rsinfu@gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-23 00:53:54 PDT ---
DMD doesn't allow member function templates in synchronized class:
--------------------
void main()
{
    auto c = new C;
    c.foo(10);              // (4)
}
synchronized shared class C
{
    void foo(T)(T a) {}     // (8)
}
--------------------
test.d(8): Error: function test.C.foo!(int).foo synchronized function foo must
be a member of a class
test.d(4): Error: template instance test.C.foo!(int) error instantiating
--------------------

Patch against dmd r727:
--------------------
--- src/func.c
+++ src/func.c
@@ -1551,7 +1551,8 @@ void FuncDeclaration::semantic3(Scope *sc)
             if (isSynchronized())
             {   /* Wrap the entire function body in a synchronized statement
                  */
-                ClassDeclaration *cd = parent->isClassDeclaration();
+                AggregateDeclaration *ad = isThis();
+                ClassDeclaration *cd = ad ? ad->isClassDeclaration() : NULL;
                 if (cd)
                 {
 #if TARGET_WINDOS
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5105


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
         Depends on|                            |5504


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-01-29 13:01:56 PST ---
The patch works for a simplified test case:

void main()
{
    auto c = new C;
    c.foo(10);
}
synchronized class C
{
    void foo(T)(T a) {}
}

Since DMD2.051, the original test case hits bug 5504.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5105


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-02-06 13:34:26 PST ---
Fixed:

https://github.com/D-Programming-Language/dmd/commit/f25d6e98609259de5714b805f45f16880dd3031b

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------