source: src/Common/SemanticError.h @ 9dc31c10

ADTaaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since 9dc31c10 was 9dc31c10, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

warning message for type qualifiers on zero_t/one_t

  • Property mode set to 100644
File size: 2.5 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 : Wed Apr 18 16:28:16 2018
13// Update Count     : 18
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
38constexpr const char * const WarningFormats[] = {
39        "self assignment of expression: %s",
40        "rvalue to reference conversion of rvalue: %s",
41        "questionable use of type qualifier %s with %s",
42};
43
44enum class Warning {
45        SelfAssignment,
46        RvalueToReferenceConversion,
47        BadQualifiersZeroOne,
48        NUMBER_OF_WARNINGS, //This MUST be the last warning
49};
50
51static_assert(
52        (sizeof(WarningFormats) / sizeof(WarningFormats[0])) == ((unsigned long)Warning::NUMBER_OF_WARNINGS),
53        "Each warning format should have a corresponding warning enum value"
54);
55
56// ## used here to allow empty __VA_ARGS__
57#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], ## __VA_ARGS__)
58
59void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
60
61
62//-----------------------------------------------------------------------------
63// Helpers
64namespace ErrorHelpers {
65        const std::string & error_str();
66        const std::string & warning_str();
67        const std::string & bold_ttycode();
68        const std::string & reset_font_ttycode();
69
70        std::string make_bold( const std::string & str );
71
72        struct bold {};
73        std::ostream & operator<<(std::ostream & os, bold);
74
75        struct reset_font {};
76        std::ostream & operator<<(std::ostream & os, reset_font);
77}
78
79// Local Variables: //
80// tab-width: 4 //
81// mode: c++ //
82// compile-command: "make install" //
83// End: //
Note: See TracBrowser for help on using the repository browser.