r194905 - Downgrade the Error on an 'inline' operator new or delete to an ExtWarn. Some

Richard Smith richard-llvm at metafoo.co.uk
Fri Nov 15 16:47:38 PST 2013


Author: rsmith
Date: Fri Nov 15 18:47:38 2013
New Revision: 194905

URL: http://llvm.org/viewvc/llvm-project?rev=194905&view=rev
Log:
Downgrade the Error on an 'inline' operator new or delete to an ExtWarn. Some
projects are relying on such (questionable) practices, so we should give them
a way to opt out of this diagnostic.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/new-delete.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=194905&r1=194904&r2=194905&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Nov 15 18:47:38 2013
@@ -5961,8 +5961,9 @@ def err_operator_new_delete_declared_in_
   "%0 cannot be declared inside a namespace">;
 def err_operator_new_delete_declared_static : Error<
   "%0 cannot be declared static in global scope">;
-def err_operator_new_delete_declared_inline : Error<
-  "replacement function %0 cannot be declared 'inline'">;
+def ext_operator_new_delete_declared_inline : ExtWarn<
+  "replacement function %0 cannot be declared 'inline'">,
+  InGroup<DiagGroup<"inline-new-delete">>;
 def err_operator_new_delete_invalid_result_type : Error<
   "%0 must return type %1">;
 def err_operator_new_delete_dependent_result_type : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=194905&r1=194904&r2=194905&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Nov 15 18:47:38 2013
@@ -6879,7 +6879,7 @@ Sema::ActOnFunctionDeclarator(Scope *S,
     // N.B. We diagnose declarations instead of definitions per LWG issue 2340.
     if (isInline && NewFD->isReplaceableGlobalAllocationFunction())
       Diag(D.getDeclSpec().getInlineSpecLoc(),
-           diag::err_operator_new_delete_declared_inline)
+           diag::ext_operator_new_delete_declared_inline)
         << NewFD->getDeclName();
   }
 

Modified: cfe/trunk/test/SemaCXX/new-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete.cpp?rev=194905&r1=194904&r2=194905&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/new-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/new-delete.cpp Fri Nov 15 18:47:38 2013
@@ -24,7 +24,7 @@ void* operator new(size_t, int*); // exp
 void* operator new(size_t, float*); // expected-note 3 {{candidate}}
 void* operator new(size_t, S); // expected-note 2 {{candidate}}
 
-inline void operator delete(void *); // expected-error {{replacement function 'operator delete' cannot be declared 'inline'}}
+inline void operator delete(void *); // expected-warning {{replacement function 'operator delete' cannot be declared 'inline'}}
 
 struct foo { };
 





More information about the cfe-commits mailing list