llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.69k stars 11.87k forks source link

redundant error on same undeclared identifier #17383

Open llvmbot opened 11 years ago

llvmbot commented 11 years ago
Bugzilla Link 17009
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @EdSchouten

Extended Description

Testcase: void f() { return x+x+x+x; }

Do we really need to print out a use of undeclared identifier on each use of 'x'? Could we at least batch them by inner-most scope, if not by nearest declcontext?

$ echo 'void f() { return x+x+x+x; }' | llvm/Debug+Asserts/bin/clang -x c -

:1:19: error: use of undeclared identifier 'x' void f() { return x+x+x+x; } ^ :1:21: error: use of undeclared identifier 'x' void f() { return x+x+x+x; } ^ :1:23: error: use of undeclared identifier 'x' void f() { return x+x+x+x; } ^ :1:25: error: use of undeclared identifier 'x' void f() { return x+x+x+x; } ^ 4 errors generated.
EdSchouten commented 8 years ago

This is also massively annoying when using C11's _Generic() keyword:

include

define cos(x) _Generic(x, float: cosf, double: cos, long double: cosl)(x)

int main() { cos(banana); }

bla.c:6:7: error: use of undeclared identifier 'banana' cos(banana); ^ bla.c:3:25: note: expanded from macro 'cos'

define cos(x) _Generic(x, float: cosf, double: cos, long double: cosl)(x)

                    ^

bla.c:6:7: error: use of undeclared identifier 'banana' bla.c:3:73: note: expanded from macro 'cos'

define cos(x) _Generic(x, float: cosf, double: cos, long double: cosl)(x)

                                                                    ^

2 errors generated.