summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--giscanner/maintransformer.py21
-rw-r--r--tests/warn/Makefile.am1
-rw-r--r--tests/warn/unresolved-element-type.h11
3 files changed, 27 insertions, 6 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 130d449a..67f6391a 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -263,7 +263,7 @@ usage is void (*_gtk_reserved1)(void);"""
"Too many parameters in type specification %r" % (type_str, ))
return base
def top_combiner(base, *rest):
- if orig_node is not None:
+ if orig_node is not None and isinstance(orig_node, ast.Type):
base.is_const = orig_node.is_const
return combiner(base, *rest)
@@ -271,6 +271,15 @@ usage is void (*_gtk_reserved1)(void);"""
if rest:
message.warn("Trailing components in type specification %r" % (
type_str, ))
+
+ if not result.resolved:
+ parent = orig_node
+ if isinstance(parent, ast.Function):
+ text = parent.symbol
+ else:
+ text = parent.name
+ message.warn_node(parent, "%s: Unknown type: %r" %
+ (text, result.ctype))
return result
def _apply_annotations_array(self, parent, node, options):
@@ -282,7 +291,7 @@ usage is void (*_gtk_reserved1)(void);"""
element_type = options.get(OPT_ELEMENT_TYPE)
if element_type is not None:
- element_type_node = self._resolve(element_type.one())
+ element_type_node = self._resolve(element_type.one(), parent)
elif isinstance(node.type, ast.Array):
element_type_node = node.type.element_type
else:
@@ -321,13 +330,13 @@ usage is void (*_gtk_reserved1)(void);"""
element_type = element_type_opt.flat()
if isinstance(node.type, ast.List):
assert len(element_type) == 1
- node.type.element_type = self._resolve(element_type[0])
+ node.type.element_type = self._resolve(element_type[0], parent)
elif isinstance(node.type, ast.Map):
assert len(element_type) == 2
- node.type.key_type = self._resolve(element_type[0])
- node.type.value_type = self._resolve(element_type[1])
+ node.type.key_type = self._resolve(element_type[0], parent)
+ node.type.value_type = self._resolve(element_type[1], parent)
elif isinstance(node.type, ast.Array):
- node.type.element_type = self._resolve(element_type[0])
+ node.type.element_type = self._resolve(element_type[0], parent)
else:
message.warn_node(parent,
"Unknown container %r for element-type annotation" % (node.type, ))
diff --git a/tests/warn/Makefile.am b/tests/warn/Makefile.am
index deece2f3..921ec593 100644
--- a/tests/warn/Makefile.am
+++ b/tests/warn/Makefile.am
@@ -5,6 +5,7 @@ TESTS = \
callback-missing-scope.h \
return-gobject.h \
unknown-parameter.h \
+ unresolved-element-type.h \
unresolved-type.h
EXTRA_DIST = warningtester.py common.h $(TESTS)
diff --git a/tests/warn/unresolved-element-type.h b/tests/warn/unresolved-element-type.h
new file mode 100644
index 00000000..af60a391
--- /dev/null
+++ b/tests/warn/unresolved-element-type.h
@@ -0,0 +1,11 @@
+#include "common.h"
+
+/**
+ * test_unresolved_element_type:
+ *
+ * Returns: (element-type Unresolved) (transfer full):
+ */
+
+GList* test_unresolved_element_type(void);
+
+// EXPECT:9: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved'