Index: driver/cc1.cc
===================================================================
--- driver/cc1.cc	(revision 9b34766037fcf6a9e66504724d599e583522b849)
+++ driver/cc1.cc	(revision a77496cbc62f805fc69d3c3f9abd928bfccc0e4b)
@@ -10,6 +10,6 @@
 // Created On       : Fri Aug 26 14:23:51 2005
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May 30 18:09:05 2020
-// Update Count     : 404
+// Last Modified On : Sun Aug 16 21:03:02 2020
+// Update Count     : 413
 //
 
@@ -24,5 +24,5 @@
 #include <unistd.h>										// execvp, fork, unlink
 #include <sys/wait.h>									// wait
-#include <fcntl.h>
+#include <fcntl.h>										// creat
 
 
@@ -59,5 +59,5 @@
 
 
-static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );		// "N__=" suffix
+static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );		// "__CFA_FLAG__=" suffix
 
 static void checkEnv1( const char * args[], int & nargs ) { // stage 1
@@ -111,6 +111,7 @@
 } // checkEnv2
 
-
-static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
+#define CFA_SUFFIX ".ifa"
+
+static char tmpname[] = P_tmpdir "/CFAXXXXXX" CFA_SUFFIX;
 static int tmpfilefd = -1;
 static bool startrm = false;
@@ -170,5 +171,5 @@
 			if ( arg == "-quiet" ) {
 			} else if ( arg == "-imultilib" || arg == "-imultiarch" ) {
-				i += 1;									// and the argument
+				i += 1;									// and argument
 			} else if ( prefix( arg, "-A" ) ) {
 			} else if ( prefix( arg, "-D__GNU" ) ) {
@@ -177,5 +178,5 @@
 				//********
 			} else if ( arg == "-D" && prefix( argv[i + 1], "__GNU" ) ) {
-				i += 1;									// and the argument
+				i += 1;									// and argument
 
 				// strip flags controlling cpp step
@@ -184,5 +185,5 @@
 				cpp_flag = true;
 			} else if ( arg == "-D" && string( argv[i + 1] ) == "__CPP__" ) {
-				i += 1;									// and the argument
+				i += 1;									// and argument
 				cpp_flag = true;
 
@@ -194,5 +195,5 @@
 				cpp_out = argv[i];
 			} else {
-				args[nargs++] = argv[i];				// pass the flag along
+				args[nargs++] = argv[i];				// pass flag along
 				// CPP flags with an argument
 				if ( arg == "-D" || arg == "-U" || arg == "-I" || arg == "-MF" || arg == "-MT" || arg == "-MQ" ||
@@ -200,12 +201,14 @@
 					 arg == "-iwithprefix" || arg == "-iwithprefixbefore" || arg == "-isystem" || arg == "-isysroot" ) {
 					i += 1;
-					args[nargs++] = argv[i];			// pass the argument along
+					args[nargs++] = argv[i];			// pass argument along
 					#ifdef __DEBUG_H__
 					cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
 					#endif // __DEBUG_H__
 				} else if ( arg == "-MD" || arg == "-MMD" ) {
+					// gcc frontend generates the dependency file-name after the -MD/-MMD flag, but it is necessary to
+					// prefix that file name with -MF.
 					args[nargs++] = "-MF";				// insert before file
 					i += 1;
-					args[nargs++] = argv[i];			// pass the argument along
+					args[nargs++] = argv[i];			// pass argument along
 					#ifdef __DEBUG_H__
 					cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
@@ -279,5 +282,5 @@
 	// Run the C preprocessor and save the output in the given file.
 
-	if ( fork() == 0 ) {								 // child process ?
+	if ( fork() == 0 ) {								// child process ?
 		// -o xxx.ii cannot be used to write the output file from cpp because no output file is created if cpp detects
 		// an error (e.g., cannot find include file). Whereas, output is always generated, even when there is an error,
@@ -319,9 +322,10 @@
 
 	if ( WIFSIGNALED(code) ) {							// child failed ?
+		rmtmpfile();									// remove tmpname
 		cerr << "CC1 Translator error: stage 1, child failed " << WTERMSIG(code) << endl;
 		exit( EXIT_FAILURE );
 	} // if
 
-	exit( WEXITSTATUS(code) );							// bad cpp result stops top-level gcc
+	exit( WEXITSTATUS( code ) );						// bad cpp result stops top-level gcc
 } // Stage1
 
@@ -371,9 +375,9 @@
 			} else if ( arg == "-fno-diagnostics-color" ) {
 				color_arg = Color_Auto;
-			}
+			} // if
 
 			if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
-				// Currently CFA does not suppose precompiled .h files.
-				prefix( arg, "--output-pch" ) ) {
+				 // Currently CFA does not suppose precompiled .h files.
+				 prefix( arg, "--output-pch" ) ) {
 
 				// strip inappropriate flags with an argument
@@ -388,9 +392,9 @@
 
 			} else {
-				args[nargs++] = argv[i];				// pass the flag along
+				args[nargs++] = argv[i];				// pass flag along
 				if ( arg == "-o" ) {
 					i += 1;
 					cpp_out = argv[i];
-					args[nargs++] = argv[i];			// pass the argument along
+					args[nargs++] = argv[i];			// pass argument along
 					#ifdef __DEBUG_H__
 					cerr << "arg:\"" << argv[i] << "\"" << endl;
@@ -439,5 +443,5 @@
 			} // if
 
-			cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + ".ifa";
+			cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + CFA_SUFFIX;
 			if ( creat( cfa_cpp_out.c_str(), 0666 ) == -1 ) {
 				perror( "CC1 Translator error: stage 2, creat" );
@@ -460,5 +464,5 @@
 	// output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
 
-	if ( fork() == 0 ) {								// child runs CFA
+	if ( fork() == 0 ) {								// child runs CFA preprocessor
 		cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
 		cargs[ncargs++] = cpp_in;
@@ -518,5 +522,5 @@
 	#endif // __DEBUG_H__
 
-	if ( fork() == 0 ) {								// child runs CFA
+	if ( fork() == 0 ) {								// child runs gcc
 		args[0] = compiler_path.c_str();
 		args[nargs++] = "-S";							// only compile and put assembler output in specified file
Index: driver/cfa.cc
===================================================================
--- driver/cfa.cc	(revision 9b34766037fcf6a9e66504724d599e583522b849)
+++ driver/cfa.cc	(revision a77496cbc62f805fc69d3c3f9abd928bfccc0e4b)
@@ -10,17 +10,16 @@
 // Created On       : Tue Aug 20 13:44:49 2002
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Aug 18 16:40:22 2020
-// Update Count     : 435
+// Last Modified On : Thu Aug 20 23:43:59 2020
+// Update Count     : 436
 //
 
 #include <iostream>
-#include <cstdio>      // perror
-#include <cstdlib>     // putenv, exit
-#include <climits>     // PATH_MAX
-#include <unistd.h>    // execvp
-#include <string>      // STL version
-#include <string.h>    // strcmp
-#include <algorithm>   // find
-
+#include <cstdio>										// perror
+#include <cstdlib>										// putenv, exit
+#include <climits>										// PATH_MAX
+#include <string>										// STL version
+#include <algorithm>									// find
+
+#include <unistd.h>										// execvp
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -34,10 +33,12 @@
 using std::to_string;
 
-// #define __DEBUG_H__
-
-// "N__=" suffix
-static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
-
-void Putenv( char * argv[], string arg ) {
+//#define __DEBUG_H__
+
+#define xstr(s) str(s)
+#define str(s) #s
+
+static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );		// "__CFA_FLAG__=" suffix
+
+static void Putenv( char * argv[], string arg ) {
 	// environment variables must have unique names
 	static int flags = 0;
@@ -49,10 +50,9 @@
 } // Putenv
 
-// check if string has prefix
-bool prefix( const string & arg, const string & pre ) {
+static bool prefix( const string & arg, const string & pre ) { // check if string has prefix
 	return arg.substr( 0, pre.size() ) == pre;
 } // prefix
 
-inline bool ends_with(const string & str, const string & sfix) {
+static inline bool ends_with(const string & str, const string & sfix) {
 	if (sfix.size() > str.size()) return false;
 	return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend());
@@ -60,5 +60,5 @@
 
 // check if string has suffix
-bool suffix( const string & arg ) {
+static bool suffix( const string & arg ) {
 	enum { NumSuffixes = 3 };
 	static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
@@ -70,5 +70,4 @@
 } // suffix
 
-
 static inline bool dirExists( const string & path ) {	// check if directory exists
     struct stat info;
@@ -79,5 +78,5 @@
 static inline string dir(const string & path) {
 	return path.substr(0, path.find_last_of('/'));
-}
+} // dir
 
 // Different path modes
@@ -118,7 +117,4 @@
 }
 
-
-#define xstr(s) str(s)
-#define str(s) #s
 
 int main( int argc, char * argv[] ) {
@@ -158,9 +154,9 @@
 	PathMode path = FromProc();
 
-	const char *args[argc + 100];						// cfa command line values, plus some space for additional flags
+	const char * args[argc + 100];						// cfa command line values, plus some space for additional flags
 	int sargs = 1;										// starting location for arguments in args list
 	int nargs = sargs;									// number of arguments in args list; 0 => command name
 
-	const char *libs[argc + 20];						// non-user libraries must come separately, plus some added libraries and flags
+	const char * libs[argc + 20];						// non-user libraries must come separately, plus some added libraries and flags
 	int nlibs = 0;
 
@@ -180,26 +176,22 @@
 
 			if ( arg == "-Xlinker" || arg == "-o" ) {
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 				i += 1;
 				if ( i == argc ) continue;				// next argument available ?
 				args[nargs++] = argv[i];				// pass argument along
 				if ( arg == "-o" ) o_file = i;			// remember file
-			} else if ( strncmp(arg.c_str(), "-XCFA", 5) == 0 ) {				// CFA pass through
-				if(arg.size() == 5) {
+
+				// CFA specific arguments
+
+			} else if ( strncmp(arg.c_str(), "-XCFA", 5) == 0 ) { // CFA pass through
+				if ( arg.size() == 5 ) {
 					i += 1;
-					if ( i == argc ) continue;				// next argument available ?
+					if ( i == argc ) continue;			// next argument available ?
 					Putenv( argv, argv[i] );
-
-					// CFA specific arguments
-				}
-				else if(arg[5] == ',') {
+				} else if ( arg[5] == ',' ) {			// CFA specific arguments
 					Putenv( argv, argv[i] + 6 );
-
-					// CFA specific arguments
-				}
-				else {
+				} else {								// CFA specific arguments
 					args[nargs++] = argv[i];
-				}
-
+				} // if
 			} else if ( arg == "-CFA" ) {
 				CFA_flag = true;						// strip the -CFA flag
@@ -210,16 +202,16 @@
 			} else if ( arg == "-nodebug" ) {
 				debug = false;							// strip the nodebug flag
-			} else if ( arg == "-nolib" ) {
-				nolib = true;							// strip the nodebug flag
 			} else if ( arg == "-quiet" ) {
 				quiet = true;							// strip the quiet flag
 			} else if ( arg == "-noquiet" ) {
 				quiet = false;							// strip the noquiet flag
+			} else if ( arg == "-no-include-stdhdr" ) {
+				noincstd_flag = true;					// strip the no-include-stdhdr flag
+			} else if ( arg == "-nolib" ) {
+				nolib = true;							// strip the nolib flag
 			} else if ( arg == "-help" ) {
 				help = true;							// strip the help flag
 			} else if ( arg == "-nohelp" ) {
 				help = false;							// strip the nohelp flag
-			} else if ( arg == "-no-include-stdhdr" ) {
-				noincstd_flag = true;					// strip the no-include-stdhdr flag
 			} else if ( arg == "-cfalib") {
 				compiling_libs = true;
@@ -235,14 +227,14 @@
 			} else if ( arg == "-v" ) {
 				verbose = true;							// verbosity required
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 			} else if ( arg == "-g" ) {
 				debugging = true;						// symbolic debugging required
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 			} else if ( arg == "-save-temps" ) {
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 				Putenv( argv, arg );					// save cfa-cpp output
 			} else if ( prefix( arg, "-x" ) ) {			// file suffix ?
 				string lang;
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 				if ( arg.length() == 2 ) {				// separate argument ?
 					i += 1;
@@ -261,11 +253,11 @@
 			} else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
 				std_flag = true;						// -std=XX provided
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 			} else if ( arg == "-w" ) {
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 				Putenv( argv, arg );
 			} else if ( prefix( arg, "-W" ) ) {			// check before next tests
 				if ( arg == "-Werror" || arg == "-Wall" ) {
-					args[nargs++] = argv[i];			// pass argument along
+					args[nargs++] = argv[i];			// pass flag along
 					Putenv( argv, argv[i] );
 				} else {
@@ -281,9 +273,15 @@
 				bprefix = arg.substr(2);				// strip the -B flag
 			} else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
-				args[nargs++] = argv[i];				// pass argument along
+				args[nargs++] = argv[i];				// pass flag along
 				if ( arg == "-E" || arg == "-M" || arg == "-MM" ) {
 					cpp_flag = true;					// cpp only
 				} // if
 				link = false;                           // no linkage required
+			} else if ( arg == "-D" || arg == "-U" || arg == "-I" || arg == "-MF" || arg == "-MT" || arg == "-MQ" ||
+						arg == "-include" || arg == "-imacros" || arg == "-idirafter" || arg == "-iprefix" ||
+						arg == "-iwithprefix" || arg == "-iwithprefixbefore" || arg == "-isystem" || arg == "-isysroot" ) {
+				args[nargs++] = argv[i];				// pass flag along
+				i += 1;
+				args[nargs++] = argv[i];				// pass argument along
 			} else if ( arg[1] == 'l' ) {
 				// if the user specifies a library, load it after user code
@@ -337,5 +335,5 @@
 	string libbase;
 	switch(path) {
-	case Installed:
+	  case Installed:
 		args[nargs++] = "-I" CFA_INCDIR;
 		// do not use during build
@@ -347,6 +345,6 @@
 		libbase = CFA_LIBDIR;
 		break;
-	case BuildTree:
-	case Distributed:
+	  case BuildTree:
+	  case Distributed:
 		args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
 		// do not use during build
@@ -382,5 +380,5 @@
 	string libdir = libbase + arch + "-" + config;
 
-	if (path != Distributed) {
+	if ( path != Distributed ) {
 		if ( ! nolib && ! dirExists( libdir ) ) {
 			cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
@@ -402,8 +400,8 @@
 	string preludedir;
 	switch(path) {
-	case Installed   : preludedir = libdir; break;
-	case BuildTree   : preludedir = libdir + "/prelude"; break;
-	case Distributed : preludedir = dir(argv[0]); break;
-	}
+	  case Installed   : preludedir = libdir; break;
+	  case BuildTree   : preludedir = libdir + "/prelude"; break;
+	  case Distributed : preludedir = dir(argv[0]); break;
+	} // switch
 
 	Putenv( argv, "--prelude-dir=" + preludedir );
@@ -477,11 +475,11 @@
 	if ( bprefix.length() == 0 ) {
 		switch(path) {
-		case Installed   : bprefix = installlibdir; break;
-		case BuildTree   : bprefix = srcdriverdir ; break;
-		case Distributed : bprefix = dir(argv[0]) ; break;
-		}
-		if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';
-		Putenv( argv, string("-B=") + bprefix );
-	} // if
+		  case Installed   : bprefix = installlibdir; break;
+		  case BuildTree   : bprefix = srcdriverdir ; break;
+		  case Distributed : bprefix = dir(argv[0]) ; break;
+		} // switch
+	} // if
+	if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';
+	Putenv( argv, string("-B=") + bprefix );
 
 	args[nargs++] = "-Xlinker";							// used by backtrace
@@ -505,6 +503,6 @@
 		args[nargs++] = "-Wno-cast-function-type";
 		#endif // HAVE_CAST_FUNCTION_TYPE
-		if ( ! std_flag ) {								// default c11, if none specified
-			args[nargs++] = "-std=gnu11";
+		if ( ! std_flag && ! x_flag ) {
+			args[nargs++] = "-std=gnu11";				// default c11, if none specified
 		} // if
 		args[nargs++] = "-fgnu89-inline";
@@ -556,5 +554,5 @@
 	// execute the command and return the result
 
-	execvp( args[0], (char *const *)args );				// should not return
+	execvp( args[0], (char * const *)args );			// should not return
 	perror( "CFA Translator error: execvp" );
 	exit( EXIT_FAILURE );
