]> granicus.if.org Git - clang/commitdiff
PR12500: Improve the wording of the diagnostic for a redefinition of a name
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 13 Apr 2012 04:07:40 +0000 (04:07 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 13 Apr 2012 04:07:40 +0000 (04:07 +0000)
in the wrong namespace scope. Patch by Jonathan Sauer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154656 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
test/SemaCXX/nested-name-spec.cpp
test/SemaCXX/qual-id-test.cpp

index 813ef19d87daee8818e98ad7ae14c4bf077fe6ac..e553740ab1dfe7d1c35800071b50a21624fa64bf 100644 (file)
@@ -4296,8 +4296,8 @@ def err_typecheck_deleted_function : Error<
 def err_expected_class_or_namespace : Error<"expected a class or namespace">;
 def err_expected_class : Error<"%0 is not a class%select{ or namespace|, "
   "namespace, or scoped enumeration}1">;
-def err_invalid_declarator_scope : Error<
-  "definition or redeclaration of %0 not in a namespace enclosing %1">;
+def err_invalid_declarator_scope : Error<"cannot define or redeclare %0 here "
+  "because namespace %1 does not enclose namespace %2">;
 def err_invalid_declarator_global_scope : Error<
   "definition or redeclaration of %0 cannot name the global scope">;
 def err_invalid_declarator_in_function : Error<
index f54f0fd942a0b91e88bf5877a434c26814be55c9..8b314b524f47629a2de7771cd48c3ef126190e0e 100644 (file)
@@ -3307,7 +3307,7 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
         << Name << SS.getRange();
     else
       Diag(Loc, diag::err_invalid_declarator_scope)
-      << Name << cast<NamedDecl>(DC) << SS.getRange();
+      << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.getRange();
     
     return true;
   }
index acfbb46447de4154a12f87050f68b9f7fba1edf1..b0a19fb93a6c40698a1ab4e90068efe555a26677 100644 (file)
@@ -33,7 +33,7 @@ namespace N0 {
 template<> void N0::f0(int) { } // okay
 
 namespace N1 {
-  template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+  template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
 }
 
 template<> void N0::f0(double) { }
@@ -129,7 +129,7 @@ template<> int N0::X0<int>::member;
 template<> float N0::X0<float>::member = 3.14f;
 
 namespace N1 {
-  template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+  template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
 }
 
 //    -- member class of a class template
@@ -227,7 +227,7 @@ void N0::X0<void*>::ft1(void *, float) { }
 
 namespace N1 {
   template<> template<>
-  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
 }
 
 
index dff7cd5b40ce644d8c5a5c913e29f320df324ccd..c972bf7c7d0aafd203cb85c68a7fc91d8584b73d 100644 (file)
@@ -33,7 +33,7 @@ namespace N0 {
 template<> void N0::f0(int) { } // okay
 
 namespace N1 {
-  template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+  template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
 }
 
 template<> void N0::f0(double); // expected-warning{{C++11 extension}}
@@ -130,7 +130,7 @@ template<> int N0::X0<int>::member;  // expected-warning{{C++11 extension}}
 template<> float N0::X0<float>::member = 3.14f;
 
 namespace N1 {
-  template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+  template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
 }
 
 //    -- member class of a class template
@@ -228,7 +228,7 @@ void N0::X0<void*>::ft1(void *, float) { } // expected-warning{{function templat
 
 namespace N1 {
   template<> template<>
-  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+  void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
 }
 
 
index a60b115695d6ba82c70db8d37ae35a683a82b142..b31763484489db3701fcf9e2b05c23dd085b4dc5 100644 (file)
@@ -45,7 +45,7 @@ void C2::m() {
 }
 
 namespace B {
-  void ::A::Af() {} // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}}
+  void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}}
 }
 
 void f1() {
index e43e6887c4707278fcf675c075520e47fe84a049..9994d75cac19da6eaeaa35dc45750da3e0963748 100644 (file)
@@ -144,6 +144,6 @@ namespace PR6645 {
   typedef int foo;
   namespace Inner {
     typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
-    // expected-error{{definition or redeclaration of 'foo' not in a namespace enclosing 'PR6645'}}
+    // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}
   }
 }