[INCOMPLETE] semantic/bovine/c: support typed enum

Ramkumar Ramachandra <[email protected]> Wed, 21 Jan 2015 15:08:54 -0500
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
Signed-off-by: Ramkumar Ramachandra <[email protected]>
---
 I've struggled with this long enough. Why doesn't it work? What am I
 missing?

 lisp/cedet/semantic/bovine/c.by     | 19 +++++++++++++++----
 lisp/cedet/semantic/bovine/c.el     |  1 +
 tests/cedet/semantic/tests/test.cpp |  5 +++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/lisp/cedet/semantic/bovine/c.by b/lisp/cedet/semantic/bovine/c.by
index 8dc3a82..3ac63b6 100644
--- a/lisp/cedet/semantic/bovine/c.by
+++ b/lisp/cedet/semantic/bovine/c.by
@@ -114,7 +114,7 @@
 %token UNION "union"
 %put UNION summary "Union Type Declaration: union [name] { ... };"
 %token ENUM "enum"
-%put ENUM summary "Enumeration Type Declaration: enum [name] { ... };"
+%put ENUM summary "Enumeration Type Declaration: enum [name] [: type] { ... };"
 %token TYPEDEF "typedef"
 %put TYPEDEF summary "Arbitrary Type Declaration: typedef <typedeclaration> <name>;"
 %token CLASS "class"
@@ -416,6 +416,16 @@ opt-name
     ( "" )
   ;
 
+enum-type
+  : type
+  ;
+
+opt-enum-type
+  : COLON enum-type
+    ,(car $2)
+  |
+  ;
+
 typesimple
   : struct-or-class opt-class opt-name opt-template-specifier
     opt-class-parents semantic-list
@@ -434,9 +444,10 @@ typesimple
   | UNION opt-class opt-name unionparts
     (TYPE-TAG (car $3) $1 $4 nil
               :parent (car ,$2))
-  | ENUM opt-class opt-name enumparts
-    (TYPE-TAG (car $3) $1 $4 nil
-              :parent (car ,$2))
+  | ENUM opt-class opt-name opt-enum-type enumparts
+    (TYPE-TAG (car $3) $1 $5 nil
+              :parent (car ,$2)
+	      :enum-type $4)
  ;; Klaus Berndl: a typedef can be a typeformbase with all this
  ;; declmods stuff.
   | TYPEDEF declmods typeformbase cv-declmods typedef-symbol-list
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el
index d0e1a16..22463b6 100644
--- a/lisp/cedet/semantic/bovine/c.el
+++ b/lisp/cedet/semantic/bovine/c.el
@@ -1341,6 +1341,7 @@ Optional argument STAR and REF indicate the number of * and & in the typedef."
 	    :constant-flag (if (member "const" declmods) t nil)
 	    :typemodifiers (delete "const" declmods)
 	    :parent (car (nth 2 tokenpart))
+	    :enum-type (nth 3 tokenpart)
 	    :destructor-flag (if (car (nth 3 tokenpart) ) t)
 	    :constructor-flag (if constructor t)
 	    :function-pointer fcnpointer
diff --git a/tests/cedet/semantic/tests/test.cpp b/tests/cedet/semantic/tests/test.cpp
index 8bb27ed..a170c52 100644
--- a/tests/cedet/semantic/tests/test.cpp
+++ b/tests/cedet/semantic/tests/test.cpp
@@ -22,6 +22,11 @@ int simple1(int a) {
 
 }
 
+enum typedenum : unsigned {
+  FIRST = 0UL,
+  SECOND = ~0UL
+};
+
 struct foo1 {
   int test;
 };
-- 
2.2.1


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet