Bug 49129 - confusing diagnostic for missing semi-colon after member template
Summary: confusing diagnostic for missing semi-colon after member template
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 enhancement
Target Milestone: ---
Assignee: David Malcolm
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2011-05-23 18:14 UTC by Jonathan Wakely
Modified: 2021-06-01 09:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2011-05-23 18:14:20 UTC
typedef int I;

struct X
{
  template<class> struct Y { }  // oops, missing ';'

  static I f();
};

expinit.cc:7:12: error: expected initializer before ‘f’


If f returns 'int' instead of a typedef then the error is good:
expinit.cc:5:30: error: expected ‘;’ after struct definition

If X::Y is not a template then the error is good:
expinit.cc:7:10: error: expected ‘;’ at end of member declaration
expinit.cc:7:14: error: ISO C++ forbids declaration of ‘f’ with no type [-fpermissive]
Comment 1 Nathan Froyd 2011-05-24 13:30:16 UTC
I believe I tried to do that at one point; you can see the comment in cp/parser.c:class_specifier_1 about handling user-defined types.  I might not have been clever enough, though.  It'd certainly be helpful.
Comment 2 Andrew Pinski 2011-07-24 20:52:32 UTC
Confirmed.
Comment 3 Jonathan Wakely 2018-03-16 11:31:46 UTC
Since GCC 6.1 the error is slightly better, although it suggests putting the semi-colon in the wrong place:

tm.cc:7:3: error: a storage class can only be specified for objects and functions
   static I f();
   ^~~~~~
tm.cc:7:9: error: expected ';' before 'I'
   static I f();
         ^~
         ;
Comment 4 Jakub Jelinek 2019-05-03 09:18:31 UTC
GCC 9.1 has been released.
Comment 5 Jakub Jelinek 2019-08-12 08:58:14 UTC
GCC 9.2 has been released.
Comment 6 Eric Gallager 2019-08-12 19:06:51 UTC
ASSIGNED due to assignee
Comment 7 Jakub Jelinek 2020-03-12 11:58:36 UTC
GCC 9.3.0 has been released, adjusting target milestone.
Comment 8 Richard Biener 2021-06-01 08:05:18 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 9 Jonathan Wakely 2021-06-01 09:15:40 UTC
Clearing target milestone, I don't think Dave is going to fix this on the branches.