Ignore:
Timestamp:
Dec 16, 2023, 1:01:44 AM (22 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
b7898ac
Parents:
0fa0201d (diff), 69ab896 (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 branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.h

    r0fa0201d r5546eee4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 12:01:31 2023
    13 // Update Count     : 37
     12// Last Modified On : Thu Dec 14 13:48:07 2023
     13// Update Count     : 72
    1414//
    1515
     
    1818#include "ErrorObjects.h"
    1919#include "AST/Node.hpp"
     20#include "AST/ParseNode.hpp"
    2021#include <cstring>
    2122
     
    2526extern bool SemanticErrorThrow;
    2627
    27 __attribute__((noreturn)) void SemanticError( CodeLocation location, std::string error );
     28__attribute__((noreturn, format(printf, 2, 3))) void SemanticError( CodeLocation location, const char fmt[], ... );
    2829
    29 template< typename T >
    30 __attribute__((noreturn)) static inline void SemanticError( const T * obj, const std::string & error ) {
     30__attribute__((noreturn)) static inline void SemanticError( CodeLocation location, std::string error ) {
     31        SemanticErrorThrow = true;
     32        throw SemanticErrorException( location, error );
     33}
     34
     35__attribute__((noreturn)) static inline void SemanticError( const ast::ParseNode * obj, const std::string & error ) {
    3136        SemanticError( obj->location, toString( error, obj ) );
    3237}
    3338
    34 template< typename T >
    35 __attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const T * obj, const std::string & error ) {
     39__attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const ast::Node * obj, const std::string & error ) {
    3640        SemanticError( location, toString( error, obj ) );
    3741}
     
    5458
    5559constexpr WarningData WarningFormats[] = {
    56         {"self-assign"              , Severity::Warn    , "self assignment of expression: %s"                          },
    57         {"reference-conversion"     , Severity::Warn    , "rvalue to reference conversion of rvalue: %s"               },
    58         {"qualifiers-zero_t-one_t"  , Severity::Warn    , "questionable use of type qualifier(s) with %s"              },
    59         {"aggregate-forward-decl"   , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
    60         {"superfluous-decl"         , Severity::Warn    , "declaration does not allocate storage: %s"                  },
    61         {"superfluous-else"         , Severity::Warn    , "else clause never executed for empty loop conditional"      },
    62         {"gcc-attributes"           , Severity::Warn    , "invalid attribute: %s"                                      },
    63         {"c++-like-copy"            , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
    64         {"depreciated-trait-syntax" , Severity::Warn    , "trait type-parameters are now specified using the forall clause" },
     60        {"self-assign"              , Severity::Warn, "self assignment of expression: %s"                          },
     61        {"reference-conversion"     , Severity::Warn, "rvalue to reference conversion of rvalue: %s"               },
     62        {"qualifiers-zero_t-one_t"  , Severity::Warn, "questionable use of type qualifier(s) with %s"              },
     63        {"aggregate-forward-decl"   , Severity::Warn, "forward declaration of nested aggregate: %s"                },
     64        {"superfluous-decl"         , Severity::Warn, "declaration does not allocate storage: %s"                  },
     65        {"superfluous-else"         , Severity::Warn, "else clause never executed for empty loop conditional"      },
     66        {"gcc-attributes"           , Severity::Warn, "invalid attribute: %s"                                      },
     67        {"c++-like-copy"            , Severity::Warn, "Constructor from reference is not a valid copy constructor" },
     68        {"depreciated-trait-syntax" , Severity::Warn, "trait type-parameters are now specified using the forall clause" },
    6569};
    6670
     
    7579        CppCopy,
    7680        DeprecTraitSyntax,
    77         NUMBER_OF_WARNINGS, // This MUST be the last warning
     81        NUMBER_OF_WARNINGS, // MUST be last warning
    7882};
    7983
     
    8387);
    8488
    85 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, ##__VA_ARGS__)
     89void SemanticWarning( CodeLocation loc, Warning warn, ... );
    8690
    87 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
    88 
    89 void SemanticWarning_SuppressAll   ();
    90 void SemanticWarning_EnableAll     ();
     91void SemanticWarning_SuppressAll();
     92void SemanticWarning_EnableAll();
    9193void SemanticWarning_WarningAsError();
    92 void SemanticWarning_Set           (const char * const name, Severity s);
     94void SemanticWarning_Set(const char * const name, Severity s);
    9395
    9496// SKULLDUGGERY: cfa.cc is built before SemanticError.cc but needs this routine.
Note: See TracChangeset for help on using the changeset viewer.