diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-06-18 23:58:49 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-06-18 23:58:49 +0000 |
commit | c4429b9ee5045525f532d00e820a81b7eeac28f8 (patch) | |
tree | 4a367b1b72b58ad3519845a3a12e2b22903afc9c /lib/Sema/SemaExpr.cpp | |
parent | 3d157514d70172fe9b99cbe44f3e8fdef9a4fc21 (diff) |
Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).
This removes the warning entirely from uses in the main source file in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158689 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c9b1a694d0..49c84664fc 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -203,15 +203,23 @@ static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, return; // Don't warn unless -pedantic is on if the inline function is in the main - // source file. These functions will most likely not be inlined into another - // translation unit, so they're effectively internal. + // source file, and in C++ don't warn at all, since the one-definition rule is + // still satisfied. This function will most likely not be inlined into + // another translation unit, so it's effectively internal. bool IsInMainFile = S.getSourceManager().isFromMainFile(Loc); - S.Diag(Loc, IsInMainFile ? diag::ext_internal_in_extern_inline - : diag::warn_internal_in_extern_inline) - << (bool)VD - << D - << (UsedLinkage == UniqueExternalLinkage) - << isa<CXXMethodDecl>(Current); + if (S.getLangOpts().CPlusPlus) { + if (IsInMainFile) + return; + + S.Diag(Loc, diag::warn_internal_in_extern_inline_cxx) + << (bool)VD << D + << (UsedLinkage == UniqueExternalLinkage) + << isa<CXXMethodDecl>(Current); + } else { + S.Diag(Loc, IsInMainFile ? diag::ext_internal_in_extern_inline + : diag::warn_internal_in_extern_inline) + << (bool)VD << D; + } // Suggest "static" on the inline function, if possible. if (!isa<CXXMethodDecl>(Current) && |