Struct Warning

pub struct Warning;
Expand description

A warning diagnostic.

Implementations§

§

impl Warning

pub fn constant_conversion( old_type: &AstType, new_type: &AstType, old_value: &str, new_value: &str, loc: SourceLocation, driver: &mut Driver, )

Emits an implicit conversion warning for a constant that changes value.

-Wconstant-conversion

pub fn constant_conversion_float_int_explicit_cast( old_type: &AstType, new_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits a conversion warning for a floating-point constant that is explicitly cast to an integer type, which despite the explicit cast is still UB. This is a variation of the warning above, but points out the explicit cast to the user.

-Wconstant-conversion

pub fn division_by_zero( op: &AstBinaryOp, op_loc: SourceLocation, zero_expr_loc: SourceLocation, driver: &mut Driver, )

Emits a warning about an undefined division/remainder by zero.

-Wdivision-by-zero

pub fn shift_count_negative(loc: SourceLocation, driver: &mut Driver)

Emits a warning that a shift count is negative.

-Wshift-count-negative

pub fn shift_count_zero(loc: SourceLocation, driver: &mut Driver)

Emits a warning that a shift count is zero.

-Wshift-count-zero

pub fn shift_count_overflow( bits_allowed: usize, expr_promoted_to_int: bool, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a shift count is >= the valid number of bits for the type.

-Wshift-count-overflow

pub fn integer_overflow( int_type: &AstType, new_value: &str, loc: SourceLocation, driver: &mut Driver, )

Emits a warning about an integer overflow in an expression.

-Winteger-overflow

pub fn floating_point_overflow( fp_type: &AstType, new_value: &str, loc: SourceLocation, driver: &mut Driver, )

Emits a warning about a floating-point overflow in an expression.

-Wfloating-point-overflow

pub fn implicit_int_promotion_conversion( old_type: &AstType, new_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits an implicit conversion warning where an expression that was promoted to ‘int’ is now implicitly converted and loses precision.

-Wimplicit-promotion-conversion

pub fn implicit_arithmetic_conversion( old_type: &AstType, new_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits an implicit conversion warning for an arithmetic type, where the conversion either changes signedness or results in precision loss.

-Wimplicit-conversion -Wimplicit-int-conversion -Wimplicit-float-conversion -Wsign-conversion

pub fn implicit_switch_case_conversion( case_data_type: &AstType, switch_data_type: &AstType, old_value: &str, new_value: &str, sign_change: bool, loc: SourceLocation, driver: &mut Driver, )

Emits an implicit conversion warning for a switch statement case value.

-Wimplicit-conversion

pub fn extern_initializer(loc: SourceLocation, driver: &mut Driver)

Emits a warning about an ‘extern’ variable with an initializer.

pub fn duplicate_decl_specifier( specifier: SourceIdentifier<'_>, driver: &mut Driver, )

Emits a warning for a duplicate declaration specifier (e.g. duplicate storage class or ‘signed’/‘unsigned’).

-Wduplicate-decl-specifier

pub fn missing_declaration_identifier( is_typedef: bool, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a declaration is missing its identifier.

-Wmissing-declarations

pub fn uninitialized_variable( variable: SourceIdentifier<'_>, driver: &mut Driver, )

Emits a warning that a variable is uninitialized.

-Wuninitialized

pub fn literal_range( literal_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a literal constant value is outside the type’s valid range.

-Wliteral-range

pub fn integer_literal_implicitly_unsigned( loc: SourceLocation, driver: &mut Driver, )

Emits a warning that an integer literal is too large to be interpreted as signed and therefore is implicitly converted to unsigned.

-Wimplicitly-unsigned-literal

pub fn unused_value(loc: SourceLocation, driver: &mut Driver)

Emits a warning that the value result of an expression (with no side-effects) is unused.

-Wunused-value

pub fn unused_comparison( op: AstBinaryOp, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that the comparison result of an expression (with no side-effects) is unused.

-Wunused-comparison

pub fn unused_symbol( symbol: SourceIdentifier<'_>, kind: SymbolKind, driver: &mut Driver, )

Emits a warning that a symbol is unused.

-Wunused-variable -Wunused-function -Wunused-local-typedef

pub fn mixed_operators_missing_parens( child_expr_op: AstBinaryOp, parent_expr_op: AstBinaryOp, child_op_loc: SourceLocation, parent_op_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that an expression has mixed operators and is missing parentheses.

-Wlogical-op-parentheses -Wbitwise-op-parentheses -Wparentheses

pub fn assignment_in_condition_missing_parens( assignment_expr_loc: SourceLocation, assignment_operator_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that the result of an assignment is used as a condition without parentheses.

-Wparentheses

pub fn compare_distinct_pointer_types( a: &AstType, b: &AstType, cmp_loc: SourceLocation, a_loc: SourceLocation, b_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that two different pointer types are being compared.

-Wcompare-distinct-pointer-types

pub fn compare_pointer_and_integer( ptr_type: &AstType, int_type: &AstType, op_loc: SourceLocation, ptr_loc: SourceLocation, int_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a pointer and an integer are being compared.

-Wpointer-integer-compare

pub fn pointer_to_smaller_int_cast( ptr_type: &AstType, int_type: &AstType, cmp_loc: SourceLocation, int_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a pointer is casted to an integer type smaller than pointer type.

-Wpointer-to-int-cast

pub fn pointer_bool_conversion( symbol_name: &str, symbol_kind: SymbolKind, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that taking the address of a symbol will always evaluate to ‘true’.

-Wpointer-bool-conversion

pub fn expression_interpreted_as_null_ptr_constant( loc: SourceLocation, ptr_type: &AstType, driver: &mut Driver, )

Emits a warning that an expression evaluated to zero and is interpreted as a null pointer constant.

-Wnon-literal-null-conversion

pub fn conditional_type_mismatch( a: &AstType, b: &AstType, ternary_op_loc: SourceLocation, a_loc: SourceLocation, b_loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a ternary condition’s consequent and alternative types do not match.

-Wconditional-type-mismatch

pub fn too_many_elements_for_initializer( variable_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that there are too many elements in the initializer list for the given variable_type.

-Wexcess-initializers

pub fn initializer_string_too_long_for_array( array_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that an initializer string is too long for a char array.

-Wexcess-initializers

pub fn missing_braces_around_sub_object( loc: SourceLocation, driver: &mut Driver, )

Emits a warning that a subobject initializer is missing braces.

-Wmissing-braces

pub fn too_many_braces_for_scalar_initializer( loc: SourceLocation, driver: &mut Driver, )

Emits a warning that there are too many braces around an initializer list for a scalar type.

-Wmany-braces-around-scalar-init

pub fn array_index_out_of_bounds( index: i32, array_type: &AstType, loc: SourceLocation, driver: &mut Driver, )

Emits a warning that an array subscript index is out of bounds.

-Warray-bounds

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.