aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZiemowit Laski <zlaski@apple.com>2005-07-08 01:53:37 +0000
committerZiemowit Laski <zlaski@gcc.gnu.org>2005-07-08 01:53:37 +0000
commita0e71127bb2ab3450437010387edd33404590de8 (patch)
tree42e7259e06a7cac78cdf1510f45d3e6ca75fa394 /gcc
parent478cc28d237453d3d30fe1ee99cdaef2f9e15a88 (diff)
downloadgcc-a0e71127bb2ab3450437010387edd33404590de8.zip
gcc-a0e71127bb2ab3450437010387edd33404590de8.tar.gz
gcc-a0e71127bb2ab3450437010387edd33404590de8.tar.bz2
objc-act.c (objc_build_struct): Pass in an actual @interface instead of its name...
[gcc/objc/ChangeLog] 2005-07-07 Ziemowit Laski <zlaski@apple.com> * objc-act.c (objc_build_struct): Pass in an actual @interface instead of its name, and annotate the struct created (and all existing variants thereof) with the @interface. (objc_compare_types): Treat forward-declared ObjC classes as stand-alone (root) classes for purposes of type comparisons. (build_private_template): Move some code to objc_build_struct(). [gcc/testsuite/ChangeLog] 2005-07-07 Ziemowit Laski <zlaski@apple.com> * obj-c++.dg/proto-lossage-6.mm: New. * objc.dg/proto-lossage-6.m: New. From-SVN: r101750
Diffstat (limited to 'gcc')
-rw-r--r--gcc/objc/ChangeLog9
-rw-r--r--gcc/objc/objc-act.c35
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/obj-c++.dg/proto-lossage-6.mm17
-rw-r--r--gcc/testsuite/objc.dg/proto-lossage-6.m18
5 files changed, 75 insertions, 9 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 6d7b9a4..00fa28a 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,5 +1,14 @@
2005-07-07 Ziemowit Laski <zlaski@apple.com>
+ * objc-act.c (objc_build_struct): Pass in an actual @interface
+ instead of its name, and annotate the struct created (and all
+ existing variants thereof) with the @interface.
+ (objc_compare_types): Treat forward-declared ObjC classes
+ as stand-alone (root) classes for purposes of type comparisons.
+ (build_private_template): Move some code to objc_build_struct().
+
+2005-07-07 Ziemowit Laski <zlaski@apple.com>
+
PR objc/22274
* objc-act.c (objc_build_string_object): For GNU-style constants,
use the @interface type rather than the built-in type.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 48cf707..35d5343 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -794,12 +794,13 @@ objc_is_class_id (tree type)
return OBJC_TYPE_NAME (type) == objc_class_id;
}
-/* Construct a C struct with tag NAME, a base struct with tag
+/* Construct a C struct with same name as CLASS, a base struct with tag
SUPER_NAME (if any), and FIELDS indicated. */
static tree
-objc_build_struct (tree name, tree fields, tree super_name)
+objc_build_struct (tree class, tree fields, tree super_name)
{
+ tree name = CLASS_NAME (class);
tree s = start_struct (RECORD_TYPE, name);
tree super = (super_name ? xref_tag (RECORD_TYPE, super_name) : NULL_TREE);
tree t, objc_info = NULL_TREE;
@@ -857,15 +858,26 @@ objc_build_struct (tree name, tree fields, tree super_name)
= chainon (objc_info,
build_tree_list (NULL_TREE, TYPE_OBJC_INFO (t)));
+ /* Point the struct at its related Objective-C class. */
+ INIT_TYPE_OBJC_INFO (s);
+ TYPE_OBJC_INTERFACE (s) = class;
+
s = finish_struct (s, fields, NULL_TREE);
for (t = TYPE_NEXT_VARIANT (s); t;
t = TYPE_NEXT_VARIANT (t), objc_info = TREE_CHAIN (objc_info))
- TYPE_OBJC_INFO (t) = TREE_VALUE (objc_info);
+ {
+ TYPE_OBJC_INFO (t) = TREE_VALUE (objc_info);
+ /* Replace the IDENTIFIER_NODE with an actual @interface. */
+ TYPE_OBJC_INTERFACE (t) = class;
+ }
/* Use TYPE_BINFO structures to point at the super class, if any. */
objc_xref_basetypes (s, super);
+ /* Mark this struct as a class template. */
+ CLASS_STATIC_TEMPLATE (class) = s;
+
return s;
}
@@ -1099,6 +1111,16 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee)
else
rcls = rproto = NULL_TREE;
+ /* If we could not find an @interface declaration, we must have
+ only seen a @class declaration; for purposes of type comparison,
+ treat it as a stand-alone (root) class. */
+
+ if (lcls && TREE_CODE (lcls) == IDENTIFIER_NODE)
+ lcls = NULL_TREE;
+
+ if (rcls && TREE_CODE (rcls) == IDENTIFIER_NODE)
+ rcls = NULL_TREE;
+
/* If either type is an unqualified 'id', we're done. */
if ((!lproto && objc_is_object_id (ltyp))
|| (!rproto && objc_is_object_id (rtyp)))
@@ -4109,15 +4131,10 @@ build_private_template (tree class)
{
if (!CLASS_STATIC_TEMPLATE (class))
{
- tree record = objc_build_struct (CLASS_NAME (class),
+ tree record = objc_build_struct (class,
get_class_ivars (class, false),
CLASS_SUPER_NAME (class));
- /* mark this record as class template - for class type checking */
- INIT_TYPE_OBJC_INFO (record);
- TYPE_OBJC_INTERFACE (record) = class;
- CLASS_STATIC_TEMPLATE (class) = record;
-
/* Set the TREE_USED bit for this struct, so that stab generator
can emit stabs for this struct type. */
if (flag_debug_only_used_symbols && TYPE_STUB_DECL (record))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index afafe9c..394b846 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -12,6 +12,11 @@
2005-07-07 Ziemowit Laski <zlaski@apple.com>
+ * obj-c++.dg/proto-lossage-6.mm: New.
+ * objc.dg/proto-lossage-6.m: New.
+
+2005-07-07 Ziemowit Laski <zlaski@apple.com>
+
* obj-c++.dg/gnu-runtime-2.mm: Compile, do not run.
* objc.dg/gnu-runtime-2.m: Likewise.
diff --git a/gcc/testsuite/obj-c++.dg/proto-lossage-6.mm b/gcc/testsuite/obj-c++.dg/proto-lossage-6.mm
new file mode 100644
index 0000000..6a4552e
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/proto-lossage-6.mm
@@ -0,0 +1,17 @@
+@class Base;
+@protocol _Protocol;
+
+@interface ClassA {
+}
+-(void) func1:(Base<_Protocol> *)inTarget;
+@end
+
+int main()
+{
+ ClassA* theA = 0;
+ Base<_Protocol>* myBase = 0;
+ [theA func1:myBase];
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/objc.dg/proto-lossage-6.m b/gcc/testsuite/objc.dg/proto-lossage-6.m
new file mode 100644
index 0000000..2b8720c
--- /dev/null
+++ b/gcc/testsuite/objc.dg/proto-lossage-6.m
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+@class Base;
+@protocol _Protocol;
+
+@interface ClassA {
+}
+-(void) func1:(Base<_Protocol> *)inTarget;
+@end
+
+int main()
+{
+ ClassA* theA = 0;
+ Base<_Protocol>* myBase = 0;
+ [theA func1:myBase];
+
+ return 0;
+}
+