[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pnet-developers] Re: C# compiler bug-fix help
From: |
Kaushik Srenevasan |
Subject: |
[Pnet-developers] Re: C# compiler bug-fix help |
Date: |
Mon, 16 Jan 2006 09:50:09 +0600 |
User-agent: |
Mozilla Thunderbird 1.0.2-6 (X11/20050513) |
Kaushik Srenevasan wrote:
Hi,
1. I'm trying to put this check into pnet/cscc/csharp/cs_decls.tc into
ILNode_SemAnalysis(ILNode_MethodDeclaration) as follows...
if(ILMethod_IsConstructor(node->methodInfo) ||
ILMethod_IsStaticConstructor(node->methodInfo))
{
CSProcessAttrs(info, ILToProgramItem(node->methodInfo),
node->attributes, CS_ATTR_CONSTRUCTOR);
/* added */
if (ILClassIsValueType(
((ILNode_ClassDefn *)info->currentClass)->classInfo))
{
if(!CSGetMethodParamCount(ILToProgramItem(node->methodInfo)))
{
/* print error message */
}
....
I realised that there were functions to do this already. So i've
implemented this as follows
if (ILClassIsValueType(((ILNode_ClassDefn *)info->currentClass)->classInfo)
+ &&
ILMethod_IsConstructor(node->methodInfo))
+ {
+ int numParams =
ILTypeNumParams(ILMethod_Signature(ILToProgramItem(node->methodInfo)));
+
+ if (numParams == 0)
+ {
+ CCErrorOnLine(yygetfilename(node),
yygetlinenum(node),
+ "Structs cannot contain explicit
parameterless constructors");
+
+ return CSSemValueDefault;
+ }
+
+ }
I've submitted this patch
https://savannah.gnu.org/patch/?func=detailitem&item_id=4800
Thanks,
Kaushik