r199531 - Restrict redeclaration of tags introduced by using decls to MSVCCompat

Alp Toker alp at nuanti.com
Fri Jan 17 16:59:32 PST 2014


Author: alp
Date: Fri Jan 17 18:59:32 2014
New Revision: 199531

URL: http://llvm.org/viewvc/llvm-project?rev=199531&view=rev
Log:
Restrict redeclaration of tags introduced by using decls to MSVCCompat

This limits the facility added in r199490 while we seek clarification on the
standard.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
    cfe/trunk/test/SemaCXX/using-decl-1.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=199531&r1=199530&r2=199531&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 17 18:59:32 2014
@@ -10681,8 +10681,9 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   }
 
   if (!Previous.empty()) {
-    NamedDecl *DirectPrevDecl = *Previous.begin();
-    NamedDecl *PrevDecl = DirectPrevDecl->getUnderlyingDecl();
+    NamedDecl *PrevDecl = Previous.getFoundDecl();
+    NamedDecl *DirectPrevDecl =
+        getLangOpts().MSVCCompat ? *Previous.begin() : PrevDecl;
 
     // It's okay to have a tag decl in the same scope as a typedef
     // which hides a tag decl in the same scope.  Finding this

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=199531&r1=199530&r2=199531&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Fri Jan 17 18:59:32 2014
@@ -120,6 +120,27 @@ private:
 
 }
 
+namespace using_tag_redeclaration
+{
+  struct S;
+  namespace N {
+    using ::using_tag_redeclaration::S;
+    struct S {}; // expected-note {{previous definition is here}}
+  }
+  void f() {
+    N::S s1;
+    S s2;
+  }
+  void g() {
+    struct S; // expected-note {{forward declaration of 'S'}}
+    S s3; // expected-error {{variable has incomplete type 'S'}}
+  }
+  void h() {
+    using ::using_tag_redeclaration::S;
+    struct S {}; // expected-error {{redefinition of 'S'}}
+  }
+}
+
 
 namespace MissingTypename {
 

Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=199531&r1=199530&r2=199531&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Fri Jan 17 18:59:32 2014
@@ -119,27 +119,6 @@ namespace foo
   };
 }
 
-namespace using_tag_redeclaration
-{
-  struct S;
-  namespace N {
-    using ::using_tag_redeclaration::S;
-    struct S {}; // expected-note {{previous definition is here}}
-  }
-  void f() {
-    N::S s1;
-    S s2;
-  }
-  void g() {
-    struct S; // expected-note {{forward declaration of 'S'}}
-    S s3; // expected-error {{variable has incomplete type 'S'}}
-  }
-  void h() {
-    using ::using_tag_redeclaration::S;
-    struct S {}; // expected-error {{redefinition of 'S'}}
-  }
-}
-
 // Don't suggest non-typenames for positions requiring typenames.
 namespace using_suggestion_tyname_val {
 namespace N { void FFF() {} }





More information about the cfe-commits mailing list