r282981 - Fix bogus "inline namespace cannot be reopened as non-inline" diagnostic to
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 30 16:16:08 PDT 2016
Author: rsmith
Date: Fri Sep 30 18:16:08 2016
New Revision: 282981
URL: http://llvm.org/viewvc/llvm-project?rev=282981&view=rev
Log:
Fix bogus "inline namespace cannot be reopened as non-inline" diagnostic to
just warn that the second declaration is missing the 'inline' keyword. This is
valid, and we shouldn't be suggesting otherwise.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=282981&r1=282980&r2=282981&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 30 18:16:08 2016
@@ -1142,10 +1142,9 @@ def warn_cxx14_compat_inline_variable :
DefaultIgnore, InGroup<CXXPre1zCompat>;
def warn_inline_namespace_reopened_noninline : Warning<
- "inline namespace cannot be reopened as a non-inline namespace">;
+ "inline namespace reopened as a non-inline namespace">;
def err_inline_namespace_mismatch : Error<
- "%select{|non-}0inline namespace "
- "cannot be reopened as %select{non-|}0inline">;
+ "non-inline namespace cannot be reopened as inline">;
def err_unexpected_friend : Error<
"friends can only be classes or functions">;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=282981&r1=282980&r2=282981&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Sep 30 18:16:08 2016
@@ -8089,7 +8089,7 @@ static void DiagnoseNamespaceInlineMisma
S.Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
<< FixItHint::CreateInsertion(KeywordLoc, "inline ");
else
- S.Diag(Loc, diag::err_inline_namespace_mismatch) << *IsInline;
+ S.Diag(Loc, diag::err_inline_namespace_mismatch);
S.Diag(PrevNS->getLocation(), diag::note_previous_definition);
*IsInline = PrevNS->isInline();
Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp?rev=282981&r1=282980&r2=282981&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp Fri Sep 30 18:16:08 2016
@@ -1,13 +1,18 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// FIXME: We should probably suppress the warning on reopening an inline
+// namespace without the inline keyword if it's not the first opening of the
+// namespace in the file, because there's no risk of the inlineness differing
+// across TUs in that case.
+
namespace NIL {} // expected-note {{previous definition}}
inline namespace NIL {} // expected-error {{cannot be reopened as inline}}
inline namespace IL {} // expected-note {{previous definition}}
-namespace IL {} // expected-warning{{inline namespace cannot be reopened as a non-inline namespace}}
+namespace IL {} // expected-warning{{inline namespace reopened as a non-inline namespace}}
namespace {} // expected-note {{previous definition}}
inline namespace {} // expected-error {{cannot be reopened as inline}}
namespace X {
inline namespace {} // expected-note {{previous definition}}
- namespace {} // expected-warning {{cannot be reopened as a non-inline namespace}}
+ namespace {} // expected-warning {{inline namespace reopened as a non-inline namespace}}
}
More information about the cfe-commits
mailing list