Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: master
...
compare: notfound/declaration-after-statement
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 05, 2012
@NotFound NotFound drop -Werror=declaration-after-statement from auto config
going to use more recent C standard
cc2af07
@NotFound NotFound profit from declarations after statements:
move some declarations to the first use of the variable
make some of it const, now that we can
e0095f4
@NotFound NotFound move some options from gcc-g++ to gcc only, to avoid noise with recen…
…t g++
e2f5606
@NotFound NotFound use some declarations after statements in a pmc file
to check that the pmc processor handle it correctly, just in case
ce35df3
View
9 config/auto/warnings.pm
@@ -120,12 +120,10 @@ sub _init {
-Wformat-nonliteral
-Wformat-security
-Wformat-y2k
- -Wimplicit
-Wimport
-Winit-self
-Winline
-Winvalid-pch
- -Wjump-misses-init
-Wlogical-op
-Werror=missing-braces
-Wmissing-declarations
@@ -136,7 +134,6 @@ sub _init {
-Wpacked
-Wparentheses
-Wpointer-arith
- -Wpointer-sign
-Wreturn-type
-Wsequence-point
-Wsign-compare
@@ -153,15 +150,17 @@ sub _init {
-Wstack-usage=500
);
- # gcc-only warnings that would break g++
+ # gcc-only warnings that would break or cause spurious warnings g++
my @gcc_basic = qw(
-Wc++-compat
- -Werror=declaration-after-statement
-Werror=implicit-function-declaration
-Wmissing-prototypes
-Werror=nested-externs
-Werror=old-style-definition
-Werror=strict-prototypes
+ -Wimplicit
+ -Wjump-misses-init
+ -Wpointer-sign
);
$gcc->{'basic'} = [ @gcc_or_gpp_basic, @gcc_basic ];
View
30 src/pmc/fixedpmcarray.pmc
@@ -81,12 +81,11 @@ Reverse the contents of the array.
METHOD reverse() {
INTVAL n = SELF.elements();
if (n > 1) {
- PMC *val;
- PMC **data = PMC_array(SELF);
+ PMC ** const data = PMC_array(SELF);
INTVAL i;
for (i = 0; i <= --n; i++) {
- val = data[i];
+ PMC * const val = data[i];
data[i] = data[n];
data[n] = val;
}
@@ -357,13 +356,11 @@ Returns the PMC value of the element at index C<key>.
*/
VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
- PMC **data;
-
if (key < 0 || key >= PMC_size(SELF))
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
_("FixedPMCArray: index out of bounds!"));
- data = PMC_array(SELF);
+ PMC ** const data = PMC_array(SELF);
return data[key];
}
@@ -380,12 +377,11 @@ Returns the PMC value of the element at index C<*key>.
VTABLE PMC *get_pmc_keyed(PMC *key) {
const INTVAL k = VTABLE_get_integer(INTERP, key);
PMC * const nextkey = Parrot_key_next(INTERP, key);
- PMC *box;
if (!nextkey)
return SELF.get_pmc_keyed_int(k);
- box = SELF.get_pmc_keyed_int(k);
+ PMC * const box = SELF.get_pmc_keyed_int(k);
/* TT #1561, return NULL early if we must autovivify. */
if (PMC_IS_NULL(box))
@@ -406,9 +402,6 @@ array.
*/
VTABLE void set_integer_native(INTVAL size) {
- int i;
- PMC **data;
-
if (PMC_size(SELF) && size)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
_("FixedPMCArray: Can't resize!"));
@@ -420,8 +413,9 @@ array.
_("FixedPMCArray: Cannot set array size to a negative number"));
PMC_size(SELF) = size;
- data = mem_gc_allocate_n_typed(INTERP, size, PMC *);
+ PMC ** const data = mem_gc_allocate_n_typed(INTERP, size, PMC *);
+ int i;
for (i = 0; i < size; ++i)
data[i] = PMCNULL;
@@ -564,13 +558,11 @@ Sets the PMC value of the element at index C<key> to C<*src>.
*/
VTABLE void set_pmc_keyed_int(INTVAL key, PMC *src) {
- PMC **data;
-
if (key < 0 || key >= PMC_size(SELF))
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
_("FixedPMCArray: index out of bounds!"));
- data = PMC_array(SELF);
+ PMC ** const data = PMC_array(SELF);
data[key] = src;
}
@@ -612,16 +604,15 @@ The C<==> operation. Compares two array to hold equal elements.
*/
VTABLE INTVAL is_equal(PMC *value) {
- INTVAL j, n;
-
if (value->vtable->base_type != SELF->vtable->base_type)
return 0;
- n = SELF.elements();
+ const INTVAL n = SELF.elements();
if (VTABLE_elements(INTERP, value) != n)
return 0;
+ INTVAL j;
for (j = 0; j < n; ++j) {
PMC * const item1 = SELF.get_pmc_keyed_int(j);
PMC * const item2 = VTABLE_get_pmc_keyed_int(INTERP, value, j);
@@ -667,12 +658,11 @@ Returns TRUE is the element at C<key> exists; otherwise returns false.
*/
VTABLE INTVAL exists_keyed_int(INTVAL key) {
- PMC **data;
if (key < 0 || key >= PMC_size(SELF))
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
_("FixedPMCArray: index out of bounds!"));
- data = PMC_array(SELF);
+ PMC ** const data = PMC_array(SELF);
return !PMC_IS_NULL(data[key]);
}
View
47 src/string/api.c
@@ -124,7 +124,6 @@ void
Parrot_str_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_str_init)
- Hash *const_cstring_hash;
size_t i;
const size_t n_parrot_cstrings =
sizeof (parrot_cstrings) / sizeof (parrot_cstrings[0]);
@@ -147,10 +146,8 @@ Parrot_str_init(PARROT_INTERP)
}
/* Set up the cstring cache, then load the basic encodings */
- const_cstring_hash = Parrot_hash_create_sized(interp,
- enum_type_PMC,
- Hash_key_type_cstring,
- n_parrot_cstrings);
+ Hash * const const_cstring_hash = Parrot_hash_create_sized(interp,
+ enum_type_PMC, Hash_key_type_cstring, n_parrot_cstrings);
interp->const_cstring_hash = const_cstring_hash;
Parrot_encodings_init(interp);
@@ -344,14 +341,12 @@ STRING *
Parrot_str_clone(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
{
ASSERT_ARGS(Parrot_str_clone)
- size_t alloc_size;
- STRING *result;
if (STRING_IS_NULL(s))
return STRINGNULL;
- result = Parrot_gc_new_string_header(interp, 0);
- alloc_size = s->bufused;
+ STRING * const result = Parrot_gc_new_string_header(interp, 0);
+ const size_t alloc_size = s->bufused;
if (alloc_size) {
/* Allocate new chunk of memory */
@@ -387,13 +382,11 @@ STRING *
Parrot_str_copy(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
{
ASSERT_ARGS(Parrot_str_copy)
- STRING *d;
- int is_movable;
if (STRING_IS_NULL(s))
return STRINGNULL;
- d = Parrot_gc_new_string_header(interp,
+ STRING * const d = Parrot_gc_new_string_header(interp,
PObj_get_FLAGS(s) & ~PObj_constant_FLAG);
/* This might set the constant flag again but it is the right thing
@@ -413,7 +406,7 @@ Parrot_str_copy(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
/* Set the string copy flag */
PObj_is_string_copy_SET(d);
- is_movable = PObj_is_movable_TESTALL(s);
+ int is_movable = PObj_is_movable_TESTALL(s);
/* Now check that buffer allocated from pool and affected by compacting */
if (is_movable && Buffer_bufstart(s)) {
@@ -449,9 +442,7 @@ Parrot_str_concat(PARROT_INTERP, ARGIN_NULLOK(const STRING *a),
ARGIN_NULLOK(const STRING *b))
{
ASSERT_ARGS(Parrot_str_concat)
- const STR_VTABLE *enc;
STRING *dest;
- UINTVAL total_length;
if (STRING_IS_NULL(a) && STRING_IS_NULL(b))
return STRINGNULL;
@@ -470,7 +461,7 @@ Parrot_str_concat(PARROT_INTERP, ARGIN_NULLOK(const STRING *a),
ASSERT_STRING_SANITY(a);
ASSERT_STRING_SANITY(b);
- enc = string_rep_compatible(a, b);
+ const STR_VTABLE * enc = string_rep_compatible(a, b);
if (!enc) {
/* upgrade strings for concatenation */
@@ -489,7 +480,7 @@ Parrot_str_concat(PARROT_INTERP, ARGIN_NULLOK(const STRING *a),
b = enc->to_encoding(interp, b);
}
/* calc usable and total bytes */
- total_length = a->bufused + b->bufused;
+ UINTVAL total_length = a->bufused + b->bufused;
if (PObj_is_growable_TESTALL(a)
&& a->strstart + total_length <=
@@ -819,7 +810,6 @@ Parrot_str_extract_chars(PARROT_INTERP, ARGIN(const char *buffer),
{
ASSERT_ARGS(Parrot_str_extract_chars)
Parrot_String_Bounds bounds;
- STRING *result;
bounds.bytes = len;
bounds.chars = chars;
@@ -832,7 +822,7 @@ Parrot_str_extract_chars(PARROT_INTERP, ARGIN(const char *buffer),
EXCEPTION_OUT_OF_BOUNDS,
"extract_chars: index out of bounds");
- result = Parrot_str_new_noinit(interp, bounds.bytes);
+ STRING * const result = Parrot_str_new_noinit(interp, bounds.bytes);
result->encoding = encoding;
result->bufused = bounds.bytes;
@@ -1166,7 +1156,6 @@ Parrot_str_iter_index(PARROT_INTERP,
ASSERT_ARGS(Parrot_str_iter_index)
String_iter search_iter, search_start, next_start;
const UINTVAL len = search->strlen;
- UINTVAL c0;
if (len == 0) {
*end = *start;
@@ -1174,7 +1163,7 @@ Parrot_str_iter_index(PARROT_INTERP,
}
STRING_ITER_INIT(interp, &search_iter);
- c0 = STRING_iter_get_and_advance(interp, search, &search_iter);
+ UINTVAL c0 = STRING_iter_get_and_advance(interp, search, &search_iter);
search_start = search_iter;
next_start = *start;
@@ -1237,13 +1226,9 @@ Parrot_str_replace(PARROT_INTERP, ARGIN(const STRING *src),
ASSERT_ARGS(Parrot_str_replace)
String_iter iter;
const STR_VTABLE *enc;
- STRING *dest = NULL;
UINTVAL true_offset = (UINTVAL)offset;
UINTVAL true_length = (UINTVAL)length;
- UINTVAL start_byte, end_byte, start_char, end_char;
- INTVAL buf_size;
-
if (STRING_IS_NULL(src)) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
"Can't replace in NULL string");
@@ -1286,12 +1271,12 @@ Parrot_str_replace(PARROT_INTERP, ARGIN(const STRING *src),
STRING_ITER_INIT(interp, &iter);
STRING_iter_skip(interp, src, &iter, true_offset);
- start_byte = iter.bytepos;
- start_char = iter.charpos;
+ const UINTVAL start_byte = iter.bytepos;
+ const UINTVAL start_char = iter.charpos;
STRING_iter_skip(interp, src, &iter, true_length);
- end_byte = iter.bytepos;
- end_char = iter.charpos;
+ const UINTVAL end_byte = iter.bytepos;
+ const UINTVAL end_char = iter.charpos;
/* not possible.... */
if (end_byte < start_byte)
@@ -1300,7 +1285,7 @@ Parrot_str_replace(PARROT_INTERP, ARGIN(const STRING *src),
"replace: subend somehow is less than substart");
/* Now do the replacement */
- dest = Parrot_gc_new_string_header(interp, 0);
+ STRING * const dest = Parrot_gc_new_string_header(interp, 0);
/* Set encoding to compatible */
dest->encoding = enc;
@@ -1310,7 +1295,7 @@ Parrot_str_replace(PARROT_INTERP, ARGIN(const STRING *src),
| PObj_is_COWable_FLAG;
/* size removed bytes added bytes */
- buf_size = src->bufused - (end_byte - start_byte) + rep->bufused;
+ const INTVAL buf_size = src->bufused - (end_byte - start_byte) + rep->bufused;
/* Alloctate new string size. */
Parrot_gc_allocate_string_storage(interp, dest, buf_size);

No commit comments for this range

Something went wrong with that request. Please try again.