- if(var.declaration && constant_expression && !var.declaration->constant)
- error(var, format("Reference to non-constant variable '%s' in a constant expression", var.name));
+ if(var.declaration && constant_expression)
+ {
+ if(!var.declaration->constant)
+ error(var, format("Reference to non-constant variable '%s' in a constant expression", var.name));
+ else if(var.declaration->layout && constant_expression==FIXED_CONSTANT)
+ {
+ if(has_layout_qualifier(var.declaration->layout.get(), "constant_id"))
+ error(var, format("Reference to specialization constant '%s' in a fixed constant expression", var.name));
+ }
+ }