In gcc/cp/:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Oct 2010 22:07:08 +0000 (22:07 +0000)
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Oct 2010 22:07:08 +0000 (22:07 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165067 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/encode-9.mm [new file with mode: 0644]

index 8143763..6219f04 100644 (file)
@@ -1,3 +1,21 @@
+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>
 
        PR c++/45908
index 1eb25c3..1065c80 100644 (file)
@@ -335,6 +335,10 @@ DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1)
    expansion.  */
 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
    expansion.  This is the GCC extension { ( ... ) }.  The
    STMT_EXPR_STMT is the statement given by the expression.  */
index c481ae3..7e25157 100644 (file)
@@ -21128,6 +21128,13 @@ cp_parser_objc_encode_expression (cp_parser* parser)
       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);
 }
 
index eabd11b..506bf9a 100644 (file)
@@ -12359,6 +12359,19 @@ tsubst_copy_and_build (tree t,
        return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t), 
                                            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:
       op1 = TREE_OPERAND (t, 0);
       ++cp_unevaluated_operand;
index 187ba7e..23919a3 100644 (file)
@@ -1,3 +1,12 @@
+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>
 
        * g++.dg/cpp0x/pr45908.C: New test.
diff --git a/gcc/testsuite/obj-c++.dg/encode-9.mm b/gcc/testsuite/obj-c++.dg/encode-9.mm
new file mode 100644 (file)
index 0000000..6b064df
--- /dev/null
@@ -0,0 +1,26 @@
+/* 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;
+}
+