aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/misc/flymake.texi4
-rw-r--r--lisp/progmodes/flymake-proc.el33
-rw-r--r--lisp/progmodes/flymake.el22
-rw-r--r--test/lisp/progmodes/flymake-resources/Makefile4
-rw-r--r--test/lisp/progmodes/flymake-resources/errors-and-warnings.c15
-rw-r--r--test/lisp/progmodes/flymake-resources/no-problems.h1
-rw-r--r--test/lisp/progmodes/flymake-resources/some-problems.h5
-rw-r--r--test/lisp/progmodes/flymake-tests.el20
8 files changed, 81 insertions, 23 deletions
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 1bc416fd02e..01849b7d9a5 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -492,7 +492,7 @@ our case this target might look like this:
492 492
493@verbatim 493@verbatim
494check-syntax: 494check-syntax:
495 gcc -o /dev/null -S ${CHK_SOURCES} 495 gcc -o /dev/null -S ${CHK_SOURCES} || true
496@end verbatim 496@end verbatim
497 497
498@noindent 498@noindent
@@ -504,7 +504,7 @@ Automake variable @code{COMPILE}:
504 504
505@verbatim 505@verbatim
506check-syntax: 506check-syntax:
507 $(COMPILE) -o /dev/null -S ${CHK_SOURCES} 507 $(COMPILE) -o /dev/null -S ${CHK_SOURCES} || true
508@end verbatim 508@end verbatim
509 509
510@node Flymake Implementation 510@node Flymake Implementation
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 37b7e49dea4..48d35598b72 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -66,7 +66,10 @@
66 :type 'integer) 66 :type 'integer)
67 67
68(defcustom flymake-proc-allowed-file-name-masks 68(defcustom flymake-proc-allowed-file-name-masks
69 '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-proc-simple-make-init) 69 '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'"
70 flymake-proc-simple-make-init
71 nil
72 flymake-proc-real-file-name-considering-includes)
70 ("\\.xml\\'" flymake-proc-xml-init) 73 ("\\.xml\\'" flymake-proc-xml-init)
71 ("\\.html?\\'" flymake-proc-xml-init) 74 ("\\.html?\\'" flymake-proc-xml-init)
72 ("\\.cs\\'" flymake-proc-simple-make-init) 75 ("\\.cs\\'" flymake-proc-simple-make-init)
@@ -419,12 +422,25 @@ Create parent directories as needed."
419 (condition-case-unless-debug err 422 (condition-case-unless-debug err
420 (cl-loop 423 (cl-loop
421 with (regexp file-idx line-idx col-idx message-idx) = pattern 424 with (regexp file-idx line-idx col-idx message-idx) = pattern
422 while (search-forward-regexp regexp nil t) 425 while (and
426 (search-forward-regexp regexp nil t)
427 ;; If the preceding search spanned more than one line,
428 ;; move to the start of the line we ended up in. This
429 ;; preserves the usefulness of the patterns in
430 ;; `flymake-proc-err-line-patterns', which were
431 ;; written primarily for flymake's original
432 ;; line-by-line parsing and thus never spanned
433 ;; multiple lines.
434 (if (/= (line-number-at-pos (match-beginning 0))
435 (line-number-at-pos))
436 (goto-char (line-beginning-position))
437 t))
423 for fname = (and file-idx (match-string file-idx)) 438 for fname = (and file-idx (match-string file-idx))
424 for message = (and message-idx (match-string message-idx)) 439 for message = (and message-idx (match-string message-idx))
425 for line-string = (and line-idx (match-string line-idx)) 440 for line-string = (and line-idx (match-string line-idx))
426 for line-number = (and line-string 441 for line-number = (or (and line-string
427 (string-to-number line-string)) 442 (string-to-number line-string))
443 1)
428 for col-string = (and col-idx (match-string col-idx)) 444 for col-string = (and col-idx (match-string col-idx))
429 for col-number = (and col-string 445 for col-number = (and col-string
430 (string-to-number col-string)) 446 (string-to-number col-string))
@@ -436,7 +452,7 @@ Create parent directories as needed."
436 fname))) 452 fname)))
437 for buffer = (and full-file 453 for buffer = (and full-file
438 (find-buffer-visiting full-file)) 454 (find-buffer-visiting full-file))
439 if (eq buffer (process-buffer proc)) 455 if (and (eq buffer (process-buffer proc)) message)
440 collect (with-current-buffer buffer 456 collect (with-current-buffer buffer
441 (pcase-let ((`(,beg . ,end) 457 (pcase-let ((`(,beg . ,end)
442 (flymake-diag-region line-number col-number))) 458 (flymake-diag-region line-number col-number)))
@@ -1030,6 +1046,13 @@ Use CREATE-TEMP-F for creating temp copy."
1030 '("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'") 1046 '("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'")
1031 "[ \t]*#[ \t]*include[ \t]*\"\\([[:word:]0-9/\\_.]*%s\\)\"")) 1047 "[ \t]*#[ \t]*include[ \t]*\"\\([[:word:]0-9/\\_.]*%s\\)\""))
1032 1048
1049(defun flymake-proc-real-file-name-considering-includes (scraped)
1050 (flymake-proc-get-real-file-name
1051 (let ((case-fold-search t))
1052 (replace-regexp-in-string "^in file included from[ \t*]"
1053 ""
1054 scraped))))
1055
1033;;;; .java/make specific 1056;;;; .java/make specific
1034(defun flymake-proc-simple-make-java-init () 1057(defun flymake-proc-simple-make-java-init ()
1035 (flymake-proc-simple-make-init-impl 'flymake-proc-create-temp-with-folder-structure nil nil "Makefile" 'flymake-proc-get-make-cmdline)) 1058 (flymake-proc-simple-make-init-impl 'flymake-proc-create-temp-with-folder-structure nil nil "Makefile" 'flymake-proc-get-make-cmdline))
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 282727e315d..285ef93db62 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -248,9 +248,10 @@ verify FILTER, sort them by COMPARE (using KEY)."
248(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1") 248(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1")
249(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1") 249(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1")
250 250
251(defun flymake-diag-region (line col) 251(defun flymake-diag-region (line &optional col)
252 "Compute region (BEG . END) corresponding to LINE and COL. 252 "Compute region (BEG . END) corresponding to LINE and COL.
253Or nil if the region is invalid." 253If COL is nil, return a region just for LINE.
254Return nil if the region is invalid."
254 (condition-case-unless-debug _err 255 (condition-case-unless-debug _err
255 (let ((line (min (max line 1) 256 (let ((line (min (max line 1)
256 (line-number-at-pos (point-max) 'absolute)))) 257 (line-number-at-pos (point-max) 'absolute))))
@@ -267,13 +268,18 @@ Or nil if the region is invalid."
267 (if (eq (point) beg) 268 (if (eq (point) beg)
268 (line-beginning-position 2) 269 (line-beginning-position 2)
269 (point))))) 270 (point)))))
270 (if col 271 (if (and col (cl-plusp col))
271 (let* ((beg (progn (forward-char (1- col)) (point))) 272 (let* ((beg (progn (forward-char (1- col))
273 (point)))
272 (sexp-end (ignore-errors (end-of-thing 'sexp))) 274 (sexp-end (ignore-errors (end-of-thing 'sexp)))
273 (end (or sexp-end 275 (end (or (and sexp-end
274 (fallback-eol beg)))) 276 (not (= sexp-end beg))
275 (cons (if sexp-end beg (fallback-bol)) 277 sexp-end)
276 end)) 278 (ignore-errors (goto-char (1+ beg)))))
279 (safe-end (or end
280 (fallback-eol beg))))
281 (cons (if end beg (fallback-bol))
282 safe-end))
277 (let* ((beg (fallback-bol)) 283 (let* ((beg (fallback-bol))
278 (end (fallback-eol beg))) 284 (end (fallback-eol beg)))
279 (cons beg end)))))) 285 (cons beg end))))))
diff --git a/test/lisp/progmodes/flymake-resources/Makefile b/test/lisp/progmodes/flymake-resources/Makefile
index 0f3f39791c8..494407567f2 100644
--- a/test/lisp/progmodes/flymake-resources/Makefile
+++ b/test/lisp/progmodes/flymake-resources/Makefile
@@ -1,6 +1,6 @@
1# Makefile for flymake tests 1# Makefile for flymake tests
2 2
3CC_OPTS = -Wall 3CC_OPTS = -Wall -Wextra
4 4
5## Recent gcc (e.g. 4.8.2 on RHEL7) can automatically colorize their output, 5## Recent gcc (e.g. 4.8.2 on RHEL7) can automatically colorize their output,
6## which can confuse flymake. Set GCC_COLORS to disable that. 6## which can confuse flymake. Set GCC_COLORS to disable that.
@@ -8,6 +8,6 @@ CC_OPTS = -Wall
8## normally use flymake, so it seems like just avoiding the issue 8## normally use flymake, so it seems like just avoiding the issue
9## in this test is fine. Set flymake-log-level to 3 to investigate. 9## in this test is fine. Set flymake-log-level to 3 to investigate.
10check-syntax: 10check-syntax:
11 GCC_COLORS= $(CC) $(CC_OPTS) ${CHK_SOURCES} 11 GCC_COLORS= $(CC) $(CC_OPTS) ${CHK_SOURCES} || true
12 12
13# eof 13# eof
diff --git a/test/lisp/progmodes/flymake-resources/errors-and-warnings.c b/test/lisp/progmodes/flymake-resources/errors-and-warnings.c
index 6454dd20236..1d38bd6bd27 100644
--- a/test/lisp/progmodes/flymake-resources/errors-and-warnings.c
+++ b/test/lisp/progmodes/flymake-resources/errors-and-warnings.c
@@ -1,10 +1,13 @@
1 int main() 1/* Flymake should notice an error on the next line, since
2 that file has at least one warning.*/
3#include "some-problems.h"
4/* But not this one */
5#include "no-problems.h"
6
7int main()
2{ 8{
3 char c = 1000; 9 char c = 1000; /* a note and a warning */
4 int bla; 10 int bla;
5 /* The following line should have one warning and one error. The 11 char c; if (bla == (void*)3); /* an error, and two warnings */
6 warning spans the full line because gcc (at least 6.3.0) points
7 places the error at the =, which isn't a sexp.*/
8 char c; if (bla == (void*)3);
9 return c; 12 return c;
10} 13}
diff --git a/test/lisp/progmodes/flymake-resources/no-problems.h b/test/lisp/progmodes/flymake-resources/no-problems.h
new file mode 100644
index 00000000000..19ddc615b32
--- /dev/null
+++ b/test/lisp/progmodes/flymake-resources/no-problems.h
@@ -0,0 +1 @@
typedef int no_problems;
diff --git a/test/lisp/progmodes/flymake-resources/some-problems.h b/test/lisp/progmodes/flymake-resources/some-problems.h
new file mode 100644
index 00000000000..165d8dd525e
--- /dev/null
+++ b/test/lisp/progmodes/flymake-resources/some-problems.h
@@ -0,0 +1,5 @@
1#include <stdio.h>
2
3strange;
4
5sint main();
diff --git a/test/lisp/progmodes/flymake-tests.el b/test/lisp/progmodes/flymake-tests.el
index fa77a9a8ae6..222c8f11848 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -122,14 +122,34 @@ SEVERITY-PREDICATE is used to setup
122 (flymake-tests--with-flymake 122 (flymake-tests--with-flymake
123 ("errors-and-warnings.c") 123 ("errors-and-warnings.c")
124 (flymake-goto-next-error) 124 (flymake-goto-next-error)
125 (should (eq 'flymake-error (face-at-point)))
126 (flymake-goto-next-error)
125 (should (eq 'flymake-note (face-at-point))) 127 (should (eq 'flymake-note (face-at-point)))
126 (flymake-goto-next-error) 128 (flymake-goto-next-error)
127 (should (eq 'flymake-warning (face-at-point))) 129 (should (eq 'flymake-warning (face-at-point)))
128 (flymake-goto-next-error) 130 (flymake-goto-next-error)
131 (should (eq 'flymake-error (face-at-point)))
132 (flymake-goto-next-error)
133 (should (eq 'flymake-warning (face-at-point)))
134 (flymake-goto-next-error)
135 (should (eq 'flymake-warning (face-at-point)))
136 (let ((flymake-wrap-around nil))
137 (should-error (flymake-goto-next-error nil nil t))) ))
138
139(ert-deftest included-c-header-files ()
140 "Test inclusion of .h header files."
141 (skip-unless (and (executable-find "gcc") (executable-find "make")))
142 (flymake-tests--with-flymake
143 ("some-problems.h")
144 (flymake-goto-next-error)
129 (should (eq 'flymake-warning (face-at-point))) 145 (should (eq 'flymake-warning (face-at-point)))
130 (flymake-goto-next-error) 146 (flymake-goto-next-error)
131 (should (eq 'flymake-error (face-at-point))) 147 (should (eq 'flymake-error (face-at-point)))
132 (let ((flymake-wrap-around nil)) 148 (let ((flymake-wrap-around nil))
149 (should-error (flymake-goto-next-error nil nil t))) )
150 (flymake-tests--with-flymake
151 ("no-problems.h")
152 (let ((flymake-wrap-around nil))
133 (should-error (flymake-goto-next-error nil nil t))) )) 153 (should-error (flymake-goto-next-error nil nil t))) ))
134 154
135(defmacro flymake-tests--assert-set (set 155(defmacro flymake-tests--assert-set (set