summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-06-18 17:49:58 +0000
committerJordan Rose <jordan_rose@apple.com>2012-06-18 17:49:58 +0000
commitedff0200115c2bdfe44fe77a2d10a22a38808d98 (patch)
tree4977d7c6a3aeadea45b832bf020ed92019d3f474 /clang/lib/Sema/SemaExpr.cpp
parent9563a053de1337ec8827cf170e39345d541ef87c (diff)
downloadbcm5719-llvm-edff0200115c2bdfe44fe77a2d10a22a38808d98.tar.gz
bcm5719-llvm-edff0200115c2bdfe44fe77a2d10a22a38808d98.zip
Allow internal decls in inline functions if the function is in the main file.
This handles the very common case of people writing inline functions in their main source files and not tagging them as inline. These cases should still behave as the user intended. (The diagnostic is still emitted as an extension.) I'm reworking this code anyway to account for C++'s equivalent restriction in [basic.def.odr]p6, but this should get some bots back to green. llvm-svn: 158666
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ae3a6369e19..d9950949ea8 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -194,7 +194,13 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
if (FunctionDecl *Current = getCurFunctionDecl()) {
if (Current->isInlined() && Current->getLinkage() > InternalLinkage) {
if (D->getLinkage() == InternalLinkage) {
- Diag(Loc, diag::warn_internal_in_extern_inline)
+ // We won't warn by default if the inline function is in the main
+ // source file; in these cases it is almost certain that the inlining
+ // will only occur in this file, even if there is an external
+ // declaration as well.
+ bool IsFromMainFile = getSourceManager().isFromMainFile(Loc);
+ Diag(Loc, IsFromMainFile ? diag::ext_internal_in_extern_inline
+ : diag::warn_internal_in_extern_inline)
<< !isa<FunctionDecl>(D) << D << isa<CXXMethodDecl>(Current);
// If the user didn't explicitly specify a storage class,
OpenPOWER on IntegriCloud