http://d.puremagic.com/issues/show_bug.cgi?id=4987

           Summary: C function pointer syntax needs to be deprecated
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: clugd...@yahoo.com.au


--- Comment #0 from Don <clugd...@yahoo.com.au> 2010-10-04 01:14:13 PDT ---
This patch also gives a reasonable fix for bug 4962, "Improve error message for
wrong constructor name?"
It also gives nice error messages for missing return types in function
declarations.
Most importantly, it makes x(y) an invalid type, instead of being a declaration
of a 'y', where &y is type 'x function()'. It's critical that syntax be
removed.

---

PATCH: parse.c, Parser::parseDeclarator() line 2497
----
        case TOKlparen:
            if (peekNext() == TOKmul || peekNext() == TOKlparen ||
                peekNext() == TOKlbracket)
            {
                /* Parse things with parentheses around the identifier, like:
                 *  int (*ident[3])[]
                 * although the D style would be:
                 *  int[]*[3] ident
                 */
                if (!global.params.useDeprecated) {
                    error("C-style function pointer syntax is deprecated. Use
'function' to declare function pointers");
                }
                nextToken();
                ts = parseDeclarator(t, pident);
                check(TOKrparen);
                break;
            }
            ts = t;      
            Token *peekt = &token;
            // Improve error messages for the common bug of a missing return
type
            if (isParameters(&peekt)) {
                error("function declaration without return type. "
                "(Note that constructors are always named 'this')");
            }
            else
                error("unexpected ( in declarator");
            break;

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

Reply via email to