From 6079e1dffcfa30fb5c96e6e4cf6a1c1fd9cce388 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 30 Sep 2016 23:16:08 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282981 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 5 ++--- lib/Sema/SemaDeclCXX.cpp | 2 +- test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp | 9 +++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 58e8e00d85..a65cf97ca6 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1142,10 +1142,9 @@ def warn_cxx14_compat_inline_variable : Warning< DefaultIgnore, InGroup; 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">; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 6c952e0182..133f1f47cc 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8089,7 +8089,7 @@ static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, 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(); diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp index f92362380a..39bed7db7a 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp @@ -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}} } -- 2.50.1