Bug 18368 - [3.4 Regression] C++ error message regression
[3.4 Regression] C++ error message regression
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
3.4.0
: P2 normal
: 3.4.5
Assigned To: Volker Reichelt
http://gcc.gnu.org/ml/gcc-patches/200...
: diagnostic, patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-08 04:44 UTC by Chris Lattner
Modified: 2005-10-05 15:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-28 00:46:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2004-11-08 04:44:58 UTC
On this c++ code:

struct C {
  struct foo { int A; }
  void method();
};

G++ 3.4 and above print the useless error message:

t.cpp:3: error: new types may not be defined in a return type
t.cpp:3: error: two or more data types in declaration of `method'

G++ 3.3 prints something like this (which is actually useful):

t.cpp:2: error: semicolon missing after declaration of `foo'
t.cpp:2: error: ISO C++ forbids defining types within return type
t.cpp:2: error: two or more data types in declaration of `method'
t.cpp:2: error: semicolon missing after declaration of `struct foo'

This probably also happens at global scope.

-Chris
Comment 1 Daniel Berlin 2004-11-08 04:47:56 UTC
Subject: Re:  New: C++ error message regression


Yes, it happens ta global scope too.

struct foo {}
void method () {}
will give the same error

On Sun, 8 Nov 2004, sabre at nondot dot org wrote:

> On this c++ code:
>
> struct C {
>  struct foo { int A; }
>  void method();
> };
> This probably also happens at global scope.
> -Chris
Comment 2 Andrew Pinski 2004-11-08 04:55:37 UTC
Confirmed, but the error message to me is clear (maybe I have read the error message too much).
When I said there was most likely a dup, I was thinking of a related case, see PR 16189.
Comment 3 CVS Commits 2004-11-29 20:10:48 UTC
Subject: Bug 18368

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-11-29 20:10:18

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog cp-tree.def cp-tree.h decl.c error.c 
	                 friend.c parser.c pt.c 
	gcc/testsuite/g++.old-deja/g++.brendan: crash16.C 
	gcc/testsuite/g++.old-deja/g++.law: ctors5.C 
	gcc/testsuite/g++.old-deja/g++.other: crash25.C 
Added files:
	gcc/testsuite/g++.dg/template: error16.C crash29.C 

Log message:
	PR c++/18368
	* parser.c (cp_parser_check_for_definition_in_return_type): Take
	the defined type as a parameter, and inform the user about the
	possibility of a missing semicolon.
	(cp_parser_explicit_instantiation): Adjust call to
	cp_parser_check_for_definition_in_return_type.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_member_declaration): Likewise.
	
	PR c++/18674
	* cp-tree.def (TYPENAME_TYPE): Remove discussion of implicit
	typename from comments.
	* cp-tree.h (TYPENAME_IS_ENUM_P): New macro.
	(TYPENAME_IS_CLASS_P): Likewise.
	(make_typename_type): Change prototype.
	* decl.c (struct_typename_info): New type.
	(typename_compare): Expect the second argument to be a
	typename_info, not a tree.
	(build_typename_type): Add tag_type parameter.  Do not create a
	new type until necessary.
	(make_typename_type): Add tag_type parameter.
	* error.c (TYPENAME_TYPE): Print tags other than "typename" if
	appropriate.
	* friend.c (make_friend_class): Adjust call to make_typename_type.
	* parser.c (cp_parser_make_typename_type): Likewise.
	(cp_parser_primary_expression): Adjust call to
	cp_parser_lookup_name.
	(cp_parser_unqualified_id): Adjust calls to cp_parser_class_name.
	(cp_parser_class_or_namespace_name): Likewise.
	(cp_parser_postfix_expression): Adjust calls to
	make_typename_type.
	(cp_parser_mem_initializer_id): Adjust calls to
	cp_parser_class_name.
	(cp_parser_type_parameter): Adjust calls to cp_parser_lookup_name.
	(cp_parser_template_name): Likewise.
	(cp_parser_template_argument): Likewise.
	(cp_parser_type_name): Adjust call to cp_parser_class_name.
	(cp_parser_elaborated_type_specifier): Adjust calls to
	make_typename_type and cp_parser_lookup_name.
	(cp_parser_namespace_name): Likewise.
	(cp_parser_class_name): Replace type_p parameter with tag_type.
	Adjust calls to make_typename_type and cp_parser_lookup_name.
	(cp_parser_class_head): Adjust calls to cp_parser_class_name.
	(cp_parser_base_specifier): Likewise.
	(cp_parser_lookup_name): Replace is_type parameter with tag_type.
	Adjust calls to make_typename_type and lookup_qualified_name.
	(cp_parser_lookup_name_simple): Adjust call to
	cp_parser_lookup_name.
	(cp_parser_constructor_declarator_p): Adjust call to
	cp_parser_class_name.
	* pt.c (convert_template_argument): Adjust all to
	make_typename_type.
	(tsubst_decl): Do not pre-substitute the type of the declaration.
	(tsubst): Hand off declarations more quickly.  Adjust call to
	make_typename_type.
	
	PR c++/18512
	* parser.c (cp_parser_postfix_dot_deref_expression): Robustify.
	
	PR c++/18674
	* g++.old-deja/g++.brendan/crash16.C: Adjust error messages.
	* g++.old-deja/g++.law/ctors5.C: Likewise.
	* g++.old-deja/g++.other/crash25.C: Likewise.
	
	PR c++/18674
	* g++.dg/template/error16.C: New test.
	
	PR c++/18512
	* g++.dg/template/crash29.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4679&r2=1.4680
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error16.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash29.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4504&r2=1.4505
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.90&r2=1.91
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1076&r2=1.1077
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1336&r2=1.1337
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.272&r2=1.273
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/friend.c.diff?cvsroot=gcc&r1=1.102&r2=1.103
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.283&r2=1.284
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.951&r2=1.952
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.law/ctors5.C.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.other/crash25.C.diff?cvsroot=gcc&r1=1.6&r2=1.7

Comment 4 Mark Mitchell 2004-11-29 20:23:32 UTC
Fixed in 4.0.
Comment 5 Volker Reichelt 2005-09-01 14:56:00 UTC
Taking care of the backport to the 3.4 branch.
Comment 6 CVS Commits 2005-09-17 21:57:32 UTC
Subject: Bug 18368

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	reichelt@gcc.gnu.org	2005-09-17 21:57:26

Modified files:
	gcc/cp         : ChangeLog parser.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/other: semicolon.C 

Log message:
	Backport:
	
	2004-11-27  Mark Mitchell  <mark@codesourcery.com>
	PR c++/18368
	* parser.c (cp_parser_check_for_definition_in_return_type): Take
	the defined type as a parameter, and inform the user about the
	possibility of a missing semicolon.
	(cp_parser_explicit_instantiation): Adjust call to
	cp_parser_check_for_definition_in_return_type.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_member_declaration): Likewise.
	
	PR c++/18368
	* g++.dg/other/semicolon.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.241&r2=1.3892.2.242
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.62&r2=1.157.2.63
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.435&r2=1.3389.2.436
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/semicolon.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 7 CVS Commits 2005-09-17 22:05:49 UTC
Subject: Bug 18368

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	reichelt@gcc.gnu.org	2005-09-17 22:05:39

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/other: semicolon.C 

Log message:
	PR c++/18368
	* g++.dg/other/semicolon.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6073&r2=1.6074
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/semicolon.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 8 Volker Reichelt 2005-09-17 22:07:47 UTC
This is now fixed also on the 3.4 branch.
Testcase applied to 3.4 branch and mainline.
Waiting for the 4.0 branch to thaw before committing testcase there.
Keeping PR open until testcase is committed to 4.0 branch.
Comment 9 CVS Commits 2005-10-05 15:49:53 UTC
Subject: Bug 18368

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	reichelt@gcc.gnu.org	2005-10-05 15:49:50

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/other: semicolon.C 

Log message:
	PR c++/18368
	* g++.dg/other/semicolon.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.430&r2=1.5084.2.431
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/semicolon.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.10.1

Comment 10 Volker Reichelt 2005-10-05 15:50:40 UTC
Testcase now also on the 4.0 branch.