- 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)
+ {
+ auto i = find_member(var.declaration->layout->qualifiers, string("constant_id"), &Layout::Qualifier::name);
+ if(i!=var.declaration->layout->qualifiers.end())
+ error(var, format("Reference to specialization constant '%s' in a fixed constant expression", var.name));
+ }
+ }