Commit b67bc44c by Nicola Pero Committed by Nicola Pero

In gcc/cp/: 2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/cp/:
2010-10-06  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from apple/trunk branch on FSF servers.
        * cp-tree.def: Added AT_ENCODE_EXPR here instead of to the no
        longer existing gcc/c-common.def.
        
        2005-12-14  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4278774
        * pt.c (tsubst_copy_and_build): Instantiate @endcode(T).
        * parser.c (cp_parser_objc_encode_expression): Build a templatized 
        parse tree for @encode(T).

        2005-12-14  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4278774
        * c-common.def: Add new expression code AT_ENCODE_EXPR.
        
In gcc/testsuite/:
2010-10-06  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.
        
        2005-12-14  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4278774
        * obj-c++.dg/encode-9.mm: New.

From-SVN: r165067
parent 6e9bd0f8
2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from apple/trunk branch on FSF servers.
* cp-tree.def: Added AT_ENCODE_EXPR here instead of to the no
longer existing gcc/c-common.def.
2005-12-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 4278774
* pt.c (tsubst_copy_and_build): Instantiate @endcode(T).
* parser.c (cp_parser_objc_encode_expression): Build a templatized
parse tree for @encode(T).
2005-12-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 4278774
* c-common.def: Add new expression code AT_ENCODE_EXPR.
2010-10-06 Eric Botcazou <ebotcazou@adacore.com> 2010-10-06 Eric Botcazou <ebotcazou@adacore.com>
PR c++/45908 PR c++/45908
......
...@@ -335,6 +335,10 @@ DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1) ...@@ -335,6 +335,10 @@ DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1)
expansion. */ expansion. */
DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_expression, 1) DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_expression, 1)
/* Represents an Objective-C++ '@encode' expression during template
expansion. */
DEFTREECODE (AT_ENCODE_EXPR, "at_encode_expr", tcc_unary, 1)
/* A STMT_EXPR represents a statement-expression during template /* A STMT_EXPR represents a statement-expression during template
expansion. This is the GCC extension { ( ... ) }. The expansion. This is the GCC extension { ( ... ) }. The
STMT_EXPR_STMT is the statement given by the expression. */ STMT_EXPR_STMT is the statement given by the expression. */
......
...@@ -21128,6 +21128,13 @@ cp_parser_objc_encode_expression (cp_parser* parser) ...@@ -21128,6 +21128,13 @@ cp_parser_objc_encode_expression (cp_parser* parser)
return error_mark_node; return error_mark_node;
} }
if (dependent_type_p (type))
{
tree value = build_min (AT_ENCODE_EXPR, size_type_node, type);
TREE_READONLY (value) = 1;
return value;
}
return objc_build_encode_expr (type); return objc_build_encode_expr (type);
} }
......
...@@ -12359,6 +12359,19 @@ tsubst_copy_and_build (tree t, ...@@ -12359,6 +12359,19 @@ tsubst_copy_and_build (tree t,
return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t), return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t),
complain & tf_error); complain & tf_error);
case AT_ENCODE_EXPR:
{
op1 = TREE_OPERAND (t, 0);
++cp_unevaluated_operand;
++c_inhibit_evaluation_warnings;
op1 = tsubst_copy_and_build (op1, args, complain, in_decl,
/*function_p=*/false,
/*integral_constant_expression_p=*/false);
--cp_unevaluated_operand;
--c_inhibit_evaluation_warnings;
return objc_build_encode_expr (op1);
}
case NOEXCEPT_EXPR: case NOEXCEPT_EXPR:
op1 = TREE_OPERAND (t, 0); op1 = TREE_OPERAND (t, 0);
++cp_unevaluated_operand; ++cp_unevaluated_operand;
......
2010-10-06 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-12-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 4278774
* obj-c++.dg/encode-9.mm: New.
2010-10-06 Eric Botcazou <ebotcazou@adacore.com> 2010-10-06 Eric Botcazou <ebotcazou@adacore.com>
* g++.dg/cpp0x/pr45908.C: New test. * g++.dg/cpp0x/pr45908.C: New test.
......
/* Test than @encode is properly instantiated. */
/* { dg-options "-lobjc" } */
/* { dg-do run } */
#include <string.h>
#include <stdlib.h>
#include <objc/objc.h>
template<typename T>
class typeOf {
public:
operator const char*() { return @encode(T); }
};
int main() {
typeOf<int> t;
if (strcmp ((const char *)t, @encode(int)))
abort();
typeOf<const char*> c;
if (strcmp ((const char *)c, @encode(const char*)))
abort();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment