This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ Patch] PR 33212
- From: Paolo Carlini <pcarlini at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Aug 2007 12:37:08 +0200
- Subject: [C++ Patch] PR 33212
Hi,
tested x86_64-linux. Ok?
Paolo.
//////////////////
/cp
2007-08-28 Paolo Carlini <pcarlini@suse.de>
PR c++/33212
* parser.c (cp_parser_trait_expr): Check rerurn value of
cp_parser_type_id.
/testsuite
2007-08-28 Paolo Carlini <pcarlini@suse.de>
PR c++/33212
* g++.dg/ext/is_class_error.C: New.
Index: testsuite/g++.dg/ext/is_class_error.C
===================================================================
*** testsuite/g++.dg/ext/is_class_error.C (revision 0)
--- testsuite/g++.dg/ext/is_class_error.C (revision 0)
***************
*** 0 ****
--- 1,6 ----
+ // PR c++/33212
+
+ template<int> void foo()
+ {
+ __is_class((int); // { dg-error "type-specifier|primary-expression" }
+ }
Index: cp/parser.c
===================================================================
*** cp/parser.c (revision 127853)
--- cp/parser.c (working copy)
*************** cp_parser_trait_expr (cp_parser* parser,
*** 6502,6507 ****
--- 6502,6510 ----
type1 = cp_parser_type_id (parser);
+ if (type1 == error_mark_node)
+ return error_mark_node;
+
/* Build a trivial decl-specifier-seq. */
clear_decl_specs (&decl_specs);
decl_specs.type = type1;
*************** cp_parser_trait_expr (cp_parser* parser,
*** 6516,6521 ****
--- 6519,6527 ----
type2 = cp_parser_type_id (parser);
+ if (type2 == error_mark_node)
+ return error_mark_node;
+
/* Build a trivial decl-specifier-seq. */
clear_decl_specs (&decl_specs);
decl_specs.type = type2;
*************** cp_parser_trait_expr (cp_parser* parser,
*** 6527,6534 ****
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
! /* Complete the trait expr, which may mean either processing the
! static assert now or saving it for template instantiation. */
return finish_trait_expr (kind, type1, type2);
}
--- 6533,6540 ----
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
! /* Complete the trait expression, which may mean either processing
! the trait expr now or saving it for template instantiation. */
return finish_trait_expr (kind, type1, type2);
}