Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'rurban/pmc2c-unused-gh836'

Fixed conflict:
	config/auto/warnings.pm
fixes already in master
  • Loading branch information...
commit 0525faa867810706bbeb957befd9e44876257a23 2 parents fdd0ca3 + 7913e25
@rurban rurban authored
View
2  ChangeLog
@@ -10,6 +10,8 @@
bytes from every installed executable.
- Build
+ Improved warnings for clang.
+ + Cleaned wrong UNUSED(arg) macros in all pmc's due to an improved
+ pmc2c compiler, which SHIMs all UNUSED args. [GH #836]
- Branches
+ The threads branch is almost ready to be merged. Some remaining races
have been fixed. There are only some remaining platforms errors on
View
8 config/gen/makefiles/root.in
@@ -735,10 +735,10 @@ src/string/private_cstring.h : $(STR_FILES) $(BUILD_TOOLS_DIR)/c2str.pl
H2INC = $(BUILD_TOOLS_DIR)/h2inc.pl
# classes PMC build utils and rules
-PMC2C = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl @no_lines_flag@
-PMC2CD = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --dump @no_lines_flag@
-PMC2CC = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --c @no_lines_flag@
-PMC2CV = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --vtable @no_lines_flag@
+PMC2C = $(PERL) -Ilib $(BUILD_TOOLS_DIR)/pmc2c.pl @no_lines_flag@
+PMC2CD = $(PERL) -Ilib $(BUILD_TOOLS_DIR)/pmc2c.pl --dump @no_lines_flag@
+PMC2CC = $(PERL) -Ilib $(BUILD_TOOLS_DIR)/pmc2c.pl --c @no_lines_flag@
+PMC2CV = $(PERL) -Ilib $(BUILD_TOOLS_DIR)/pmc2c.pl --vtable @no_lines_flag@
#.pmc.dump : # suffix rule (limited support)
# $(PMC2CD) $<
View
39 lib/Parrot/Pmc2c/Method.pm
@@ -36,6 +36,7 @@ sub new {
parent_name => "",
decorators => [],
pmc_unused => 0,
+ interp_unused => 0,
%{ $self_hash || {} }
)
};
@@ -66,8 +67,7 @@ EOC
}
sub is_vtable {
- my ($self) = @_;
- my $type = $self->type;
+ my $type = shift->type;
return $type eq VTABLE || $type eq VTABLE_ENTRY;
}
@@ -76,10 +76,21 @@ sub is_multi {
return $self->type eq MULTI;
}
+# if is_ro
sub pmc_unused {
+ return shift->{pmc_unused};
+}
+
+# detect empty body, like return 1
+sub interp_unused {
my ($self) = @_;
- return $self->{pmc_unused};
+ my $body = $self->body;
+ if ($body->{data} and $body->{data} =~ /^\s+return 1;\s+$/) {
+ $self->{interp_unused} = 1;
+ $self->{pmc_unused} = 1;
+ }
+ return $self->{interp_unused};
}
=head2 C<trans($type)>
@@ -246,6 +257,25 @@ sub decl {
$args = ", $args" if $args =~ /\S/;
$args =~ s/(\w+)\s*(\*)\s*/$1 $2/g;
+ # SHIM UNUSED(arg) in body
+ my $body = $self->body;
+ if ($body->{data} and $body->{data} =~ /^\s*UNUSED\((\w+)\)/m) {
+ my $key = $1;
+ if ($args =~ s/, (\w+ \*?$key)/, SHIM($1)/) {
+ $body->{data} =~ s/^\s*UNUSED\((\w+)\);?\n//;
+ }
+ if ($body->{data} =~ m/^\s*UNUSED\((INTERP|interp)\);?\n/) {
+ $self->{interp_unused} = 1;
+ warn "Replace UNUSED(interp) with UNUSED(INTERP) in $pmcname METHOD $meth\n"
+ if $1 eq 'interp' and $self->{parent_name} ne 'Null';
+ $body->{data} =~ s/^\s*UNUSED\((INTERP|interp)\);?\n//;
+ }
+ if ($body->{data} =~ m/^\s*UNUSED\(SELF\);?\n/) {
+ $self->{pmc_unused} = 1;
+ $body->{data} =~ s/^\s*UNUSED\(SELF\);?\n//;
+ }
+ }
+
my ( $extern, $newl, $semi );
if ( $for_header eq 'HEADER' ) {
$newl = ' ';
@@ -255,10 +285,11 @@ sub decl {
$newl = "\n";
$semi = '';
}
+ my $interp = $self->interp_unused ? 'SHIM_INTERP' : 'PARROT_INTERP';
my $pmcarg = $self->pmc_unused ? 'SHIM(PMC *_self)' : 'ARGMOD(PMC *_self)';
return <<"EOC";
-static $decs $ret${newl}Parrot_${pmcname}_$meth(PARROT_INTERP, $pmcarg$args)$semi
+static $decs $ret${newl}Parrot_${pmcname}_$meth($interp, $pmcarg$args)$semi
EOC
}
View
5 lib/Parrot/Pmc2c/PMC/Null.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2008, Parrot Foundation.
+# Copyright (C) 2007-2012, Parrot Foundation.
package Parrot::Pmc2c::PMC::Null;
use base 'Parrot::Pmc2c::PMC';
@@ -42,8 +42,7 @@ sub pre_method_gen {
# take care to mark the parameters as unused
# to avoid compiler warnings
my $body = <<"EOC";
- UNUSED(interp)
- UNUSED(_self)
+ UNUSED(SELF)
EOC
foreach my $param (split /,\s*/, $method->parameters) {
View
3  src/ops/core.ops
@@ -58,6 +58,8 @@ Halts the interpreter. See also B<exit>.
=cut
inline op end() :check_event :flow {
+ UNUSED(interp);
+ UNUSED(cur_opcode);
goto ADDRESS(0);
}
@@ -97,7 +99,6 @@ actions on it.
inline op noop() {
UNUSED(interp);
- UNUSED(CUR_OPCODE);
}
inline op check_events() :flow {
View
9 src/ops/core_ops.c
@@ -13605,13 +13605,14 @@ static op_info_t core_op_info_table[1126] = {
opcode_t *
Parrot_end(opcode_t *cur_opcode, PARROT_INTERP) {
+ UNUSED(interp);
+ UNUSED(cur_opcode);
return (opcode_t *)0;
}
opcode_t *
Parrot_noop(opcode_t *cur_opcode, PARROT_INTERP) {
UNUSED(interp);
- UNUSED(CUR_OPCODE);
return cur_opcode + 1;
}
@@ -13746,15 +13747,13 @@ Parrot_local_return_p(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_jump_i(opcode_t *cur_opcode, PARROT_INTERP) {
- opcode_t * const loc = INTVAL2PTR(opcode_t *, IREG(1));
-
+ opcode_t * const loc = INTVAL2PTR(opcode_t *, IREG(1));
return (opcode_t *)loc;
}
opcode_t *
Parrot_jump_ic(opcode_t *cur_opcode, PARROT_INTERP) {
- opcode_t * const loc = INTVAL2PTR(opcode_t *, ICONST(1));
-
+ opcode_t * const loc = INTVAL2PTR(opcode_t *, ICONST(1));
return (opcode_t *)loc;
}
View
6 src/pmc/addrregistry.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2005-2011, Parrot Foundation.
+Copyright (C) 2005-2012, Parrot Foundation.
=head1 NAME
@@ -183,10 +183,10 @@ reaches 0, delete the entry.
*/
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
+ UNUSED(value)
const void *oldval;
ptrcast_t newval = 1;
Hash *hash;
- UNUSED(value);
GET_ATTR_pmc_registry(INTERP, SELF, hash);
@@ -199,10 +199,10 @@ reaches 0, delete the entry.
}
VTABLE void set_pmc_keyed_str(STRING *key, PMC *value) {
+ UNUSED(value)
const void *oldval;
ptrcast_t newval = 1;
Hash *hash;
- UNUSED(value);
GET_ATTR_str_registry(INTERP, SELF, hash);
View
4 src/pmc/class.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -1762,8 +1762,8 @@ Called after the class has been thawed.
*/
VTABLE void thawfinish(PMC *info) {
- Parrot_Class_attributes * const _class = PARROT_CLASS(SELF);
UNUSED(info)
+ Parrot_Class_attributes * const _class = PARROT_CLASS(SELF);
/* Recalculate full MRO from thawed parents */
_class->all_parents = Parrot_ComputeMRO_C3(INTERP, SELF);
View
4 src/pmc/continuation.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2010, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -283,10 +283,10 @@ destination to continue execution.
*/
VTABLE opcode_t *invoke(void *next) {
+ UNUSED(next)
PMC * const from_obj = Parrot_pcc_get_signature(INTERP, CURRENT_CONTEXT(INTERP));
opcode_t *pc;
PackFile_ByteCode *seg;
- UNUSED(next)
GET_ATTR_seg(INTERP, SELF, seg);
GET_ATTR_address(INTERP, SELF, pc);
View
3  src/pmc/default.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -893,7 +893,6 @@ Initializes the PMC during unarchiving.
*/
VTABLE void thaw(PMC *info) {
- UNUSED(INTERP);
UNUSED(info);
/* default - initialize the PMC */
SELF.init();
View
12 src/pmc/key.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -42,6 +42,7 @@ Initializes the key.
*/
VTABLE void init() {
+ UNUSED(INTERP)
PObj_custom_mark_SET(SELF);
}
@@ -186,7 +187,9 @@ Sets the value of the key to C<*value>.
*/
VTABLE void set_pmc(PMC *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
+ UNUSED(SELF)
+ UNUSED(value)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_UNIMPLEMENTED,
"this is broken - see TT #1683");
}
@@ -245,6 +248,8 @@ Returns the key itself.
*/
VTABLE PMC *get_pmc_keyed(PMC *key) {
+ UNUSED(INTERP)
+ UNUSED(SELF)
return key;
}
@@ -350,8 +355,8 @@ Called after the Key has been thawed: convert last PMC_NULL key to NULL.
}
VTABLE void thawfinish(PMC *info) {
- PMC *key = SELF;
UNUSED(info)
+ PMC *key = SELF;
while (1) {
PMC *next;
@@ -398,6 +403,7 @@ Aggregate interface.
*/
VTABLE INTVAL elements() {
+ UNUSED(INTERP)
INTVAL n = 0;
for (; SELF; SELF = PARROT_KEY(SELF)->next_key)
n++;
View
3  src/pmc/orderedhashiterator.pmc
@@ -124,7 +124,6 @@ Returns this Iterator's Hash.
*/
VTABLE PMC* get_pmc() {
- UNUSED(INTERP)
return PARROT_ORDEREDHASHITERATOR(SELF)->pmc_hash;
}
@@ -153,12 +152,10 @@ Returns the number of remaining elements in the Hash.
*/
VTABLE INTVAL elements() {
- UNUSED(INTERP)
return PARROT_ORDEREDHASHITERATOR(SELF)->elements;
}
VTABLE INTVAL get_integer() {
- UNUSED(INTERP)
return SELF.elements();
}
View
16 src/pmc/pointer.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -38,7 +38,7 @@ Initializes the pointer.
*/
VTABLE void init() {
- UNUSED(interp);
+ UNUSED(INTERP)
PObj_custom_mark_SET(SELF);
}
@@ -88,7 +88,7 @@ Sets the pointer value.
*/
VTABLE void set_pointer(void *ptr) {
- UNUSED(interp);
+ UNUSED(INTERP)
PARROT_POINTER(SELF)->pointer = ptr;
}
@@ -103,7 +103,7 @@ Returns the pointer value.
*/
VTABLE void *get_pointer() {
- UNUSED(interp);
+ UNUSED(INTERP)
return PARROT_POINTER(SELF)->pointer;
}
@@ -118,7 +118,7 @@ Returns the pointer value as an integer.
*/
VTABLE INTVAL get_integer() {
- UNUSED(interp);
+ UNUSED(INTERP)
return (INTVAL)(PARROT_POINTER(SELF)->pointer);
}
@@ -133,7 +133,6 @@ Returns the pointer value as a floating-point number.
*/
VTABLE FLOATVAL get_number() {
- UNUSED(interp);
return (FLOATVAL)(INTVAL)(PARROT_POINTER(SELF)->pointer);
}
@@ -148,7 +147,6 @@ Returns the pointer value as a Parrot string.
*/
VTABLE STRING *get_repr() {
- UNUSED(interp);
return Parrot_sprintf_c(INTERP, "Pointer = 0x%p", PARROT_POINTER(SELF)->pointer);
}
@@ -178,7 +176,7 @@ Returns whether the pointer is not C<NULL>.
*/
VTABLE INTVAL get_bool() {
- UNUSED(interp);
+ UNUSED(INTERP)
return (INTVAL)(PMC_data(SELF) != NULL);
}
@@ -193,7 +191,7 @@ Returns whether the pointer has the same value as C<*pmc2>.
*/
VTABLE INTVAL is_same(PMC *pmc2) {
- UNUSED(interp);
+ UNUSED(INTERP)
return (INTVAL)(SELF->vtable == pmc2->vtable &&
PARROT_POINTER(SELF)->pointer == PARROT_POINTER(pmc2)->pointer);
}
View
22 src/pmc/scheduler.pmc
@@ -126,8 +126,8 @@ current maximum, and a birthtime of the current time.
void push_pmc(PMC *task) {
/* TODO: This doesn't appear to do anything */
Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
- PMC * const type_pmc = VTABLE_get_attr_str(interp, task, CONST_STRING(interp, "type"));
- STRING * const type = VTABLE_get_string(interp, type_pmc);
+ PMC * const type_pmc = VTABLE_get_attr_str(INTERP, task, CONST_STRING(INTERP, "type"));
+ STRING * const type = VTABLE_get_string(INTERP, type_pmc);
}
@@ -175,8 +175,8 @@ Frees the scheduler's underlying struct.
*/
VTABLE void destroy() {
- UNUSED(SELF);
- UNUSED(interp);
+ UNUSED(SELF)
+ UNUSED(INTERP)
}
@@ -307,16 +307,16 @@ Returns a ResizablePMCArray containing pointers to all active tasks.
METHOD active_tasks() {
Parrot_Scheduler_attributes *sdata = PARROT_SCHEDULER(SELF);
- PMC * const tasks = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
- PMC * const iter = Parrot_pmc_new_init(interp, enum_class_HashIterator, sdata->all_tasks);
+ PMC * const tasks = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+ PMC * const iter = Parrot_pmc_new_init(INTERP, enum_class_HashIterator, sdata->all_tasks);
- while (!VTABLE_get_bool(interp, iter)) {
- PMC * const pair = VTABLE_shift_pmc(interp, iter);
+ while (!VTABLE_get_bool(INTERP, iter)) {
+ PMC * const pair = VTABLE_shift_pmc(INTERP, iter);
PMC * task = PMCNULL;
- STRING * const value = CONST_STRING(interp, "value");
- Parrot_pcc_invoke_method_from_c_args(interp, pair,
+ STRING * const value = CONST_STRING(INTERP, "value");
+ Parrot_pcc_invoke_method_from_c_args(INTERP, pair,
value, "->P", &task);
- VTABLE_push_pmc(interp, tasks, task);
+ VTABLE_push_pmc(INTERP, tasks, task);
}
RETURN(PMC* tasks);
View
4 src/pmc/sub.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -334,8 +334,8 @@ now.> -DRS
*/
VTABLE INTVAL get_integer_keyed(PMC *key) {
- Parrot_Sub_attributes *sub;
UNUSED(key)
+ Parrot_Sub_attributes *sub;
PMC_get_sub(INTERP, SELF, sub);
return (INTVAL) (sub->seg->base.data);
View
36 src/pmc/undef.pmc
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2004-2011, Parrot Foundation.
+Copyright (C) 2004-2012, Parrot Foundation.
=head1 NAME
@@ -101,8 +101,8 @@ Returns 0.
*/
VTABLE INTVAL get_integer() {
- UNUSED(SELF);
- UNUSED(INTERP);
+ UNUSED(SELF)
+ UNUSED(INTERP)
return 0;
}
@@ -117,8 +117,8 @@ Returns 0.
*/
VTABLE INTVAL defined() {
- UNUSED(SELF);
- UNUSED(INTERP);
+ UNUSED(SELF)
+ UNUSED(INTERP)
return 0;
}
@@ -148,8 +148,8 @@ Returns 0.0.
*/
VTABLE FLOATVAL get_number() {
- UNUSED(SELF);
- UNUSED(INTERP);
+ UNUSED(SELF)
+ UNUSED(INTERP)
return 0.0;
}
@@ -179,7 +179,7 @@ Returns an empty string.
*/
VTABLE STRING *get_string() {
- UNUSED(SELF);
+ UNUSED(SELF)
Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
"Stringifying an Undef PMC");
@@ -212,8 +212,8 @@ Returns 0.
*/
VTABLE INTVAL get_bool() {
- UNUSED(SELF);
- UNUSED(INTERP);
+ UNUSED(SELF)
+ UNUSED(INTERP)
return 0;
}
@@ -228,8 +228,8 @@ Unknown. (TODO)
*/
VTABLE void share() {
- UNUSED(SELF);
- UNUSED(INTERP);
+ UNUSED(SELF)
+ UNUSED(INTERP)
/* see src/pmc/integer.pmc */
}
@@ -258,16 +258,16 @@ Returns 1 if the C<*value> is an Undef PMC, 0 otherwise.
*/
MULTI INTVAL is_equal(Undef value) {
- UNUSED(SELF);
- UNUSED(INTERP);
- UNUSED(value);
+ UNUSED(SELF)
+ UNUSED(INTERP)
+ UNUSED(value)
return 1;
}
MULTI INTVAL is_equal(DEFAULT value) {
- UNUSED(SELF);
- UNUSED(INTERP);
- UNUSED(value);
+ UNUSED(SELF)
+ UNUSED(INTERP)
+ UNUSED(value)
return 0;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.