]> granicus.if.org Git - clang/commitdiff
Have the parser tell sema whether a member declaration is a function definition....
authorSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 24 Nov 2009 23:38:44 +0000 (23:38 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 24 Nov 2009 23:38:44 +0000 (23:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89816 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/ParseCXXInlineMethods.cpp
lib/Parse/ParseDeclCXX.cpp
lib/Sema/Sema.h
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/class.cpp

index de5a82f071dea39b2aed10b7f81a7374fed604cb..3db90c6574c36c58c33e149ae395b904101762d5 100644 (file)
@@ -1481,6 +1481,7 @@ public:
                                  MultiTemplateParamsArg TemplateParameterLists,
                                              ExprTy *BitfieldWidth,
                                              ExprTy *Init,
+                                             bool IsDefinition,
                                              bool Deleted = false) {
     return DeclPtrTy();
   }
index c34653ee425c4b8d2864ed8f0d1ced3ba0438d2d..b9314d242442d8e327e1eb921388c73175892c94 100644 (file)
@@ -37,7 +37,8 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
     FnD = Actions.ActOnFriendFunctionDecl(CurScope, D, true, move(TemplateParams));
   else // FIXME: pass template information through
     FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D,
-                                           move(TemplateParams), 0, 0);
+                                           move(TemplateParams), 0, 0,
+                                           /*IsDefinition*/true);
 
   HandleMemberFunctionDefaultArgs(D, FnD);
 
index a21f0344272c9cbe42d63279da6333c9bcf8ca83..2a3b5d665cc4c998bb82c41699d838ce5ee8dfa5 100644 (file)
@@ -1237,6 +1237,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
                                                   move(TemplateParams),
                                                   BitfieldSize.release(),
                                                   Init.release(),
+                                                  /*IsDefinition*/Deleted,
                                                   Deleted);
     }
     if (ThisDecl)
index 1dda7308e023d2262d9a51d61e182a4fad127183..feff59a0264952d56dd77c70c259c78610f38af6 100644 (file)
@@ -2041,7 +2041,7 @@ public:
                                              Declarator &D,
                                  MultiTemplateParamsArg TemplateParameterLists,
                                              ExprTy *BitfieldWidth,
-                                             ExprTy *Init,
+                                             ExprTy *Init, bool IsDefinition,
                                              bool Deleted = false);
 
   virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
index 797dbf5fe270a7d19e3c98dfa440c1c7b68fe5cd..b5419c1c907e50643fd1dc1f7f3429294a04350e 100644 (file)
@@ -790,7 +790,8 @@ std::string Sema::getAmbiguousPathsDisplayString(CXXBasePaths &Paths) {
 Sema::DeclPtrTy
 Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
                                MultiTemplateParamsArg TemplateParameterLists,
-                               ExprTy *BW, ExprTy *InitExpr, bool Deleted) {
+                               ExprTy *BW, ExprTy *InitExpr, bool IsDefinition,
+                               bool Deleted) {
   const DeclSpec &DS = D.getDeclSpec();
   DeclarationName Name = GetNameForDeclarator(D);
   Expr *BitWidth = static_cast<Expr*>(BW);
@@ -872,7 +873,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
                          AS);
     assert(Member && "HandleField never returns null");
   } else {
-    Member = HandleDeclarator(S, D, move(TemplateParameterLists), false)
+    Member = HandleDeclarator(S, D, move(TemplateParameterLists), IsDefinition)
                .getAs<Decl>();
     if (!Member) {
       if (BitWidth) DeleteExpr(BitWidth);
index 302d1d58d39c7f03ec323d2162e89ed4cc1db495..2637f320207f845ba6ca440172a1cd2568b6545c 100644 (file)
@@ -114,8 +114,7 @@ struct C4 {
 // PR5415 - don't hang!
 struct S
 {
-  void f(); // expected-note 2 {{previous declaration}}
-  // FIXME: the out-of-line error shouldn't be there
-  void S::f() {} // expected-error {{class member cannot be redeclared}} expected-error {{out-of-line}} expected-note {{previous definition}}
+  void f(); // expected-note 1 {{previous declaration}}
+  void S::f() {} // expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
   void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}
 };