[llvm-commits] [dragonegg] r141658 - in /dragonegg/trunk: Makefile src/Types.cpp
Duncan Sands
baldrick at free.fr
Tue Oct 11 02:21:32 PDT 2011
Author: baldrick
Date: Tue Oct 11 04:21:32 2011
New Revision: 141658
URL: http://llvm.org/viewvc/llvm-project?rev=141658&view=rev
Log:
Workaround a missing sanity check in array_type_nelts in some versions of GCC.
This can cause crashes when compiling Fortran with dragonegg and an oldish GCC.
Modified:
dragonegg/trunk/Makefile
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Makefile?rev=141658&r1=141657&r2=141658&view=diff
==============================================================================
--- dragonegg/trunk/Makefile (original)
+++ dragonegg/trunk/Makefile Tue Oct 11 04:21:32 2011
@@ -34,6 +34,7 @@
GCC_VERSION:=$(shell $(GCC) -dumpversion)
GCC_MAJOR=$(word 1, $(subst ., ,$(GCC_VERSION)))
GCC_MINOR=$(word 2, $(subst ., ,$(GCC_VERSION)))
+GCC_MICRO=$(word 3, $(subst ., ,$(GCC_VERSION)))
TARGET_TRIPLE:=$(shell $(GCC) -dumpmachine)
# NOTE: replace with an informative string when doing a release.
@@ -55,6 +56,7 @@
-MD -MP \
-DIN_GCC -DREVISION=\"$(REVISION)\" \
-DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \
+ -DGCC_MICRO=$(GCC_MICRO) \
-I$(INCLUDE_DIR) -I$(GCC_PLUGIN_DIR)/include
LD_OPTIONS+=$(shell $(LLVM_CONFIG) --ldflags) $(LDFLAGS)
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=141658&r1=141657&r2=141658&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Tue Oct 11 04:21:32 2011
@@ -211,6 +211,10 @@
/// if the array has variable or unknown length.
uint64_t ArrayLengthOf(tree type) {
assert(TREE_CODE(type) == ARRAY_TYPE && "Only for array types!");
+ // Workaround for missing sanity checks in older versions of GCC.
+ if ((GCC_MINOR == 5 && GCC_MICRO < 3) || (GCC_MINOR == 6 && GCC_MICRO < 2))
+ if (!TYPE_DOMAIN(type) || !TYPE_MAX_VALUE(TYPE_DOMAIN(type)))
+ return NO_LENGTH;
tree range = array_type_nelts(type); // The number of elements minus one.
// Bail out if the array has variable or unknown length.
if (!isInt64(range, false))
More information about the llvm-commits
mailing list