Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r4358c1e r6040e67d  
    77// SemanticError.cc --
    88//
    9 // Author           : Thierry Delisle
     9// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 16 15:01:20 2018
    13 // Update Count     : 9
     12// Last Modified On : Tue Aug 29 18:17:35 2017
     13// Update Count     : 3
    1414//
    1515
    1616#include <cstdarg>
    1717#include <cstdio>                                                                               // for fileno, stderr
    18 #include <cstring>
    1918#include <unistd.h>                                                                             // for isatty
    2019#include <iostream>                                                                             // for basic_ostream, operator<<, ostream
    2120#include <list>                                                                                 // for list, _List_iterator
    2221#include <string>                                                                               // for string, operator<<, operator+, to_string
    23 #include <vector>
    2422
    2523#include "Common/utility.h"                                                             // for to_string, CodeLocation (ptr only)
    2624#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;
    7325
    7426SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) {
     
    9648
    9749void SemanticError( CodeLocation location, std::string error ) {
    98         SemanticErrorThrow = true;
    9950        throw SemanticErrorException(location, error);
    10051}
     
    11869
    11970void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) {
    120         Severity severity = get_severities()[(int)warning];
     71        Severity severity = WarningFormats[(int)warning].severity;
    12172        switch(severity) {
    12273        case Severity::Suppress :
Note: See TracChangeset for help on using the changeset viewer.