Changeset b1f2007
- Timestamp:
- Dec 13, 2023, 9:17:13 AM (12 months ago)
- Branches:
- master
- Children:
- 4c2fe47
- Parents:
- c40157e
- Location:
- src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
rc40157e rb1f2007 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Andrew Beach11 // Last Modified By : Peter A. Buhr 12 12 // Created On : Wed May 18 13:56:00 2022 13 // Update Count : 813 // Update Count : 12 14 14 // 15 15 … … 168 168 return addrType( refType->base ); 169 169 } 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() ); 172 172 } 173 173 } … … 240 240 return 1; 241 241 } 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() ); 243 244 } 244 245 -
src/AST/LinkageSpec.cpp
rc40157e rb1f2007 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu May 9 10:00:00 201913 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 11 16:08:58 2023 13 // Update Count : 2 14 14 // 15 15 … … 37 37 return spec; 38 38 } else { 39 SemanticError( loc, "Invalid linkage specifier " + *cmd);39 SemanticError( loc, "Invalid linkage specifier %s", cmd->c_str() ); 40 40 } 41 41 } -
src/AST/TypeSubstitution.hpp
rc40157e rb1f2007 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr May 25 12:31:00 202313 // Update Count : 1 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 11 16:07:30 2023 13 // Update Count : 15 14 14 // 15 15 … … 156 156 } // if 157 157 } 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() ); 159 160 } // if 160 161 } else { -
src/Common/SemanticError.cc
rc40157e rb1f2007 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 08:05:26 201813 // Update Count : 1 012 // Last Modified On : Mon Dec 11 15:59:09 2023 13 // Update Count : 14 14 14 // 15 15 … … 70 70 //----------------------------------------------------------------------------- 71 71 // Semantic Error 72 72 73 bool SemanticErrorThrow = false; 73 74 … … 101 102 std::cerr << ErrorHelpers::bold() << err.location << ErrorHelpers::error_str() << ErrorHelpers::reset_font() << err.description << std::endl; 102 103 } 104 } 105 106 void SemanticError( CodeLocation location, const char * fmt, ... ) { 107 char msg[2048]; // worst-case error-message buffer 108 va_list args; 109 va_start( args, fmt ); 110 vsnprintf( msg, sizeof(msg), fmt, args ); // always null terminated, but may be truncated 111 va_end( args ); 112 113 SemanticErrorThrow = true; 114 throw SemanticErrorException( location, msg ); // convert msg to string 103 115 } 104 116 -
src/Common/SemanticError.h
rc40157e rb1f2007 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 25 12:01:31202313 // Update Count : 3712 // Last Modified On : Mon Dec 11 21:54:22 2023 13 // Update Count : 54 14 14 // 15 15 … … 18 18 #include "ErrorObjects.h" 19 19 #include "AST/Node.hpp" 20 #include "AST/ParseNode.hpp" 20 21 #include <cstring> 21 22 … … 25 26 extern bool SemanticErrorThrow; 26 27 28 __attribute__((noreturn, format(printf, 2, 3))) void SemanticError( CodeLocation location, const char fmt[], ... ); 29 27 30 __attribute__((noreturn)) void SemanticError( CodeLocation location, std::string error ); 28 31 29 template< typename T > 30 __attribute__((noreturn)) static inline void SemanticError( const T * obj, const std::string & error ) { 32 __attribute__((noreturn)) static inline void SemanticError( const ast::ParseNode * obj, const std::string & error ) { 31 33 SemanticError( obj->location, toString( error, obj ) ); 32 34 } 33 35 34 template< typename T > 35 __attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const T * obj, const std::string & error ) { 36 __attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const ast::Node * obj, const std::string & error ) { 36 37 SemanticError( location, toString( error, obj ) ); 37 38 } … … 54 55 55 56 constexpr WarningData WarningFormats[] = { 56 {"self-assign" , Severity::Warn 57 {"reference-conversion" , Severity::Warn 58 {"qualifiers-zero_t-one_t" , Severity::Warn 59 {"aggregate-forward-decl" , Severity::Warn 60 {"superfluous-decl" , Severity::Warn 61 {"superfluous-else" , Severity::Warn 62 {"gcc-attributes" , Severity::Warn 63 {"c++-like-copy" , Severity::Warn 64 {"depreciated-trait-syntax" , Severity::Warn 57 {"self-assign" , Severity::Warn, "self assignment of expression: %s" }, 58 {"reference-conversion" , Severity::Warn, "rvalue to reference conversion of rvalue: %s" }, 59 {"qualifiers-zero_t-one_t" , Severity::Warn, "questionable use of type qualifier(s) with %s" }, 60 {"aggregate-forward-decl" , Severity::Warn, "forward declaration of nested aggregate: %s" }, 61 {"superfluous-decl" , Severity::Warn, "declaration does not allocate storage: %s" }, 62 {"superfluous-else" , Severity::Warn, "else clause never executed for empty loop conditional" }, 63 {"gcc-attributes" , Severity::Warn, "invalid attribute: %s" }, 64 {"c++-like-copy" , Severity::Warn, "Constructor from reference is not a valid copy constructor" }, 65 {"depreciated-trait-syntax" , Severity::Warn, "trait type-parameters are now specified using the forall clause" }, 65 66 }; 66 67 … … 75 76 CppCopy, 76 77 DeprecTraitSyntax, 77 NUMBER_OF_WARNINGS, // ThisMUST be the last warning78 NUMBER_OF_WARNINGS, // MUST be the last warning 78 79 }; 79 80 -
src/ControlStruct/FixLabels.cpp
rc40157e rb1f2007 10 10 // Created On : Mon Nov 1 09:39:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 31 22:19:17 202213 // Update Count : 912 // Last Modified On : Sun Nov 26 15:06:51 2023 13 // Update Count : 10 14 14 // 15 15 … … 47 47 for ( auto kvp : labelTable ) { 48 48 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() ); 51 50 } 52 51 } -
src/ControlStruct/MultiLevelExit.cpp
rc40157e rb1f2007 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Nov 1 13:48:00 2021 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Sep 8 17:04:00202313 // Update Count : 3 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 11 13:44:45 2023 13 // Update Count : 38 14 14 // 15 15 … … 521 521 assert(0); 522 522 } 523 SemanticError( stmt->location, toString( "'return' may not appear in a ", context ));523 SemanticError( stmt->location, "'return' may not appear in a %s", context ); 524 524 } 525 525 -
src/Parser/ParseNode.h
rc40157e rb1f2007 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Apr 3 17:55:00202313 // Update Count : 94 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 9 17:39:34 2023 13 // Update Count : 945 14 14 // 15 15 … … 37 37 class ExpressionNode; 38 38 struct StatementNode; 39 39 40 40 41 //############################################################################## … … 97 98 std::ostream & operator<<( std::ostream & out, const ParseNode * node ); 98 99 100 __attribute__((noreturn)) static inline void SemanticError( const ParseNode * obj, const std::string & error ) { 101 SemanticError( obj->location, toString( error, obj ) ); 102 } 103 99 104 // Local Variables: // 100 105 // tab-width: 4 // -
src/Parser/TypeData.cc
rc40157e rb1f2007 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Apr 4 13:39:00202313 // Update Count : 68 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Nov 26 15:51:05 2023 13 // Update Count : 681 14 14 // 15 15 … … 864 864 865 865 static 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] ); 867 867 } // genTSError 868 868 … … 1507 1507 } // for 1508 1508 // 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() ); 1510 1510 } // for 1511 1511 -
src/Parser/parser.yy
rc40157e rb1f2007 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 3 17:14:12202313 // Update Count : 639 612 // Last Modified On : Sun Nov 26 13:18:06 2023 13 // Update Count : 6398 14 14 // 15 15 … … 260 260 } // if 261 261 } 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; 263 263 } // if 264 264 } // forCtrl 265 265 266 266 static 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 ); 269 270 } // IdentifierBeforeIdentifier 270 271 271 272 static 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 ); 274 276 } // IdentifierBeforeType 275 277 … … 689 691 // { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; } 690 692 | IDENTIFIER IDENTIFIER // invalid syntax rule 691 { IdentifierBeforeIdentifier( *$1.str, *$2.str, " nexpression" ); $$ = nullptr; }693 { IdentifierBeforeIdentifier( *$1.str, *$2.str, "expression" ); $$ = nullptr; } 692 694 | IDENTIFIER type_qualifier // invalid syntax rule 693 695 { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; } … … 1155 1157 | identifier_or_type_name ':' attribute_list_opt error // invalid syntax rule 1156 1158 { 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() ); 1160 1162 $$ = nullptr; 1161 1163 } … … 2101 2103 | sue_declaration_specifier invalid_types // invalid syntax rule 2102 2104 { 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 ) ); 2106 2107 $$ = nullptr; 2107 2108 } … … 2161 2162 type_qualifier: 2162 2163 type_qualifier_name 2163 | attribute // trick handles most at rribute locations2164 | attribute // trick handles most attribute locations 2164 2165 ; 2165 2166 … … 2585 2586 | type_specifier field_declaring_list_opt '}' // invalid syntax rule 2586 2587 { 2587 SemanticError( yylloc, ::toString( "syntax error, expecting ';' at end of previous declaration." ));2588 SemanticError( yylloc, "syntax error, expecting ';' at end of previous declaration." ); 2588 2589 $$ = nullptr; 2589 2590 } -
src/ResolvExpr/CurrentObject.cc
rc40157e rb1f2007 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Jun 13 15:28:32 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Apr 10 9:40:00202313 // Update Count : 1811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 9 17:49:51 2023 13 // Update Count : 20 14 14 // 15 15 … … 181 181 auto res = eval( expr ); 182 182 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() ); 184 184 } 185 185 return res.knownValue; -
src/Validate/FixQualifiedTypes.cpp
rc40157e rb1f2007 9 9 // Author : Andrew Beach 10 10 // Created On : Thr Apr 21 11:13:00 2022 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Sep 20 16:15:00 202213 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 13 09:00:25 2023 13 // Update Count : 6 14 14 // 15 15 … … 41 41 auto td = symtab.globalLookupType( inst->name ); 42 42 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() ); 44 44 } 45 45 auto base = td->base; … … 50 50 } else { 51 51 // .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 ) ); 53 53 } 54 54 } else { … … 63 63 instp = inst; 64 64 } 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 ) ); 66 66 } 67 67 // TODO: Need to handle forward declarations. … … 81 81 } else { 82 82 // 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 ) ); 84 84 } 85 85 } 86 86 // 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 ) ); 88 88 } 89 89 } -
src/Validate/ForallPointerDecay.cpp
rc40157e rb1f2007 9 9 // Author : Andrew Beach 10 10 // Created On : Tue Dec 7 16:15:00 2021 11 // Last Modified By : Andrew Beach12 // Last Modified On : S at Apr 23 13:10:00 202213 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Nov 26 18:49:57 2023 13 // Update Count : 2 14 14 // 15 15 … … 213 213 auto type = obj->type->stripDeclarator(); 214 214 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() ); 218 216 } 219 217 }; -
src/Validate/ReplaceTypedef.cpp
rc40157e rb1f2007 9 9 // Author : Andrew Beach 10 10 // Created On : Tue Jun 29 14:59:00 2022 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Sep 20 17:00:00 202213 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 27 08:55:06 2023 13 // Update Count : 3 14 14 // 15 15 … … 111 111 if ( !rtt ) { 112 112 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() ); 114 114 } 115 115 rtt->params.clear(); … … 125 125 if ( base == typedeclNames.end() ) { 126 126 assert( location ); 127 SemanticError( *location, toString( "Use of undefined type ", type->name) );127 SemanticError( *location, "Use of undefined type %s.", type->name.c_str() ); 128 128 } 129 129 return ast::mutate_field( type, &ast::TypeInstType::base, base->second ); -
src/Virtual/ExpandCasts.cc
rc40157e rb1f2007 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jul 24 13:59:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Aug 11 12:06:00 202213 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 27 09:28:20 2023 13 // Update Count : 10 14 14 // 15 15 … … 160 160 161 161 // 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() ); 167 165 }; 168 166
Note: See TracChangeset
for help on using the changeset viewer.