It would certainly be very practical if compiler issued warnings when one mistook bit name - especially in a register variable. But to make it possible to implement one would have to apply a way of declaring bit constants and variables that would let the compiler unequivocally recognize the connection, like
var Variable1: byte;
const Variablebit0 = 0; register;
var Variablebit0_bit: sbit at Variable1.Variablebit0;
var INTCON: byte; absolute 0x00B; volatile; sfr;
const GIE = 7; register;
var GIE_bit : sbit at INTCON.GIE;
In the above, the connection between holding byte and a bit name is specified in sbit declaration and thus makes test of correct use of bit constants possible.
Indeed, but still nothing prevents you to use a bitnumber declaration on the "wrong" variable, e.g.:
var INTCON_: byte; absolute 0x00B; volatile; sfr;
const GIE_ = 7; register;
var GIE_bit_ : sbit at INTCON_.GIE_;
var xxx_bit : sbit at STATUS.GIE_; // <------- here
In above code the bitnumber "GIE_" (meant for variable INTCON) is used to define a bit in variable "STATUS" which has no GIE bit at all, in fact bit 7 there has no meaning (in the PIC18F2550).
One can even declare:
var GIE_bit_ : sbit at STATUS.GIE_;
which is totally wrong seen from the perspective of the user... but to the compiler this is Ok, it will not complain or warn.Note: in above code I did add an underscore to all variable names to make it not conflicting with already existing declarations.