~ chicken-core (chicken-5) dc071fbae201f2b8db5539fd016c0d51be0bbe15
commit dc071fbae201f2b8db5539fd016c0d51be0bbe15
Author: Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Mon Oct 21 22:15:29 2013 +0200
Commit: Moritz Heidkamp <moritz@twoticketsplease.de>
CommitDate: Wed Oct 23 11:53:02 2013 +0200
Use "noreturn" attribute in newer clang versions and get rid of a clang warning.
The division procedure C_2_divide would try to call C_fix on the
uninitialised variable "iresult" in the case where either of the
divident or the divisor values are flonums ("fflag" will be 1 then).
In the situation where neither value is a flonum, it'll either barf
(which is declared "noreturn"), or properly initialise iresult.
This means the C_unfix() call on an uninitialised value which gets
C_fix()ed later is pure overhead in the case either value is a flonum.
Signed-off-by: Moritz Heidkamp <moritz@twoticketsplease.de>
diff --git a/chicken.h b/chicken.h
index aea58fec..cb9320ee 100644
--- a/chicken.h
+++ b/chicken.h
@@ -229,11 +229,16 @@ void *alloca ();
#define HAVE_STATEMENT_EXPRESSIONS 1
#endif
+#if !defined(__clang__) && !defined(__has_attribute)
+/* Define so it won't error on other compilers with keywords like "noreturn" */
+#define __has_attribute(x) 0
+#endif
+
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
# ifndef __cplusplus
# define C_cblock ({
# define C_cblockend })
-# ifdef __clang__
+# if defined(__clang__) && !__has_attribute(noreturn)
# define C_noret
# else
# define C_noret __attribute__ ((noreturn))
diff --git a/runtime.c b/runtime.c
index 41894761..58f8e078 100644
--- a/runtime.c
+++ b/runtime.c
@@ -6731,11 +6731,8 @@ C_regparm C_word C_fcall C_2_divide(C_word **ptr, C_word x, C_word y)
}
else barf(C_BAD_ARGUMENT_TYPE_ERROR, "/", x);
- iresult = C_fix(iresult);
-
- if(fflag || (double)C_unfix(iresult) != fresult) return C_flonum(ptr, fresult);
-
- return iresult;
+ if(fflag || (double)iresult != fresult) return C_flonum(ptr, fresult);
+ else return C_fix(iresult);
}
Trap