[PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

Ryan Yee via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 21:02:01 PDT 2016


ryee88 updated this revision to Diff 55707.
ryee88 added a comment.

Removed unnecessary code changes. This patch contains a unit test to detect a regression of this global name specifier issue.


http://reviews.llvm.org/D16965

Files:
  test/Parser/cxx-class.cpp

Index: test/Parser/cxx-class.cpp
===================================================================
--- test/Parser/cxx-class.cpp
+++ test/Parser/cxx-class.cpp
@@ -120,17 +120,36 @@
     // expected-error{{unknown type name 'UnknownType'}}
 }
 
-namespace nns_decl {
-  struct A {
-    struct B;
+namespace NestedNameSpecifiers {
+  struct OuterStruct {
+    struct InnerStruct;
   };
-  namespace N {
-    union C;
+  namespace UnionOuterNamespace {
+    union UnionInner;
   }
-  struct A::B; // expected-error {{forward declaration of struct cannot have a nested name specifier}}
-  union N::C; // expected-error {{forward declaration of union cannot have a nested name specifier}}
+	class OuterClass{
+		class InnerClass;
+	};
+
+  struct OuterStruct::InnerStruct; // expected-error {{forward declaration of struct cannot have a nested name specifier}}
+  struct ::NestedNameSpecifiers::OuterStruct::InnerStruct; // expected-error {{forward declaration of struct cannot have a nested name specifier}}
+
+  union UnionOuterNamespace::UnionInner; // expected-error {{forward declaration of union cannot have a nested name specifier}}
+  union ::NestedNameSpecifiers::UnionOuterNamespace::UnionInner; // expected-error {{forward declaration of union cannot have a nested name specifier}}
+
+  class OuterClass::InnerClass; // expected-error {{forward declaration of class cannot have a nested name specifier}}
+  class ::NestedNameSpecifiers::OuterClass::InnerClass; // expected-error {{forward declaration of class cannot have a nested name specifier}}
 }
 
+// Testing the global "nested" name qualifier
+class GlobalSpecifierOuterClass {class InnerClass;};
+class ::GlobalSpecifierOuterClass; // expected-error {{forward declaration of class cannot have a nested name specifier}} expected-warning {{extra qualification on member 'GlobalSpecifierOuterClass'}}
+class GlobalSpecifierOuterClass;
+// specializations of qualified type introduction?
+class GlobalSpecifierOuterClass::InnerClass; // expected-error {{forward declaration of class cannot have a nested name specifier}}
+class ::GlobalSpecifierOuterClass::InnerClass; // expected-error {{forward declaration of class cannot have a nested name specifier}}
+
+
 // PR13775: Don't assert here.
 namespace PR13775 {
   class bar


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16965.55707.patch
Type: text/x-patch
Size: 2288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160430/c0410d04/attachment.bin>


More information about the cfe-commits mailing list