diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-20 15:48:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-20 15:48:31 +0000 |
commit | a912197fff7a95d1f7e8f7244d046e690e43a6ee (patch) | |
tree | cb65372e1ecda0cdd4bdc9e9c072e49d47c62cc9 | |
parent | 4385d8b0a2317f3571f3ead62acbf958bb19d61f (diff) | |
download | bcm5719-llvm-a912197fff7a95d1f7e8f7244d046e690e43a6ee.tar.gz bcm5719-llvm-a912197fff7a95d1f7e8f7244d046e690e43a6ee.zip |
Downgrade the error about re-opening an inline namespace as non-inline
to a warning, since apparently libstdc++'s debug mode does this (and
we can recover safely). Add a Fix-It to insert the "inline", just for kicks.
llvm-svn: 131732
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 14 | ||||
-rw-r--r-- | clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 84106856ca7..d96b40ac7ee 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -502,6 +502,8 @@ def err_static_assert_expression_is_not_constant : Error< "static_assert expression is not an integral constant expression">; def err_static_assert_failed : Error<"static_assert failed \"%0\"">; +def warn_inline_namespace_reopened_noninline : Warning< + "inline namespace cannot be re-opened as a non-inline namespace">; def err_inline_namespace_mismatch : Error< "%select{|non-}0inline namespace " "cannot be reopened as %select{non-|}0inline">; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c6a0490c247..90c840ba7fa 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4657,10 +4657,18 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, // This is an extended namespace definition. if (Namespc->isInline() != OrigNS->isInline()) { // inline-ness must match - Diag(Namespc->getLocation(), diag::err_inline_namespace_mismatch) - << Namespc->isInline(); + if (OrigNS->isInline()) { + // The user probably just forgot the 'inline', so suggest that it + // be added back. + Diag(Namespc->getLocation(), + diag::warn_inline_namespace_reopened_noninline) + << FixItHint::CreateInsertion(NamespaceLoc, "inline "); + } else { + Diag(Namespc->getLocation(), diag::err_inline_namespace_mismatch) + << Namespc->isInline(); + } Diag(OrigNS->getLocation(), diag::note_previous_definition); - Namespc->setInvalidDecl(); + // Recover by ignoring the new namespace's inline status. Namespc->setInline(OrigNS->isInline()); } diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp index 198b0135187..e3d3d683ceb 100644 --- a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp +++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp @@ -3,7 +3,7 @@ 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-error {{cannot be reopened as non-inline}} +namespace IL {} // expected-warning{{inline namespace cannot be re-opened as a non-inline namespace}} namespace {} // expected-note {{previous definition}} inline namespace {} // expected-error {{cannot be reopened as inline}} |