A type parameter can never be optional.
[mono.git] / mcs / gmcs / decl.cs
index 51825fa41ea4f8e3d74cc065d40ed5e19c2977ff..800a622ad3e08bd69ffd748644d2270ce278f077 100755 (executable)
@@ -2,6 +2,7 @@
 // decl.cs: Declaration base class for structs, classes, enums and interfaces.
 //
 // Author: Miguel de Icaza (miguel@gnu.org)
+//         Marek Safar (marek.safar@seznam.cz)
 //
 // Licensed under the terms of the GNU GPL
 //
@@ -269,6 +270,9 @@ namespace Mono.CSharp {
                        HasCompliantAttribute_Undetected = 1 << 5,      // Presence of CLSCompliantAttribute has not been detected
                        HasClsCompliantAttribute = 1 << 6,                      // Type has CLSCompliantAttribute
                        ClsCompliantAttributeTrue = 1 << 7,                     // Type has CLSCompliant (true)
+                       Excluded_Undetected = 1 << 8,           // Conditional attribute has not been detected yet
+                       Excluded = 1 << 9                                       // Method is conditional
+
                }
   
                /// <summary>
@@ -282,7 +286,22 @@ namespace Mono.CSharp {
                        Name = name.GetName (!(this is GenericMethod) && !(this is Method));
                        MemberName = name;
                        Location = loc;
-                       caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected;
+                       caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
+               }
+
+               /// <summary>
+               /// Tests presence of ObsoleteAttribute and report proper error
+               /// </summary>
+               protected void CheckUsageOfObsoleteAttribute (Type type)
+               {
+                       if (type == null)
+                               return;
+
+                       ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
+                       if (obsolete_attr == null)
+                               return;
+
+                       AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
                }
 
                public abstract bool Define (TypeContainer parent);
@@ -300,6 +319,8 @@ namespace Mono.CSharp {
                /// </summary>
                public virtual void Emit (TypeContainer container)
                {
+                       VerifyObsoleteAttribute ();
+
                        if (!RootContext.VerifyClsCompliance)
                                return;
 
@@ -516,6 +537,8 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               protected abstract void VerifyObsoleteAttribute ();
+
        }
 
        /// <summary>