diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -495,6 +495,8 @@ opts.searchDirectoriesFromIntrModPath.emplace_back(currentArg->getValue()); // -cpp/-nocpp + // Set the default so that we process macros + opts.macrosFlag = PPMacrosFlag::Include; if (const auto *currentArg = args.getLastArg( clang::driver::options::OPT_cpp, clang::driver::options::OPT_nocpp)) opts.macrosFlag = @@ -762,6 +764,19 @@ Fortran::common::LanguageFeature::OpenMP)) { fortranOptions.predefinitions.emplace_back("_OPENMP", "201511"); } +#if __x86_64__ + fortranOptions.predefinitions.emplace_back("__x86_64__", "1"); +#elif __aarch64__ + fortranOptions.predefinitions.emplace_back("__aarch64__", "1"); +#elif defined(_M_AMD64) + // MSVC option for x86 64 bit and ARM emulation mode + fortranOptions.predefinitions.emplace_back("__x86_64__", "1"); +#elif defined(_M_ARM64) + // MSVC option for ARM 64bit + fortranOptions.predefinitions.emplace_back("__aarch64__", "1"); +#else +#error "arch not set" +#endif } void CompilerInvocation::setFortranOpts() { diff --git a/flang/test/Driver/debug-provenance.f90 b/flang/test/Driver/debug-provenance.f90 --- a/flang/test/Driver/debug-provenance.f90 +++ b/flang/test/Driver/debug-provenance.f90 @@ -1,6 +1,6 @@ ! Ensure argument -fdebug-dump-provenance works as expected. -! RUN: %flang_fc1 -fdebug-dump-provenance %s 2>&1 | FileCheck %s +! RUN: %flang_fc1 -nocpp -fdebug-dump-provenance %s 2>&1 | FileCheck %s ! CHECK: AllSources: ! CHECK-NEXT: AllSources range_ [{{[0-9]*}}..{{[0-9]*}}] ({{[0-9]*}} bytes) diff --git a/flang/test/Driver/input-from-stdin/input-from-stdin.f90 b/flang/test/Driver/input-from-stdin/input-from-stdin.f90 --- a/flang/test/Driver/input-from-stdin/input-from-stdin.f90 +++ b/flang/test/Driver/input-from-stdin/input-from-stdin.f90 @@ -6,7 +6,7 @@ ! Input type is implicit ! RUN: cat %s | %flang -E -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED ! RUN: cat %s | %flang -DNEW -E -cpp - | FileCheck %s --check-prefix=PP-DEFINED -! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED ! RUN: cat %s | %flang -DNEW -E -nocpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED ! Input type is explicit