mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-02 05:50:26 +08:00
re PR c++/34267 (ICE applying __decltype to name of template class)
PR c++/34267 PR c++/34268 * parser.c (cp_parser_decltype): Don't call finish_id_expression on ~type. * semantics.c (finish_decltype_type): Issue error on types, TYPE_DECLs and ~type early. * g++.dg/cpp0x/decltype7.C: New test. * g++.dg/cpp0x/decltype8.C: New test. From-SVN: r130519
This commit is contained in:
parent
10650fbb88
commit
7a547b936c
@ -1,3 +1,12 @@
|
||||
2007-11-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/34267
|
||||
PR c++/34268
|
||||
* parser.c (cp_parser_decltype): Don't call finish_id_expression
|
||||
on ~type.
|
||||
* semantics.c (finish_decltype_type): Issue error on types, TYPE_DECLs
|
||||
and ~type early.
|
||||
|
||||
2007-11-27 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/34181
|
||||
|
@ -8512,10 +8512,12 @@ cp_parser_decltype (cp_parser *parser)
|
||||
/*check_dependency=*/true,
|
||||
/*ambiguous_decls=*/NULL);
|
||||
|
||||
if (expr
|
||||
if (expr
|
||||
&& expr != error_mark_node
|
||||
&& TREE_CODE (expr) != TEMPLATE_ID_EXPR
|
||||
&& TREE_CODE (expr) != TYPE_DECL
|
||||
&& (TREE_CODE (expr) != BIT_NOT_EXPR
|
||||
|| !TYPE_P (TREE_OPERAND (expr, 0)))
|
||||
&& cp_lexer_peek_token (parser->lexer)->type == CPP_CLOSE_PAREN)
|
||||
{
|
||||
/* Complete lookup of the id-expression. */
|
||||
|
@ -4066,6 +4066,15 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p)
|
||||
if (!expr || error_operand_p (expr))
|
||||
return error_mark_node;
|
||||
|
||||
if (TYPE_P (expr)
|
||||
|| TREE_CODE (expr) == TYPE_DECL
|
||||
|| (TREE_CODE (expr) == BIT_NOT_EXPR
|
||||
&& TYPE_P (TREE_OPERAND (expr, 0))))
|
||||
{
|
||||
error ("argument to decltype must be an expression");
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
if (type_dependent_expression_p (expr))
|
||||
{
|
||||
type = make_aggr_type (DECLTYPE_TYPE);
|
||||
|
@ -1,3 +1,10 @@
|
||||
2007-11-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/34267
|
||||
PR c++/34268
|
||||
* g++.dg/cpp0x/decltype7.C: New test.
|
||||
* g++.dg/cpp0x/decltype8.C: New test.
|
||||
|
||||
2007-11-29 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/34248
|
||||
|
14
gcc/testsuite/g++.dg/cpp0x/decltype7.C
Normal file
14
gcc/testsuite/g++.dg/cpp0x/decltype7.C
Normal file
@ -0,0 +1,14 @@
|
||||
// PR c++/34268
|
||||
// { dg-do compile }
|
||||
|
||||
struct A
|
||||
{
|
||||
__decltype (A); // { dg-error "must be an expression" }
|
||||
__decltype (~A); // { dg-error "must be an expression" }
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
__typeof__ (B);
|
||||
__typeof__ (~B); // { dg-error "expected primary-expression" }
|
||||
};
|
12
gcc/testsuite/g++.dg/cpp0x/decltype8.C
Normal file
12
gcc/testsuite/g++.dg/cpp0x/decltype8.C
Normal file
@ -0,0 +1,12 @@
|
||||
// PR c++/34267
|
||||
// { dg-do compile }
|
||||
|
||||
struct A {};
|
||||
__decltype (A); // { dg-error "must be an expression" }
|
||||
template<int> struct B
|
||||
{
|
||||
__decltype (A); // { dg-error "must be an expression" }
|
||||
__decltype (~A); // { dg-error "must be an expression" }
|
||||
__decltype (B); // { dg-error "must be an expression" }
|
||||
__decltype (~B); // { dg-error "must be an expression" }
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user