[cfe-commits] r80333 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td lib/Parse/ParseDeclCXX.cpp lib/Sema/SemaDeclCXX.cpp test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp

Anders Carlsson andersca at mac.com
Thu Aug 27 20:35:20 PDT 2009


Author: andersca
Date: Thu Aug 27 22:35:18 2009
New Revision: 80333

URL: http://llvm.org/viewvc/llvm-project?rev=80333&view=rev
Log:
More work on using declarations.

Added:
    cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
    cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=80333&r1=80332&r2=80333&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Aug 27 22:35:18 2009
@@ -161,8 +161,8 @@
   "use of tagged type %0 without '%1' tag">;
 def err_expected_ident_in_using : Error<
   "expected an identifier in using directive">;
-def err_unexpected_template_spec_in_using : Error<
-  "use of template specialization in using directive not allowed">;
+def err_using_decl_can_not_refer_to_template_spec : Error<
+  "using declaration can not refer to template specialization">;
 
 
 /// Objective-C parser diagnostics

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=80333&r1=80332&r2=80333&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Aug 27 22:35:18 2009
@@ -102,9 +102,11 @@
   "dependent using declaration not supported yet">;
 def err_using_decl_nested_name_specifier_is_not_a_base_class : Error<
   "using declaration refers into %0, which is not a base class of %1">;
-def err_using_decl_refers_to_class_member : Error<
-  "using declaration refers to class member">;
-  
+def err_using_decl_can_not_refer_to_class_member : Error<
+  "using declaration can not refer to class member">;
+ def err_using_decl_can_not_refer_to_namespace : Error<
+  "using declaration can not refer to namespace">;
+
 def err_invalid_thread : Error<
   "'__thread' is only allowed on variable declarations">;
 def err_thread_non_global : Error<

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=80333&r1=80332&r2=80333&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Aug 27 22:35:18 2009
@@ -282,7 +282,9 @@
     return DeclPtrTy();
   }
   if (Tok.is(tok::annot_template_id)) {
-    Diag(Tok, diag::err_unexpected_template_spec_in_using);
+    // C++0x N2914 [namespace.udecl]p5:
+    // A using-declaration shall not name a template-id. 
+    Diag(Tok, diag::err_using_decl_can_not_refer_to_template_spec);
     SkipUntil(tok::semi);
     return DeclPtrTy();
   }

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=80333&r1=80332&r2=80333&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Aug 27 22:35:18 2009
@@ -2151,7 +2151,7 @@
     // C++0x N2914 [namespace.udecl]p8:
     // A using-declaration for a class member shall be a member-declaration.
     if (NNS->getKind() == NestedNameSpecifier::TypeSpec) {
-      Diag(IdentLoc, diag::err_using_decl_refers_to_class_member)
+      Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_class_member)
         << SS.getRange();
       return DeclPtrTy();
     }
@@ -2181,6 +2181,14 @@
     return DeclPtrTy();
   }
 
+  // C++0x N2914 [namespace.udecl]p6:
+  // A using-declaration shall not name a namespace.
+  if (isa<NamespaceDecl>(ND)) {
+    Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
+      << SS.getRange();
+    return DeclPtrTy();
+  }
+  
   UsingAlias = 
     UsingDecl::Create(Context, CurContext, IdentLoc, SS.getRange(),
                       ND->getLocation(), UsingLoc, ND, NNS, IsTypeName);

Added: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp?rev=80333&view=auto

==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp Thu Aug 27 22:35:18 2009
@@ -0,0 +1,12 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+// C++0x N2914.
+
+struct A {
+  template<class T> void f(T);
+  template<class T> struct X { };
+};
+
+struct B : A {
+  using A::f<double>; // expected-error{{using declaration can not refer to template specialization}}
+  using A::X<int>; // expected-error{{using declaration can not refer to template specialization}}
+};
\ No newline at end of file

Added: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp?rev=80333&view=auto

==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp Thu Aug 27 22:35:18 2009
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+// C++0x N2914.
+
+namespace A {
+  namespace B { }
+}
+
+using A::B; // expected-error{{using declaration can not refer to namespace}}

Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp?rev=80333&r1=80332&r2=80333&view=diff

==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp Thu Aug 27 22:35:18 2009
@@ -6,10 +6,10 @@
   static int a;
 };
 
-using X::i; // expected-error{{error: using declaration refers to class member}}
-using X::s; // expected-error{{error: using declaration refers to class member}}
+using X::i; // expected-error{{using declaration can not refer to class member}}
+using X::s; // expected-error{{using declaration can not refer to class member}}
 
 void f() {
-  using X::i; // expected-error{{error: using declaration refers to class member}}
-  using X::s; // expected-error{{error: using declaration refers to class member}}
+  using X::i; // expected-error{{using declaration can not refer to class member}}
+  using X::s; // expected-error{{using declaration can not refer to class member}}
 }





More information about the cfe-commits mailing list