]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-langs.el
Merge from emacs-24
[gnu-emacs] / lisp / progmodes / cc-langs.el
index ba9c42e4c89f605eb2b8dd1081f6e127a0ddcd43..bc3fb66d3e1125e2deec447fa5b4d94c591a9e00 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
 
 ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
 
-;; Copyright (C) 1985, 1987, 1992-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2014 Free Software Foundation, Inc.
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
 
 
 ;; This file is not always loaded.  See note above.
 
 
 ;; This file is not always loaded.  See note above.
-(cc-external-require 'cl)
+;; Except it is always loaded - see bug#17463.
+;;;(cc-external-require 'cl)
+(require 'cl-lib)
 
 \f
 ;;; Setup for the `c-lang-defvar' system.
 
 \f
 ;;; Setup for the `c-lang-defvar' system.
@@ -209,9 +211,8 @@ the evaluated constant value at compile time."
 ;; Suppress "might not be defined at runtime" warning.
 ;; This file is only used when compiling other cc files.
 ;; These are defined in cl as aliases to the cl- versions.
 ;; Suppress "might not be defined at runtime" warning.
 ;; This file is only used when compiling other cc files.
 ;; These are defined in cl as aliases to the cl- versions.
-(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
-(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
-(declare-function cl-macroexpand-all "cl" (form &optional env))
+;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
+;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
 
 (eval-and-compile
   ;; Some helper functions used when building the language constants.
 
 (eval-and-compile
   ;; Some helper functions used when building the language constants.
@@ -252,14 +253,14 @@ the evaluated constant value at compile time."
     (unless xlate
       (setq xlate 'identity))
     (c-with-syntax-table (c-lang-const c-mode-syntax-table)
     (unless xlate
       (setq xlate 'identity))
     (c-with-syntax-table (c-lang-const c-mode-syntax-table)
-      (delete-duplicates
-       (mapcan (lambda (opgroup)
+      (cl-delete-duplicates
+       (cl-mapcan (lambda (opgroup)
                 (when (if (symbolp (car opgroup))
                           (when (funcall opgroup-filter (car opgroup))
                             (setq opgroup (cdr opgroup))
                             t)
                         t)
                 (when (if (symbolp (car opgroup))
                           (when (funcall opgroup-filter (car opgroup))
                             (setq opgroup (cdr opgroup))
                             t)
                         t)
-                  (mapcan (lambda (op)
+                  (cl-mapcan (lambda (op)
                             (when (funcall op-filter op)
                               (let ((res (funcall xlate op)))
                                 (if (listp res) res (list res)))))
                             (when (funcall op-filter op)
                               (let ((res (funcall xlate op)))
                                 (if (listp res) res (list res)))))
@@ -392,7 +393,9 @@ The syntax tables aren't stored directly since they're quite large."
   ;; lists are parsed.  Note that this encourages incorrect parsing of
   ;; templates since they might contain normal operators that uses the
   ;; '<' and '>' characters.  Therefore this syntax table might go
   ;; lists are parsed.  Note that this encourages incorrect parsing of
   ;; templates since they might contain normal operators that uses the
   ;; '<' and '>' characters.  Therefore this syntax table might go
-  ;; away when CC Mode handles templates correctly everywhere.
+  ;; away when CC Mode handles templates correctly everywhere.  WHILE
+  ;; THIS SYNTAX TABLE IS CURRENT, `c-parse-state' MUST _NOT_ BE
+  ;; CALLED!!!
   t   nil
   (java c++) `(lambda ()
         (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
   t   nil
   (java c++) `(lambda ()
         (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
@@ -403,7 +406,7 @@ The syntax tables aren't stored directly since they're quite large."
   (and (c-lang-const c++-make-template-syntax-table)
        (funcall (c-lang-const c++-make-template-syntax-table))))
 
   (and (c-lang-const c++-make-template-syntax-table)
        (funcall (c-lang-const c++-make-template-syntax-table))))
 
-(c-lang-defconst c-no-parens-syntax-table
+(c-lang-defconst c-make-no-parens-syntax-table
   ;; A variant of the standard syntax table which is used to find matching
   ;; "<"s and ">"s which have been marked as parens using syntax table
   ;; properties.  The other paren characters (e.g. "{", ")" "]") are given a
   ;; A variant of the standard syntax table which is used to find matching
   ;; "<"s and ">"s which have been marked as parens using syntax table
   ;; properties.  The other paren characters (e.g. "{", ")" "]") are given a
@@ -411,18 +414,20 @@ The syntax tables aren't stored directly since they're quite large."
   ;; even when there's unbalanced other parens inside them.
   ;;
   ;; This variable is nil for languages which don't have template stuff.
   ;; even when there's unbalanced other parens inside them.
   ;;
   ;; This variable is nil for languages which don't have template stuff.
-  t  `(lambda ()
-       (if (c-lang-const c-recognize-<>-arglists)
-           (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
-             (modify-syntax-entry ?\( "." table)
-             (modify-syntax-entry ?\) "." table)
-             (modify-syntax-entry ?\[ "." table)
-             (modify-syntax-entry ?\] "." table)
-             (modify-syntax-entry ?\{ "." table)
-             (modify-syntax-entry ?\} "." table)
-             table))))
+  t  (if (c-lang-const c-recognize-<>-arglists)
+     `(lambda ()
+       ;(if (c-lang-const c-recognize-<>-arglists)
+       (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
+         (modify-syntax-entry ?\( "." table)
+         (modify-syntax-entry ?\) "." table)
+         (modify-syntax-entry ?\[ "." table)
+         (modify-syntax-entry ?\] "." table)
+         (modify-syntax-entry ?\{ "." table)
+         (modify-syntax-entry ?\} "." table)
+         table))))
 (c-lang-defvar c-no-parens-syntax-table
 (c-lang-defvar c-no-parens-syntax-table
-              (funcall (c-lang-const c-no-parens-syntax-table)))
+  (and (c-lang-const c-make-no-parens-syntax-table)
+       (funcall (c-lang-const c-make-no-parens-syntax-table))))
 
 (c-lang-defconst c-identifier-syntax-modifications
   "A list that describes the modifications that should be done to the
 
 (c-lang-defconst c-identifier-syntax-modifications
   "A list that describes the modifications that should be done to the
@@ -812,8 +817,8 @@ Assumed to not contain any submatches or \\| operators."
 (c-lang-defconst c-anchored-cpp-prefix
   "Regexp matching the prefix of a cpp directive anchored to BOL,
 in the languages that have a macro preprocessor."
 (c-lang-defconst c-anchored-cpp-prefix
   "Regexp matching the prefix of a cpp directive anchored to BOL,
 in the languages that have a macro preprocessor."
-  t (if (c-lang-const c-opt-cpp-prefix)
-       (concat "^" (c-lang-const c-opt-cpp-prefix))))
+  t "^\\s *\\(#\\)\\s *"
+  (java awk) nil)
 (c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
 
 (c-lang-defconst c-opt-cpp-start
 (c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
 
 (c-lang-defconst c-opt-cpp-start
@@ -937,10 +942,13 @@ Note that operators like \".\" and \"->\" which in language references
 often are described as postfix operators are considered binary here,
 since CC Mode treats every identifier as an expression."
 
 often are described as postfix operators are considered binary here,
 since CC Mode treats every identifier as an expression."
 
-  ;; There's currently no code in CC Mode that exploit all the info
+  ;; There's currently no code in CC Mode that exploits all the info
   ;; in this variable; precedence, associativity etc are present as a
   ;; preparation for future work.
 
   ;; in this variable; precedence, associativity etc are present as a
   ;; preparation for future work.
 
+  ;; FIXME!!!  C++11's "auto" operators "=" and "->" need to go in here
+  ;; somewhere.  2012-03-24.
+
   t `(;; Preprocessor.
       ,@(when (c-lang-const c-opt-cpp-prefix)
          `((prefix "#"
   t `(;; Preprocessor.
       ,@(when (c-lang-const c-opt-cpp-prefix)
          `((prefix "#"
@@ -1147,7 +1155,7 @@ operators."
 (c-lang-defconst c-all-op-syntax-tokens
   ;; List of all tokens in the punctuation and parenthesis syntax
   ;; classes.
 (c-lang-defconst c-all-op-syntax-tokens
   ;; List of all tokens in the punctuation and parenthesis syntax
   ;; classes.
-  t (delete-duplicates (append (c-lang-const c-other-op-syntax-tokens)
+  t (cl-delete-duplicates (append (c-lang-const c-other-op-syntax-tokens)
                               (c-lang-const c-operator-list))
                       :test 'string-equal))
 
                               (c-lang-const c-operator-list))
                       :test 'string-equal))
 
@@ -1214,22 +1222,41 @@ operators."
 
 (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
 
 
 (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
 
+(c-lang-defconst c->-op-cont-tokens
+  ;; A list of second and subsequent characters of all multicharacter tokens
+  ;; that begin with ">".
+  t (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+                 t
+                 "\\`>."
+                 (lambda (op) (substring op 1)))
+  java (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+                    t
+                    "\\`>[^>]\\|\\`>>[^>]"
+                    (lambda (op) (substring op 1))))
+
 (c-lang-defconst c->-op-cont-regexp
   ;; Regexp matching the second and subsequent characters of all
   ;; multicharacter tokens that begin with ">".
 (c-lang-defconst c->-op-cont-regexp
   ;; Regexp matching the second and subsequent characters of all
   ;; multicharacter tokens that begin with ">".
-  t (c-make-keywords-re nil
-      (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
-                   t
-                   "\\`>."
-                   (lambda (op) (substring op 1))))
-  java (c-make-keywords-re nil
-        (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
-                      t
-                      "\\`>[^>]\\|\\`>>[^>]"
-                      (lambda (op) (substring op 1)))))
+  t (c-make-keywords-re nil (c-lang-const c->-op-cont-tokens)))
 
 (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
 
 
 (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
 
+(c-lang-defconst c->-op-without->-cont-regexp
+  ;; Regexp matching the second and subsequent characters of all
+  ;; multicharacter tokens that begin with ">" except for those beginning with
+  ;; ">>".
+  t (c-make-keywords-re nil
+      (set-difference
+       (c-lang-const c->-op-cont-tokens)
+       (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+                    t
+                    "\\`>>"
+                    (lambda (op) (substring op 1)))
+       :test 'string-equal)))
+
+(c-lang-defvar c->-op-without->-cont-regexp
+  (c-lang-const c->-op-without->-cont-regexp))
+
 (c-lang-defconst c-stmt-delim-chars
   ;; The characters that should be considered to bound statements.  To
   ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
 (c-lang-defconst c-stmt-delim-chars
   ;; The characters that should be considered to bound statements.  To
   ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
@@ -1244,6 +1271,21 @@ operators."
 (c-lang-defvar c-stmt-delim-chars-with-comma
   (c-lang-const c-stmt-delim-chars-with-comma))
 
 (c-lang-defvar c-stmt-delim-chars-with-comma
   (c-lang-const c-stmt-delim-chars-with-comma))
 
+(c-lang-defconst c-auto-ops
+  ;; Ops which signal C++11's new auto uses.
+  t nil
+  c++ '("=" "->"))
+(c-lang-defconst c-auto-ops-re
+  t (c-make-keywords-re nil (c-lang-const c-auto-ops)))
+(c-lang-defvar c-auto-ops-re (c-lang-const c-auto-ops-re))
+
+(c-lang-defconst c-haskell-op
+  ;; Op used in the new C++11 auto function definition, indicating type.
+  t nil
+  c++ '("->"))
+(c-lang-defconst c-haskell-op-re
+  t (c-make-keywords-re nil (c-lang-const c-haskell-op)))
+(c-lang-defvar c-haskell-op-re (c-lang-const c-haskell-op-re))
 \f
 ;;; Syntactic whitespace.
 
 \f
 ;;; Syntactic whitespace.
 
@@ -1651,6 +1693,18 @@ of a variable declaration."
   t (c-make-keywords-re t (c-lang-const c-typedef-kwds)))
 (c-lang-defvar c-typedef-key (c-lang-const c-typedef-key))
 
   t (c-make-keywords-re t (c-lang-const c-typedef-kwds)))
 (c-lang-defvar c-typedef-key (c-lang-const c-typedef-key))
 
+(c-lang-defconst c-typeof-kwds
+  "Keywords followed by a parenthesized expression, which stands for
+the type of that expression."
+  t nil
+  c '("typeof")                                ; longstanding GNU C(++) extension.
+  c++ '("decltype" "typeof"))
+
+(c-lang-defconst c-typeof-key
+  ;; Adorned regexp matching `c-typeof-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-typeof-kwds)))
+(c-lang-defvar c-typeof-key (c-lang-const c-typeof-key))
+
 (c-lang-defconst c-type-prefix-kwds
   "Keywords where the following name - if any - is a type name, and
 where the keyword together with the symbol works as a type in
 (c-lang-defconst c-type-prefix-kwds
   "Keywords where the following name - if any - is a type name, and
 where the keyword together with the symbol works as a type in
@@ -1700,7 +1754,7 @@ not the type face."
 (c-lang-defconst c-type-start-kwds
   ;; All keywords that can start a type (i.e. are either a type prefix
   ;; or a complete type).
 (c-lang-defconst c-type-start-kwds
   ;; All keywords that can start a type (i.e. are either a type prefix
   ;; or a complete type).
-  t (delete-duplicates (append (c-lang-const c-primitive-type-kwds)
+  t (cl-delete-duplicates (append (c-lang-const c-primitive-type-kwds)
                               (c-lang-const c-type-prefix-kwds)
                               (c-lang-const c-type-modifier-kwds))
                       :test 'string-equal))
                               (c-lang-const c-type-prefix-kwds)
                               (c-lang-const c-type-modifier-kwds))
                       :test 'string-equal))
@@ -1834,6 +1888,7 @@ will be handled."
   ;; {...}").
   t    (append (c-lang-const c-class-decl-kwds)
               (c-lang-const c-brace-list-decl-kwds))
   ;; {...}").
   t    (append (c-lang-const c-class-decl-kwds)
               (c-lang-const c-brace-list-decl-kwds))
+  c++  (append (c-lang-const c-typeless-decl-kwds) '("auto")) ; C++11.
   ;; Note: "manages" for CORBA CIDL clashes with its presence on
   ;; `c-type-list-kwds' for IDL.
   idl  (append (c-lang-const c-typeless-decl-kwds)
   ;; Note: "manages" for CORBA CIDL clashes with its presence on
   ;; `c-type-list-kwds' for IDL.
   idl  (append (c-lang-const c-typeless-decl-kwds)
@@ -1943,7 +1998,7 @@ one of `c-type-list-kwds', `c-ref-list-kwds',
   ;; something is a type or just some sort of macro in front of the
   ;; declaration.  They might be ambiguous with types or type
   ;; prefixes.
   ;; something is a type or just some sort of macro in front of the
   ;; declaration.  They might be ambiguous with types or type
   ;; prefixes.
-  t (delete-duplicates (append (c-lang-const c-class-decl-kwds)
+  t (cl-delete-duplicates (append (c-lang-const c-class-decl-kwds)
                               (c-lang-const c-brace-list-decl-kwds)
                               (c-lang-const c-other-block-decl-kwds)
                               (c-lang-const c-typedef-decl-kwds)
                               (c-lang-const c-brace-list-decl-kwds)
                               (c-lang-const c-other-block-decl-kwds)
                               (c-lang-const c-typedef-decl-kwds)
@@ -1983,7 +2038,8 @@ one of `c-type-list-kwds', `c-ref-list-kwds',
   t (c-make-keywords-re t
       (set-difference (c-lang-const c-keywords)
                      (append (c-lang-const c-type-start-kwds)
   t (c-make-keywords-re t
       (set-difference (c-lang-const c-keywords)
                      (append (c-lang-const c-type-start-kwds)
-                             (c-lang-const c-prefix-spec-kwds))
+                             (c-lang-const c-prefix-spec-kwds)
+                             (c-lang-const c-typeof-kwds))
                      :test 'string-equal)))
 (c-lang-defvar c-not-decl-init-keywords
   (c-lang-const c-not-decl-init-keywords))
                      :test 'string-equal)))
 (c-lang-defvar c-not-decl-init-keywords
   (c-lang-const c-not-decl-init-keywords))
@@ -2040,6 +2096,12 @@ declarations."
         ;; In CORBA PSDL:
         "as" "const" "implements" "of" "ref"))
 
         ;; In CORBA PSDL:
         "as" "const" "implements" "of" "ref"))
 
+(c-lang-defconst c-postfix-decl-spec-key
+  ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))
+(c-lang-defvar c-postfix-decl-spec-key
+  (c-lang-const c-postfix-decl-spec-key))
+
 (c-lang-defconst c-nonsymbol-sexp-kwds
   "Keywords that may be followed by a nonsymbol sexp before whatever
 construct it's part of continues."
 (c-lang-defconst c-nonsymbol-sexp-kwds
   "Keywords that may be followed by a nonsymbol sexp before whatever
 construct it's part of continues."
@@ -2130,7 +2192,7 @@ type identifiers separated by arbitrary tokens."
   pike '("array" "function" "int" "mapping" "multiset" "object" "program"))
 
 (c-lang-defconst c-paren-any-kwds
   pike '("array" "function" "int" "mapping" "multiset" "object" "program"))
 
 (c-lang-defconst c-paren-any-kwds
-  t (delete-duplicates (append (c-lang-const c-paren-nontype-kwds)
+  t (cl-delete-duplicates (append (c-lang-const c-paren-nontype-kwds)
                               (c-lang-const c-paren-type-kwds))
                       :test 'string-equal))
 
                               (c-lang-const c-paren-type-kwds))
                       :test 'string-equal))
 
@@ -2156,15 +2218,14 @@ assumed to be set if this isn't nil."
 
 (c-lang-defconst c-<>-sexp-kwds
   ;; All keywords that can be followed by an angle bracket sexp.
 
 (c-lang-defconst c-<>-sexp-kwds
   ;; All keywords that can be followed by an angle bracket sexp.
-  t (delete-duplicates (append (c-lang-const c-<>-type-kwds)
+  t (cl-delete-duplicates (append (c-lang-const c-<>-type-kwds)
                               (c-lang-const c-<>-arglist-kwds))
                       :test 'string-equal))
 
 (c-lang-defconst c-opt-<>-sexp-key
   ;; Adorned regexp matching keywords that can be followed by an angle
   ;; bracket sexp.  Always set when `c-recognize-<>-arglists' is.
                               (c-lang-const c-<>-arglist-kwds))
                       :test 'string-equal))
 
 (c-lang-defconst c-opt-<>-sexp-key
   ;; Adorned regexp matching keywords that can be followed by an angle
   ;; bracket sexp.  Always set when `c-recognize-<>-arglists' is.
-  t (if (c-lang-const c-recognize-<>-arglists)
-       (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds))))
+  t (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds)))
 (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
 
 (c-lang-defconst c-brace-id-list-kwds
 (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
 
 (c-lang-defconst c-brace-id-list-kwds
@@ -2187,6 +2248,18 @@ identifiers that follows the type in a normal declaration."
   t (c-make-keywords-re t (c-lang-const c-block-stmt-1-kwds)))
 (c-lang-defvar c-block-stmt-1-key (c-lang-const c-block-stmt-1-key))
 
   t (c-make-keywords-re t (c-lang-const c-block-stmt-1-kwds)))
 (c-lang-defvar c-block-stmt-1-key (c-lang-const c-block-stmt-1-key))
 
+(c-lang-defconst c-block-stmt-1-2-kwds
+  "Statement keywords optionally followed by a paren sexp.
+Keywords here should also be in `c-block-stmt-1-kwds'."
+  t nil
+  java '("try"))
+
+(c-lang-defconst c-block-stmt-1-2-key
+  ;; Regexp matching the start of a statement which may be followed by a
+  ;; paren sexp and will then be followed by a substatement.
+  t (c-make-keywords-re t (c-lang-const c-block-stmt-1-2-kwds)))
+(c-lang-defvar c-block-stmt-1-2-key (c-lang-const c-block-stmt-1-2-key))
+
 (c-lang-defconst c-block-stmt-2-kwds
   "Statement keywords followed by a paren sexp and then by a substatement."
   t    '("for" "if" "switch" "while")
 (c-lang-defconst c-block-stmt-2-kwds
   "Statement keywords followed by a paren sexp and then by a substatement."
   t    '("for" "if" "switch" "while")
@@ -2205,7 +2278,7 @@ identifiers that follows the type in a normal declaration."
 
 (c-lang-defconst c-block-stmt-kwds
   ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
 
 (c-lang-defconst c-block-stmt-kwds
   ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
-  t (delete-duplicates (append (c-lang-const c-block-stmt-1-kwds)
+  t (cl-delete-duplicates (append (c-lang-const c-block-stmt-1-kwds)
                               (c-lang-const c-block-stmt-2-kwds))
                       :test 'string-equal))
 
                               (c-lang-const c-block-stmt-2-kwds))
                       :test 'string-equal))
 
@@ -2309,7 +2382,7 @@ This construct is \"<keyword> <expression> :\"."
 (c-lang-defconst c-expr-kwds
   ;; Keywords that can occur anywhere in expressions.  Built from
   ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
 (c-lang-defconst c-expr-kwds
   ;; Keywords that can occur anywhere in expressions.  Built from
   ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
-  t (delete-duplicates
+  t (cl-delete-duplicates
      (append (c-lang-const c-primary-expr-kwds)
             (c-filter-ops (c-lang-const c-operator-list)
                           t
      (append (c-lang-const c-primary-expr-kwds)
             (c-filter-ops (c-lang-const c-operator-list)
                           t
@@ -2413,7 +2486,7 @@ Note that Java specific rules are currently applied to tell this from
 
 (c-lang-defconst c-keywords
   ;; All keywords as a list.
 
 (c-lang-defconst c-keywords
   ;; All keywords as a list.
-  t (delete-duplicates
+  t (cl-delete-duplicates
      (c-lang-defconst-eval-immediately
       `(append ,@(mapcar (lambda (kwds-lang-const)
                           `(c-lang-const ,kwds-lang-const))
      (c-lang-defconst-eval-immediately
       `(append ,@(mapcar (lambda (kwds-lang-const)
                           `(c-lang-const ,kwds-lang-const))
@@ -2576,6 +2649,15 @@ Note that Java specific rules are currently applied to tell this from
 \f
 ;;; Additional constants for parser-level constructs.
 
 \f
 ;;; Additional constants for parser-level constructs.
 
+(c-lang-defconst c-decl-start-colon-kwd-re
+  "Regexp matching a keyword that is followed by a colon, where
+  the whole construct can precede a declaration.
+  E.g. \"public:\" in C++."
+  t "\\<\\>"
+  c++ (c-make-keywords-re t (c-lang-const c-protection-kwds)))
+(c-lang-defvar c-decl-start-colon-kwd-re
+  (c-lang-const c-decl-start-colon-kwd-re))
+
 (c-lang-defconst c-decl-prefix-re
   "Regexp matching something that might precede a declaration, cast or
 label, such as the last token of a preceding statement or declaration.
 (c-lang-defconst c-decl-prefix-re
   "Regexp matching something that might precede a declaration, cast or
 label, such as the last token of a preceding statement or declaration.
@@ -2615,8 +2697,11 @@ more info."
   java "\\([\{\}\(;,<]+\\)"
   ;; Match "<" in C++ to get the first argument in a template arglist.
   ;; In that case there's an additional check in `c-find-decl-spots'
   java "\\([\{\}\(;,<]+\\)"
   ;; Match "<" in C++ to get the first argument in a template arglist.
   ;; In that case there's an additional check in `c-find-decl-spots'
-  ;; that it got open paren syntax.
-  c++ "\\([\{\}\(\);,<]+\\)"
+  ;; that it got open paren syntax.  Match ":" to aid in picking up
+  ;; "public:", etc.  This involves additional checks in
+  ;; `c-find-decl-prefix-search' to prevent a match of identifiers
+  ;; or labels.
+  c++ "\\([\{\}\(\);:,<]+\\)"
   ;; Additionally match the protection directives in Objective-C.
   ;; Note that this doesn't cope with the longer directives, which we
   ;; would have to match from start to end since they don't end with
   ;; Additionally match the protection directives in Objective-C.
   ;; Note that this doesn't cope with the longer directives, which we
   ;; would have to match from start to end since they don't end with
@@ -2805,7 +2890,8 @@ is in effect when this is matched (see `c-identifier-syntax-table')."
                     "\\>")
                  "")
                "\\)")
                     "\\>")
                  "")
                "\\)")
-  (java idl) "\\([\[\(]\\)")
+  java "\\([\[\(\)]\\)"
+  idl "\\([\[\(]\\)")
 (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
   'dont-doc)
 
 (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
   'dont-doc)
 
@@ -2926,7 +3012,7 @@ calls before a brace block.  This setting does not affect declarations
 that are preceded by a declaration starting keyword, so
 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
   t nil
 that are preceded by a declaration starting keyword, so
 e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
   t nil
-  (c c++ objc) t)
+  (c c++ objc java) t)
 (c-lang-defvar c-recognize-typeless-decls
   (c-lang-const c-recognize-typeless-decls))
 
 (c-lang-defvar c-recognize-typeless-decls
   (c-lang-const c-recognize-typeless-decls))
 
@@ -2938,7 +3024,8 @@ identifier or one of the keywords on `c-<>-type-kwds' or
 `c-<>-arglist-kwds'.  If there's an identifier before then the whole
 expression is considered to be a type."
   t (or (consp (c-lang-const c-<>-type-kwds))
 `c-<>-arglist-kwds'.  If there's an identifier before then the whole
 expression is considered to be a type."
   t (or (consp (c-lang-const c-<>-type-kwds))
-       (consp (c-lang-const c-<>-arglist-kwds))))
+       (consp (c-lang-const c-<>-arglist-kwds)))
+  java t)
 (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
 
 (c-lang-defconst c-enums-contain-decls
 (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
 
 (c-lang-defconst c-enums-contain-decls
@@ -3150,7 +3237,7 @@ accomplish that conveniently."
       `(lambda ()
 
         ;; This let sets up the context for `c-mode-var' and similar
       `(lambda ()
 
         ;; This let sets up the context for `c-mode-var' and similar
-        ;; that could be in the result from `cl-macroexpand-all'.
+        ;; that could be in the result from `macroexpand-all'.
         (let ((c-buffer-is-cc-mode ',mode)
               current-var source-eval)
           (c-make-emacs-variables-local)
         (let ((c-buffer-is-cc-mode ',mode)
               current-var source-eval)
           (c-make-emacs-variables-local)
@@ -3160,12 +3247,12 @@ accomplish that conveniently."
                   (setq ,@(let ((c-buffer-is-cc-mode mode)
                                 (c-lang-const-expansion 'immediate))
                             ;; `c-lang-const' will expand to the evaluated
                   (setq ,@(let ((c-buffer-is-cc-mode mode)
                                 (c-lang-const-expansion 'immediate))
                             ;; `c-lang-const' will expand to the evaluated
-                            ;; constant immediately in `cl-macroexpand-all'
+                            ;; constant immediately in `macroexpand-all'
                             ;; below.
                             ;; below.
-                             (mapcan
+                             (cl-mapcan
                               (lambda (init)
                                 `(current-var ',(car init)
                               (lambda (init)
                                 `(current-var ',(car init)
-                                  ,(car init) ,(cl-macroexpand-all
+                                  ,(car init) ,(macroexpand-all
                                                 (elt init 1))))
                               ;; Note: The following `append' copies the
                               ;; first argument.  That list is small, so
                                                 (elt init 1))))
                               ;; Note: The following `append' copies the
                               ;; first argument.  That list is small, so