File tcc-0.9.27-git.patch of Package tcc

diff --git a/Makefile b/Makefile
index 3ae466f..02d3625 100644
--- a/Makefile
+++ b/Makefile
@@ -349,6 +349,9 @@ test:
 tests2.%:
 	$(MAKE) -C tests/tests2 $@
 
+testspp.%:
+	$(MAKE) -C tests/pp $@
+
 clean:
 	rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod
 	rm -f  *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS
@@ -394,6 +397,8 @@ help:
 	@echo ""
 	@echo "make tests2.all / make tests2.37 / make tests2.37+"
 	@echo "   run all/single test(s) from tests2, optionally update .expect"
+	@echo "make testspp.all / make testspp.17"
+	@echo "   run all/single test(s) from tests/pp"
 	@echo ""
 	@echo "Other supported make targets:"
 	@echo "   install install-strip tags ETAGS tar clean distclean help"
diff --git a/tcc.c b/tcc.c
index cd887d1..ee55ddd 100644
--- a/tcc.c
+++ b/tcc.c
@@ -298,8 +298,10 @@ redo:
             if (n > 1 && s->outfile)
                 tcc_error("cannot specify output file with -c many files");
         } else {
-            if (s->option_pthread)
+            if (s->option_pthread) {
                 tcc_set_options(s, "-lpthread");
+		n = s->nb_files;
+	    }
         }
 
         if (s->do_bench)
diff --git a/tccelf.c b/tccelf.c
index 70d47e1..e979a4c 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -873,6 +873,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr)
         sym_index = ELFW(R_SYM)(rel->r_info);
         type = ELFW(R_TYPE)(rel->r_info);
         switch(type) {
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
 #if defined(TCC_TARGET_I386)
         case R_386_32:
             if (!get_sym_attr(s1, sym_index, 0)->dyn_index
@@ -896,6 +897,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr)
             if (get_sym_attr(s1, sym_index, 0)->dyn_index)
                 count++;
             break;
+#endif
         default:
             break;
         }
@@ -1531,7 +1533,7 @@ static int alloc_sec_names(TCCState *s1, int file_type, Section *strsec)
             prepare_dynamic_rel(s1, s)) {
                 if (s1->sections[s->sh_info]->sh_flags & SHF_EXECINSTR)
                     textrel = 1;
-        } else if (s1->do_debug ||
+        } else if ((s1->do_debug && s->sh_type != SHT_RELX) ||
             file_type == TCC_OUTPUT_OBJ ||
             (s->sh_flags & SHF_ALLOC) ||
 	    i == (s1->nb_sections - 1)) {
@@ -1832,14 +1834,7 @@ static int final_sections_reloc(TCCState *s1)
     /* XXX: ignore sections with allocated relocations ? */
     for(i = 1; i < s1->nb_sections; i++) {
         s = s1->sections[i];
-#if defined(TCC_TARGET_I386) || defined(TCC_MUSL)
-        if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr
-        /* On X86 gdb 7.3 works in any case but gdb 6.6 will crash if SHF_ALLOC
-        checking is removed */
-#else
         if (s->reloc && s != s1->got)
-        /* On X86_64 gdb 7.3 will crash if SHF_ALLOC checking is present */
-#endif
             relocate_section(s1, s);
     }
 
diff --git a/tccgen.c b/tccgen.c
index e0b744e..5265e49 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2049,9 +2049,10 @@ static void gen_opif(int op)
         case '*': f1 *= f2; break;
         case '/': 
             if (f2 == 0.0) {
-                if (const_wanted)
-                    tcc_error("division by zero in constant");
-                goto general_case;
+		/* If not in initializer we need to potentially generate
+		   FP exceptions at runtime, otherwise we want to fold.  */
+                if (!const_wanted)
+                    goto general_case;
             }
             f1 /= f2; 
             break;
@@ -5051,17 +5052,18 @@ ST_FUNC void unary(void)
     }
     // special qnan , snan and infinity values
     case TOK___NAN__:
-        vpush64(VT_DOUBLE, 0x7ff8000000000000ULL);
+        n = 0x7fc00000;
+special_math_val:
+	vpushi(n);
+	vtop->type.t = VT_FLOAT;
         next();
         break;
     case TOK___SNAN__:
-        vpush64(VT_DOUBLE, 0x7ff0000000000001ULL);
-        next();
-        break;
+	n = 0x7f800001;
+	goto special_math_val;
     case TOK___INF__:
-        vpush64(VT_DOUBLE, 0x7ff0000000000000ULL);
-        next();
-        break;
+	n = 0x7f800000;
+	goto special_math_val;
 
     default:
     tok_identifier:
@@ -6086,6 +6088,8 @@ static void block(int *bsym, int *csym, int is_expr)
         skip(TOK_WHILE);
         skip('(');
         gsym(b);
+	if (b)
+	    nocode_wanted = saved_nocode_wanted;
 	gexpr();
 	c = gvtst(0, 0);
 	gsym_addr(c, d);
diff --git a/tests/Makefile b/tests/Makefile
index 5f6777d..d3c49fb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -279,7 +279,7 @@ cache: tcc_g
 clean:
 	rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc
 	rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
-	rm -f asm-c-connect$(EXESUF)
+	rm -f asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF)
 	rm -f ex? tcc_g weaktest.*.txt *.def
 	@$(MAKE) -C tests2 $@
 	@$(MAKE) -C pp $@
diff --git a/tests/pp/Makefile b/tests/pp/Makefile
index 687aa52..4785db3 100644
--- a/tests/pp/Makefile
+++ b/tests/pp/Makefile
@@ -10,7 +10,7 @@ VPATH = $(SRC)
 files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))
 TESTS = $(call files,c) $(call files,S)
 
-all test : $(sort $(TESTS))
+all test testspp.all: $(sort $(TESTS))
 
 DIFF_OPTS = -Nu -b -B
 
@@ -29,6 +29,8 @@ FILTER = 2>&1 | sed 's,$(SRC)/,,g'
 	    diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \
 	    && rm -f $*.output
 
+testspp.%: %.test ;
+
 # automatically generate .expect files with gcc:
 %.expect: # %.c
 	gcc -E -P $*.[cS] >$*.expect 2>&1
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 57670be..f807966 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -2234,6 +2234,9 @@ void float_test(void)
     double da, db;
     int a;
     unsigned int b;
+    static double nan2 = 0.0/0.0;
+    static double inf1 = 1.0/0.0;
+    static double inf2 = 1e5000;
 
     printf("float_test:\n");
     printf("sizeof(float) = %d\n", sizeof(float));
@@ -2255,6 +2258,7 @@ void float_test(void)
     b = 4000000000;
     db = b;
     printf("db = %f\n", db);
+    printf("nan != nan = %d, inf1 = %f, inf2 = %f\n", nan2 != nan2, inf1, inf2);
 #endif
 }
 
diff --git a/tests/tests2/87_dead_code.c b/tests/tests2/87_dead_code.c
index 98d4566..0d5a64c 100644
--- a/tests/tests2/87_dead_code.c
+++ b/tests/tests2/87_dead_code.c
@@ -26,6 +26,36 @@ static void kb_wait_1(void)
       timeout--;
   } while (timeout);
 }
+
+static int global;
+
+static void foo(int i)
+{
+  global+=i;
+  printf ("g=%d\n", global);
+}
+
+static int check(void)
+{
+  printf ("check %d\n", global);
+  return 1;
+}
+
+static void dowhile(void)
+{
+  do {
+      foo(1);
+      if (global == 1) {
+	  continue;
+      } else if (global == 2) {
+	  continue;
+      }
+      /* The following break shouldn't disable the check() call,
+         as it's reachable by the continues above.  */
+      break;
+  } while (check());
+}
+
 int main (void)
 {
   int i = 1;
@@ -118,5 +148,8 @@ enterloop3:
 	  printf ("error4\n");
       }
   }
+
+  dowhile();
+
   return 0;
 }
diff --git a/tests/tests2/87_dead_code.expect b/tests/tests2/87_dead_code.expect
index 0b3ec1d..a8c93bd 100644
--- a/tests/tests2/87_dead_code.expect
+++ b/tests/tests2/87_dead_code.expect
@@ -16,3 +16,8 @@ once3
 twice3
 caseok
 caseok2
+g=1
+check 1
+g=2
+check 2
+g=3
openSUSE Build Service is sponsored by