Author: marek
Date: 2007-02-18 09:16:46 -0500 (Sun, 18 Feb 2007)
New Revision: 73079
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/cs-parser.jay
Log:
2007-02-18 Marek Safar <[EMAIL PROTECTED]>
A fix for bug #80493 by Atsushi Enomoto
* cs-parser.jay: Ignore invalid attribute target.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2007-02-18 14:08:08 UTC (rev 73078)
+++ trunk/mcs/gmcs/ChangeLog 2007-02-18 14:16:46 UTC (rev 73079)
@@ -1,3 +1,8 @@
+2007-02-18 Marek Safar <[EMAIL PROTECTED]>
+
+ A fix for bug #80493 by Atsushi Enomoto
+ * cs-parser.jay: Ignore invalid attribute target.
+
2007-02-15 Miguel de Icaza <[EMAIL PROTECTED]>
* Remove the call to SetExpression for lambda expressions, we do
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2007-02-18 14:08:08 UTC (rev 73078)
+++ trunk/mcs/gmcs/cs-parser.jay 2007-02-18 14:16:46 UTC (rev 73079)
@@ -560,55 +560,63 @@
attribute_sections
: attribute_section
{
- ArrayList sect = (ArrayList) $1;
+ if (current_attr_target != String.Empty) {
+ ArrayList sect = (ArrayList) $1;
- if (global_attrs_enabled) {
- if (current_attr_target == "module") {
- CodeGen.Module.AddAttributes (sect);
- $$ = null;
- } else if (current_attr_target != null &&
current_attr_target.Length > 0) {
- CodeGen.Assembly.AddAttributes (sect);
- $$ = null;
+ if (global_attrs_enabled) {
+ if (current_attr_target == "module") {
+ CodeGen.Module.AddAttributes (sect);
+ $$ = null;
+ } else if (current_attr_target != null &&
current_attr_target.Length > 0) {
+ CodeGen.Assembly.AddAttributes (sect);
+ $$ = null;
+ } else {
+ $$ = new Attributes (sect);
+ }
+ if ($$ == null) {
+ if (RootContext.Documentation != null) {
+
Lexer.check_incorrect_doc_comment ();
+ Lexer.doc_state =
+ XmlCommentState.Allowed;
+ }
+ }
} else {
$$ = new Attributes (sect);
- }
- if ($$ == null) {
- if (RootContext.Documentation != null) {
- Lexer.check_incorrect_doc_comment ();
- Lexer.doc_state =
- XmlCommentState.Allowed;
- }
- }
- } else {
- $$ = new Attributes (sect);
- }
+ }
+ }
+ else
+ $$ = null;
current_attr_target = null;
- }
+ }
| attribute_sections attribute_section
{
- Attributes attrs = $1 as Attributes;
- ArrayList sect = (ArrayList) $2;
+ if (current_attr_target != String.Empty) {
+ Attributes attrs = $1 as Attributes;
+ ArrayList sect = (ArrayList) $2;
- if (global_attrs_enabled) {
- if (current_attr_target == "module") {
- CodeGen.Module.AddAttributes (sect);
- $$ = null;
- } else if (current_attr_target == "assembly") {
- CodeGen.Assembly.AddAttributes (sect);
- $$ = null;
+ if (global_attrs_enabled) {
+ if (current_attr_target == "module") {
+ CodeGen.Module.AddAttributes (sect);
+ $$ = null;
+ } else if (current_attr_target == "assembly") {
+ CodeGen.Assembly.AddAttributes (sect);
+ $$ = null;
+ } else {
+ if (attrs == null)
+ attrs = new Attributes (sect);
+ else
+ attrs.AddAttributes (sect);
+ }
} else {
if (attrs == null)
attrs = new Attributes (sect);
else
- attrs.AddAttributes (sect);
- }
- } else {
- if (attrs == null)
- attrs = new Attributes (sect);
- else
- attrs.AddAttributes (sect);
- }
- $$ = attrs;
+ attrs.AddAttributes (sect);
+ }
+ $$ = attrs;
+ }
+ else
+ $$ = null;
current_attr_target = null;
}
;
@@ -636,11 +644,15 @@
: IDENTIFIER
{
LocatedToken lt = (LocatedToken) $1;
- CheckAttributeTarget (lt.Value, lt.Location);
- $$ = lt.Value; // Location won't be required anymore.
+ $$ = CheckAttributeTarget (lt.Value, lt.Location);
}
| EVENT { $$ = "event"; }
| RETURN { $$ = "return"; }
+ | error
+ {
+ string name = yyNames [yyToken].ToLower ();
+ $$ = CheckAttributeTarget (name, GetLocation ($1));
+ }
;
attribute_list
@@ -676,7 +688,9 @@
Expression left_expr = left == null ? null :
left.GetTypeExpression ();
- if (current_attr_target == "assembly" || current_attr_target ==
"module")
+ if (current_attr_target == String.Empty)
+ $$ = null;
+ else if (current_attr_target == "assembly" ||
current_attr_target == "module")
// FIXME: supply "nameEscaped" parameter here.
$$ = new GlobalAttribute (current_namespace,
current_attr_target,
left_expr, identifier,
arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
@@ -5356,18 +5370,16 @@
return implicit_block;
}
-void CheckAttributeTarget (string a, Location l)
+string CheckAttributeTarget (string a, Location l)
{
switch (a) {
-
case "assembly" : case "module" : case "field" : case "method" : case
"param" : case "property" : case "type" :
- return;
-
- default :
- Report.Error (658, l, "`" + a + "' is an invalid attribute
target");
- break;
+ return a;
}
+ Report.Warning (658, 1, l,
+ "`{0}' is invalid attribute target. All attributes in this
attribute section will be ignored", a);
+ return string.Empty;
}
void CheckUnaryOperator (Operator.OpType op, Location l)
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-02-18 14:08:08 UTC (rev 73078)
+++ trunk/mcs/mcs/ChangeLog 2007-02-18 14:16:46 UTC (rev 73079)
@@ -1,4 +1,9 @@
2007-02-18 Marek Safar <[EMAIL PROTECTED]>
+
+ A fix for bug #80493 by Atsushi Enomoto
+ * cs-parser.jay: Ignore invalid attribute target.
+
+2007-02-18 Marek Safar <[EMAIL PROTECTED]>
* cs-tokenizer.cs: Ignore '\0' as white space character.
Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2007-02-18 14:08:08 UTC (rev 73078)
+++ trunk/mcs/mcs/cs-parser.jay 2007-02-18 14:16:46 UTC (rev 73079)
@@ -545,55 +545,63 @@
attribute_sections
: attribute_section
{
- ArrayList sect = (ArrayList) $1;
+ if (current_attr_target != String.Empty) {
+ ArrayList sect = (ArrayList) $1;
- if (global_attrs_enabled) {
- if (current_attr_target == "module") {
- CodeGen.Module.AddAttributes (sect);
- $$ = null;
- } else if (current_attr_target != null &&
current_attr_target.Length > 0) {
- CodeGen.Assembly.AddAttributes (sect);
- $$ = null;
+ if (global_attrs_enabled) {
+ if (current_attr_target == "module") {
+ CodeGen.Module.AddAttributes (sect);
+ $$ = null;
+ } else if (current_attr_target != null &&
current_attr_target.Length > 0) {
+ CodeGen.Assembly.AddAttributes (sect);
+ $$ = null;
+ } else {
+ $$ = new Attributes (sect);
+ }
+ if ($$ == null) {
+ if (RootContext.Documentation != null) {
+
Lexer.check_incorrect_doc_comment ();
+ Lexer.doc_state =
+ XmlCommentState.Allowed;
+ }
+ }
} else {
$$ = new Attributes (sect);
- }
- if ($$ == null) {
- if (RootContext.Documentation != null) {
- Lexer.check_incorrect_doc_comment ();
- Lexer.doc_state =
- XmlCommentState.Allowed;
- }
- }
- } else {
- $$ = new Attributes (sect);
- }
+ }
+ }
+ else
+ $$ = null;
current_attr_target = null;
}
| attribute_sections attribute_section
{
- Attributes attrs = $1 as Attributes;
- ArrayList sect = (ArrayList) $2;
+ if (current_attr_target != String.Empty) {
+ Attributes attrs = $1 as Attributes;
+ ArrayList sect = (ArrayList) $2;
- if (global_attrs_enabled) {
- if (current_attr_target == "module") {
- CodeGen.Module.AddAttributes (sect);
- $$ = null;
- } else if (current_attr_target == "assembly") {
- CodeGen.Assembly.AddAttributes (sect);
- $$ = null;
+ if (global_attrs_enabled) {
+ if (current_attr_target == "module") {
+ CodeGen.Module.AddAttributes (sect);
+ $$ = null;
+ } else if (current_attr_target == "assembly") {
+ CodeGen.Assembly.AddAttributes (sect);
+ $$ = null;
+ } else {
+ if (attrs == null)
+ attrs = new Attributes (sect);
+ else
+ attrs.AddAttributes (sect);
+ }
} else {
if (attrs == null)
attrs = new Attributes (sect);
else
- attrs.AddAttributes (sect);
- }
- } else {
- if (attrs == null)
- attrs = new Attributes (sect);
- else
- attrs.AddAttributes (sect);
- }
- $$ = attrs;
+ attrs.AddAttributes (sect);
+ }
+ $$ = attrs;
+ }
+ else
+ $$ = null;
current_attr_target = null;
}
;
@@ -621,11 +629,15 @@
: IDENTIFIER
{
LocatedToken lt = (LocatedToken) $1;
- CheckAttributeTarget (lt.Value, lt.Location);
- $$ = lt.Value; // Location won't be required anymore.
+ $$ = CheckAttributeTarget (lt.Value, lt.Location);
}
- | EVENT { $$ = "event"; }
- | RETURN { $$ = "return"; }
+ | EVENT { $$ = "event"; }
+ | RETURN { $$ = "return"; }
+ | error
+ {
+ string name = yyNames [yyToken].ToLower ();
+ $$ = CheckAttributeTarget (name, GetLocation ($1));
+ }
;
attribute_list
@@ -656,7 +668,9 @@
Expression left_expr = left == null ? null :
left.GetTypeExpression ();
- if (current_attr_target == "assembly" || current_attr_target ==
"module")
+ if (current_attr_target == String.Empty)
+ $$ = null;
+ else if (current_attr_target == "assembly" ||
current_attr_target == "module")
// FIXME: supply "nameEscaped" parameter here.
$$ = new GlobalAttribute (current_namespace,
current_attr_target,
left_expr, identifier,
arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
@@ -4964,18 +4978,16 @@
return implicit_block;
}
-void CheckAttributeTarget (string a, Location l)
+string CheckAttributeTarget (string a, Location l)
{
switch (a) {
-
- case "assembly" : case "module" : case "field" : case "method" : case
"param" : case "property" : case "type" :
- return;
-
- default :
- Report.Error (658, l, "`" + a + "' is an invalid attribute
target");
- break;
+ case "assembly" : case "module" : case "field" : case "method"
: case "param" : case "property" : case "type" :
+ return a;
}
-
+
+ Report.Warning (658, 1, l,
+ "`{0}' is invalid attribute target. All attributes in this
attribute section will be ignored", a);
+ return string.Empty;
}
void CheckUnaryOperator (Operator.OpType op, Location l)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches