simple-declaration (was: Re: On inlining in C++)
Gabriel Dos Reis
gdr@integrable-solutions.net
Tue Aug 5 12:06:00 GMT 2003
Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
| Maybe
|
| void g(int i) {
| inline void (&f_inline)(int) = f;
| f_inline(5);
| f(i);
| }
|
| yields
|
| inline2.cpp: In function `void g(int)':
| inline2.cpp:5: `f_inline' declared as an `inline' variable
|
| shouldnt an inline variable declaration look like
|
| void (inline &f_inline)(int) = f;
|
| ? So the warning is bogous... (but of course this aint C++ either).
Since the notion of "inline variable" does not exist in C++, either
way is bogus :-)
The declaration
inline void (&f_inline)(int) = f;
can be broken into three parts:
(1) the decl-specifier-seq: "inline void"
(2) the declarator: "(&f_inline)(int)
(3) the initializer: "= f"
The first part can further be broken into
(1.a) the function-specifier: "inline"
(1.b) the type-specifier: "void"
C++ rules that a function-specifier can be used only for function
declarations.
Therefore, the diagnostic message could pedantically read:
'inline' cannot be used as a decl-specifier in a declaration that
does not declare a function.
-- Gaby
More information about the Gcc
mailing list