Enable -Wshadow and fix shadowing variables.
diff --git a/SConstruct b/SConstruct
index 607dd5f..0d55b12 100644
--- a/SConstruct
+++ b/SConstruct
@@ -20,7 +20,7 @@
CCFLAGS = []
if int(debug):
- CCFLAGS.append(ARGUMENTS.get('CXXFLAGS', '-g -Wall -Werror'))
+ CCFLAGS.append(ARGUMENTS.get('CXXFLAGS', '-g -Wall -Wshadow -Werror'))
if int(optimize):
CCFLAGS.append(ARGUMENTS.get('CXXFLAGS', '-O3'))
diff --git a/src/diy-fp.h b/src/diy-fp.h
index 9dcf8fb..2edf346 100644
--- a/src/diy-fp.h
+++ b/src/diy-fp.h
@@ -42,7 +42,7 @@
static const int kSignificandSize = 64;
DiyFp() : f_(0), e_(0) {}
- DiyFp(uint64_t f, int e) : f_(f), e_(e) {}
+ DiyFp(uint64_t significand, int exponent) : f_(significand), e_(exponent) {}
// this = this - other.
// The exponents of both numbers must be the same and the significand of this
@@ -76,22 +76,22 @@
void Normalize() {
ASSERT(f_ != 0);
- uint64_t f = f_;
- int e = e_;
+ uint64_t significand = f_;
+ int exponent = e_;
// This method is mainly called for normalizing boundaries. In general
// boundaries need to be shifted by 10 bits. We thus optimize for this case.
const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000);
- while ((f & k10MSBits) == 0) {
- f <<= 10;
- e -= 10;
+ while ((significand & k10MSBits) == 0) {
+ significand <<= 10;
+ exponent -= 10;
}
- while ((f & kUint64MSB) == 0) {
- f <<= 1;
- e--;
+ while ((significand & kUint64MSB) == 0) {
+ significand <<= 1;
+ exponent--;
}
- f_ = f;
- e_ = e;
+ f_ = significand;
+ e_ = exponent;
}
static DiyFp Normalize(const DiyFp& a) {
diff --git a/src/double-conversion.cc b/src/double-conversion.cc
index 909985b..b962b3b 100644
--- a/src/double-conversion.cc
+++ b/src/double-conversion.cc
@@ -852,9 +852,9 @@
return junk_string_value_;
}
}
- char sign = '+';
+ char exponen_sign = '+';
if (*current == '+' || *current == '-') {
- sign = static_cast<char>(*current);
+ exponen_sign = static_cast<char>(*current);
++current;
if (current == end) {
if (allow_trailing_junk) {
@@ -888,7 +888,7 @@
++current;
} while (current != end && *current >= '0' && *current <= '9');
- exponent += (sign == '-' ? -num : num);
+ exponent += (exponen_sign == '-' ? -num : num);
}
if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
diff --git a/src/utils.h b/src/utils.h
index d8e03d4..f52a519 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -167,8 +167,8 @@
class Vector {
public:
Vector() : start_(NULL), length_(0) {}
- Vector(T* data, int length) : start_(data), length_(length) {
- ASSERT(length == 0 || (length > 0 && data != NULL));
+ Vector(T* data, int len) : start_(data), length_(len) {
+ ASSERT(len == 0 || (len > 0 && data != NULL));
}
// Returns a vector using the same backing storage as this one,
@@ -210,8 +210,8 @@
// buffer bounds on all operations in debug mode.
class StringBuilder {
public:
- StringBuilder(char* buffer, int size)
- : buffer_(buffer, size), position_(0) { }
+ StringBuilder(char* buffer, int buffer_size)
+ : buffer_(buffer, buffer_size), position_(0) { }
~StringBuilder() { if (!is_finalized()) Finalize(); }
diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc
index 4de4c00..6d85bfd 100644
--- a/test/cctest/cctest.cc
+++ b/test/cctest/cctest.cc
@@ -34,16 +34,18 @@
CcTest* CcTest::last_ = NULL;
-CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
- const char* dependency, bool enabled)
- : callback_(callback), name_(name), dependency_(dependency), prev_(last_) {
+CcTest::CcTest(TestFunction* callback, const char* test_file,
+ const char* test_name, const char* test_dependency,
+ bool test_is_enabled)
+ : callback_(callback), name_(test_name), dependency_(test_dependency),
+ prev_(last_) {
// Find the base name of this test (const_cast required on Windows).
- char *basename = strrchr(const_cast<char *>(file), '/');
+ char *basename = strrchr(const_cast<char *>(test_file), '/');
if (!basename) {
- basename = strrchr(const_cast<char *>(file), '\\');
+ basename = strrchr(const_cast<char *>(test_file), '\\');
}
if (!basename) {
- basename = strdup(file);
+ basename = strdup(test_file);
} else {
basename = strdup(basename + 1);
}
@@ -52,7 +54,7 @@
if (extension) *extension = 0;
// Install this test in the list of tests
file_ = basename;
- enabled_ = enabled;
+ enabled_ = test_is_enabled;
prev_ = last_;
last_ = this;
}