public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31489] error says struct when it should say class
[not found] <bug-31489-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-27 10:15 ` paolo.carlini at oracle dot com
2011-09-27 21:57 ` paolo at gcc dot gnu.org
2011-09-27 22:06 ` paolo.carlini at oracle dot com
2 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-27 10:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31489
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-27 10:06:09 UTC ---
I just discovered that actually we *do* have machinery to do this, in general
terms (see CLASSTYPE_DECLARED_CLASS, used by eg, class_key_or_enum_as_string).
But cp_parser_elaborated_type_specifier doesn't use it, ie doesn't set
CLASSTYPE_DECLARED_CLASS (at variance with cp_parser_class_head). Thus
something like the following patchlet should do the trick. That said, Andrew
has a point of course, for its second example we would say struct or class,
whichever comes last in the redeclaration. All in all, seems an improvement to
me, if the below works pretty well I'm going to submit it.
/////////////
Index: parser.c
===================================================================
--- parser.c (revision 179242)
+++ parser.c (working copy)
@@ -13423,8 +13423,15 @@ cp_parser_elaborated_type_specifier (cp_parser* pa
}
if (tag_type != enum_type)
- cp_parser_check_class_key (tag_type, type);
+ {
+ /* Indicate whether this class was declared as a `class' or as a
+ `struct'. */
+ if (TREE_CODE (type) == RECORD_TYPE)
+ CLASSTYPE_DECLARED_CLASS (type) = (tag_type == class_type);
+ cp_parser_check_class_key (tag_type, type);
+ }
+
/* A "<" cannot follow an elaborated type specifier. If that
happens, the user was probably trying to form a template-id. */
cp_parser_check_for_invalid_template_id (parser, type, token->location);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/31489] error says struct when it should say class
[not found] <bug-31489-4@http.gcc.gnu.org/bugzilla/>
2011-09-27 10:15 ` [Bug c++/31489] error says struct when it should say class paolo.carlini at oracle dot com
@ 2011-09-27 21:57 ` paolo at gcc dot gnu.org
2011-09-27 22:06 ` paolo.carlini at oracle dot com
2 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-09-27 21:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31489
--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-09-27 21:52:23 UTC ---
Author: paolo
Date: Tue Sep 27 21:52:19 2011
New Revision: 179293
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179293
Log:
/cp
2011-09-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31489
* parser.c (cp_parser_elaborated_type_specifier): For RECORD_TYPE,
set CLASSTYPE_DECLARED_CLASS.
/testsuite
2011-09-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/31489
* g++.dg/parse/error40.C: New.
* g++.dg/warn/incomplete1.C: Adjust.
Added:
trunk/gcc/testsuite/g++.dg/parse/error40.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/warn/incomplete1.C
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/31489] error says struct when it should say class
[not found] <bug-31489-4@http.gcc.gnu.org/bugzilla/>
2011-09-27 10:15 ` [Bug c++/31489] error says struct when it should say class paolo.carlini at oracle dot com
2011-09-27 21:57 ` paolo at gcc dot gnu.org
@ 2011-09-27 22:06 ` paolo.carlini at oracle dot com
2 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-27 22:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31489
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
CC|gcc-bugs at gcc dot gnu.org |
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-27 21:54:26 UTC ---
Fixed for 4.7.0.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/31489] error says struct when it should say class
2007-04-05 22:50 [Bug c++/31489] New: " jg at jguk dot org
2007-04-05 23:09 ` [Bug c++/31489] " pinskia at gcc dot gnu dot org
@ 2007-04-07 15:23 ` bangerth at dealii dot org
1 sibling, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2007-04-07 15:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2007-04-07 16:23 -------
Confirmed.
I think a patch would be of interest. Maybe one could just tweak
the error to read
x.cc:5: error: invalid use of undefined type 'foobar'
x.cc:1: error: forward declaration of struct or class 'foobar'
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-04-07 16:23:28
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31489
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/31489] error says struct when it should say class
2007-04-05 22:50 [Bug c++/31489] New: " jg at jguk dot org
@ 2007-04-05 23:09 ` pinskia at gcc dot gnu dot org
2007-04-07 15:23 ` bangerth at dealii dot org
1 sibling, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-05 23:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-04-06 00:09 -------
I don't think this matters anyways as class == struct and can be used
interchangably for tags.
if you summit a patch, see what this shows you:
struct foobar;
int main()
{
foobar * o = new foobar;
}
Or even this:
struct foobar;
class foobar;
int main()
{
foobar * o = new foobar;
}
Since all three are the same code, so it is weird not to have struct == class
here really.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31489
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-27 21:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-31489-4@http.gcc.gnu.org/bugzilla/>
2011-09-27 10:15 ` [Bug c++/31489] error says struct when it should say class paolo.carlini at oracle dot com
2011-09-27 21:57 ` paolo at gcc dot gnu.org
2011-09-27 22:06 ` paolo.carlini at oracle dot com
2007-04-05 22:50 [Bug c++/31489] New: " jg at jguk dot org
2007-04-05 23:09 ` [Bug c++/31489] " pinskia at gcc dot gnu dot org
2007-04-07 15:23 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).