Ticket #6134: Improve the mechanism differentiating template declarations from template definitions.

Hi,

This ticket is an infinite loop upon invalid code, that's due to the code differentiating template declarations from definitions only concluding from the presence of a { or ; regardless of whether we're in parameters list of not. This patch fixes this, and the ticket as well. Thanks to consider merging.

Cheers,
  Simon