diff --git a/flang/docs/IntrinsicTypes.md b/flang/docs/IntrinsicTypes.md --- a/flang/docs/IntrinsicTypes.md +++ b/flang/docs/IntrinsicTypes.md @@ -73,8 +73,7 @@ #### Modifying the default kind with default-integer-8: INTEGER 8 - -There is no option to modify the default logical kind. +LOGICAL 8 Modules compiled with different default-real and default-integer kinds may be freely mixed. 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 @@ -704,6 +704,7 @@ res.getDefaultKinds().set_defaultIntegerKind(8); res.getDefaultKinds().set_subscriptIntegerKind(8); res.getDefaultKinds().set_sizeIntegerKind(8); + res.getDefaultKinds().set_defaultLogicalKind(8); } if (args.hasArg(clang::driver::options::OPT_fdefault_double_8)) { if (!args.hasArg(clang::driver::options::OPT_fdefault_real_8)) { diff --git a/flang/test/Lower/Intrinsics/get_environment_variable.f90 b/flang/test/Lower/Intrinsics/get_environment_variable.f90 --- a/flang/test/Lower/Intrinsics/get_environment_variable.f90 +++ b/flang/test/Lower/Intrinsics/get_environment_variable.f90 @@ -82,7 +82,8 @@ ! CHECK-LABEL: func @_QPname_and_trim_name_only( ! CHECK-SAME: %[[nameArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "name"}, -! CHECK-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}) { +! CHECK-32-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}) { +! CHECK-64-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}) { subroutine name_and_trim_name_only(name, trim_name) character(len=32) :: name logical :: trim_name @@ -120,7 +121,8 @@ ! CHECK-SAME: %[[valueArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "value"}, ! CHECK-SAME: %[[lengthArg:[^:]*]]: !fir.ref {fir.bindc_name = "length"}, ! CHECK-SAME: %[[statusArg:.*]]: !fir.ref {fir.bindc_name = "status"}, -! CHECK-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}, +! CHECK-32-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}, +! CHECK-64-SAME: %[[trimNameArg:.*]]: !fir.ref> {fir.bindc_name = "trim_name"}, ! CHECK-SAME: %[[errmsgArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "errmsg"}) { subroutine all_arguments(name, value, length, status, trim_name, errmsg) character(len=32) :: name, value, errmsg @@ -138,15 +140,17 @@ ! CHECK-NEXT: %[[lengthBoxed:.*]] = fir.embox %[[lengthArg]] : (!fir.ref) -> !fir.box ! CHECK-NEXT: %[[errmsgBoxed:.*]] = fir.embox %[[errmsgCast]] : (!fir.ref>) -> !fir.box> ! CHECK: %[[trimName:.*]] = fir.if %{{.*}} -> (i1) { -! CHECK-NEXT: %[[trimNameLoaded:.*]] = fir.load %[[trimNameArg]] : !fir.ref> -! CHECK-NEXT: %[[trimCast:.*]] = fir.convert %[[trimNameLoaded]] : (!fir.logical<4>) -> i1 +! CHECK-32-NEXT: %[[trimNameLoaded:.*]] = fir.load %[[trimNameArg]] : !fir.ref> +! CHECK-64-NEXT: %[[trimNameLoaded:.*]] = fir.load %[[trimNameArg]] : !fir.ref> +! CHECK-32-NEXT: %[[trimCast:.*]] = fir.convert %[[trimNameLoaded]] : (!fir.logical<4>) -> i1 +! CHECK-64-NEXT: %[[trimCast:.*]] = fir.convert %[[trimNameLoaded]] : (!fir.logical<8>) -> i1 ! CHECK-NEXT: fir.result %[[trimCast]] : i1 ! CHECK-NEXT: } else { ! CHECK-NEXT: %[[trueVal:.*]] = arith.constant true ! CHECK-NEXT: fir.result %[[trueVal]] : i1 ! CHECK-NEXT: } ! CHECK: %[[sourceFileString:.*]] = fir.address_of(@_QQcl.[[fileString:.*]]) : !fir.ref> -! CHECK-NEXT: %[[sourceLine:.*]] = arith.constant [[# @LINE - 20]] : i32 +! CHECK-NEXT: %[[sourceLine:.*]] = arith.constant [[# @LINE - 22]] : i32 ! CHECK-NEXT: %[[name:.*]] = fir.convert %[[nameBoxed]] : (!fir.box>) -> !fir.box ! CHECK-NEXT: %[[value:.*]] = fir.convert %[[valueBoxed]] : (!fir.box>) -> !fir.box ! CHECK-NEXT: %[[length:.*]] = fir.convert %[[lengthBoxed]] : (!fir.box) -> !fir.box diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp --- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp +++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp @@ -405,6 +405,7 @@ defaultKinds.set_defaultRealKind(8); } else if (arg == "-i8" || arg == "-fdefault-integer-8") { defaultKinds.set_defaultIntegerKind(8); + defaultKinds.set_defaultLogicalKind(8); } else if (arg == "-help" || arg == "--help" || arg == "-?") { llvm::errs() << "f18-parse-demo options:\n"