Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(flycheck-fold-include-levels): Find include file first, then find next #783

Closed
wants to merge 1 commit into from

Conversation

@xwl
Copy link
Contributor

commented Nov 7, 2015

error in the same file.

gcc(e.g, 4.8.3, 4.9.1) sometimes seems not printing included files
immediately after error. Here is a small testcase:
// foo.cpp
#include "foo.h"
int main(int argc, char *argv[]) {
CHECK(Hi::b);
xx;
}

// foo.h
namespace Hi { int a; };
#define CHECK(arg) arg

gcc gives below errors:
In file included from foo.cpp:1:0:
foo.cpp: In function ‘int main(int, char**)’:
foo.cpp:6:11: error: ‘b’ is not a member of ‘Hi’
CHECK(Hi::b);
^
foo.h:5:20: note: in definition of macro ‘CHECK’
#define CHECK(arg) arg
^
foo.cpp:8:5: error: ‘xx’ was not declared in this scope
xx;
^
flycheck will complain:
Error from syntax checker c/c++-gcc: Undefined error level: nil

@lunaryorn

This comment has been minimized.

Copy link
Contributor

commented Nov 8, 2015

@xwl Sorry, but I have a hard time to understand what this PR is supposed to fix. Please edit your original post to fix the formatting and provide more details.

@xwl

This comment has been minimized.

Copy link
Contributor Author

commented Nov 8, 2015

Actually I explain in the commit message, the content here is auto formated by github. Can you look at this commit message, which has the original format: xwl@72072a4

I give a testcase there, the error message generated by gcc can't be correctly parsed by flycheck.

flycheck.el Outdated
(car remaining-errors))
current-filename)))
(progn
(setq filename (flycheck-error-filename (car remaining-errors)))

This comment has been minimized.

Copy link
@lunaryorn

lunaryorn Nov 8, 2015

Contributor

Well, I do not really like this pattern of setting variables in conditions of while. I know that it's somewhat common in Emacs Lisp, but do you think that we could refactor this to not change a variable here? It's just easier to understand.

This comment has been minimized.

Copy link
@lunaryorn

lunaryorn Nov 8, 2015

Contributor

But if it's too complex, I'll merge this code as well.

This comment has been minimized.

Copy link
@xwl

xwl Nov 8, 2015

Author Contributor

It can be improved. I will update.

@lunaryorn

This comment has been minimized.

Copy link
Contributor

commented Nov 8, 2015

@xwl Ah, I see, thanks for explaining.

(flycheck-fold-include-levels): Find include file first, then find next
error in the same file.

gcc(e.g, 4.8.3, 4.9.1) sometimes seems not printing included files
immediately after error. Here is a small testcase:
	// foo.cpp
	#include "foo.h"
	int main(int argc, char *argv[]) {
	    CHECK(Hi::b);
	    xx;
	}

	// foo.h
	namespace Hi { int a; };
	#define CHECK(arg) arg

gcc gives below errors:
	In file included from foo.cpp:1:0:
	foo.cpp: In function ‘int main(int, char**)’:
	foo.cpp:6:11: error: ‘b’ is not a member of ‘Hi’
	     CHECK(Hi::b);
		   ^
	foo.h:5:20: note: in definition of macro ‘CHECK’
	 #define CHECK(arg) arg
			    ^
	foo.cpp:8:5: error: ‘xx’ was not declared in this scope
	     xx;
	     ^
flycheck will complain:
    Error from syntax checker c/c++-gcc: Undefined error level: nil

@xwl xwl force-pushed the xwl:fix-flycheck-fold-include-levels branch from 72072a4 to bedf298 Nov 8, 2015

@xwl

This comment has been minimized.

Copy link
Contributor Author

commented Nov 8, 2015

i did a force push: xwl@bedf298

@lunaryorn lunaryorn self-assigned this Nov 23, 2015

@lunaryorn lunaryorn closed this in 104d704 Nov 23, 2015

@lunaryorn lunaryorn removed the ready label Nov 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.