]> granicus.if.org Git - clang/commitdiff
Enter the scope of an initializer for direct-initialization as well as
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 17:47:17 +0000 (17:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 17:47:17 +0000 (17:47 +0000)
for copy-initialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91909 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp

index 43c92456d29130abfd4ceb1aa95749b6ae1b057f..347d67a19acbdc78368758ac91d0812c88319a56 100644 (file)
@@ -574,14 +574,30 @@ Parser::DeclPtrTy Parser::ParseDeclarationAfterDeclarator(Declarator &D,
     ExprVector Exprs(Actions);
     CommaLocsTy CommaLocs;
 
+    if (getLang().CPlusPlus && D.getCXXScopeSpec().isSet()) {
+      EnterScope(0);
+      Actions.ActOnCXXEnterDeclInitializer(CurScope, ThisDecl);
+    }
+
     if (ParseExpressionList(Exprs, CommaLocs)) {
       SkipUntil(tok::r_paren);
+
+      if (getLang().CPlusPlus && D.getCXXScopeSpec().isSet()) {
+        Actions.ActOnCXXExitDeclInitializer(CurScope, ThisDecl);
+        ExitScope();
+      }
     } else {
       // Match the ')'.
       SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
 
       assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() &&
              "Unexpected number of commas!");
+
+      if (getLang().CPlusPlus && D.getCXXScopeSpec().isSet()) {
+        Actions.ActOnCXXExitDeclInitializer(CurScope, ThisDecl);
+        ExitScope();
+      }
+
       Actions.AddCXXDirectInitializerToDecl(ThisDecl, LParenLoc,
                                             move_arg(Exprs),
                                             CommaLocs.data(), RParenLoc);
index 846d385e1e56f49177afbf3498cd7fffbc0b7c1e..2ed87b4e68ccf892964be9473b18d99b12971c21 100644 (file)
@@ -10,7 +10,9 @@ namespace N {
   struct S {};
   S i; 
   extern S j;
+  extern S j2;
 } 
 
 int i = 2; 
 N::S N::j = i;
+N::S N::j(i);