r245236 - [modules] When parsing the base specifiers of a parse-merged class, the current

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 13:24:18 PDT 2015


Author: rsmith
Date: Mon Aug 17 15:24:17 2015
New Revision: 245236

URL: http://llvm.org/viewvc/llvm-project?rev=245236&view=rev
Log:
[modules] When parsing the base specifiers of a parse-merged class, the current
context is the class itself but lookups should be performed starting with the
lookup parent of the class (class and base members don't shadow types from the
surrounding context because they have not been declared yet).

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
    cfe/trunk/test/Modules/Inputs/template-default-args/a.h
    cfe/trunk/test/Modules/submodules-merge-defs.cpp
    cfe/trunk/test/Modules/template-default-args.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=245236&r1=245235&r2=245236&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Aug 17 15:24:17 2015
@@ -1089,7 +1089,9 @@ Sema::SkippedDefinitionContext Sema::Act
   auto Result = static_cast<SkippedDefinitionContext>(CurContext);
   CurContext = cast<TagDecl>(D)->getDefinition();
   assert(CurContext && "skipping definition of undefined tag");
-  S->setEntity(CurContext);
+  // Start lookups from the parent of the current context; we don't want to look
+  // into the pre-existing complete definition.
+  S->setEntity(CurContext->getLookupParent());
   return Result;
 }
 

Modified: cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h?rev=245236&r1=245235&r2=245236&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h (original)
+++ cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h Mon Aug 17 15:24:17 2015
@@ -5,10 +5,17 @@ class B {
   struct Inner1 {};
 public:
   struct Inner2;
+  struct Inner3;
   template<typename T> void f();
 };
+struct BFriend {
+  friend class B::Inner3;
+private:
+  struct Inner3Base {};
+};
 // Check that lookup and access checks are performed in the right context.
 struct B::Inner2 : Inner1 {};
+struct B::Inner3 : BFriend::Inner3Base {};
 template<typename T> void B::f() {}
 template<> inline void B::f<int>() {}
 

Modified: cfe/trunk/test/Modules/Inputs/template-default-args/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/a.h?rev=245236&r1=245235&r2=245236&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/template-default-args/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/a.h Mon Aug 17 15:24:17 2015
@@ -6,4 +6,7 @@ template<typename T> struct D;
 template<typename T> struct E;
 template<typename T = int> struct G;
 template<typename T = int> struct H;
+template<typename T> struct J {};
+template<typename T = int> struct J;
+struct K : J<> {};
 END

Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=245236&r1=245235&r2=245236&view=diff
==============================================================================
--- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original)
+++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Mon Aug 17 15:24:17 2015
@@ -26,38 +26,38 @@ int pre_use_a = use_a(pre_a); // expecte
 
 B::Inner2 pre_bi; // expected-error +{{must be imported}}
 // expected-note at defs.h:4 +{{here}}
-// expected-note at defs.h:11 +{{here}}
+// expected-note at defs.h:17 +{{here}}
 void pre_bfi(B b) { // expected-error {{must use 'class'}} expected-error +{{must be imported}}
   b.f<int>(); // expected-error +{{must be imported}} expected-error +{{}}
-  // expected-note at defs.h:12 +{{here}}
+  // expected-note at defs.h:19 +{{here}}
 }
 
 C_Base<1> pre_cb1; // expected-error +{{must be imported}}
-// expected-note at defs.h:16 +{{here}}
+// expected-note at defs.h:23 +{{here}}
 C1 pre_c1; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}
-// expected-note at defs.h:18 +{{here}}
+// expected-note at defs.h:25 +{{here}}
 C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}
-// expected-note at defs.h:19 +{{here}}
+// expected-note at defs.h:26 +{{here}}
 
 D::X pre_dx; // expected-error +{{must be imported}}
-// expected-note at defs.h:21 +{{here}}
-// expected-note at defs.h:22 +{{here}}
+// expected-note at defs.h:28 +{{here}}
+// expected-note at defs.h:29 +{{here}}
 // FIXME: We should warn that use_dx is being used without being imported.
 int pre_use_dx = use_dx(pre_dx);
 
 int pre_e = E(0); // expected-error {{must be imported}}
-// expected-note at defs.h:25 +{{here}}
+// expected-note at defs.h:32 +{{here}}
 
 int pre_ff = F<int>().f(); // expected-error +{{must be imported}}
 int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}}
-// expected-note at defs.h:27 +{{here}}
+// expected-note at defs.h:34 +{{here}}
 
 G::A pre_ga // expected-error +{{must be imported}}
   = G::a; // expected-error +{{must be imported}}
-// expected-note at defs.h:42 +{{here}}
-// expected-note at defs.h:43 +{{here}}
+// expected-note at defs.h:49 +{{here}}
+// expected-note at defs.h:50 +{{here}}
 decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}}
-// expected-note at defs.h:44 +{{here}}
+// expected-note at defs.h:51 +{{here}}
 
 J<> pre_j; // expected-error {{declaration of 'J' must be imported}}
 #ifdef IMPORT_USE_2
@@ -67,10 +67,10 @@ J<> pre_j; // expected-error {{declarati
 #else
 // expected-error at -6 {{default argument of 'J' must be imported from module 'stuff.use'}}
 #endif
-// expected-note at defs.h:51 +{{here}}
+// expected-note at defs.h:58 +{{here}}
 
 ScopedEnum pre_scopedenum; // expected-error {{must be imported}} expected-error {{must use 'enum'}}
-// expected-note at defs.h:99 {{here}}
+// expected-note at defs.h:106 {{here}}
 enum ScopedEnum : int;
 ScopedEnum pre_scopedenum_declared; // ok
 

Modified: cfe/trunk/test/Modules/template-default-args.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/template-default-args.cpp?rev=245236&r1=245235&r2=245236&view=diff
==============================================================================
--- cfe/trunk/test/Modules/template-default-args.cpp (original)
+++ cfe/trunk/test/Modules/template-default-args.cpp Mon Aug 17 15:24:17 2015
@@ -22,6 +22,9 @@ template<typename T = int> struct C;
 template<typename T> struct D {};
 template<typename T> struct F {};
 template<typename T> struct G {};
+template<typename T> struct J {};
+template<typename T = int> struct J;
+struct K : J<> {};
 END
 
 #include "c.h"




More information about the cfe-commits mailing list