Author: marek
Date: 2007-06-14 16:51:05 -0400 (Thu, 14 Jun 2007)
New Revision: 79629

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/attribute.cs
   trunk/mcs/mcs/cs-parser.jay
   trunk/mcs/mcs/ecore.cs
Log:
2007-06-14  Marek Safar  <[EMAIL PROTECTED]>

        A fix for bugs #81855 and #76274
        * attribute.cs (AttachTo): Always set owner for global attributes to
        prefined owner.
        
        * ecore.cs (Error_TypeDoesNotContainDefinition): A type location can be
        usefull too.
        
        * cs-parser.jay: Assembly and module attributes must precede all other
        elements except using clauses and extern alias declarations.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-06-14 20:47:46 UTC (rev 79628)
+++ trunk/mcs/mcs/ChangeLog     2007-06-14 20:51:05 UTC (rev 79629)
@@ -1,3 +1,15 @@
+2007-06-14  Marek Safar  <[EMAIL PROTECTED]>
+
+       A fix for bugs #81855 and #76274
+       * attribute.cs (AttachTo): Always set owner for global attributes to
+       prefined owner.
+       
+       * ecore.cs (Error_TypeDoesNotContainDefinition): A type location can be
+       usefull too.
+       
+       * cs-parser.jay: Assembly and module attributes must precede all other
+       elements except using clauses and extern alias declarations.
+
 2007-06-13  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #81748

Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs  2007-06-14 20:47:46 UTC (rev 79628)
+++ trunk/mcs/mcs/attribute.cs  2007-06-14 20:51:05 UTC (rev 79629)
@@ -95,7 +95,7 @@
                readonly bool nameEscaped;
 
                // It can contain more onwers when the attribute is applied to 
multiple fiels.
-               Attributable[] owners;
+               protected Attributable[] owners;
 
                static readonly AttributeUsageAttribute DefaultUsageAttribute = 
new AttributeUsageAttribute (AttributeTargets.All);
                static Assembly orig_sec_assembly;
@@ -137,7 +137,7 @@
                        att_cache = new PtrHashtable ();
                }
 
-               public void AttachTo (Attributable owner)
+               public virtual void AttachTo (Attributable owner)
                {
                        if (this.owners == null) {
                                this.owners = new Attributable[1] { owner };
@@ -1303,7 +1303,21 @@
                        base (target, left_expr, identifier, args, loc, 
nameEscaped)
                {
                        this.ns = ns;
+                       this.owners = new Attributable[1];
                }
+               
+               public override void AttachTo (Attributable owner)
+               {
+                       if (ExplicitTarget == "assembly") {
+                               owners [0] = CodeGen.Assembly;
+                               return;
+                       }
+                       if (ExplicitTarget == "module") {
+                               owners [0] = CodeGen.Module;
+                               return;
+                       }
+                       throw new NotImplementedException ("Unknown global 
explicit target " + ExplicitTarget);
+               }
 
                void Enter ()
                {
@@ -1779,6 +1793,7 @@
                public static bool IsConditionalMethodExcluded (MethodBase mb)
                {
                        mb = TypeManager.DropGenericMethodArguments (mb);
+                       // TODO: Has to be fixed for partial methods
                        if ((mb is MethodBuilder) || (mb is ConstructorBuilder))
                                return false;
 

Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2007-06-14 20:47:46 UTC (rev 79628)
+++ trunk/mcs/mcs/cs-parser.jay 2007-06-14 20:51:05 UTC (rev 79629)
@@ -521,8 +521,16 @@
 global_attributes
        : attribute_sections
 {
-       if ($1 != null)
-               CodeGen.Assembly.AddAttributes (((Attributes)$1).Attrs);
+       if ($1 != null) {
+               Attributes attrs = (Attributes)$1;
+               if (global_attrs_enabled) {
+                       CodeGen.Assembly.AddAttributes (attrs.Attrs);
+               } else {
+                       foreach (Attribute a in attrs.Attrs) {
+                               Report.Error (1730, a.Location, "Assembly and 
module attributes must precede all other elements except using clauses and 
extern alias declarations");
+                       }
+               }
+       }
 
        $$ = $1;
 }
@@ -669,7 +677,7 @@
 
                if (current_attr_target == String.Empty)
                        $$ = null;
-               else if (current_attr_target == "assembly" || 
current_attr_target == "module")
+               else if (global_attrs_enabled && (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));

Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs      2007-06-14 20:47:46 UTC (rev 79628)
+++ trunk/mcs/mcs/ecore.cs      2007-06-14 20:51:05 UTC (rev 79629)
@@ -368,6 +368,7 @@
 
                public static void Error_TypeDoesNotContainDefinition (Location 
loc, Type type, string name)
                {
+                       Report.SymbolRelatedToPreviousError (type);
                        Report.Error (117, loc, "`{0}' does not contain a 
definition for `{1}'",
                                TypeManager.CSharpName (type), name);
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to