Subject: bug#8438: 24.0.50; C++ macro make indentation fail

From: Daniel Colascione <[email-masked]>
Date: Wed, 13 Apr 2011 02:25:19 -0700

On 4/7/11 3:45 AM, Andrea Crotti wrote:
> I send from my fully customized emacs but I also tested it with "emacs -Q".
> A simple macro in C++ mode makes the indentation fail, this is what it
> should be:
> 
> --8<---------------cut here---------------start------------->8---
> #define OUT (std::cout << "DEBUG: (" << hwaddress << "):\t")
> 
> PadNode::PadNode(const PadNodeID& _hwaddress, landmark_idx_t _land_idx, bool _is_mobile)
> : Node(),

The problem actually has nothing to do with the macro:
c-forward-decl-or-cast-1 is choking on the const because it's mistaking
it for something that might be part of a member function pointer.
Because c-forward-decl-or-cast-1 fails inside
c-just-after-func-arglist-p, c-guess-basic-offset tries the next best
thing, which happens to be a template argument continuation.

The attached patch resolves the issue.
=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2011-03-06 17:03:45 +0000
+++ lisp/progmodes/cc-engine.el	2011-04-13 09:18:47 +0000
@@ -6475,7 +6475,7 @@
       ;; `c-font-lock-declarators'.)
       (while (and (looking-at c-type-decl-prefix-key)
 		  (if (and (c-major-mode-is 'c++-mode)
-			   (match-beginning 2))
+			   (match-beginning 3))
 		      ;; If the second submatch matches in C++ then
 		      ;; we're looking at an identifier that's a
 		      ;; prefix only if it specifies a member pointer.