Skip to content

Commit

Permalink
More breakage tests (#35)
Browse files Browse the repository at this point in the history
* Rename enum test add_to_sizeenum to add_enumclass_enumerator
* Add enum test remove_enumclass_enumerator
* Add enum test add_enum_enumerator
* Add enum test remove_enum_enumerator
* Update function-pointer/Makefile to new format
* Add function-pointer breaks
* Add complex-double breaks
  • Loading branch information
hainest committed Aug 15, 2022
1 parent 59ac4c1 commit a39200c
Show file tree
Hide file tree
Showing 37 changed files with 582 additions and 1 deletion.
File renamed without changes.
2 changes: 2 additions & 0 deletions complex-double/breaks/narrow_to_double/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extern "C" void test_long_double__Complex(long double _Complex x) {}
void foo(double _Complex c1, double _Complex c2) {}
9 changes: 9 additions & 0 deletions complex-double/breaks/narrow_to_float/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
2 changes: 2 additions & 0 deletions complex-double/breaks/narrow_to_float/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extern "C" void test_long_double__Complex(long double _Complex x) {}
void foo(float _Complex c1, float _Complex c2) {}
9 changes: 9 additions & 0 deletions enum/breaks/add_enum_enumerator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
19 changes: 19 additions & 0 deletions enum/breaks/add_enum_enumerator/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enum Color { red, green, blue, orange };

enum class ColorClassEnum : int { red=-77, blue=14, green=0 };
void foo(ColorClassEnum c) {}

Color print_color(Color r){
return r;
}

// Enums with different sizes underlying types
enum class CharEnum : char {h='h', i='i', j='j'};
enum class BoolEnum : bool { a=true, b=false};
enum class SizeEnum : unsigned long { a=1, b=2, c=3};

void enumfunc(CharEnum c) {}
void boolfunc(BoolEnum c) {}
void sizefunc(SizeEnum c) {}


9 changes: 9 additions & 0 deletions enum/breaks/add_enumclass_enumerator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
File renamed without changes.
9 changes: 9 additions & 0 deletions enum/breaks/remove_enum_enumerator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
19 changes: 19 additions & 0 deletions enum/breaks/remove_enum_enumerator/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enum Color { red, green };

enum class ColorClassEnum : int { red=-77, blue=14, green=0 };
void foo(ColorClassEnum c) {}

Color print_color(Color r){
return r;
}

// Enums with different sizes underlying types
enum class CharEnum : char {h='h', i='i', j='j'};
enum class BoolEnum : bool { a=true, b=false};
enum class SizeEnum : unsigned long { a=1, b=2, c=3};

void enumfunc(CharEnum c) {}
void boolfunc(BoolEnum c) {}
void sizefunc(SizeEnum c) {}


9 changes: 9 additions & 0 deletions enum/breaks/remove_enumclass_enumerator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
19 changes: 19 additions & 0 deletions enum/breaks/remove_enumclass_enumerator/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enum Color { red, green, blue };

enum class ColorClassEnum : int { red=-77, blue=14, green=0 };
void foo(ColorClassEnum c) {}

Color print_color(Color r){
return r;
}

// Enums with different sizes underlying types
enum class CharEnum : char {h='h', i='i', j='j'};
enum class BoolEnum : bool { a=true, b=false};
enum class SizeEnum : unsigned long { a=1, b=2};

void enumfunc(CharEnum c) {}
void boolfunc(BoolEnum c) {}
void sizefunc(SizeEnum c) {}


9 changes: 8 additions & 1 deletion function-pointer/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
g++ -g -c example.cpp -o lib.so
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_narrow_no_conversion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_narrow_no_conversion/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(char x, char y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(char x, char y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(char, char))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_narrow_unsigned/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_narrow_unsigned/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(unsigned char x, unsigned char y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(unsigned char x, unsigned char y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(unsigned char, unsigned char))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_no_narrow_unsigned/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_no_narrow_unsigned/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(unsigned int x, unsigned int y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(unsigned int x, unsigned int y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(unsigned int, unsigned int))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_widen_no_conversion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_widen_no_conversion/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(long int x, long int y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(long int x, long int y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(long int, long int))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_widen_unsigned/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_widen_unsigned/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(long unsigned int x, long unsigned int y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(long unsigned int x, long unsigned int y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(long unsigned int, long unsigned int))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/param_widen_with_conversion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp
30 changes: 30 additions & 0 deletions function-pointer/breaks/param_widen_with_conversion/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to pass function as a
// pointer to any function

// Function that add two numbers
int add(double x, double y)
{
return x + y;
}

// Function that multiplies two
// numbers
int multiply(double x, double y)
{
return x * y;
}

// Function that takes a pointer
// to a function
int invoke(int x, int y,
int (*func)(double, double))
{
return func(x, y);
}

// Driver Code
int main()
{
// Pass pointers to add & multiply
return invoke(20,10,&add) + invoke(20,10,&multiply);
}
9 changes: 9 additions & 0 deletions function-pointer/breaks/return_narrow_no_conversion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CXX ?= g++
CXXFLAGS ?= -g -Wall

ifneq (${VERBOSE},1)
MUTE := @
endif

all:
${MUTE} ${CXX} ${CXXFLAGS} -Wl,-E -fPIC -shared -o lib.so example.cpp

0 comments on commit a39200c

Please sign in to comment.