summaryrefslogtreecommitdiffstats
path: root/clang/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
commitc2a9493a26f422fc6ae8a5608c65a0c16e1a9538 (patch)
tree67c5c85393965bb58f1ddabda3efe56b0ab2cd88 /clang/lib/Sema/SemaDecl.cpp
parent177df6f35c945efe5c09d9ec268de03ede7a3df6 (diff)
downloadbcm5719-llvm-c2a9493a26f422fc6ae8a5608c65a0c16e1a9538.tar.gz
bcm5719-llvm-c2a9493a26f422fc6ae8a5608c65a0c16e1a9538.zip
Adding support for warning when a non-C compatible user-defined type is returned from an extern "C" function.
Fixes bug 6143 llvm-svn: 150128
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed8d8a5d71b..3d24c592914 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud