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]

parameter attributes placement



               Hi again.

        Here's another weirdness with attribute placement: if you want to
declare that a function parameter is meant to be possibly unused, you do that
in the function definition. Fine. However, consider the following piece of
code:

 ,----
| void foo (int i __attribute__ ((__unused__)));
| 
| /* ... */
| 
| void foo (int i)
| {
| }
| 
| int main (int argc, char *argv[])
| {
|   foo (2);
| 
|   return 0;
| }
`-----

        Several misbehaviors (IMHO) occur:

- gcc doesn't signal that the attribute is not placed where it should be. It
  silently accepts the prototype (consider the preceding case (with function):
  you got a parse error in the equivalent situation.

- gcc forgets about the prototype, and you get the unexpected warning about an
  unused parameter in the function definition. It would be better to remember
  the attribute, or at least, to signal a prototype mismatch.

Comments ?


-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-BicÍtre, France   Fax.+33 (1) 44 08 01 99   didier@xemacs.org


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