Changeset 5546eee4 for src


Ignore:
Timestamp:
Dec 16, 2023, 1:01:44 AM (22 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
b7898ac
Parents:
0fa0201d (diff), 69ab896 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r0fa0201d r5546eee4  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thu May  5 12:10:00 2022
    13 // Update Count     : 24
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Dec  9 16:28:51 2023
     13// Update Count     : 31
    1414//
    1515
     
    113113// --- EnumDecl
    114114
    115 bool EnumDecl::valueOf( const Decl * enumerator, long long& value ) const {
     115bool EnumDecl::valueOf( const Decl * enumerator, long long & value ) const {
    116116        if ( enumValues.empty() ) {
    117117                Evaluation crntVal = {0, true, true};  // until expression is given, we know to start counting from 0
    118118                for ( const Decl * member : members ) {
    119                         const ObjectDecl* field = strict_dynamic_cast< const ObjectDecl* >( member );
     119                        const ObjectDecl * field = strict_dynamic_cast< const ObjectDecl * >( member );
    120120                        if ( field->init ) {
    121                                 const SingleInit * init = strict_dynamic_cast< const SingleInit* >( field->init.get() );
     121                                const SingleInit * init = strict_dynamic_cast< const SingleInit * >( field->init.get() );
    122122                                crntVal = eval( init->value );
    123123                                if ( ! crntVal.isEvaluableInGCC ) {
    124                                         SemanticError( init->location, ::toString( "Non-constexpr in initialization of "
    125                                                 "enumerator: ", field ) );
     124                                        SemanticError( init->location, "Non-constexpr in initialization of enumerator %s", field->name.c_str() );
    126125                                }
    127126                        }
    128127                        if ( enumValues.count( field->name ) != 0 ) {
    129                                 SemanticError( location, ::toString( "Enum ", name, " has multiple members with the "   "name ", field->name ) );
     128                                SemanticError( location, "Enum %s has multiple members with %s", name.c_str(), field->name.c_str() );
    130129                        }
    131130                        if (crntVal.hasKnownValue) {
  • src/AST/Expr.cpp

    r0fa0201d r5546eee4  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May 15 17:00:00 2019
    11 // Last Modified By : Andrew Beach
     11// Last Modified By : Peter A. Buhr
    1212// Created On       : Wed May 18 13:56:00 2022
    13 // Update Count     : 8
     13// Update Count     : 12
    1414//
    1515
     
    168168                        return addrType( refType->base );
    169169                } else {
    170                         SemanticError( loc, arg->result.get(),
    171                                 "Attempt to take address of non-lvalue expression: " );
     170                        SemanticError( loc, "Attempt to take address of non-lvalue expression %s",
     171                                                   toString( arg->result.get() ).c_str() );
    172172                }
    173173        }
     
    240240                return 1;
    241241        }
    242         SemanticError( this, "Constant expression of non-integral type " );
     242        SemanticError( this->location, "Constant expression of non-integral type %s",
     243                                   toString( this ).c_str() );
    243244}
    244245
  • src/AST/LinkageSpec.cpp

    r0fa0201d r5546eee4  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 11 16:08:58 2023
     13// Update Count     : 2
    1414//
    1515
     
    3737                return spec;
    3838        } else {
    39                 SemanticError( loc, "Invalid linkage specifier " + *cmd );
     39                SemanticError( loc, "Invalid linkage specifier %s", cmd->c_str() );
    4040        }
    4141}
  • src/AST/TypeSubstitution.hpp

    r0fa0201d r5546eee4  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May 25 12:31:00 2023
    13 // Update Count     : 10
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Dec 11 16:07:30 2023
     13// Update Count     : 15
    1414//
    1515
     
    156156                                } // if
    157157                        } else {
    158                                 SemanticError( formal, toString( "Attempt to provide non-type parameter: ", toString( *actualIt ).c_str(), " for type parameter " ) );
     158                                SemanticError( formal->location, "Attempt to provide non-type parameter %s for type parameter %s",
     159                                                           toString( *actualIt ).c_str(), formal->name.c_str() );
    159160                        } // if
    160161                } else {
  • src/CodeGen/CodeGenerator.cpp

    r0fa0201d r5546eee4  
    10261026        output << " ) ";
    10271027
    1028         output << "{";
     1028        output << "{" << endl;
    10291029        ++indent;
    10301030        for ( auto node : stmt->cases ) {
  • src/CodeGen/FixMain.cc

    r0fa0201d r5546eee4  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 0
     13// Update Count     : 1
    1414//
    1515
     
    3939                if ( isMain( decl ) ) {
    4040                        if ( main_declaration ) {
    41                                 SemanticError( decl, "Multiple definition of main routine\n" );
     41                                SemanticError( decl, "Multiple definition of main routine" );
    4242                        }
    4343                        main_declaration = decl;
  • src/CodeGen/FixNames.cc

    r0fa0201d r5546eee4  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 20 11:49:00 2022
    13 // Update Count     : 24
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 16:16:51 2023
     13// Update Count     : 25
    1414//
    1515
     
    5757                        int nargs = mutDecl->params.size();
    5858                        if ( 0 != nargs && 2 != nargs && 3 != nargs ) {
    59                                 SemanticError( functionDecl, "Main expected to have 0, 2 or 3 arguments\n" );
     59                                SemanticError( functionDecl, "Main expected to have 0, 2 or 3 arguments" );
    6060                        }
    6161                        ast::chain_mutate( mutDecl->stmts )->kids.push_back(
  • src/Common/ErrorObjects.h

    r0fa0201d r5546eee4  
    4646        std::list< error > errors;
    4747};
    48 
    49 void SemanticWarningImpl( CodeLocation location, std::string error );
    50 
    51 template< typename T >
    52 static inline void SemanticWarningImpl( const T * obj, const std::string & error ) {
    53         SemanticWarning( obj->location, toString( error, obj ) );
    54 }
    55 
    56 template< typename T >
    57 static inline void SemanticWarningImpl( CodeLocation location, const T * obj, const std::string & error ) {
    58         SemanticWarningImpl( location, toString( error, obj ) );
    59 }
  • src/Common/SemanticError.cc

    r0fa0201d r5546eee4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 08:05:26 2018
    13 // Update Count     : 10
     12// Last Modified On : Thu Dec 14 13:45:28 2023
     13// Update Count     : 34
    1414//
    1515
     
    2323#include <vector>
    2424
     25using namespace std;
     26
    2527#include "Common/utility.h"                                                             // for to_string, CodeLocation (ptr only)
    2628#include "SemanticError.h"
     
    2830//-----------------------------------------------------------------------------
    2931// Severity Handling
    30 std::vector<Severity> & get_severities() {
    31         static std::vector<Severity> severities;
     32vector<Severity> & get_severities() {
     33        static vector<Severity> severities;
    3234        if(severities.empty()) {
    3335                severities.reserve((size_t)Warning::NUMBER_OF_WARNINGS);
     
    6062        size_t idx = 0;
    6163        for ( const auto & w : WarningFormats ) {
    62                 if ( std::strcmp( name, w.name ) == 0 ) {
     64                if ( strcmp( name, w.name ) == 0 ) {
    6365                        get_severities()[idx] = s;
    6466                        break;
     
    7072//-----------------------------------------------------------------------------
    7173// Semantic Error
     74
    7275bool SemanticErrorThrow = false;
    7376
    74 SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) {
     77SemanticErrorException::SemanticErrorException( CodeLocation location, string error ) {
    7578        append( location, error );
    7679}
     
    8083}
    8184
    82 void SemanticErrorException::append( CodeLocation location, const std::string & msg ) {
     85void SemanticErrorException::append( CodeLocation location, const string & msg ) {
    8386        errors.emplace_back( location, msg );
    8487}
     
    8992
    9093void SemanticErrorException::print() {
    91         using std::to_string;
     94//      using to_string;
    9295
    9396        errors.sort([](const error & lhs, const error & rhs) -> bool {
     
    99102
    100103        for( auto err : errors ) {
    101                 std::cerr << ErrorHelpers::bold() << err.location << ErrorHelpers::error_str() << ErrorHelpers::reset_font() << err.description << std::endl;
     104                cerr << ErrorHelpers::bold() << err.location << ErrorHelpers::error_str() << ErrorHelpers::reset_font() << err.description << endl;
    102105        }
    103106}
    104107
    105 void SemanticError( CodeLocation location, std::string error ) {
     108void SemanticError( CodeLocation location, const char * fmt, ... ) {
     109        char msg[2048];                                                                         // worst-case error-message buffer
     110        va_list args;
     111        va_start( args, fmt );
     112        vsnprintf( msg, sizeof(msg), fmt, args );                       // always null terminated, but may be truncated
     113        va_end( args );
     114
    106115        SemanticErrorThrow = true;
    107         throw SemanticErrorException( location, error );
     116        throw SemanticErrorException( location, msg );          // convert msg to string
    108117}
    109118
    110 namespace {
    111         // convert format string and arguments into a single string
    112         std::string fmtToString(const char * fmt, va_list ap) {
    113                 int size = 128;
    114                 while ( true ) {
    115                         char buf[size];
    116                         va_list args;
    117                         va_copy( args, ap );
    118                         int n = vsnprintf(&buf[0], size, fmt, args);
    119                         va_end( args );
    120                         if ( n < size && n >= 0 ) return buf;
    121                         size *= 2;
    122                 }
    123                 assert( false );
    124         }
    125 }
     119void SemanticWarning( CodeLocation location, Warning warning, ... ) {
     120        Severity severity = get_severities()[(int)warning];
    126121
    127 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) {
    128         Severity severity = get_severities()[(int)warning];
    129         switch(severity) {
     122        switch ( severity ) {
    130123        case Severity::Suppress :
    131124                break;
    132125        case Severity::Warn :
    133                 {
    134                         va_list args;
    135                         va_start(args, fmt);
    136                         std::string msg = fmtToString( fmt, args );
    137                         va_end(args);
    138                         std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
    139                 }
    140                 break;
    141126        case Severity::Error :
    142127                {
     128                        char msg[2048];                                                         // worst-case error-message buffer
    143129                        va_list args;
    144                         va_start(args, fmt);
    145                         std::string msg = fmtToString( fmt, args );
    146                         va_end(args);
    147                         SemanticError(location, msg);
     130                        va_start( args, warning );
     131                        vsnprintf( msg, sizeof(msg), WarningFormats[(int)warning].message, args ); // always null terminated, but may be truncated
     132                        va_end( args );
     133
     134                        if ( severity == Severity::Warn ) {
     135                                cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << endl;
     136                        } else {
     137                                SemanticError( location, string( msg ) );
     138                        }
    148139                }
    149140                break;
     
    163154        }
    164155
    165         const std::string & error_str() {
    166                 static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
     156        const string & error_str() {
     157                static string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
    167158                return str;
    168159        }
    169160
    170         const std::string & warning_str() {
    171                 static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
     161        const string & warning_str() {
     162                static string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
    172163                return str;
    173164        }
    174165
    175         const std::string & bold_ttycode() {
    176                 static std::string str = with_colors() ? "\e[1m" : "";
     166        const string & bold_ttycode() {
     167                static string str = with_colors() ? "\e[1m" : "";
    177168                return str;
    178169        }
    179170
    180         const std::string & reset_font_ttycode() {
    181                 static std::string str = with_colors() ? "\e[0m" : "";
     171        const string & reset_font_ttycode() {
     172                static string str = with_colors() ? "\e[0m" : "";
    182173                return str;
    183174        }
    184175
    185         std::string make_bold( const std::string & str ) {
     176        string make_bold( const string & str ) {
    186177                return bold_ttycode() + str + reset_font_ttycode();
    187178        }
    188179
    189         std::ostream & operator<<(std::ostream & os, bold) {
     180        ostream & operator<<(ostream & os, bold) {
    190181                os << bold_ttycode();
    191182                return os;
    192183        }
    193184
    194         std::ostream & operator<<(std::ostream & os, reset_font) {
     185        ostream & operator<<(ostream & os, reset_font) {
    195186                os << reset_font_ttycode();
    196187                return os;
  • src/Common/SemanticError.h

    r0fa0201d r5546eee4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 12:01:31 2023
    13 // Update Count     : 37
     12// Last Modified On : Thu Dec 14 13:48:07 2023
     13// Update Count     : 72
    1414//
    1515
     
    1818#include "ErrorObjects.h"
    1919#include "AST/Node.hpp"
     20#include "AST/ParseNode.hpp"
    2021#include <cstring>
    2122
     
    2526extern bool SemanticErrorThrow;
    2627
    27 __attribute__((noreturn)) void SemanticError( CodeLocation location, std::string error );
     28__attribute__((noreturn, format(printf, 2, 3))) void SemanticError( CodeLocation location, const char fmt[], ... );
    2829
    29 template< typename T >
    30 __attribute__((noreturn)) static inline void SemanticError( const T * obj, const std::string & error ) {
     30__attribute__((noreturn)) static inline void SemanticError( CodeLocation location, std::string error ) {
     31        SemanticErrorThrow = true;
     32        throw SemanticErrorException( location, error );
     33}
     34
     35__attribute__((noreturn)) static inline void SemanticError( const ast::ParseNode * obj, const std::string & error ) {
    3136        SemanticError( obj->location, toString( error, obj ) );
    3237}
    3338
    34 template< typename T >
    35 __attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const T * obj, const std::string & error ) {
     39__attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const ast::Node * obj, const std::string & error ) {
    3640        SemanticError( location, toString( error, obj ) );
    3741}
     
    5458
    5559constexpr WarningData WarningFormats[] = {
    56         {"self-assign"              , Severity::Warn    , "self assignment of expression: %s"                          },
    57         {"reference-conversion"     , Severity::Warn    , "rvalue to reference conversion of rvalue: %s"               },
    58         {"qualifiers-zero_t-one_t"  , Severity::Warn    , "questionable use of type qualifier(s) with %s"              },
    59         {"aggregate-forward-decl"   , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
    60         {"superfluous-decl"         , Severity::Warn    , "declaration does not allocate storage: %s"                  },
    61         {"superfluous-else"         , Severity::Warn    , "else clause never executed for empty loop conditional"      },
    62         {"gcc-attributes"           , Severity::Warn    , "invalid attribute: %s"                                      },
    63         {"c++-like-copy"            , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
    64         {"depreciated-trait-syntax" , Severity::Warn    , "trait type-parameters are now specified using the forall clause" },
     60        {"self-assign"              , Severity::Warn, "self assignment of expression: %s"                          },
     61        {"reference-conversion"     , Severity::Warn, "rvalue to reference conversion of rvalue: %s"               },
     62        {"qualifiers-zero_t-one_t"  , Severity::Warn, "questionable use of type qualifier(s) with %s"              },
     63        {"aggregate-forward-decl"   , Severity::Warn, "forward declaration of nested aggregate: %s"                },
     64        {"superfluous-decl"         , Severity::Warn, "declaration does not allocate storage: %s"                  },
     65        {"superfluous-else"         , Severity::Warn, "else clause never executed for empty loop conditional"      },
     66        {"gcc-attributes"           , Severity::Warn, "invalid attribute: %s"                                      },
     67        {"c++-like-copy"            , Severity::Warn, "Constructor from reference is not a valid copy constructor" },
     68        {"depreciated-trait-syntax" , Severity::Warn, "trait type-parameters are now specified using the forall clause" },
    6569};
    6670
     
    7579        CppCopy,
    7680        DeprecTraitSyntax,
    77         NUMBER_OF_WARNINGS, // This MUST be the last warning
     81        NUMBER_OF_WARNINGS, // MUST be last warning
    7882};
    7983
     
    8387);
    8488
    85 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, ##__VA_ARGS__)
     89void SemanticWarning( CodeLocation loc, Warning warn, ... );
    8690
    87 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
    88 
    89 void SemanticWarning_SuppressAll   ();
    90 void SemanticWarning_EnableAll     ();
     91void SemanticWarning_SuppressAll();
     92void SemanticWarning_EnableAll();
    9193void SemanticWarning_WarningAsError();
    92 void SemanticWarning_Set           (const char * const name, Severity s);
     94void SemanticWarning_Set(const char * const name, Severity s);
    9395
    9496// SKULLDUGGERY: cfa.cc is built before SemanticError.cc but needs this routine.
  • src/Concurrency/Corun.cpp

    r0fa0201d r5546eee4  
    99// Author           : Colby Parsons
    1010// Created On       : Monday October 9 15:16:42 2023
    11 // Last Modified By : Colby Parsons
    12 // Last Modified On : Monday October 9 15:16:42 2023
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 17:32:17 2023
     13// Update Count     : 1
    1414//
    1515
     
    5757    Stmt * postvisit( const CoforStmt * stmt ) {
    5858        if ( !runnerBlockDecl || !coforRunnerDecl )
    59             SemanticError( stmt->location, "To use cofor statements add #include <cofor.hfa>\n" );
     59            SemanticError( stmt->location, "To use cofor statements add #include <cofor.hfa>" );
    6060
    6161        if ( stmt->inits.size() != 1 )
    62             SemanticError( stmt->location, "Cofor statements must have a single initializer in the loop control\n" );
     62            SemanticError( stmt->location, "Cofor statements must have a single initializer in the loop control" );
    6363
    6464        if ( !stmt->body )
     
    7777        const DeclStmt * declStmtPtr = dynamic_cast<const DeclStmt *>(stmt->inits.at(0).get());
    7878        if ( ! declStmtPtr )
    79             SemanticError( stmt->location, "Cofor statement initializer is somehow not a decl statement?\n" );
     79            SemanticError( stmt->location, "Cofor statement initializer is somehow not a decl statement?" );
    8080
    8181        const Decl * declPtr = dynamic_cast<const Decl *>(declStmtPtr->decl.get());
    8282        if ( ! declPtr )
    83             SemanticError( stmt->location, "Cofor statement initializer is somehow not a decl?\n" );
     83            SemanticError( stmt->location, "Cofor statement initializer is somehow not a decl?" );
    8484
    8585        Type * initType = new TypeofType( new NameExpr( loc, declPtr->name ) );
     
    246246    Stmt * postvisit( const CorunStmt * stmt ) {
    247247        if ( !runnerBlockDecl || !coforRunnerDecl )
    248             SemanticError( stmt->location, "To use corun statements add #include <cofor.hfa>\n" );
     248            SemanticError( stmt->location, "To use corun statements add #include <cofor.hfa>" );
    249249
    250250        if ( !stmt->stmt )
  • src/Concurrency/Keywords.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Tue Nov 16  9:53:00 2021
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Mar 11 10:40:00 2022
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:02:25 2023
     13// Update Count     : 6
    1414//
    1515
     
    682682
    683683        if ( 0 != decl->returns.size() ) {
    684                 SemanticError( decl->location, "Generator main must return void" );
     684                SemanticError( decl->location, "Generator main must return void." );
    685685        }
    686686
     
    789789        case ast::SuspendStmt::Generator:
    790790                // Generator suspends must be directly in a generator.
    791                 if ( !in_generator ) SemanticError( stmt->location, "'suspend generator' must be used inside main of generator type." );
     791                if ( !in_generator ) SemanticError( stmt->location, "\"suspend generator\" must be used inside main of generator type." );
    792792                return make_generator_suspend( stmt );
    793793        }
     
    847847
    848848        if ( !decl_suspend ) {
    849                 SemanticError( location, "suspend keyword applied to coroutines requires coroutines to be in scope, add #include <coroutine.hfa>\n" );
     849                SemanticError( location, "suspend keyword applied to coroutines requires coroutines to be in scope, add #include <coroutine.hfa>." );
    850850        }
    851851        if ( stmt->then ) {
     
    918918                        // If it is a monitor, then it is a monitor.
    919919                        if( baseStruct->base->is_monitor() || baseStruct->base->is_thread() ) {
    920                                 SemanticError( decl, "destructors for structures declared as \"monitor\" must use mutex parameters\n" );
     920                                SemanticError( decl, "destructors for structures declared as \"monitor\" must use mutex parameters " );
    921921                        }
    922922                }
     
    926926        // Monitors can't be constructed with mutual exclusion.
    927927        if ( CodeGen::isConstructor( decl->name ) && is_first_argument_mutex ) {
    928                 SemanticError( decl, "constructors cannot have mutex parameters\n" );
     928                SemanticError( decl, "constructors cannot have mutex parameters " );
    929929        }
    930930
    931931        // It makes no sense to have multiple mutex parameters for the destructor.
    932932        if ( isDtor && mutexArgs.size() != 1 ) {
    933                 SemanticError( decl, "destructors can only have 1 mutex argument\n" );
     933                SemanticError( decl, "destructors can only have 1 mutex argument " );
    934934        }
    935935
     
    945945        // Check to if the required headers have been seen.
    946946        if ( !monitor_decl || !guard_decl || !dtor_guard_decl ) {
    947                 SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor.hfa>\n" );
     947                SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor.hfa>." );
    948948        }
    949949
     
    952952        if ( isDtor && isThread( mutexArgs.front() ) ) {
    953953                if ( !thread_guard_decl ) {
    954                         SemanticError( decl, "thread destructor requires threads to be in scope, add #include <thread.hfa>\n" );
     954                        SemanticError( decl, "thread destructor requires threads to be in scope, add #include <thread.hfa>." );
    955955                }
    956956                newBody = addThreadDtorStatements( decl, body, mutexArgs );
     
    987987const ast::Stmt * MutexKeyword::postvisit( const ast::MutexStmt * stmt ) {
    988988        if ( !lock_guard_decl ) {
    989                 SemanticError( stmt->location, "mutex stmt requires a header, add #include <mutex_stmt.hfa>\n" );
     989                SemanticError( stmt->location, "mutex stmt requires a header, add #include <mutex_stmt.hfa>." );
    990990        }
    991991        ast::CompoundStmt * body =
     
    15471547        if ( !type->base->is_thread() ) return decl;
    15481548        if ( !thread_decl || !thread_ctor_seen ) {
    1549                 SemanticError( type->base->location, "thread keyword requires threads to be in scope, add #include <thread.hfa>" );
     1549                SemanticError( type->base->location, "thread keyword requires threads to be in scope, add #include <thread.hfa>." );
    15501550        }
    15511551        const ast::CompoundStmt * stmt = decl->stmts;
  • src/ControlStruct/FixLabels.cpp

    r0fa0201d r5546eee4  
    1010// Created On       : Mon Nov  1 09:39:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 31 22:19:17 2022
    13 // Update Count     : 9
     12// Last Modified On : Sun Nov 26 15:06:51 2023
     13// Update Count     : 10
    1414//
    1515
     
    4747        for ( auto kvp : labelTable ) {
    4848                if ( nullptr == kvp.second ) {
    49                         SemanticError( kvp.first.location,
    50                                                    "Use of undefined label: " + kvp.first.name );
     49                        SemanticError( kvp.first.location, "Use of undefined label %s.", kvp.first.name.c_str() );
    5150                }
    5251        }
  • src/ControlStruct/MultiLevelExit.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Nov  1 13:48:00 2021
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Sep  8 17:04:00 2023
    13 // Update Count     : 36
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 17:34:12 2023
     13// Update Count     : 39
    1414//
    1515
     
    254254                                if ( enclosing_control_structures.empty() ) {
    255255                                          SemanticError( stmt->location,
    256                                                                          "'break' outside a loop, 'switch', or labelled block" );
     256                                                                         "\"break\" outside a loop, \"switch\", or labelled block" );
    257257                                }
    258258                                targetEntry = findEnclosingControlStructure( isBreakTarget );
     
    268268                // Ensure that selected target is valid.
    269269                if ( targetEntry == enclosing_control_structures.rend() || ( isContinue && ! isContinueTarget( *targetEntry ) ) ) {
    270                         SemanticError( stmt->location, toString( (isContinue ? "'continue'" : "'break'"),
     270                        SemanticError( stmt->location, toString( (isContinue ? "\"continue\"" : "\"break\""),
    271271                                                        " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "),
    272272                                                        stmt->originalTarget ) );
     
    279279                // Check that target is valid.
    280280                if ( targetEntry == enclosing_control_structures.rend() ) {
    281                         SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
     281                        SemanticError( stmt->location, "\"fallthrough\" must be enclosed in a \"switch\" or \"choose\"" );
    282282                }
    283283                if ( ! stmt->target.empty() ) {
    284284                        // Labelled fallthrough: target must be a valid fallthough label.
    285285                        if ( ! fallthrough_labels.count( stmt->target ) ) {
    286                                 SemanticError( stmt->location, toString( "'fallthrough' target must be a later case statement: ",
     286                                SemanticError( stmt->location, toString( "\"fallthrough\" target must be a later case statement: ",
    287287                                                                                                                   stmt->originalTarget ) );
    288288                        }
     
    296296                // Check if in switch or choose statement.
    297297                if ( targetEntry == enclosing_control_structures.rend() ) {
    298                         SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
     298                        SemanticError( stmt->location, "\"fallthrough\" must be enclosed in a \"switch\" or \"choose\"" );
    299299                }
    300300
     
    309309                }
    310310                if ( ! foundDefault ) {
    311                         SemanticError( stmt->location, "'fallthrough default' must be enclosed in a 'switch' or 'choose'"
    312                                                    "control structure with a 'default' clause" );
     311                        SemanticError( stmt->location, "\"fallthrough default\" must be enclosed in a \"switch\" or \"choose\""
     312                                                   "control structure with a \"default\" clause" );
    313313                }
    314314                break;
     
    338338                // Check that fallthrough default comes before the default clause.
    339339                if ( ! targetEntry->isFallDefaultValid() ) {
    340                         SemanticError( stmt->location, "'fallthrough default' must precede the 'default' clause" );
     340                        SemanticError( stmt->location, "\"fallthrough default\" must precede the \"default\" clause" );
    341341                }
    342342                break;
     
    521521                assert(0);
    522522        }
    523         SemanticError( stmt->location, toString( "'return' may not appear in a ", context ) );
     523        SemanticError( stmt->location, "\"return\" may not appear in a %s", context );
    524524}
    525525
  • src/GenPoly/Box.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Thr Oct  6 13:39:00 2022
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Oct  2 17:00:00 2023
    13 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 17:42:17 2023
     13// Update Count     : 7
    1414//
    1515
     
    777777                if ( !concrete ) {
    778778                        // Should this be an assertion?
    779                         SemanticError( expr, toString( typeSubs,
    780                                 "\nunbound type variable: ", typeVar->typeString(),
    781                                 " in application " ) );
     779                        SemanticError( expr->location, "\nunbound type variable %s in application %s",
     780                                                   toString( typeSubs ).c_str(), typeVar->typeString().c_str() );
    782781                }
    783782                arg = expr->args.insert( arg,
  • src/InitTweak/FixInit.cpp

    r0fa0201d r5546eee4  
    10571057        )
    10581058        if ( ! diff.empty() ) {
    1059                 SemanticError( stmt, std::string("jump to label '") + stmt->target.name + "' crosses initialization of " + (*diff.begin())->name + " " );
     1059                SemanticError( stmt->location, "jump to label \"%s\" crosses initialization of \"%s\".",
     1060                                           stmt->target.name.c_str(), (*diff.begin())->name.c_str() );
    10601061        } // if
    10611062}
     
    10761077
    10771078bool checkWarnings( const ast::FunctionDecl * funcDecl ) {
    1078         // only check for warnings if the current function is a user-defined
    1079         // constructor or destructor
     1079        // only check for warnings if the current function is a user-defined constructor or destructor
    10801080        if ( ! funcDecl ) return false;
    10811081        if ( ! funcDecl->stmts ) return false;
  • src/Parser/DeclarationNode.cc

    r0fa0201d r5546eee4  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 17 14:41:48 2023
    13 // Update Count     : 1405
     12// Last Modified On : Thu Dec 14 19:05:17 2023
     13// Update Count     : 1407
    1414//
    1515
     
    632632                                        dst->basictype = src->basictype;
    633633                                } else if ( src->basictype != DeclarationNode::NoBasicType )
    634                                         SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::basicTypeNames[ dst->basictype ] +
    635                                                                    "\" and \"" + DeclarationNode::basicTypeNames[ src->basictype ] + "\"." );
    636 
     634                                        SemanticError( yylloc, "multiple declaration types \"%s\" and \"%s\".",
     635                                                                   DeclarationNode::basicTypeNames[ dst->basictype ],
     636                                                                   DeclarationNode::basicTypeNames[ src->basictype ] );
    637637                                if ( dst->complextype == DeclarationNode::NoComplexType ) {
    638638                                        dst->complextype = src->complextype;
    639639                                } else if ( src->complextype != DeclarationNode::NoComplexType )
    640                                         SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::complexTypeNames[ src->complextype ] +
    641                                                                    "\" and \"" + DeclarationNode::complexTypeNames[ src->complextype ] + "\"." );
    642 
     640                                        SemanticError( yylloc, "multiple declaration types \"%s\" and \"%s\".",
     641                                                                   DeclarationNode::complexTypeNames[ src->complextype ],
     642                                                                   DeclarationNode::complexTypeNames[ src->complextype ] );
    643643                                if ( dst->signedness == DeclarationNode::NoSignedness ) {
    644644                                        dst->signedness = src->signedness;
    645645                                } else if ( src->signedness != DeclarationNode::NoSignedness )
    646                                         SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::signednessNames[ dst->signedness ] +
    647                                                                    "\" and \"" + DeclarationNode::signednessNames[ src->signedness ] + "\"." );
    648 
     646                                        SemanticError( yylloc, "conflicting type specifier \"%s\" and \"%s\".",
     647                                                                   DeclarationNode::signednessNames[ dst->signedness ],
     648                                                                   DeclarationNode::signednessNames[ src->signedness ] );
    649649                                if ( dst->length == DeclarationNode::NoLength ) {
    650650                                        dst->length = src->length;
     
    652652                                        dst->length = DeclarationNode::LongLong;
    653653                                } else if ( src->length != DeclarationNode::NoLength )
    654                                         SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::lengthNames[ dst->length ] +
    655                                                                    "\" and \"" + DeclarationNode::lengthNames[ src->length ] + "\"." );
     654                                        SemanticError( yylloc, "conflicting type specifier \"%s\" and \"%s\".",
     655                                                                   DeclarationNode::lengthNames[ dst->length ],
     656                                                                   DeclarationNode::lengthNames[ src->length ] );
    656657                        } // if
    657658                        break;
  • src/Parser/ExpressionNode.cc

    r0fa0201d r5546eee4  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 11:07:00 2023
    13 // Update Count     : 1083
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:57:07 2023
     13// Update Count     : 1087
    1414//
    1515
     
    193193
    194194#if ! defined(__SIZEOF_INT128__)
    195         if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target " + str );
     195        if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target \"%s\"", str.c_str() );
    196196#endif // ! __SIZEOF_INT128__
    197197
     
    204204                        } else {                                                                        // hex int128 constant
    205205                                unsigned int len = str.length();
    206                                 if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large " + str );
     206                                if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large \"%s\"", str.c_str() );
    207207                                // hex digits < 2^64
    208208                                if ( len > (2 + 16) ) {
     
    219219                        unsigned int len = str.length();
    220220                        if ( type == 5 && len > 2 + 64 ) {
    221                                 if ( len > 2 + 64 + 64 ) SemanticError( yylloc, "128-bit binary constant to large " + str );
     221                                if ( len > 2 + 64 + 64 ) SemanticError( yylloc, "128-bit binary constant to large \"%s\".", str.c_str() );
    222222                                str2 = "0b" + str.substr( len - 64 );
    223223                                str = str.substr( 0, len - 64 );
     
    233233                        } else {                                                                        // octal int128 constant
    234234                                unsigned int len = str.length();
    235                                 if ( len > 1 + 43 || (len == 1 + 43 && str[0] > '3') ) SemanticError( yylloc, "128-bit octal constant to large " + str );
     235                                if ( len > 1 + 43 || (len == 1 + 43 && str[0] > '3') ) SemanticError( yylloc, "128-bit octal constant to large \"%s\"", str.c_str() );
    236236                                char buf[32];
    237237                                if ( len <= 1 + 21 ) {                                  // value < 21 octal digitis
     
    266266                        unsigned int len = str.length();
    267267                        if ( str.length() == 39 && str > (Unsigned ? "340282366920938463463374607431768211455" : "170141183460469231731687303715884105727") )
    268                                 SemanticError( yylloc, "128-bit decimal constant to large " + str );
     268                                SemanticError( yylloc, "128-bit decimal constant to large \"%s\".", str.c_str() );
    269269                        char buf[32];
    270270                        if ( len <= 19 ) {                                                      // value < 19 decimal digitis
     
    502502ast::Expr * build_field_name_FLOATING_FRACTIONconstant(
    503503                const CodeLocation & location, const string & str ) {
    504         if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str );
     504        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index \"%s\".", str.c_str() );
    505505        ast::Expr * ret = build_constantInteger( location,
    506506                *new string( str.substr(1) ) );
     
    511511ast::Expr * build_field_name_FLOATING_DECIMALconstant(
    512512                const CodeLocation & location, const string & str ) {
    513         if ( str[str.size() - 1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
     513        if ( str[str.size() - 1] != '.' ) SemanticError( yylloc, "invalid tuple index \"%s\".", str.c_str() );
    514514        ast::Expr * ret = build_constantInteger(
    515515                location, *new string( str.substr( 0, str.size()-1 ) ) );
  • src/Parser/ParseNode.h

    r0fa0201d r5546eee4  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Apr  3 17:55:00 2023
    13 // Update Count     : 942
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Dec  9 17:39:34 2023
     13// Update Count     : 945
    1414//
    1515
     
    3737class ExpressionNode;
    3838struct StatementNode;
     39
    3940
    4041//##############################################################################
     
    9798std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    9899
     100__attribute__((noreturn)) static inline void SemanticError( const ParseNode * obj, const std::string & error ) {
     101        SemanticError( obj->location, toString( error, obj ) );
     102}
     103
    99104// Local Variables: //
    100105// tab-width: 4 //
  • src/Parser/TypeData.cc

    r0fa0201d r5546eee4  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 13:39:00 2023
    13 // Update Count     : 680
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:59:12 2023
     13// Update Count     : 684
    1414//
    1515
     
    864864
    865865static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
    866         SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     866        SemanticError( yylloc, "invalid type specifier \"%s\" for type \"%s\".", msg.c_str(), DeclarationNode::basicTypeNames[basictype] );
    867867} // genTSError
    868868
     
    14961496                                // type set => parameter name already transformed by a declaration names so there is a duplicate
    14971497                                // declaration name attempting a second transformation
    1498                                 if ( param->type ) SemanticError( param->location, string( "duplicate declaration name " ) + *param->name );
     1498                                if ( param->type ) SemanticError( param->location, "duplicate declaration name \"%s\".", param->name->c_str() );
    14991499                                // declaration type reset => declaration already transformed by a parameter name so there is a duplicate
    15001500                                // parameter name attempting a second transformation
    1501                                 if ( ! decl->type ) SemanticError( param->location, string( "duplicate parameter name " ) + *param->name );
     1501                                if ( ! decl->type ) SemanticError( param->location, "duplicate parameter name \"%s\".", param->name->c_str() );
    15021502                                param->type = decl->type;                               // set copy declaration type to parameter type
    15031503                                decl->type = nullptr;                                   // reset declaration type
     
    15071507                } // for
    15081508                // declaration type still set => type not moved to a matching parameter so there is a missing parameter name
    1509                 if ( decl->type ) SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );
     1509                if ( decl->type ) SemanticError( decl->location, "missing name in parameter list %s", decl->name->c_str() );
    15101510        } // for
    15111511
  • src/Parser/parser.yy

    r0fa0201d r5546eee4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct  3 17:14:12 2023
    13 // Update Count     : 6396
     12// Last Modified On : Sun Nov 26 13:18:06 2023
     13// Update Count     : 6398
    1414//
    1515
     
    260260                } // if
    261261        } else {
    262                 SemanticError( yylloc, "syntax error, loop-index name missing. Expression disallowed. ." ); return nullptr;
     262                SemanticError( yylloc, "syntax error, loop-index name missing. Expression disallowed." ); return nullptr;
    263263        } // if
    264264} // forCtrl
    265265
    266266static void IdentifierBeforeIdentifier( string & identifier1, string & identifier2, const char * kind ) {
    267         SemanticError( yylloc, ::toString( "syntax error, adjacent identifiers \"", identifier1, "\" and \"", identifier2, "\" are not meaningful in a", kind, ".\n"
    268                                    "Possible cause is misspelled type name or missing generic parameter." ) );
     267        SemanticError( yylloc, "syntax error, adjacent identifiers \"%s\" and \"%s\" are not meaningful in an %s.\n"
     268                                   "Possible cause is misspelled type name or missing generic parameter.",
     269                                   identifier1.c_str(), identifier2.c_str(), kind );
    269270} // IdentifierBeforeIdentifier
    270271
    271272static void IdentifierBeforeType( string & identifier, const char * kind ) {
    272         SemanticError( yylloc, ::toString( "syntax error, identifier \"", identifier, "\" cannot appear before a ", kind, ".\n"
    273                                    "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) );
     273        SemanticError( yylloc, "syntax error, identifier \"%s\" cannot appear before a %s.\n"
     274                                   "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter.",
     275                                   identifier.c_str(), kind );
    274276} // IdentifierBeforeType
    275277
     
    689691        //      { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; }
    690692        | IDENTIFIER IDENTIFIER                                                         // invalid syntax rule
    691                 { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; }
     693                { IdentifierBeforeIdentifier( *$1.str, *$2.str, "expression" ); $$ = nullptr; }
    692694        | IDENTIFIER type_qualifier                                                     // invalid syntax rule
    693695                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
     
    11551157        | identifier_or_type_name ':' attribute_list_opt error // invalid syntax rule
    11561158                {
    1157                         SemanticError( yylloc, ::toString( "syntx error, label \"", *$1.str, "\" must be associated with a statement, "
    1158                                                                                            "where a declaration, case, or default is not a statement. "
    1159                                                                                            "Move the label or terminate with a semi-colon." ) );
     1159                        SemanticError( yylloc, "syntx error, label \"%s\" must be associated with a statement, "
     1160                                                   "where a declaration, case, or default is not a statement.\n"
     1161                                                   "Move the label or terminate with a semicolon.", $1.str->c_str() );
    11601162                        $$ = nullptr;
    11611163                }
     
    21012103        | sue_declaration_specifier invalid_types                       // invalid syntax rule
    21022104                {
    2103                         SemanticError( yylloc, ::toString( "syntax error, expecting ';' at end of ",
    2104                                 $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ),
    2105                                 " declaration." ) );
     2105                        SemanticError( yylloc, "syntax error, expecting ';' at end of \"%s\" declaration.",
     2106                                                   $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ) );
    21062107                        $$ = nullptr;
    21072108                }
     
    21612162type_qualifier:
    21622163        type_qualifier_name
    2163         | attribute                                                                                     // trick handles most atrribute locations
     2164        | attribute                                                                                     // trick handles most attribute locations
    21642165        ;
    21652166
     
    25852586        | type_specifier field_declaring_list_opt '}'           // invalid syntax rule
    25862587                {
    2587                         SemanticError( yylloc, ::toString( "syntax error, expecting ';' at end of previous declaration." ) );
     2588                        SemanticError( yylloc, "syntax error, expecting ';' at end of previous declaration." );
    25882589                        $$ = nullptr;
    25892590                }
  • src/ResolvExpr/CurrentObject.cc

    r0fa0201d r5546eee4  
    99// Author           : Rob Schluntz
    1010// Created On       : Tue Jun 13 15:28:32 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Apr 10  9:40:00 2023
    13 // Update Count     : 18
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Dec  9 17:49:51 2023
     13// Update Count     : 20
    1414//
    1515
     
    181181                auto res = eval( expr );
    182182                if ( !res.hasKnownValue ) {
    183                         SemanticError( location, toString( "Array designator must be a constant expression: ", expr ) );
     183                        SemanticError( location, "Array designator must be a constant expression %s", toString( expr ).c_str() );
    184184                }
    185185                return res.knownValue;
  • src/ResolvExpr/Resolver.cc

    r0fa0201d r5546eee4  
    99// Author           : Aaron B. Moss
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 20 10:41:00 2022
    13 // Update Count     : 248
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 18:44:43 2023
     13// Update Count     : 251
    1414//
    1515
     
    632632                                                maybe_accept( mutDecl->init.get(), res );
    633633                                                if ( !res.core.result ) {
    634                                                         SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" );
     634                                                        SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object.\n"
     635                                                                                   "If this is really what you want, initialize with @=." );
    635636                                                }
    636637                                        }
     
    958959                                                                ++n_mutex_param;
    959960
    960                                                                 // Check if the argument matches the parameter type in the current
    961                                                                 // scope
     961                                                                // Check if the argument matches the parameter type in the current scope.
    962962                                                                // ast::ptr< ast::Type > paramType = (*param)->get_type();
     963
    963964                                                                if (
    964965                                                                        ! unify(
  • src/Validate/FixQualifiedTypes.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Thr Apr 21 11:13:00 2022
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Sep 20 16:15:00 2022
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 13 09:00:25 2023
     13// Update Count     : 6
    1414//
    1515
     
    4141                                auto td = symtab.globalLookupType( inst->name );
    4242                                if ( !td ) {
    43                                         SemanticError( *location, toString("Use of undefined global type ", inst->name) );
     43                                        SemanticError( *location, "Use of undefined global type %s.", inst->name.c_str() );
    4444                                }
    4545                                auto base = td->base;
     
    5050                        } else {
    5151                                // .T => T is not a type name.
    52                                 assertf( false, "unhandled global qualified child type: %s", toCString(child) );
     52                                assertf( false, "unhandled global qualified child type: %s", toCString( child ) );
    5353                        }
    5454                } else {
     
    6363                                instp = inst;
    6464                        } else {
    65                                 SemanticError( *location, toString("Qualified type requires an aggregate on the left, but has: ", parent) );
     65                                SemanticError( *location, "Qualified type requires an aggregate on the left, but has %s.", toCString( parent ) );
    6666                        }
    6767                        // TODO: Need to handle forward declarations.
     
    8181                                } else {
    8282                                        // S.T - S is not an aggregate => error.
    83                                         assertf( false, "unhandled qualified child type: %s", toCString(type) );
     83                                        assertf( false, "unhandled qualified child type %s.", toCString( type ) );
    8484                                }
    8585                        }
    8686                        // failed to find a satisfying definition of type
    87                         SemanticError( *location, toString("Undefined type in qualified type: ", type) );
     87                        SemanticError( *location, "Undefined type in qualified type %s", toCString( type ) );
    8888                }
    8989        }
  • src/Validate/ForallPointerDecay.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Tue Dec  7 16:15:00 2021
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Sat Apr 23 13:10:00 2022
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Nov 26 18:49:57 2023
     13// Update Count     : 2
    1414//
    1515
     
    213213                auto type = obj->type->stripDeclarator();
    214214                if ( dynamic_cast< const ast::FunctionType * >( type ) ) return;
    215                 SemanticError( obj->location,
    216                         toCString( "operator ", obj->name.c_str(),
    217                         " is not a function or function pointer." ) );
     215                SemanticError( obj->location, "operator %s is not a function or function pointer.", obj->name.c_str() );
    218216        }
    219217};
  • src/Validate/ReplaceTypedef.cpp

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Tue Jun 29 14:59:00 2022
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Sep 20 17:00:00 2022
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Dec 14 16:11:51 2023
     13// Update Count     : 4
    1414//
    1515
     
    111111                        if ( !rtt ) {
    112112                                assert( location );
    113                                 SemanticError( *location, "Cannot apply type parameters to base type of " + type->name );
     113                                SemanticError( *location, "Cannot apply type parameters to base type of %s.", type->name.c_str() );
    114114                        }
    115115                        rtt->params.clear();
     
    125125                if ( base == typedeclNames.end() ) {
    126126                        assert( location );
    127                         SemanticError( *location, toString( "Use of undefined type ", type->name ) );
     127                        SemanticError( *location, "Use of undefined type %s.", type->name.c_str() );
    128128                }
    129129                return ast::mutate_field( type, &ast::TypeInstType::base, base->second );
     
    152152                                || ast::Pass<VarLenChecker>::read( t0 )
    153153                                || ast::Pass<VarLenChecker>::read( t1 ) ) {
    154                         SemanticError( decl->location, "Cannot redefine typedef: " + decl->name );
     154                        SemanticError( decl->location, "Cannot redefine typedef %s", decl->name.c_str() );
    155155                }
    156156        } else {
  • src/Virtual/ExpandCasts.cc

    r0fa0201d r5546eee4  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Jul 24 13:59:00 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Aug 11 12:06:00 2022
    13 // Update Count     : 5
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Nov 27 09:28:20 2023
     13// Update Count     : 10
    1414//
    1515
     
    160160
    161161        // Helper function for throwing semantic errors.
    162         auto throwError = [&fieldName, &errorLocation, &oldDecl](
    163                         std::string const & message ) {
    164                 std::string const & context = "While following head pointer of " +
    165                         oldDecl->name + " named '" + fieldName + "': ";
    166                 SemanticError( errorLocation, context + message );
     162        auto throwError = [&fieldName, &errorLocation, &oldDecl]( std::string const & message ) {
     163                SemanticError( errorLocation, "While following head pointer of %s named \"%s\": %s",
     164                                           oldDecl->name.c_str(), fieldName.c_str(), message.c_str() );
    167165        };
    168166
Note: See TracChangeset for help on using the changeset viewer.