[cfe-commits] r89816 - in /cfe/trunk: 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

Sebastian Redl sebastian.redl at getdesigned.at
Tue Nov 24 15:38:44 PST 2009


Author: cornedbee
Date: Tue Nov 24 17:38:44 2009
New Revision: 89816

URL: http://llvm.org/viewvc/llvm-project?rev=89816&view=rev
Log:
Have the parser tell sema whether a member declaration is a function definition. This allows sema to not emit spurious diagnostics in some invalid code.

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

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Nov 24 17:38:44 2009
@@ -1481,6 +1481,7 @@
                                  MultiTemplateParamsArg TemplateParameterLists,
                                              ExprTy *BitfieldWidth,
                                              ExprTy *Init,
+                                             bool IsDefinition,
                                              bool Deleted = false) {
     return DeclPtrTy();
   }

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=89816&r1=89815&r2=89816&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Tue Nov 24 17:38:44 2009
@@ -37,7 +37,8 @@
     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);
 

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=89816&r1=89815&r2=89816&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Nov 24 17:38:44 2009
@@ -1237,6 +1237,7 @@
                                                   move(TemplateParams),
                                                   BitfieldSize.release(),
                                                   Init.release(),
+                                                  /*IsDefinition*/Deleted,
                                                   Deleted);
     }
     if (ThisDecl)

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=89816&r1=89815&r2=89816&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Nov 24 17:38:44 2009
@@ -2041,7 +2041,7 @@
                                              Declarator &D,
                                  MultiTemplateParamsArg TemplateParameterLists,
                                              ExprTy *BitfieldWidth,
-                                             ExprTy *Init,
+                                             ExprTy *Init, bool IsDefinition,
                                              bool Deleted = false);
 
   virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Nov 24 17:38:44 2009
@@ -790,7 +790,8 @@
 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 @@
                          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);

Modified: cfe/trunk/test/SemaCXX/class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=89816&r1=89815&r2=89816&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/class.cpp (original)
+++ cfe/trunk/test/SemaCXX/class.cpp Tue Nov 24 17:38:44 2009
@@ -114,8 +114,7 @@
 // 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}}
 };





More information about the cfe-commits mailing list