Subject: bug#7916: [PATCH] cc-mode does not fontify constructors and destructors with exception specifications

From: Daniel Colascione <[email-masked]>
Date: Tue, 25 Jan 2011 22:25:05 -0800

struct foo {
    foo() throw()  {}
    ~foo() throw() {}
};

struct bar {
    bar() throw();
    ~bar() throw();
}

struct qux {
    qux();
    ~qux() {}
};

qux::qux<int>() {

}

bar::~bar() throw()
{}
=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2011-01-26 05:06:59 +0000
+++ lisp/progmodes/cc-engine.el	2011-01-26 05:41:17 +0000
@@ -6588,7 +6588,22 @@
 		     (when (and (not got-suffix-after-parens)
 				(= paren-depth 0))
 		       (setq got-suffix-after-parens (match-beginning 0)))
-		     (setq got-suffix t)))
+		     (setq got-suffix t)
+
+		     (when (and (not got-identifier)
+				(not got-prefix)
+				c-recognize-typeless-decls
+				c-always-postfix-suffixes
+				(progn (goto-char (match-beginning 1))
+				       (save-match-data
+					 (looking-at c-always-postfix-suffixes))))
+		       ;; "throw" and other keywords can only appear
+		       ;; after an identifier in a declaration. If we
+		       ;; see it and we've seen a type, the type is
+		       ;; really the identifier.
+		       (c-fdoc-shift-type-backward))
+		     
+		     t))
 
 	       ;; No suffix matched.  We might have matched the
 	       ;; identifier as a type and the open paren of a

=== modified file 'lisp/progmodes/cc-langs.el'
--- lisp/progmodes/cc-langs.el	2011-01-25 09:33:59 +0000
+++ lisp/progmodes/cc-langs.el	2011-01-26 05:41:17 +0000
@@ -4023,6 +4023,15 @@
 (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
   'dont-doc)
 
+(c-lang-defconst c-always-postfix-suffixes
+  "List of words that can appear only after the identifier in a
+  declarator --- e.g., \"throw\" for a C++ exception specification."
+  t nil
+  c++ '("throw" "sealed" "override"))
+(c-lang-defvar c-always-postfix-suffixes
+  (concat
+   (regexp-opt (c-lang-const c-always-postfix-suffixes c++)) "\\>"))
+
 (c-lang-defconst c-after-suffixed-type-decl-key
   "This regexp is matched after a declarator expression where
 `c-type-decl-suffix-key' has matched.  If it matches then the