@@ -667,14 +667,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
667667 const Token *oldLastToken = nullptr ;
668668
669669 const cstd_t cstd = getCStd (dui.std );
670- const bool std_is_c = cstd != CUnknown;
671- const cppstd_t cppstd = getCppStd (dui.std , std_is_c ? CPPUnknown : CPP26 ); // use C++26 by default
672-
673- unsigned long maxline;
674- if ((cstd != CUnknown && cstd < C99 ) || (cppstd != CPPUnknown && cppstd < CPP11 ))
675- maxline = 32767 ;
676- else
677- maxline = 2147483647 ;
670+ const cppstd_t cppstd = getCppStd (dui.std );
678671
679672 Location location (fileIndex (filename), 1 , 1 );
680673 while (stream.good ()) {
@@ -760,15 +753,30 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
760753 line = std::numeric_limits<unsigned long >::max ();
761754 }
762755
756+ unsigned long maxline;
757+ if ((cstd != CUnknown && cstd < C99 ) || (cppstd != CPPUnknown && cppstd < CPP11 ))
758+ maxline = 32767 ;
759+ else
760+ maxline = 2147483647 ;
761+
763762 if (line == 0 || line > maxline) {
764763 if (outputList) {
764+ const bool unknown_std = cstd == CUnknown && cppstd == CPPUnknown;
765765 std::string msg = " Line number out of range: " + ppTok->str () + " . " ;
766766 if (line == 0 ) {
767767 msg += " Line number zero is undefined behavior." ;
768768 } else {
769- msg += " Line numbers above " + std::to_string (maxline) + " are " +
770- (cppstd >= CPP26 ? " conditionally supported" : " undefined behavior" ) +
771- " in " + (std_is_c ? getCStdName (cstd) : getCppStdName (cppstd)) + " ." ;
769+ msg += " Line numbers above " + std::to_string (maxline) + " are " ;
770+ if (unknown_std || cppstd >= CPP26 )
771+ msg += " conditionally supported" ;
772+ else
773+ msg += " undefined behavior" ;
774+ msg += " in " ;
775+ if (cstd != CUnknown)
776+ msg += getCStdName (cstd);
777+ else
778+ msg += getCppStdName (unknown_std ? CPP26 : cppstd);
779+ msg += " ." ;
772780 }
773781 simplecpp::Output err{
774782 simplecpp::Output::PORTABILITY_LINE_DIRECTIVE ,
0 commit comments