Changes in src/Common/SemanticError.cc [4358c1e:6040e67d]
- File:
-
- 1 edited
-
src/Common/SemanticError.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r4358c1e r6040e67d 7 7 // SemanticError.cc -- 8 8 // 9 // Author : Thierry Delisle9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 16 15:01:20 201813 // Update Count : 912 // Last Modified On : Tue Aug 29 18:17:35 2017 13 // Update Count : 3 14 14 // 15 15 16 16 #include <cstdarg> 17 17 #include <cstdio> // for fileno, stderr 18 #include <cstring>19 18 #include <unistd.h> // for isatty 20 19 #include <iostream> // for basic_ostream, operator<<, ostream 21 20 #include <list> // for list, _List_iterator 22 21 #include <string> // for string, operator<<, operator+, to_string 23 #include <vector>24 22 25 23 #include "Common/utility.h" // for to_string, CodeLocation (ptr only) 26 24 #include "SemanticError.h" 27 28 //-----------------------------------------------------------------------------29 // Severity Handling30 std::vector<Severity> & get_severities() {31 static std::vector<Severity> severities;32 if(severities.empty()) {33 severities.reserve((size_t)Warning::NUMBER_OF_WARNINGS);34 for ( const auto w : WarningFormats ) {35 severities.push_back( w.default_severity );36 } // for37 }38 return severities;39 }40 41 void SemanticWarning_SuppressAll() {42 for( auto & s : get_severities() ) {43 s = Severity::Suppress;44 }45 }46 47 void SemanticWarning_EnableAll() {48 for( auto & s : get_severities() ) {49 s = Severity::Warn;50 }51 }52 53 void SemanticWarning_WarningAsError() {54 for( auto & s : get_severities() ) {55 if(s == Severity::Warn) s = Severity::Error;56 }57 }58 59 void SemanticWarning_Set(const char * const name, Severity s) {60 size_t idx = 0;61 for ( const auto & w : WarningFormats ) {62 if ( std::strcmp( name, w.name ) == 0 ) {63 get_severities()[idx] = s;64 break;65 }66 idx++;67 }68 }69 70 //-----------------------------------------------------------------------------71 // Semantic Error72 bool SemanticErrorThrow = false;73 25 74 26 SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) { … … 96 48 97 49 void SemanticError( CodeLocation location, std::string error ) { 98 SemanticErrorThrow = true;99 50 throw SemanticErrorException(location, error); 100 51 } … … 118 69 119 70 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) { 120 Severity severity = get_severities()[(int)warning];71 Severity severity = WarningFormats[(int)warning].severity; 121 72 switch(severity) { 122 73 case Severity::Suppress :
Note:
See TracChangeset
for help on using the changeset viewer.