if (is_static)
mods = Modifiers.STATIC;
- c.ModFlags = mods;
+ c.ModFlags |= mods;
AddConstructor (c);
if (!DoDefineParameters (parent))
return false;
- if ((ModFlags & Modifiers.STATIC) != 0)
+ if ((ModFlags & Modifiers.STATIC) != 0) {
ca |= MethodAttributes.Static;
+
+ if (this.Parameters != Parameters.EmptyReadOnlyParameters)
+ Report.Error (
+ 30479, Location,
+ "Shared constructor can not have parameters");
+
+ if ((ModFlags & Modifiers.Accessibility) != 0)
+ Report.Error (
+ 30480, Location,
+ "Shared constructor can not be declared " +
+ "explicitly as public, private, friend or protected");
+
+ if (this.Initializer != null)
+ Report.Error (
+ 30043, Location,
+ "Keywords like MyBase, MyClass, Me are not " +
+ "valid inside a Shared Constructor");
+ }
else {
- if (parent is Struct && ParameterTypes.Length == 0){
+ if (parent is Struct && ParameterTypes.Length == 0) {
Report.Error (
568, Location,
"Structs can not contain explicit parameterless " +
if ((ModFlags & Modifiers.PUBLIC) != 0)
ca |= MethodAttributes.Public;
- else if ((ModFlags & Modifiers.PROTECTED) != 0){
+ else if ((ModFlags & Modifiers.PROTECTED) != 0) {
if ((ModFlags & Modifiers.INTERNAL) != 0)
ca |= MethodAttributes.FamORAssem;
else
ca |= MethodAttributes.Family;
- } else if ((ModFlags & Modifiers.INTERNAL) != 0)
+ }\r
+ else if ((ModFlags & Modifiers.INTERNAL) != 0)
ca |= MethodAttributes.Assembly;
else if (IsDefault ())
ca |= MethodAttributes.Public;
parent.EmitFieldInitializers (ec);
}
- if (this.ConstructorBuilder.Equals (Initializer.ParentConstructor))
- Report.Error (
- 30297, Location,
- "A constructor can not call itself" );
+ if (Initializer != null) {
+ if (this.ConstructorBuilder.Equals (Initializer.ParentConstructor))
+ Report.Error (
+ 30297, Location,
+ "A constructor can not call itself" );
- if (Initializer != null)
Initializer.Emit (ec);
+ }
if ((ModFlags & Modifiers.STATIC) != 0)
parent.EmitFieldInitializers (ec);
;
module_member_declarator
- : static_constructor_declaration
+ : constructor_declaration
| method_declaration
{
Method method = (Method) $1;
// Structure members are Public by default
if ((current_container is Struct) && (mod == 0))
mod = Modifiers.PUBLIC;
+
+ if ((mod & Modifiers.Accessibility) == 0)
+ mod |= Modifiers.PRIVATE;
foreach (VariableDeclaration var in (ArrayList) $2){
Location l = var.Location;
: /* empty */
| OPEN_PARENS CLOSE_PARENS
;
-
+
+/*
static_constructor_declaration
: SHARED SUB NEW opt_empty_parens EOL
{
current_local_parameters = null;
}
END SUB EOL
+*/
constructor_declaration
: SUB NEW OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS EOL