Changeset 2103a51
- Timestamp:
- Mar 1, 2018, 2:42:45 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, resolv-new, with_gc
- Children:
- babeeda
- Parents:
- 6bc76537
- Location:
- src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Common/SemanticError.cc ¶
r6bc76537 r2103a51 50 50 } 51 51 52 void SemanticWarningImpl( CodeLocation location, std::string msg ) { 52 namespace { 53 // convert format string and arguments into a single string 54 std::string fmtToString(const char * fmt, va_list ap) { 55 int size = 128; 56 while ( true ) { 57 char buf[size]; 58 va_list args; 59 va_copy( args, ap ); 60 int n = vsnprintf(&buf[0], size, fmt, args); 61 va_end( args ); 62 if ( n < size && n >= 0 ) return buf; 63 size *= 2; 64 } 65 assert( false ); 66 } 67 } 68 69 void SemanticWarningImpl( CodeLocation location, Warning, const char * const fmt, ... ) { 70 va_list args; 71 va_start(args, fmt); 72 std::string msg = fmtToString( fmt, args ); 73 va_end(args); 53 74 std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl; 54 75 } -
TabularUnified src/Common/SemanticError.h ¶
r6bc76537 r2103a51 49 49 ); 50 50 51 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[ id], __VA_ARGS__)51 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], __VA_ARGS__) 52 52 53 53 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.