aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2012-02-09 01:21:34 +0000
committerAaron Ballman <aaron@aaronballman.com>2012-02-09 01:21:34 +0000
commit2c0bf2437089f9a297cf18530361a185e76f2150 (patch)
tree56de5796d1ad1596ee6f03cc4aca77fee2424c45 /lib/Sema/SemaDecl.cpp
parent7f99f43b362a4a4a0f47515c88690d7291756447 (diff)
Adding support for warning when a non-C compatible user-defined type is returned from an extern "C" function.
Fixes bug 6143 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp11
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;
}