diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index ed8d8a5d71..3d24c59291 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5774,6 +5774,17 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, Context.BuiltinInfo.ForgetBuiltin(BuiltinID, Context.Idents); } } + + // If this function is declared as being extern "C", then check to see if + // the function returns a UDT (class, struct, or union type) that is not C + // compatible, and if it does, warn the user. + if (NewFD->isExternC()) { + QualType R = NewFD->getResultType(); + if (!R.isPODType(Context) && + !R->isVoidType()) + Diag( NewFD->getLocation(), diag::warn_return_value_udt ) + << NewFD << R; + } } return Redeclaration; } |