https://github.com/shader-slang/slang
Raw File
Tip revision: c4790309ec46ae2f4f7c49eb50699a950ee7a9a4 authored by Yong He on 20 February 2022, 22:37:41 UTC
gfx: defer downstream shader compilation until draw/dispatch. (#2139)
Tip revision: c479030
variable-redeclaration.slang
// variable-redeclaration.slang

//DIAGNOSTIC_TEST:SIMPLE:


// This test confirms that the compiler produces
// suitable diagnostics when variables are redeclared
// in a given scope.

// Global variables, including shader parameters

static int gA;

static Texture2D gA;

// Local variables

int testLocalRedeclaration(int x)
{
	int y = x;
	int y = x;
}

int testLocalShadowing(int x)
{
	int y = x;
	{
		// Because this declaration is in an inner
		// scope it should shadow the existing `y`
		// rather than conflcit with it.
		//
		// TODO: It would be reasonable for the
		// compiler to warn on this sort of code.
		//
		int y = x;
	}
}

// Structure fields

struct S
{
	int f;
	float f;
}

// Function parameter list

int testParameterRedeclaration(
	int 	size,
	float 	size)
{
	return size;
}
back to top