|
@@ -10188,6 +10188,10 @@ static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
|
|
if (FD->hasAttr<OpenCLKernelAttr>())
|
|
if (FD->hasAttr<OpenCLKernelAttr>())
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
+ // Don't warn on explicitly deleted functions.
|
|
|
|
+ if (FD->isDeleted())
|
|
|
|
+ return false;
|
|
|
|
+
|
|
bool MissingPrototype = true;
|
|
bool MissingPrototype = true;
|
|
for (const FunctionDecl *Prev = FD->getPreviousDecl();
|
|
for (const FunctionDecl *Prev = FD->getPreviousDecl();
|
|
Prev; Prev = Prev->getPreviousDecl()) {
|
|
Prev; Prev = Prev->getPreviousDecl()) {
|
|
@@ -10330,30 +10334,6 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) {
|
|
diag::err_func_def_incomplete_result))
|
|
diag::err_func_def_incomplete_result))
|
|
FD->setInvalidDecl();
|
|
FD->setInvalidDecl();
|
|
|
|
|
|
- // GNU warning -Wmissing-prototypes:
|
|
|
|
- // Warn if a global function is defined without a previous
|
|
|
|
- // prototype declaration. This warning is issued even if the
|
|
|
|
- // definition itself provides a prototype. The aim is to detect
|
|
|
|
- // global functions that fail to be declared in header files.
|
|
|
|
- const FunctionDecl *PossibleZeroParamPrototype = nullptr;
|
|
|
|
- if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) {
|
|
|
|
- Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
|
|
|
|
-
|
|
|
|
- if (PossibleZeroParamPrototype) {
|
|
|
|
- // We found a declaration that is not a prototype,
|
|
|
|
- // but that could be a zero-parameter prototype
|
|
|
|
- if (TypeSourceInfo *TI =
|
|
|
|
- PossibleZeroParamPrototype->getTypeSourceInfo()) {
|
|
|
|
- TypeLoc TL = TI->getTypeLoc();
|
|
|
|
- if (FunctionNoProtoTypeLoc FTL = TL.getAs<FunctionNoProtoTypeLoc>())
|
|
|
|
- Diag(PossibleZeroParamPrototype->getLocation(),
|
|
|
|
- diag::note_declaration_not_a_prototype)
|
|
|
|
- << PossibleZeroParamPrototype
|
|
|
|
- << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (FnBodyScope)
|
|
if (FnBodyScope)
|
|
PushDeclContext(FnBodyScope, FD);
|
|
PushDeclContext(FnBodyScope, FD);
|
|
|
|
|
|
@@ -10555,7 +10535,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
|
|
|
|
|
|
if (!FD->isInvalidDecl()) {
|
|
if (!FD->isInvalidDecl()) {
|
|
// Don't diagnose unused parameters of defaulted or deleted functions.
|
|
// Don't diagnose unused parameters of defaulted or deleted functions.
|
|
- if (Body)
|
|
|
|
|
|
+ if (!FD->isDeleted() && !FD->isDefaulted())
|
|
DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
|
|
DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
|
|
DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(),
|
|
DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(),
|
|
FD->getReturnType(), FD);
|
|
FD->getReturnType(), FD);
|
|
@@ -10574,6 +10554,30 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
|
|
computeNRVO(Body, getCurFunction());
|
|
computeNRVO(Body, getCurFunction());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // GNU warning -Wmissing-prototypes:
|
|
|
|
+ // Warn if a global function is defined without a previous
|
|
|
|
+ // prototype declaration. This warning is issued even if the
|
|
|
|
+ // definition itself provides a prototype. The aim is to detect
|
|
|
|
+ // global functions that fail to be declared in header files.
|
|
|
|
+ const FunctionDecl *PossibleZeroParamPrototype = nullptr;
|
|
|
|
+ if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) {
|
|
|
|
+ Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
|
|
|
|
+
|
|
|
|
+ if (PossibleZeroParamPrototype) {
|
|
|
|
+ // We found a declaration that is not a prototype,
|
|
|
|
+ // but that could be a zero-parameter prototype
|
|
|
|
+ if (TypeSourceInfo *TI =
|
|
|
|
+ PossibleZeroParamPrototype->getTypeSourceInfo()) {
|
|
|
|
+ TypeLoc TL = TI->getTypeLoc();
|
|
|
|
+ if (FunctionNoProtoTypeLoc FTL = TL.getAs<FunctionNoProtoTypeLoc>())
|
|
|
|
+ Diag(PossibleZeroParamPrototype->getLocation(),
|
|
|
|
+ diag::note_declaration_not_a_prototype)
|
|
|
|
+ << PossibleZeroParamPrototype
|
|
|
|
+ << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
|
|
if (auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
|
|
const CXXMethodDecl *KeyFunction;
|
|
const CXXMethodDecl *KeyFunction;
|
|
if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
|
|
if (MD->isOutOfLine() && (MD = MD->getCanonicalDecl()) &&
|
|
@@ -10659,7 +10663,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
|
|
"handled in the block above.");
|
|
"handled in the block above.");
|
|
|
|
|
|
// Verify and clean out per-function state.
|
|
// Verify and clean out per-function state.
|
|
- if (Body) {
|
|
|
|
|
|
+ if (Body && (!FD || !FD->isDefaulted())) {
|
|
// C++ constructors that have function-try-blocks can't have return
|
|
// C++ constructors that have function-try-blocks can't have return
|
|
// statements in the handlers of that block. (C++ [except.handle]p14)
|
|
// statements in the handlers of that block. (C++ [except.handle]p14)
|
|
// Verify this.
|
|
// Verify this.
|