yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ec6b9168
master
1// variable-redeclaration.slang 2 3//DIAGNOSTIC_TEST:SIMPLE: 4 5 6// This test confirms that the compiler produces 7// suitable diagnostics when variables are redeclared 8// in a given scope. 9 10// Global variables, including shader parameters 11 12static int gA; 13 14static Texture2D gA; 15 16// Local variables 17 18int testLocalRedeclaration(int x) 19{ 20 int y = x; 21 int y = x; 22} 23 24int testLocalShadowing(int x) 25{ 26 int y = x; 27 { 28 // Because this declaration is in an inner 29 // scope it should shadow the existing `y` 30 // rather than conflcit with it. 31 // 32 // TODO: It would be reasonable for the 33 // compiler to warn on this sort of code. 34 // 35 int y = x; 36 } 37} 38 39// Structure fields 40// Note: more diagnostics will be reported here because of the constructor synthesis 41struct S 42{ 43 int f; 44 float f; 45} 46 47// Function parameter list 48 49int testParameterRedeclaration( 50 int size, 51 float size) 52{ 53 return size; 54}