Bug 32384 - [4.2 regression] Pseudo-dtor in template class rejected
Summary: [4.2 regression] Pseudo-dtor in template class rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL:
Keywords: monitored, rejects-valid
Depends on: 35138
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-17 23:10 UTC by Volker Reichelt
Modified: 2009-03-30 22:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.5
Last reconfirmed: 2007-10-31 12:31:17


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-06-17 23:10:49 UTC
The following valid code snippet is rejected since GCC 3.4.0:

=====================================================
template<typename> struct A
{
  typedef int T;
  T foo();

  A() { foo().~T(); }
};

A<int> a;
=====================================================

The error message is:
bug.cc: In constructor 'A< <template-parameter-1-1> >::A()':
bug.cc:6: error: expected class-name before '(' token

The code compiles if A is a non-template class, or if I remove the typedef
and call the anonymous template parameter "T" instead.
Comment 1 Jakub Jelinek 2007-10-31 12:31:17 UTC
Testing a patch.
Comment 2 Jakub Jelinek 2007-11-01 22:54:48 UTC
Subject: Bug 32384

Author: jakub
Date: Thu Nov  1 22:54:39 2007
New Revision: 129836

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129836
Log:
	PR c++/32384
	* parser.c (cp_parser_postfix_dot_deref_expression): If
	POSTFIX_EXPRESSION is type dependent, try to parse it as pseudo dtor
	first and if that succeeds and type is SCALAR_TYPE_P, create
	PSEUDO_DTOR_EXPR.

	* g++.dg/template/pseudodtor1.C: New test.
	* g++.dg/template/pseudodtor2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/pseudodtor1.C
    trunk/gcc/testsuite/g++.dg/template/pseudodtor2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jakub Jelinek 2007-11-01 23:10:09 UTC
Fixed on the trunk so far.
Comment 4 Joseph S. Myers 2008-07-04 22:13:39 UTC
Closing 4.1 branch.
Comment 5 Joseph S. Myers 2009-03-30 22:07:51 UTC
Closing 4.2 branch, fixed in 4.3.