diff options
| author | Alan Mackenzie | 2017-11-21 18:06:11 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-11-21 18:06:11 +0000 |
| commit | 735c8b516e09ecd056563569fb132e5ca56810d7 (patch) | |
| tree | a3365aea1cae4e504f6fde72a223d8942f9563b3 | |
| parent | 92f0c4cd56d4dc1a92c116172404e65996c5884d (diff) | |
| download | emacs-735c8b516e09ecd056563569fb132e5ca56810d7.tar.gz emacs-735c8b516e09ecd056563569fb132e5ca56810d7.zip | |
Make c-defun-name analyze more thoroughly a function type which is a struct
This fixes bug #29293.
* lisp/progmodes/cc-cmds.el (c-defun-name): When a struct (etc.) type is
encountered, check whether it is the return type of a function rather than a
declaration of the struct itself. Similarly adapt the cond arm which deals
with functions properly to recognize struct return types.
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 2b663135932..471560e19d4 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1849,7 +1849,15 @@ with a brace block." | |||
| 1849 | ;; Pick out the defun name, according to the type of defun. | 1849 | ;; Pick out the defun name, according to the type of defun. |
| 1850 | (cond | 1850 | (cond |
| 1851 | ;; struct, union, enum, or similar: | 1851 | ;; struct, union, enum, or similar: |
| 1852 | ((looking-at c-type-prefix-key) | 1852 | ((save-excursion |
| 1853 | (and | ||
| 1854 | (looking-at c-type-prefix-key) | ||
| 1855 | (consp (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil)) | ||
| 1856 | (or (not (or (eq (char-after) ?{) | ||
| 1857 | (and c-recognize-knr-p | ||
| 1858 | (c-in-knr-argdecl)))) | ||
| 1859 | (progn (c-backward-syntactic-ws) | ||
| 1860 | (not (eq (char-before) ?\))))))) | ||
| 1853 | (let ((key-pos (point))) | 1861 | (let ((key-pos (point))) |
| 1854 | (c-forward-over-token-and-ws) ; over "struct ". | 1862 | (c-forward-over-token-and-ws) ; over "struct ". |
| 1855 | (cond | 1863 | (cond |
| @@ -1897,8 +1905,16 @@ with a brace block." | |||
| 1897 | 1905 | ||
| 1898 | (t | 1906 | (t |
| 1899 | ;; Normal function or initializer. | 1907 | ;; Normal function or initializer. |
| 1900 | (when (c-syntactic-re-search-forward "[{(]" nil t) | 1908 | (when |
| 1901 | (backward-char) | 1909 | (and |
| 1910 | (consp (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil)) | ||
| 1911 | (or (eq (char-after) ?{) | ||
| 1912 | (and c-recognize-knr-p | ||
| 1913 | (c-in-knr-argdecl))) | ||
| 1914 | (progn | ||
| 1915 | (c-backward-syntactic-ws) | ||
| 1916 | (eq (char-before) ?\))) | ||
| 1917 | (c-go-list-backward)) | ||
| 1902 | (c-backward-syntactic-ws) | 1918 | (c-backward-syntactic-ws) |
| 1903 | (when (eq (char-before) ?\=) ; struct foo bar = {0, 0} ; | 1919 | (when (eq (char-before) ?\=) ; struct foo bar = {0, 0} ; |
| 1904 | (c-backward-token-2) | 1920 | (c-backward-token-2) |