[cfe-commits] r86764 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Sema/SemaLookup.cpp test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp

John McCall rjmccall at apple.com
Tue Nov 10 16:21:19 PST 2009


Author: rjmccall
Date: Tue Nov 10 18:21:18 2009
New Revision: 86764

URL: http://llvm.org/viewvc/llvm-project?rev=86764&view=rev
Log:
Create a new Scope when parsing a declaration with a C++ scope specifier.


Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=86764&r1=86763&r2=86764&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Nov 10 18:21:18 2009
@@ -1226,13 +1226,18 @@
     Parser &P;
     CXXScopeSpec &SS;
     bool EnteredScope;
+    bool CreatedScope;
   public:
     DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
-      : P(p), SS(ss), EnteredScope(false) {}
+      : P(p), SS(ss), EnteredScope(false), CreatedScope(false) {}
 
     void EnterDeclaratorScope() {
       assert(!EnteredScope && "Already entered the scope!");
       assert(SS.isSet() && "C++ scope was not set!");
+
+      CreatedScope = true;
+      P.EnterScope(0); // Not a decl scope.
+
       if (P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS))
         SS.setScopeRep(0);
       
@@ -1245,6 +1250,8 @@
         assert(SS.isSet() && "C++ scope was cleared ?");
         P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS);
       }
+      if (CreatedScope)
+        P.ExitScope();
     }
   };
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Nov 10 18:21:18 2009
@@ -90,9 +90,6 @@
       assert(InnermostFileDC && InnermostFileDC->isFileContext());
 
       for (; S; S = S->getParent()) {
-        if (!(S->getFlags() & Scope::DeclScope))
-          continue;
-
         if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity())) {
           DeclContext *EffectiveDC = (Ctx->isFileContext() ? Ctx : InnermostFileDC);
           visit(Ctx, EffectiveDC);

Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp?rev=86764&r1=86763&r2=86764&view=diff

==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp Tue Nov 10 18:21:18 2009
@@ -126,3 +126,16 @@
     return foo(); // expected-error {{call to 'foo' is ambiguous}}
   }
 }
+
+// Bug: using directives should be followed when parsing default
+// arguments in scoped declarations.
+class test5 {
+  int inc(int x);
+};
+namespace Test5 {
+  int default_x = 0;
+}
+using namespace Test5;
+int test5::inc(int x = default_x) {
+  return x+1;
+}





More information about the cfe-commits mailing list