Skip to content

cpplint fixes #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions regression/cpp-from-CVS/Assignment1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ struct A { int i;};

struct B
{
int i;
B& operator = (const B& b)
{
i = b.i;
return *this;
}
int i;
B& operator = (const B& b)
{
i = b.i;
return *this;
}
};

A funcA()
{
A a;
a.i = 10;
return a;
A a;
a.i = 10;
return a;
}


B funcB()
{
B b;
b.i = 10;
return b;
B b;
b.i = 10;
return b;
}

int main()
{
A a;
a.i = 20;
assert((funcA() = a).i == 20); // legal
A a;
a.i = 20;
assert((funcA() = a).i == 20); // legal

B b;
b.i = 20;
assert((funcB() = b).i == 20); // legal
B b;
b.i = 20;
assert((funcB() = b).i == 20); // legal
}
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Comma_Operator1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ int main()
{
int s=0;
int t=0;
t=(s=3,s+2);
t=(s=3, s+2);
assert(s==3);
assert(t==5);
}
6 changes: 3 additions & 3 deletions regression/cpp-from-CVS/ConditionalExpression2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ char b[2];

int main()
{
char* c = true ? a : b;
assert(*c == a[0]);
return 0;
char* c = true ? a : b;
assert(*c == a[0]);
return 0;
}
10 changes: 5 additions & 5 deletions regression/cpp-from-CVS/Constructor10/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class A
{
public:
int a;
A(int a):a(a){}
public:
int a;
A(int a):a(a){}
};


A f()
{
return A(0);
return A(0);
}

int main(){}
int main() {}
6 changes: 3 additions & 3 deletions regression/cpp-from-CVS/Constructor11/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
struct A
{
A(){};
A(){};
};

int main()
{
A a;
a.A();
A a;
a.A();
}
22 changes: 11 additions & 11 deletions regression/cpp-from-CVS/Constructor12/main.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
struct A
{
int i;
A():i(10){}
private:
A(const A& a); // disabled
int i;
A():i(10) {}
private:
A(const A& a); // disabled
};


class B: A {
public:
B(){};
int get_i(){return i;}
private:
B(B& b); // disabled
public:
B(){};
int get_i() {return i;}
private:
B(B& b); // disabled
};

int main()
{
B b;
assert(b.get_i() == 10);
B b;
assert(b.get_i() == 10);
}
36 changes: 18 additions & 18 deletions regression/cpp-from-CVS/Constructor13/main.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
int g;
class A {
public:
A(int i){g=i;};
private:
A();
public:
A(int i){g=i;};
private:
A();
};

class B: A {
public:
typedef A base_type;
typedef B this_type;
B():base_type(10){}
B(const this_type& b): A(20) {g++;}
public:
typedef A base_type;
typedef B this_type;
B():base_type(10) {}
B(const this_type& b): A(20) {g++;}
};

class C: B
{
typedef B base_type;
typedef C this_type;
public:
C(): base_type(){}
C(const base_type& b): base_type(b){g++;}
typedef B base_type;
typedef C this_type;
public:
C(): base_type() {}
C(const base_type& b): base_type(b){g++;}
};


C c;

int main()
{
assert(g==10);
B b;
C c2 = b;
assert(g==22);
assert(g==10);
B b;
C c2 = b;
assert(g==22);
}
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Constructor14/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct A
{
A(int i):i(i){}
A(int i):i(i) {}
int i;
};

Expand Down
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Constructor16/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class B: public A

int main()
{
B b1,b2;
B b1, b2;
b1 = b2; // not ok
}
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Constructor17/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class C
{
public:
C(int& v):v(v){};
C(int& v):v(v) {}
int v;
};

Expand Down
8 changes: 4 additions & 4 deletions regression/cpp-from-CVS/Conversion10/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
struct A {};

struct B {
explicit B(A&){}
explicit B(A&){}
};

void test(const B& b){};
void test(const B& b) {}

int main()
{
A a;
test(a); // conversion error
A a;
test(a); // conversion error
}
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Conversion11/main.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
char* func(){return (void*)0; }
char* func() {return (void*)0; }
6 changes: 3 additions & 3 deletions regression/cpp-from-CVS/Conversion3/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
int main()
{
char c = 'c';
int& i = c; // ill-formed
i++;
char c = 'c';
int& i = c; // ill-formed
i++;
}
6 changes: 3 additions & 3 deletions regression/cpp-from-CVS/Conversion4/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
int main()
{
const char c = 'c';
const int &i = c;
assert(i == 'c');
const char c = 'c';
const int &i = c;
assert(i == 'c');
}
8 changes: 4 additions & 4 deletions regression/cpp-from-CVS/Conversion5/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
int main()
{
unsigned i = 1;
unsigned j;
j = i + 1;
assert(j==2);
unsigned i = 1;
unsigned j;
j = i + 1;
assert(j==2);
}
18 changes: 9 additions & 9 deletions regression/cpp-from-CVS/Conversion6/main.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
struct A
{
int i;
int i;
};

struct B: public A {
int j;
int j;
};

int func(A a)
{
return a.i;
return a.i;
}

int main()
{
B b;
b.i = 1;
B b;
b.i = 1;

assert((* ((A*)&b)).i == 1); // This works fine.
assert((* ((A*)&b)).i == 1); // This works fine.

int bi = func( * ((A*)&b)); // Satabs Ok.
// cbmc error
assert(bi == 1);
int bi = func( * ((A*)&b)); // Satabs Ok.
// cbmc error
assert(bi == 1);
}
10 changes: 5 additions & 5 deletions regression/cpp-from-CVS/Conversion7/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
struct A{
int i;
int i;
};

struct B: public A{
};

int main()
{
B b;
b.i=4;
B b;
b.i=4;

A(b).i++; // Not a lvalue?
assert(b.i==4);
A(b).i++; // Not a lvalue?
assert(b.i==4);
}
12 changes: 6 additions & 6 deletions regression/cpp-from-CVS/Conversion8/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
int main() {
const char c[1] = {'c'};
char* pc;
const char** pcc = &pc; //1: not allowed
*pcc = &c;
*pc = 'C'; //2: modifies a const object
assert(c[0]=='c');
const char c[1] = {'c'};
char* pc;
const char** pcc = &pc; // 1: not allowed
*pcc = &c;
*pc = 'C'; // 2: modifies a const object
assert(c[0]=='c');
}
2 changes: 1 addition & 1 deletion regression/cpp-from-CVS/Conversion9/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ struct B: A {};

int main()
{
A a = B();
A a = B();
}
12 changes: 6 additions & 6 deletions regression/cpp-from-CVS/Conversion_Operator1/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
struct Char {
char c;
Char(char c):c(c){}
char c;
Char(char c):c(c){}
};

struct Int {
int i;
operator int& ();
Int(int i):i(i){}
int i;
operator int& ();
Int(int i):i(i){}
};

Int::operator int&(){return i;}
Int::operator int&() {return i;}

int main()
{
Expand Down
Loading