]> granicus.if.org Git - clang/commitdiff
Parsing fix for out-of-line constructors, from Piotr Rak
authorDouglas Gregor <dgregor@apple.com>
Mon, 6 Jul 2009 16:40:48 +0000 (16:40 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 6 Jul 2009 16:40:48 +0000 (16:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74833 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/SemaCXX/constructor.cpp

index d599438644018bbdc7a0fad4d397e8b31ba0ec83..5566751fb99dfa92321f76f70c7953c373ab9390 100644 (file)
@@ -2125,8 +2125,9 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
         // constructor name. 
         if (!D.getDeclSpec().hasTypeSpecifier() &&
             Actions.isCurrentClassName(*Tok.getIdentifierInfo(),CurScope)) {
+          CXXScopeSpec *SS = afterCXXScope? &D.getCXXScopeSpec() : 0;
           D.setConstructor(Actions.getTypeName(*Tok.getIdentifierInfo(),
-                                               Tok.getLocation(), CurScope),
+                                               Tok.getLocation(), CurScope, SS),
                            Tok.getLocation());
         // This is a normal identifier.
         } else
@@ -2171,7 +2172,8 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
           // FIXME: Inaccurate.
           SourceLocation NameLoc = Tok.getLocation();
           SourceLocation EndLoc;
-          TypeResult Type = ParseClassName(EndLoc);
+          CXXScopeSpec *SS = afterCXXScope? &D.getCXXScopeSpec() : 0;
+          TypeResult Type = ParseClassName(EndLoc, SS);
           if (Type.isInvalid())
             D.SetIdentifier(0, TildeLoc);
           else
index 8f289a2b1e961149b54590d117c8cba50aea3308..ec28e7e0455196f986a40a1dbd2052c6fec7c02a 100644 (file)
@@ -58,3 +58,28 @@ void y() {
   a z; z.b(x);
 }
 }
+
+namespace A {
+  struct S {
+    S();
+    S(int);
+    void f1();
+    void f2();
+    operator int ();
+    ~S();
+  };
+}
+
+A::S::S() {}
+
+void A::S::f1() {}
+
+struct S {};
+
+A::S::S(int) {}
+
+void A::S::f2() {}
+
+A::S::operator int() { return 1; }
+
+A::S::~S() {}