This fixes PR17591.
N.B. This actually goes beyond what the standard mandates by requiring
the restriction to hold for declarations instead of definitions. This
is believed to be a defect in the standard and an LWG issue has been
submitted.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193044
91177308-0d34-0410-b5e6-
96231b3b80d8
"%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<
+ "%0 cannot be declared 'inline'">;
def err_operator_new_delete_invalid_result_type : Error<
"%0 must return type %1">;
def err_operator_new_delete_dependent_result_type : Error<
NewFD->setType(Context.getFunctionType(FPT->getResultType(),
FPT->getArgTypes(), EPI));
}
+
+ // C++11 [replacement.functions]p3:
+ // The program's definitions shall not be specified as inline.
+ if (isInline && NewFD->isReplaceableGlobalAllocationFunction())
+ Diag(D.getDeclSpec().getInlineSpecLoc(),
+ diag::err_operator_new_delete_declared_inline)
+ << NewFD->getDeclName();
}
// Filter out previous declarations that don't match the scope.
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 {{'operator delete' cannot be declared 'inline'}}
+
struct foo { };
void good_news()