[dragonegg] r176015 - Using "-x ada" to test whether GCC supports a language like Ada only works if

Duncan Sands baldrick at free.fr
Mon Feb 25 01:42:46 PST 2013


Author: baldrick
Date: Mon Feb 25 03:42:45 2013
New Revision: 176015

URL: http://llvm.org/viewvc/llvm-project?rev=176015&view=rev
Log:
Using "-x ada" to test whether GCC supports a language like Ada only works if
GCC was configured with Ada support, but the Ada front-end wasn't installed (as
is usually the case with distribution supplied gcc's).  If GCC wasn't configured
with Ada support then attempts to compile Ada like this succeed (i.e. zero exit
code)!  Instead of using "-x ada", create a file with the appropriate contents
and suffix, and try compiling that instead.

Modified:
    dragonegg/trunk/test/DEUtils.py

Modified: dragonegg/trunk/test/DEUtils.py
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/DEUtils.py?rev=176015&r1=176014&r2=176015&view=diff
==============================================================================
--- dragonegg/trunk/test/DEUtils.py (original)
+++ dragonegg/trunk/test/DEUtils.py Mon Feb 25 03:42:45 2013
@@ -38,27 +38,39 @@ def getSuffixesForLanguage(language):
   return suffixes
 
 def isLanguageSupported(language, compiler):
-  # For most languages it suffices to try compiling an empty file.
-  source = tempfile.NamedTemporaryFile(mode='w+t')
+  if language == 'ada':
+    suffix='.ads'
+  elif language == 'c':
+    suffix='.c'
+  elif language == 'c++':
+    suffix='.cpp'
+  elif language == 'fortran':
+    suffix='.f'
+  elif language == 'go':
+    suffix='.go'
+  elif language == 'objective-c':
+    suffix='.m'
+  elif language == 'objective-c++':
+    suffix='.mm'
+  else:
+    return False
+
+  # For most languages it suffices to try compiling an empty file however for
+  # Ada and Go an empty file is not a valid compilation unit.
+  source = tempfile.NamedTemporaryFile(mode='w+t', suffix=suffix)
 
-  # However for Ada and Go an empty file is not a valid compilation unit.
   if language == 'ada':
     # Use an obscure package name, as if the package is called XYZ and a file
     # called XYZ.adb exists then the test will fail.
     source.write('package U5TE4J886W is end;\n')
   elif language == 'go':
     source.write('package main\n')
-  # GCC doesn't recognize "-x fortran" so use "-x f77" instead.
-  elif language == 'fortran':
-    language = 'f77'
 
   # If something was written then ensure it is visible to the compiler process.
   source.flush()
 
   # The language is supported if the file compiles without error.
-  out,err,exitCode = TestRunner.executeCommand([compiler, '-S', '-x',
-                          language, source.name])
-  print language,out,err,exitCode,compiler
+  out,err,exitCode = TestRunner.executeCommand([compiler, '-S', source.name])
   return exitCode == 0
 
 def getSupportedLanguages(compiler):





More information about the llvm-commits mailing list