+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
/*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. */
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);
+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
--- /dev/null
+// 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" }
+};
--- /dev/null
+// 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" }
+};