aboutsummaryrefslogtreecommitdiff
path: root/lib
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
commit11b46a0a49075f338eb4849c2b7d680945be9250 (patch)
tree52ba718f22081da7a8d580c954a710e6f62c0c6d /lib
parent790880bc3a0d8a176f1bdea4e79f60f5c7c2b2d7 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ae3a6369e1..d9950949ea 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/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,