]> granicus.if.org Git - clang/commitdiff
Downgrade the Error on an 'inline' operator new or delete to an ExtWarn. Some
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 16 Nov 2013 00:47:38 +0000 (00:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 16 Nov 2013 00:47:38 +0000 (00:47 +0000)
projects are relying on such (questionable) practices, so we should give them
a way to opt out of this diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194905 91177308-0d34-0410-b5e6-96231b3b80d8

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

index a0cf4b6f6d1ece7194d435713c4c00f76068b9f7..c3605f2c3ed2eaa04aeca32adc1ca3107f9ed66c 100644 (file)
@@ -5961,8 +5961,9 @@ def err_operator_new_delete_declared_in_namespace : Error<
   "%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<
index f5507791e7f610c27eb41b56cd9c901673bfa270..0527e4957913aa23c46dac1f5a814fae3ccdfb1a 100644 (file)
@@ -6879,7 +6879,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
     // 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();
   }
 
index 63ec4ccae389a2b7a8c5f271a4f14b52a9b9061b..2f408525ea3d1fd5e689b3da2bc9c7fa1d80cc04 100644 (file)
@@ -24,7 +24,7 @@ void* operator new(size_t, int*); // expected-note 3 {{candidate}}
 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 { };