This is the mail archive of the gcc@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]

simple-declaration (was: Re: On inlining in C++)


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


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