Changeset 6040e67d
- Timestamp:
- Apr 16, 2018, 4:24:01 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 6d2aa7ed
- Parents:
- 81bb114
- Location:
- src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r81bb114 r6040e67d 68 68 } 69 69 70 void SemanticWarningImpl( CodeLocation location, Warning, const char * const fmt, ... ) { 71 va_list args; 72 va_start(args, fmt); 73 std::string msg = fmtToString( fmt, args ); 74 va_end(args); 75 std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl; 70 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) { 71 Severity severity = WarningFormats[(int)warning].severity; 72 switch(severity) { 73 case Severity::Suppress : 74 break; 75 case Severity::Warn : 76 { 77 va_list args; 78 va_start(args, fmt); 79 std::string msg = fmtToString( fmt, args ); 80 va_end(args); 81 std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl; 82 } 83 break; 84 case Severity::Error : 85 { 86 va_list args; 87 va_start(args, fmt); 88 std::string msg = fmtToString( fmt, args ); 89 va_end(args); 90 SemanticError(location, msg); 91 } 92 break; 93 case Severity::Critical : 94 assertf(false, "Critical errors not implemented yet"); 95 break; 96 } 76 97 } 77 98 -
src/Common/SemanticError.h
r81bb114 r6040e67d 36 36 // Warnings 37 37 38 constexpr const char * const WarningFormats[] = { 39 "self assignment of expression: %s", 40 "rvalue to reference conversion of rvalue: %s", 38 enum class Severity { 39 Suppress, 40 Warn, 41 Error, 42 Critical 43 }; 44 45 struct WarningData { 46 const char * const name; 47 const char * const message; 48 mutable Severity severity; 49 }; 50 51 constexpr const WarningData WarningFormats[] = { 52 {"self-assign" , "self assignment of expression: %s" , Severity::Warn}, 53 {"reference-conversion", "rvalue to reference conversion of rvalue: %s", Severity::Warn}, 41 54 }; 42 55 … … 52 65 ); 53 66 67 <<<<<<< Updated upstream 54 68 // ## used here to allow empty __VA_ARGS__ 55 69 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], ## __VA_ARGS__) 70 ======= 71 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__) 72 >>>>>>> Stashed changes 56 73 57 74 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
Note: See TracChangeset
for help on using the changeset viewer.