Repository: Konstantin8105/c4go
Pull request #397 (2019-04-06 20:12:42)

scripts: add flag -s

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=h1) Report
> Merging [#397](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/549d2a787ffcf25ef54873d65ffb80fcd0c45d04?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/397/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #397   +/-   ##
=======================================
  Coverage   85.47%   85.47%           
=======================================
  Files         188      188           
  Lines       11076    11076           
=======================================
  Hits         9467     9467           
  Misses       1145     1145           
  Partials      464      464
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=footer). Last update [549d2a7...58c7063](https://codecov.io/gh/Konstantin8105/c4go/pull/397?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/scripts/lang.sh b/scripts/lang.sh
deleted file mode 100755
index 5d8a00f..0000000
--- a/scripts/lang.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-set -e
-
-go build
-
-mkdir -p ./testdata/
-
-# prepare variables
-	export C4GO_DIR=$GOPATH/src/github.com/Konstantin8105/c4go
-	export C4GO=$C4GO_DIR/c4go
-	export NAME="lang"
-	export TEMP_FOLDER="./testdata/$NAME"
-	export GO_FILE="$TEMP_FOLDER/$NAME.go"
-	export GO_APP="$TEMP_FOLDER/$NAME.app"
-
-# prepare C code
-    if [ ! -d $TEMP_FOLDER ]; then
-		mkdir -p $TEMP_FOLDER
-    	curl https://gitlab.com/the-language/the-language/raw/7ade276ad241c7fdff0163cf41295e03e869e7a5/core/arch/c/lang.c > $TEMP_FOLDER/$NAME.c
-	fi
-
-# remove go files from last transpilation
-	echo "***** remove go files"
-	rm -f $TEMP_FOLDER/*.go
-	rm -f $TEMP_FOLDER/*.app
-
-# transpilation of all projects
-	echo "Transpile to $GO_FILE"
-	$C4GO transpile                         \
-		-s                                  \
-		-o="$GO_FILE"                       \
-		$TEMP_FOLDER/*.c
-
-# show warnings comments in Go source
-	echo "Calculate warnings in file: $GO_FILE"
-	WARNINGS=`cat $GO_FILE | grep "^// Warning" | sort | uniq | wc -l`
-	echo "		After transpiling : $WARNINGS warnings."
-
-# show other warnings
-	# show amount error from `go build`:
-		echo "Build to $GO_APP file"
-		WARNINGS_GO=`go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1 | wc -l`
-		echo "		Go build : $WARNINGS_GO warnings"
-	# amount unsafe
-		UNSAFE=`cat $GO_FILE | grep "unsafe\." | wc -l`
-		echo "		Unsafe   : $UNSAFE"
-
-
-# Arguments menu
-echo "    -s for show detail of Go build errors"
-if [ "$1" == "-s" ]; then
-	# show go build warnings	
-		# c4go warnings
-			cat $GO_FILE | grep "^// Warning" | sort | uniq
-		# show amount error from `go build`:
-			go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1
-fi
-
-
-
diff --git a/scripts/minmad.sh b/scripts/minmad.sh
index e3ef1fd..3e24c9d 100755
--- a/scripts/minmad.sh
+++ b/scripts/minmad.sh
@@ -29,6 +29,7 @@ mkdir -p ./testdata/
 # transpilation of all projects
 	echo "Transpile to $GO_FILE"
 	$C4GO transpile                         \
+		-s                                  \
 		-o="$GO_FILE"                       \
 		$TEMP_FOLDER/*.c
 
diff --git a/scripts/neatvi.sh b/scripts/neatvi.sh
index 80737a6..1c71580 100755
--- a/scripts/neatvi.sh
+++ b/scripts/neatvi.sh
@@ -33,6 +33,7 @@ mkdir -p ./testdata/
 # transpilation of all projects
 	echo "Transpile to $GO_FILE"
 	$C4GO transpile                         \
+		-s                                  \
 		-clang-flag="-DTROFFFDIR=\"MMM\""	\
 		-clang-flag="-DTROFFMDIR=\"WWW\""	\
 		-o="$GO_FILE"                       \
diff --git a/scripts/scripts.sh b/scripts/scripts.sh
index 06b3fac..ed1bfde 100755
--- a/scripts/scripts.sh
+++ b/scripts/scripts.sh
@@ -18,9 +18,6 @@ echo "" >> $OUTPUT_FILE
 ./scripts/ed.sh			2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
-./scripts/lang.sh			2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
-echo "" >> $OUTPUT_FILE
-
 ./scripts/kilo.sh			2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
diff --git a/scripts/scripts.txt b/scripts/scripts.txt
index 5d67b78..d06f90f 100644
--- a/scripts/scripts.txt
+++ b/scripts/scripts.txt
@@ -1,7 +1,7 @@
 
 Calculate warnings : ./testdata/9wm
 		After transpiling : 2 warnings.
-		Go build : 3 warnings
+		Go build : 4 warnings
 		Unsafe   : 409
 
 Calculate warnings : ./testdata/ed
@@ -9,20 +9,15 @@ Calculate warnings : ./testdata/ed
 		Go build : 8 warnings
 		Unsafe   : 170
 
-Calculate warnings in file: ./testdata/lang/lang.go
-		After transpiling : 154 warnings.
-		Go build : 1357 warnings
-		Unsafe   : 1179
-
 Calculate warnings in file: ./testdata/kilo/kilo.go
 		After transpiling : 0 warnings.
 		Go build : 0 warnings
 		Unsafe   : 17
 
 Calculate warnings in file: ./testdata/minmad/minmad.go
-		After transpiling : 65 warnings.
-		Go build : 3 warnings
-		Unsafe   : 17
+		After transpiling : 0 warnings.
+		Go build : 2 warnings
+		Unsafe   : 66
 
 Calculate warnings in file: ./testdata/neateqn/neateqn.go
 		After transpiling : 0 warnings.
@@ -55,9 +50,9 @@ Calculate warnings in file: ./testdata/neatroff/neatroff.go
 		Unsafe   : 254
 
 Calculate warnings in file: ./testdata/neatvi/neatvi.go
-		After transpiling : 33 warnings.
+		After transpiling : 0 warnings.
 		Go build : 2 warnings
-		Unsafe   : 130
+		Unsafe   : 210
 
 Calculate warnings in file: ./testdata/triangle/triangle.go
 		After transpiling : 2 warnings.


Test patch:
diff --git a/tests/struct.c b/tests/struct.c
index ab5fc8f..682dfeb 100644
--- a/tests/struct.c
+++ b/tests/struct.c
@@ -666,9 +666,48 @@ void typedef_with_union()
 	is_eq((*u3).typet, UDEL);
 }
 
+typedef union {
+  void *p;
+  int b;
+} Value;
+
+#define TValuefields	Value value; int tt
+
+typedef struct lua_TValue {
+  TValuefields;
+} TValue;
+
+
+
+void typedef_struct_with_typedef_union()
+{
+	diag("typedef struct with typedef union");
+	Value v;
+	v.b = 42;
+	is_eq(v.b, 42);
+	TValue tv;
+	tv.value = v;
+	tv.tt    = 55;
+	is_eq(tv.value.b, 42);
+	is_eq(tv.tt     , 55);
+
+	TValue *ptv = &tv;
+	is_eq(ptv->value.b,42);
+	is_eq(ptv->tt     ,55);
+
+	double d = 45.0;
+	v.p = &d;
+	tv.value = v;
+	is_eq(*((double *)(v.p)), d);
+	is_eq(*((double *)(ptv->value.p)), d);
+	is_eq(ptv->tt, 55);
+
+	is_eq(*((double*)((&tv)->value.p)), d);
+}
+
 int main()
 {
-    plan(108);
+    plan(117);
 
     pointer_arithm_in_struct();
     test_extern_vec();
@@ -1071,6 +1110,7 @@ int main()
     struct_inside_union();
 
 	typedef_with_union();
+	typedef_struct_with_typedef_union();
 
     done_testing();
 }