Index: flang/lib/Semantics/check-declarations.cpp =================================================================== --- flang/lib/Semantics/check-declarations.cpp +++ flang/lib/Semantics/check-declarations.cpp @@ -351,6 +351,10 @@ "A dummy argument may not have the SAVE attribute"_err_en_US); } } else if (IsFunctionResult(symbol)) { + if (IsNamedConstant(symbol)) { + messages_.Say( + "A function result may not also be a named constant"_err_en_US); + } if (!symbol.test(Symbol::Flag::InDataStmt) /*caught elsewhere*/ && IsSaved(symbol)) { messages_.Say( Index: flang/test/Semantics/declarations01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/declarations01.f90 @@ -0,0 +1,8 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 +! test named constant declarations + +function f1() result(x) + !ERROR: A function result may not also be a named constant + integer, parameter :: x = 1 +end +