Bug 38313 - g++ fails to parse a member function with a parenthesized type name as its declarator
Summary: g++ fails to parse a member function with a parenthesized type name as its de...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-11-28 21:17 UTC by Jason Merrill
Modified: 2013-11-04 00:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3
Known to fail: 3.4.6, 4.1.3, 4.2.2, 4.3.3, 4.4.0
Last reconfirmed: 2008-11-28 21:18:14


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Merrill 2008-11-28 21:17:10 UTC
This testcase:

struct foo { };
struct bar { };

struct baz {
  static foo (bar)();
};

confuses cp_parser_constructor_declarator_p, which just looks as far as foo (bar) before deciding incorrectly that this is a constructor declarator.

This is related to PR 38278, but is a much older issue; it fails as far back as 3.4, though 3.2 seems to accept it.
Comment 1 Paolo Carlini 2013-11-03 16:55:49 UTC
Mine.
Comment 2 paolo@gcc.gnu.org 2013-11-03 23:49:44 UTC
Author: paolo
Date: Sun Nov  3 23:49:41 2013
New Revision: 204339

URL: http://gcc.gnu.org/viewcvs?rev=204339&root=gcc&view=rev
Log:
/cp
2013-11-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/38313
	* parser.c (cp_parser_constructor_declarator_p): Check that the
	class-name matches current_class_type.

/testsuite
2013-11-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/38313
	* g++.dg/lookup/name-clash10.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/lookup/name-clash10.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2013-11-03 23:51:02 UTC
Fixed for 4.9.0.