* driver.cs: Allow negative numbers as an error code to flag.
* cs-parser.jay: Handle 1551.
* namespace.cs: Add 1537 checking (repeated using alias namespaces).
2002-01-15 Miguel de Icaza <miguel@ximian.com>
* cs-parser.jay: Report 1518 (type declaration can only contain
class, struct, interface, enum or delegate)
(switch_label): Report 1523 (keywords `case' or `default' must
preced code)
(opt_switch_sections): Report 1522 (empty switch)
* driver.cs: Report 1515 (response file specified multiple times)
Report 1516 (Source file specified multiple times).
* expression.cs (Argument.Resolve): Signal 1510
(BaseAccess.Resolve, BaseIndexer.Resolve): Signal 1511 (base
access not allowed in static code)
svn path=/trunk/mcs/; revision=2004
+2002-01-16 Miguel de Icaza <miguel@ximian.com>
+
+ * driver.cs: Allow negative numbers as an error code to flag.
+
+ * cs-parser.jay: Handle 1551.
+
+ * namespace.cs: Add 1537 checking (repeated using alias namespaces).
+
+2002-01-15 Miguel de Icaza <miguel@ximian.com>
+
+ * cs-parser.jay: Report 1518 (type declaration can only contain
+ class, struct, interface, enum or delegate)
+
+ (switch_label): Report 1523 (keywords `case' or `default' must
+ preced code)
+
+ (opt_switch_sections): Report 1522 (empty switch)
+
+ * driver.cs: Report 1515 (response file specified multiple times)
+ Report 1516 (Source file specified multiple times).
+
+ * expression.cs (Argument.Resolve): Signal 1510
+
+ (BaseAccess.Resolve, BaseIndexer.Resolve): Signal 1511 (base
+ access not allowed in static code)
+
2002-01-11 Ravi Pratap <ravi@ximian.com>
* typemanager.cs (IsPointerType): Utility method which we are going
: USING IDENTIFIER ASSIGN
namespace_or_type_name SEMICOLON
{
- current_namespace.UsingAlias ((string) $2, (string) $4);
+ current_namespace.UsingAlias ((string) $2, (string) $4, lexer.Location);
}
;
break;
if ((mod_flags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
- error (1527, "Namespace elements cant be explicitly " +
- "declared private or protected in `" + name + "'");
+ Report.Error (
+ 1527, lexer.Location,
+ "Namespace elements cant be explicitly " +
+ "declared private or protected in `" + name + "'");
}
}
| namespace_declaration
| struct_declaration
| interface_declaration
| enum_declaration
- | delegate_declaration
+ | delegate_declaration
+//
+// Enable this when we have handled all errors, because this acts as a generic fallback
+//
+// | error {
+// Report.Error (1518, lexer.Location, "Expected class, struct, interface, enum or delegate");
+// }
;
//
;
indexer_declarator
- : type THIS OPEN_BRACKET formal_parameter_list CLOSE_BRACKET
+ : type THIS OPEN_BRACKET opt_formal_parameter_list CLOSE_BRACKET
{
- $$ = new IndexerDeclaration ((string) $1, null, (Parameters) $4);
+ Parameters pars = (Parameters) $4;
+
+ if (pars.FixedParameters == null){
+ Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
+ }
+
+ $$ = new IndexerDeclaration ((string) $1, null, pars);
}
- | type qualified_identifier DOT THIS OPEN_BRACKET formal_parameter_list CLOSE_BRACKET
+ | type qualified_identifier DOT THIS OPEN_BRACKET opt_formal_parameter_list CLOSE_BRACKET
{
- $$ = new IndexerDeclaration ((string) $1, (string) $2, (Parameters) $6);
+ Parameters pars = (Parameters) $6;
+
+ if (pars.FixedParameters == null){
+ Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
+ }
+ $$ = new IndexerDeclaration ((string) $1, (string) $2, pars);
}
;
{
$$ = new ArrayCreation ((string) $2, (string) $3, (ArrayList) $4, lexer.Location);
}
+ | NEW type error
+ {
+ Report.Error (1526, lexer.Location, "new expression requires () or [] after type");
+ }
;
opt_rank_specifier
;
opt_switch_sections
- : /* empty */ { $$ = new ArrayList (); }
+ : /* empty */
+ {
+ Report.Error (1522, lexer.Location, "Empty switch block");
+ }
| switch_sections
;
switch_label
: CASE constant_expression COLON { $$ = new SwitchLabel ((Expression) $2, lexer.Location); }
| DEFAULT COLON { $$ = new SwitchLabel (null, lexer.Location); }
+ | error {
+ Report.Error (
+ 1523, lexer.Location,
+ "The keyword case or default must precede code in switch block");
+ }
;
iteration_statement
using System.Reflection.Emit;
using System.Collections;
using System.IO;
+ using System.Globalization;
using Mono.Languages;
enum Target {
static bool parse_only = false;
static bool timestamps = false;
+ static Hashtable response_file_list;
+ static Hashtable source_files = new Hashtable ();
+
//
// An array of the defines from the command line
//
if (arg.StartsWith ("@")){
string [] new_args, extra_args;
string response_file = arg.Substring (1);
+
+ if (response_file_list == null)
+ response_file_list = new Hashtable ();
+
+ if (response_file_list.Contains (response_file)){
+ Report.Error (
+ 1515, "Response file `" + response_file +
+ "' specified multiple times");
+ Environment.Exit (1);
+ }
+ response_file_list.Add (response_file, response_file);
+
extra_args = LoadArgs (response_file);
if (extra_args == null){
Report.Error (2011, "Unable to open response file: " +
case "--probe": {
int code, line;
- code = Int32.Parse (args [++i], 0);
+ code = Int32.Parse (
+ args [++i], NumberStyles.AllowLeadingSign);
line = Int32.Parse (args [++i], 0);
Report.SetProbe (code, line);
continue;
errors++;
continue;
}
+
+ if (source_files.Contains (f)){
+ Report.Error (
+ 1516,
+ "Source file `" + f + "' specified multiple times");
+ Environment.Exit (1);
+ } else
+ source_files.Add (f, f);
+
if (tokenize)
tokenize_file (f);
else {
return expr != null;
if (expr.eclass != ExprClass.Variable){
- Report.Error (206, loc,
- "A property or indexer can not be passed as an out or ref " +
- "parameter");
+ //
+ // We just probe to match the CSC output
+ //
+ if (expr.eclass == ExprClass.PropertyAccess ||
+ expr.eclass == ExprClass.IndexerAccess){
+ Report.Error (
+ 206, loc,
+ "A property or indexer can not be passed as an out or ref " +
+ "parameter");
+ } else {
+ Report.Error (
+ 1510, loc,
+ "An lvalue is required as an argument to out or ref");
+ }
return false;
}
Type current_type = ec.TypeContainer.TypeBuilder;
Type base_type = current_type.BaseType;
Expression e;
+
+ if (ec.IsStatic){
+ Report.Error (1511, loc,
+ "Keyword base is not allowed in static method");
+ return null;
+ }
member_lookup = MemberLookup (ec, base_type, member, loc);
if (member_lookup == null)
Type base_type = current_type.BaseType;
Expression member_lookup;
+ if (ec.IsStatic){
+ Report.Error (1511, loc,
+ "Keyword base is not allowed in static method");
+ return null;
+ }
+
member_lookup = MemberLookup (ec, base_type, "get_Item", loc);
if (member_lookup == null)
return null;
CSharpParser.error (1529, "A using clause must precede all other namespace elements");
return;
}
-
+
if (using_clauses == null)
using_clauses = new ArrayList ();
}
}
- public void UsingAlias (string alias, string namespace_or_type) {
+ public void UsingAlias (string alias, string namespace_or_type, Location loc)
+ {
if (aliases == null)
aliases = new Hashtable ();
+
+ if (aliases.Contains (alias)){
+ Report.Error (1537, loc, "The using alias `" + alias +
+ "' appeared previously in this namespace");
+ return;
+ }
+
aliases [alias] = namespace_or_type;
}
- public string LookupAlias (string alias) {
+ public string LookupAlias (string alias)
+ {
string value = null;
// System.Console.WriteLine ("Lookup " + alias + " in " + name);