From 13dfdc88a9a22d4663d28c7319869ed597b88fbc Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 16 Nov 2013 00:47:38 +0000 Subject: [PATCH] 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. llvm-svn: 194905 --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 5 +++-- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/test/SemaCXX/new-delete.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a0cf4b6f6d1e..c3605f2c3ed2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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>; def err_operator_new_delete_invalid_result_type : Error< "%0 must return type %1">; def err_operator_new_delete_dependent_result_type : Error< diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f5507791e7f6..0527e4957913 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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(); } diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp index 63ec4ccae389..2f408525ea3d 100644 --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -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 { };