@@ -667,14 +667,8 @@ 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 );
671+ const bool unknown_std = cstd == CUnknown && cppstd == CUnknown;
678672
679673 Location location (fileIndex (filename), 1 , 1 );
680674 while (stream.good ()) {
@@ -760,15 +754,29 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
760754 line = std::numeric_limits<unsigned long >::max ();
761755 }
762756
757+ unsigned long maxline;
758+ if ((cstd != CUnknown && cstd < C99 ) || (cppstd != CPPUnknown && cppstd < CPP11 ))
759+ maxline = 32767 ;
760+ else
761+ maxline = 2147483647 ;
762+
763763 if (line == 0 || line > maxline) {
764764 if (outputList) {
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