Changeset ff29f08 for src/Common/SemanticError.cc
- Timestamp:
- May 18, 2018, 2:09:21 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 2472a19
- Parents:
- f6f0cca3 (diff), c7d8100c (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
rf6f0cca3 rff29f08 7 7 // SemanticError.cc -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Thierry Delisle 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 29 18:17:35 201713 // Update Count : 312 // Last Modified On : Wed May 16 15:01:20 2018 13 // Update Count : 9 14 14 // 15 15 16 16 #include <cstdarg> 17 17 #include <cstdio> // for fileno, stderr 18 #include <cstring> 18 19 #include <unistd.h> // for isatty 19 20 #include <iostream> // for basic_ostream, operator<<, ostream 20 21 #include <list> // for list, _List_iterator 21 22 #include <string> // for string, operator<<, operator+, to_string 23 #include <vector> 22 24 23 25 #include "Common/utility.h" // for to_string, CodeLocation (ptr only) 24 26 #include "SemanticError.h" 27 28 //----------------------------------------------------------------------------- 29 // Severity Handling 30 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 } // for 37 } 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 Error 72 bool SemanticErrorThrow = false; 25 73 26 74 SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) { … … 48 96 49 97 void SemanticError( CodeLocation location, std::string error ) { 98 SemanticErrorThrow = true; 50 99 throw SemanticErrorException(location, error); 51 100 } … … 69 118 70 119 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) { 71 Severity severity = WarningFormats[(int)warning].severity;120 Severity severity = get_severities()[(int)warning]; 72 121 switch(severity) { 73 122 case Severity::Suppress :
Note: See TracChangeset
for help on using the changeset viewer.