]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-langs.el
Merge branch 'emacs-25-merge'
[gnu-emacs] / lisp / progmodes / cc-langs.el
index 235ef21d066855aff36946c05f89da265370bd19..1a07c4cd699597dd4bee2983d16d307f2579370f 100644 (file)
@@ -327,7 +327,7 @@ the evaluated constant value at compile time."
 
 (defun c-populate-syntax-table (table)
   "Populate the given syntax table as necessary for a C-like language.
-This includes setting ' and \" as string delimiters, and setting up
+This includes setting \\=' and \" as string delimiters, and setting up
 the comment syntax to handle both line style \"//\" and block style
 \"/*\" \"*/\" comments."
 
@@ -403,7 +403,9 @@ The syntax tables aren't stored directly since they're quite large."
           table)))
 (c-lang-defvar c++-template-syntax-table
   (and (c-lang-const c++-make-template-syntax-table)
-       (funcall (c-lang-const c++-make-template-syntax-table))))
+       ;; The next eval remove a superfluous ' from '(lambda.  This
+       ;; gets rid of compilation warnings.
+       (funcall (eval (c-lang-const c++-make-template-syntax-table)))))
 
 (c-lang-defconst c-make-no-parens-syntax-table
   ;; A variant of the standard syntax table which is used to find matching
@@ -426,7 +428,8 @@ The syntax tables aren't stored directly since they're quite large."
          table))))
 (c-lang-defvar 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))))
+       ;; See comment in `c++template-syntax-table' about the next `eval'.
+       (funcall (eval (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
@@ -870,7 +873,7 @@ definition, or nil if the language doesn't have any."
   t (if (c-lang-const c-opt-cpp-macro-define)
        (concat (c-lang-const c-opt-cpp-prefix)
                (c-lang-const c-opt-cpp-macro-define)
-               "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(\([^\)]*\)\\)?"
+               "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(([^)]*)\\)?"
                ;;       ^                 ^ #defined name
                "\\([ \t]\\|\\\\\n\\)*")))
 (c-lang-defvar c-opt-cpp-macro-define-start
@@ -926,14 +929,14 @@ following elements.  The car of each element describes the type of the
 operator group, and the cdr is a list of the operator tokens in it.
 The operator group types are:
 
-'prefix         Unary prefix operators.
-'postfix        Unary postfix operators.
-'postfix-if-paren
+`prefix'        Unary prefix operators.
+`postfix'       Unary postfix operators.
+`postfix-if-paren'
                Unary postfix operators if and only if the chars have
                parenthesis syntax.
-'left-assoc     Binary left associative operators (i.e. a+b+c means (a+b)+c).
-'right-assoc    Binary right associative operators (i.e. a=b=c means a=(b=c)).
-'right-assoc-sequence
+`left-assoc'    Binary left associative operators (i.e. a+b+c means (a+b)+c).
+`right-assoc'   Binary right associative operators (i.e. a=b=c means a=(b=c)).
+`right-assoc-sequence'
                 Right associative operator that constitutes of a
                 sequence of tokens that separate expressions.  All the
                 tokens in the group are in this case taken as
@@ -1190,7 +1193,7 @@ operators."
   t (c-make-keywords-re nil
       (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
                    t
-                   "\\`\\(\\s.\\|\\s\(\\|\\s\)\\)+\\'")))
+                   "\\`\\(\\s.\\)+\\'")))
 (c-lang-defvar c-nonsymbol-token-regexp
   (c-lang-const c-nonsymbol-token-regexp))
 
@@ -1430,6 +1433,14 @@ properly."
            "\\)\\s *"))
 (c-lang-setvar comment-start-skip (c-lang-const comment-start-skip))
 
+(c-lang-defconst comment-end-can-be-escaped
+  "When non-nil, escaped EOLs inside comments are valid.
+This works in Emacs >= 25.1."
+  t nil
+  (c c++ objc) t)
+(c-lang-setvar comment-end-can-be-escaped
+              (c-lang-const comment-end-can-be-escaped))
+
 (c-lang-defconst c-syntactic-ws-start
   ;; Regexp matching any sequence that can start syntactic whitespace.
   ;; The only uncertain case is '#' when there are cpp directives.
@@ -1694,7 +1705,7 @@ be a subset of `c-primitive-type-kwds'."
            "strong"))
 
 (c-lang-defconst c-typedef-kwds
-  "Prefix keyword\(s\) like \"typedef\" which make a type declaration out
+  "Prefix keyword(s) like \"typedef\" which make a type declaration out
 of a variable declaration."
   t        '("typedef")
   (awk idl java) nil)
@@ -2202,7 +2213,7 @@ regexp if `c-colon-type-list-kwds' isn't nil."
        ;; before the ":" that starts the inherit list after "class"
        ;; or "struct" in C++.  (Also used as default for other
        ;; languages.)
-       "[^\]\[{}();,/#=:]*:"))
+       "[^][{}();,/#=:]*:"))
 (c-lang-defvar c-colon-type-list-re (c-lang-const c-colon-type-list-re))
 
 (c-lang-defconst c-paren-nontype-kwds
@@ -2366,7 +2377,7 @@ nevertheless contains a list separated with `;' and not `,'."
 (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key))
 
 (c-lang-defconst c-case-kwds
-  "The keyword\(s) which introduce a \"case\" like construct.
+  "The keyword(s) which introduce a \"case\" like construct.
 This construct is \"<keyword> <expression> :\"."
   t '("case")
   awk nil)
@@ -2729,25 +2740,25 @@ more info."
   ;; more quickly.  We match ")" in C for K&R region declarations, and
   ;; in all languages except Java for when a cpp macro definition
   ;; begins with a declaration.
-  t "\\([\{\}\(\);,]+\\)"
-  java "\\([\{\}\(;,<]+\\)"
+  t "\\([{}();,]+\\)"
+  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.  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++ "\\([\{\}\(\);:,<]+\\)"
+  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
   ;; any easily recognized characters.
-  objc (concat "\\([\{\}\(\);,]+\\|"
+  objc (concat "\\([{}();,]+\\|"
               (c-make-keywords-re nil (c-lang-const c-protection-kwds))
               "\\)")
   ;; Pike is like C but we also match "[" for multiple value
   ;; assignments and type casts.
-  pike "\\([\{\}\(\)\[;,]+\\)")
+  pike "\\([{}()[;,]+\\)")
 (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re)
   'dont-doc)
 
@@ -2792,7 +2803,7 @@ constructs."
   ;; languages without casts.
   t (c-filter-ops (c-lang-const c-operators)
                  '(prefix)
-                 "\\`\\s\(\\'"
+                 "\\`\\s(\\'"
                  (lambda (op) (elt op 0))))
 (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens))
 
@@ -2875,13 +2886,13 @@ Identifier syntax is in effect when this is matched \(see
   ;; Check that there's no "=" afterwards to avoid matching tokens
   ;; like "*=".
   (c objc) (concat "\\("
-                  "[*\(]"
+                  "[*(]"
                   "\\|"
                   (c-lang-const c-type-decl-prefix-key)
                   "\\)"
                   "\\([^=]\\|$\\)")
   c++  (concat "\\("
-              "[*\(&]"
+              "[*(&]"
               "\\|"
               (c-lang-const c-type-decl-prefix-key)
               "\\|"
@@ -2909,13 +2920,13 @@ is in effect when this is matched (see `c-identifier-syntax-table')."
   ;; Default to a regexp that matches `c-type-modifier-kwds' and a
   ;; function argument list parenthesis.
   t    (if (c-lang-const c-type-modifier-kwds)
-          (concat "\\(\(\\|"
+          (concat "\\((\\|"
                   (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"
                   "\\)")
-        "\\(\(\\)")
+        "\\((\\)")
   (c c++ objc) (concat
                "\\("
-               "[\)\[\(]"
+               "[)[(]"
                (if (c-lang-const c-type-modifier-kwds)
                    (concat
                     "\\|"
@@ -2926,8 +2937,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)
 
@@ -3111,7 +3122,7 @@ i.e. compound statements surrounded by parentheses inside expressions."
   t (if (c-lang-const c-opt-<>-arglist-start)
        (concat "\\("
                (c-lang-const c-opt-<>-arglist-start)
-               "\\)\\|\\s\)")))
+               "\\)\\|\\s)")))
 (c-lang-defvar c-opt-<>-arglist-start-in-paren
   (c-lang-const c-opt-<>-arglist-start-in-paren))
 
@@ -3168,7 +3179,7 @@ i.e. before \":\".  Only used if `c-recognize-colon-labels' is set."
   ;; Also check for open parens in C++, to catch member init lists in
   ;; constructors.  We normally allow it so that macros with arguments
   ;; work in labels.
-  c++ (concat "\\s\(\\|\"\\|" (c-lang-const c-nonlabel-token-key)))
+  c++ (concat "\\s(\\|\"\\|" (c-lang-const c-nonlabel-token-key)))
 (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
 
 (c-lang-defconst c-nonlabel-token-2-key
@@ -3216,7 +3227,7 @@ way."
        "\\([+-]\\)"
        (c-lang-const c-simple-ws) "*"
        (concat "\\("                   ; Return type.
-               "([^\)]*)"
+               "([^)]*)"
                (c-lang-const c-simple-ws) "*"
                "\\)?")
        "\\(" (c-lang-const c-symbol-key) "\\)"))
@@ -3304,10 +3315,9 @@ accomplish that conveniently."
                 (setq source-eval t)
                 (let ((init ',(append (cdr c-emacs-variable-inits)
                                       (cdr c-lang-variable-inits))))
-                  (while init
-                    (setq current-var (caar init))
-                    (set (caar init) (eval (cadar init)))
-                    (setq init (cdr init)))))
+                  (dolist (var-init init)
+                    (setq current-var (car var-init))
+                    (set (car var-init) (eval (cadr var-init))))))
 
             (error
              (if current-var
@@ -3333,10 +3343,9 @@ accomplish that conveniently."
         (c-make-emacs-variables-local)
         (condition-case err
 
-            (while init
-              (setq current-var (caar init))
-              (set (caar init) (eval (cadar init)))
-              (setq init (cdr init)))
+            (dolist (var-init init)
+              (setq current-var (car var-init))
+              (set (car var-init) (eval (cadr var-init))))
 
           (error
            (if current-var