Bug 51184 - Abstract class in function return type
Summary: Abstract class in function return type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 minor
Target Milestone: 4.8.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-17 05:08 UTC by Ai Azuma
Modified: 2012-05-21 15:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-11-25 00:00:00


Attachments
Outputs by -v option and preprocessed source. (1.18 KB, text/plain)
2011-11-17 05:08 UTC, Ai Azuma
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ai Azuma 2011-11-17 05:08:12 UTC
Created attachment 25842 [details]
Outputs by -v option and preprocessed source.

An abstract class shall not be used as a function return type. However, GCC 4.7-20111112 accepts the following code.


///////////////////////
template<typename T>
struct S{};

struct A
{
  virtual void f() = 0;
};

int main()
{
  S<A(int)> s;
}
///////////////////////
Comment 1 Paolo Carlini 2011-11-25 01:24:33 UTC
On it.
Comment 2 Richard Biener 2012-03-22 08:26:53 UTC
GCC 4.7.0 is being released, adjusting target milestone.
Comment 3 paolo@gcc.gnu.org 2012-05-21 15:12:22 UTC
Author: paolo
Date: Mon May 21 15:12:13 2012
New Revision: 187720

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187720
Log:
/cp
2012-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51184
	* decl.c (grokdeclarator): Diagnose functions returning abstract
	class types as TYPENAME.
	* cp-tree.h (ABSTRACT_CLASS_TYPE_P): Add.
	* except.c (is_admissible_throw_operand_or_catch_parameter): Use it.
	* pt.c (tsubst): Likewise.
	* semantics.c (trait_expr_value): Likewise.

/testsuite
2012-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51184
	* g++.dg/other/abstract4.C: New-

/cp
2012-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/40821
	* parser.c (cp_parser_attributes_opt): Enforce error checking of
	unbalanced parentheses in the presence of tentative parsing.

/testsuite
2012-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/40821
	* g++.dg/ext/attrib46.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/ext/attrib46.C
    trunk/gcc/testsuite/g++.dg/other/abstract4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/except.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2012-05-21 15:15:04 UTC
Done.