[Issue 4987] New: C function pointer syntax needs to be deprecated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 4 01:14:35 PDT 2010
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: nobody at puremagic.com
ReportedBy: clugdbug at yahoo.com.au
--- Comment #0 from Don <clugdbug at 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: -------
More information about the Digitalmars-d-bugs
mailing list