yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2896aa39a
master
1// missing-return.slang 2 3//DIAGNOSTIC_TEST:SIMPLE: 4 5// Non-`void` function that fails to return 6 7int bad(int a, int b) 8{ 9 int result = a + b; 10 11 // forgot `return` here 12} 13 14int alsoBad(int a, int b) 15{ 16 if(a > b) 17 { 18 return a + b; 19 } 20 21 // forgot `return` here 22} 23 24int okay(int a, int b) 25{ 26 int tmp = a; 27 for(;;) 28 { 29 if(a > b) 30 return tmp; 31 32 a = b; 33 b = tmp; 34 tmp = a + b; 35 } 36 37 // Lack of `return` here is not 38 // a problem, because we can never 39 // actually get here 40} 41 42int alsoOkay(int a, int b) 43{ 44 int tmp = a; 45 while(true) 46 { 47 if(a > b) 48 return tmp; 49 50 a = b; 51 b = tmp; 52 tmp = a + b; 53 } 54 55 // Lack of `return` here is not 56 // a problem, because we can never 57 // actually get here 58}