PR c++/33045
PR c++/33837
PR c++/33838
* semantics.c (finish_decltype_type): See through INDIRECT_REFs.
Be careful with ERROR_MARK_NODEs.
* parser.c (cp_parser_check_access_in_redeclaration): Handle NULL
argument.
2007-11-07 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33045
PR c++/33837
PR c++/33838
* g++.dg/cpp0x/decltype-33837.C: New.
* g++.dg/cpp0x/decltype-refbug.C: New.
* g++.dg/cpp0x/decltype-33838.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129975
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-11-07 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/33045
+ PR c++/33837
+ PR c++/33838
+ * semantics.c (finish_decltype_type): See through INDIRECT_REFs.
+ Be careful with ERROR_MARK_NODEs.
+ * parser.c (cp_parser_check_access_in_redeclaration): Handle NULL
+ argument.
+
2007-11-07 Jakub Jelinek <jakub@redhat.com>
PR c++/33501
2007-11-07 Jakub Jelinek <jakub@redhat.com>
PR c++/33501
static void
cp_parser_check_access_in_redeclaration (tree decl)
{
static void
cp_parser_check_access_in_redeclaration (tree decl)
{
- if (!CLASS_TYPE_P (TREE_TYPE (decl)))
+ if (!decl || !CLASS_TYPE_P (TREE_TYPE (decl)))
return;
if ((TREE_PRIVATE (decl)
return;
if ((TREE_PRIVATE (decl)
tree orig_expr = expr;
tree type;
tree orig_expr = expr;
tree type;
+ if (!expr || error_operand_p (expr))
+ return error_mark_node;
+
if (type_dependent_expression_p (expr))
{
type = make_aggr_type (DECLTYPE_TYPE);
if (type_dependent_expression_p (expr))
{
type = make_aggr_type (DECLTYPE_TYPE);
+ /* Expressions of reference type are sometimes wrapped in
+ INDIRECT_REFs. INDIRECT_REFs are just internal compiler
+ representation, not part of the language, so we have to look
+ through them. */
+ if (TREE_CODE (expr) == INDIRECT_REF
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
+ == REFERENCE_TYPE)
+ expr = TREE_OPERAND (expr, 0);
+
if (TREE_CODE (expr) == CALL_EXPR
&& (fndecl = get_callee_fndecl (expr))
&& (fndecl != error_mark_node))
if (TREE_CODE (expr) == CALL_EXPR
&& (fndecl = get_callee_fndecl (expr))
&& (fndecl != error_mark_node))
decltype(e) is defined as T&, otherwise decltype(e) is
defined as T. */
type = TREE_TYPE (expr);
decltype(e) is defined as T&, otherwise decltype(e) is
defined as T. */
type = TREE_TYPE (expr);
- if (expr == current_class_ptr)
+ if (type == error_mark_node)
+ return error_mark_node;
+ else if (expr == current_class_ptr)
/* If the expression is just "this", we want the
cv-unqualified pointer for the "this" type. */
type = TYPE_MAIN_VARIANT (type);
/* If the expression is just "this", we want the
cv-unqualified pointer for the "this" type. */
type = TYPE_MAIN_VARIANT (type);
+2007-11-07 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/33045
+ PR c++/33837
+ PR c++/33838
+ * g++.dg/cpp0x/decltype-33837.C: New.
+ * g++.dg/cpp0x/decltype-refbug.C: New.
+ * g++.dg/cpp0x/decltype-33838.C: New.
+
2007-11-07 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20071107-1.c: New test.
2007-11-07 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20071107-1.c: New test.
--- /dev/null
+// { dg-options -std=c++0x }
+// PR c++/33837
+void foo()
+{
+ __decltype (A::foo()); // { dg-error "was not declared|expected initializer" }
+ __decltype (B); // { dg-error "was not declared" }
+}
--- /dev/null
+// { dg-options -std=c++0x }
+// PR c++/33838
+template<typename T> struct A
+{
+ __decltype (T* foo()); // { dg-error "expected|no arguments|accept" }
+};
--- /dev/null
+// { dg-options "-std=c++0x" }
+// PR c++/33045
+int && f ();
+
+template<typename T, typename U>
+struct is_same
+{
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T>
+{
+ static const bool value = true;
+};
+
+static_assert(is_same<decltype(f()), int&&>::value, "decltype of rvalue reference");