This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ patch] report better diagnostic for static following '[' in parameter declaration


Hi,
For the test-case,
void f(int a[static 10]);

g++ gives following errors:
test-foo.cpp:1:14: error: expected primary-expression before âstaticâ
 void f(int a[static 10]);
              ^
test-foo.cpp:1:14: error: expected â]â before âstaticâ
test-foo.cpp:1:14: error: expected â)â before âstaticâ
test-foo.cpp:1:14: error: expected initializer before âstaticâ

and clang++ gives:
test-foo.cpp:1:13: error: static array size is a C99 feature, not
permitted in C++
void f(int a[static 10]);
            ^
I have attached patch that attempts to report the same diagnostic.
With patch, g++ reports:

test-foo.cpp:1:14: error: static array size is a C99 feature,not
permitted in C++
 void f(int a[static 10])
              ^~~~~~
test-foo.cpp:1:14: error: expected â]â before âstaticâ
test-foo.cpp:1:14: error: expected â)â before âstaticâ
test-foo.cpp:1:14: error: expected initializer before âstaticâ

I tried to remove the 3 errors that follow it (expected X before static)
but without luck :/

Bootstrap and tested on x86_64-unknown-linux-gnu.
OK for trunk ?

Thanks,
Prathamesh

Attachment: cpp-static-error.diff
Description: Text document

Attachment: ChangeLog
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]