source: src/Common/SemanticError.h@ b03eed6

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum with_gc
Last change on this file since b03eed6 was 6d2aa7ed, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Missed one conflict

  • Property mode set to 100644
File size: 2.6 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// SemanticError.h --
8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Aug 29 22:03:36 2017
13// Update Count : 17
14//
15
16#pragma once
17
18#include "ErrorObjects.h"
19
20//-----------------------------------------------------------------------------
21// Errors
22
23__attribute__((noreturn)) void SemanticError( CodeLocation location, std::string error );
24
25template< typename T >
26__attribute__((noreturn)) static inline void SemanticError( const T * obj, const std::string & error ) {
27 SemanticError( obj->location, toString( error, obj ) );
28}
29
30template< typename T >
31__attribute__((noreturn)) static inline void SemanticError( CodeLocation location, const T * obj, const std::string & error ) {
32 SemanticError( location, toString( error, obj ) );
33}
34
35//-----------------------------------------------------------------------------
36// Warnings
37
38enum class Severity {
39 Suppress,
40 Warn,
41 Error,
42 Critical
43};
44
45struct WarningData {
46 const char * const name;
47 const char * const message;
48 mutable Severity severity;
49};
50
51constexpr 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},
54};
55
56enum class Warning {
57 SelfAssignment,
58 RvalueToReferenceConversion,
59 NUMBER_OF_WARNINGS, //This MUST be the last warning
60};
61
62static_assert(
63 (sizeof(WarningFormats) / sizeof(WarningFormats[0])) == ((unsigned long)Warning::NUMBER_OF_WARNINGS),
64 "Each warning format should have a corresponding warning enum value"
65);
66
67#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__)
68
69void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
70
71
72//-----------------------------------------------------------------------------
73// Helpers
74namespace ErrorHelpers {
75 const std::string & error_str();
76 const std::string & warning_str();
77 const std::string & bold_ttycode();
78 const std::string & reset_font_ttycode();
79
80 std::string make_bold( const std::string & str );
81
82 struct bold {};
83 std::ostream & operator<<(std::ostream & os, bold);
84
85 struct reset_font {};
86 std::ostream & operator<<(std::ostream & os, reset_font);
87}
88
89// Local Variables: //
90// tab-width: 4 //
91// mode: c++ //
92// compile-command: "make install" //
93// End: //
Note: See TracBrowser for help on using the repository browser.