bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gctags/Cpp.c:function_definition


From: Hideki IWAMOTO
Subject: [PATCH] gctags/Cpp.c:function_definition
Date: Tue, 31 Aug 2004 18:55:32 +0900

When a symbol appears behind a right parenthesis, function_definition judges it 
function definition. I think that this should be removed in the case of C++.

1st reason:
  The old style function definition is not allowed in C++. 
  Therefore, it is not necessary to support it.

2nd reason:
  In C++, function declaration is the following form.

    D1 ( parameterdeclarationclause) cv-qualifier-seqopt 
exception-specificationopt   

  The current implementation will judge declaration to be a definition.

  example:  
  +--------------------------------------------------------------------
  |>cat decl1.cc
  |class A {
  |      int f(void) const volatile;
  |};
  |>gctags -dt -w decl1.cc
  |A                   1 decl1.cc         class A {
  |Warning: {} block unmatched. (last at level 1.)[+3 decl1.cc]
  |>cat decl2.cc
  |int g(void) throw(int);
  |int main(void){return 0;}
  |>gctags -dt -w decl2.cc
  |g                   1 decl2.cc         int g(void) throw(int);
  +--------------------------------------------------------------------

Index: gctags/Cpp.c
===================================================================
RCS file: /cvsroot/global/global/gctags/Cpp.c,v
retrieving revision 1.41
diff -u -r1.41 Cpp.c
--- gctags/Cpp.c        25 Aug 2004 11:24:01 -0000      1.41
+++ gctags/Cpp.c        31 Aug 2004 09:04:06 -0000
@@ -563,9 +563,9 @@
        int target;
 {
        int c;
-       int brace_level, isdefine;
+       int brace_level;
 
-       brace_level = isdefine = 0;
+       brace_level = 0;
        while ((c = nexttoken("()", reserved_word)) != EOF) {
                switch (c) {
                case SHARP_IFDEF:
@@ -623,12 +623,9 @@
                        brace_level++;
                else if (c == /* ( */')' || c == ']')
                        brace_level--;
-               else if (brace_level == 0 && (c == SYMBOL || IS_RESERVED(c)))
-                       isdefine = 1;
-               else if (c == ';' || c == ',') {
-                       if (!isdefine)
-                               break;
-               } else if (c == '{' /* } */) {
+               else if (brace_level == 0 && (c == ';' || c == ','))
+                       break;
+               else if (c == '{' /* } */) {
                        pushbacktoken();
                        return 1;
                } else if (c == /* { */'}')

----
Hideki IWAMOTO  address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]