@@ -619,6 +619,10 @@ static struct file_name_list *last_include = 0; /* Last in chain */
619619static struct file_name_list * after_include = 0 ;
620620static struct file_name_list * last_after_include = 0 ; /* Last in chain */
621621
622+ /* Chain to put at the start of the system include files. */
623+ static struct file_name_list * before_system = 0 ;
624+ static struct file_name_list * last_before_system = 0 ; /* Last in chain */
625+
622626/* List of included files that contained #pragma once. */
623627static struct file_name_list * dont_repeat_files = 0 ;
624628
@@ -1177,6 +1181,27 @@ main (argc, argv)
11771181 else
11781182 include_prefix = argv [++ i ];
11791183 }
1184+ if (!strcmp (argv [i ], "-isystem" )) {
1185+ struct file_name_list * dirtmp ;
1186+
1187+ if (i + 1 == argc )
1188+ fatal ("Filename missing after `-isystem' option" );
1189+
1190+ dirtmp = (struct file_name_list * )
1191+ xmalloc (sizeof (struct file_name_list ));
1192+ dirtmp -> next = 0 ;
1193+ dirtmp -> control_macro = 0 ;
1194+ dirtmp -> c_system_include_path = 1 ;
1195+ dirtmp -> fname = (char * ) xmalloc (strlen (argv [i + 1 ]) + 1 );
1196+ strcpy (dirtmp -> fname , argv [++ i ]);
1197+ dirtmp -> got_name_map = 0 ;
1198+
1199+ if (before_system == 0 )
1200+ before_system = dirtmp ;
1201+ else
1202+ last_before_system -> next = dirtmp ;
1203+ last_before_system = dirtmp ; /* Tail follows the last one */
1204+ }
11801205 /* Add directory to end of path for includes,
11811206 with the default prefix at the front of its name. */
11821207 if (!strcmp (argv [i ], "-iwithprefix" )) {
@@ -1733,7 +1758,9 @@ main (argc, argv)
17331758 }
17341759 }
17351760
1736- first_system_include = 0 ;
1761+ append_include_chain (before_system , last_before_system );
1762+ first_system_include = before_system ;
1763+
17371764 /* Unless -fnostdinc,
17381765 tack on the standard include file dirs to the specified list */
17391766 if (!no_standard_includes ) {
0 commit comments