File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -232,9 +232,48 @@ public override bool VisitMethodDecl(Method method)
232232 return true ;
233233 }
234234
235+ if ( method . IsCopyConstructor )
236+ {
237+ if ( ! CheckNonDeletedCopyConstructor ( method ) )
238+ return false ;
239+ }
240+
235241 return base . VisitMethodDecl ( method ) ;
236242 }
237243
244+ private static bool CheckNonDeletedCopyConstructor ( Method method )
245+ {
246+ if ( method . IsDeleted )
247+ {
248+ method . ExplicitlyIgnore ( ) ;
249+
250+ Diagnostics . Debug (
251+ "Copy constructor '{0}' was ignored due to being deleted" ,
252+ method . QualifiedOriginalName ) ;
253+
254+ return false ;
255+ }
256+
257+ //Check if base class has an implicitly deleted copy constructor
258+ var baseClass = ( method . Namespace as Class ) . Bases . FirstOrDefault ( ) ? . Class ;
259+ if ( baseClass != null )
260+ {
261+ var baseCopyCtor = baseClass . Methods . Find ( m => m . IsCopyConstructor ) ;
262+ if ( baseCopyCtor == null || baseCopyCtor . IsDeleted )
263+ {
264+ method . ExplicitlyIgnore ( ) ;
265+
266+ Diagnostics . Debug (
267+ "Copy constructor '{0}' was ignored due to implicitly deleted base copy constructor '{1}'" ,
268+ method . QualifiedOriginalName , baseClass . Name ) ;
269+
270+ return false ;
271+ }
272+ }
273+
274+ return true ;
275+ }
276+
238277 bool CheckIgnoredBaseOverridenMethod ( Method method )
239278 {
240279 var @class = method . Namespace as Class ;
You can’t perform that action at this time.
0 commit comments