Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    rf6f0cca3 rff29f08  
    77// SemanticError.cc --
    88//
    9 // Author           : Richard C. Bilson
     9// Author           : Thierry Delisle
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 29 18:17:35 2017
    13 // Update Count     : 3
     12// Last Modified On : Wed May 16 15:01:20 2018
     13// Update Count     : 9
    1414//
    1515
    1616#include <cstdarg>
    1717#include <cstdio>                                                                               // for fileno, stderr
     18#include <cstring>
    1819#include <unistd.h>                                                                             // for isatty
    1920#include <iostream>                                                                             // for basic_ostream, operator<<, ostream
    2021#include <list>                                                                                 // for list, _List_iterator
    2122#include <string>                                                                               // for string, operator<<, operator+, to_string
     23#include <vector>
    2224
    2325#include "Common/utility.h"                                                             // for to_string, CodeLocation (ptr only)
    2426#include "SemanticError.h"
     27
     28//-----------------------------------------------------------------------------
     29// Severity Handling
     30std::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
     41void SemanticWarning_SuppressAll() {
     42        for( auto & s : get_severities() ) {
     43                s = Severity::Suppress;
     44        }
     45}
     46
     47void SemanticWarning_EnableAll() {
     48        for( auto & s : get_severities() ) {
     49                s = Severity::Warn;
     50        }
     51}
     52
     53void SemanticWarning_WarningAsError() {
     54        for( auto & s : get_severities() ) {
     55                if(s == Severity::Warn) s = Severity::Error;
     56        }
     57}
     58
     59void 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
     72bool SemanticErrorThrow = false;
    2573
    2674SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) {
     
    4896
    4997void SemanticError( CodeLocation location, std::string error ) {
     98        SemanticErrorThrow = true;
    5099        throw SemanticErrorException(location, error);
    51100}
     
    69118
    70119void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) {
    71         Severity severity = WarningFormats[(int)warning].severity;
     120        Severity severity = get_severities()[(int)warning];
    72121        switch(severity) {
    73122        case Severity::Suppress :
Note: See TracChangeset for help on using the changeset viewer.