[Bug Report] Clang 3.5 compilation error with -Werror and -Wshado

It seems Clang is a little rabid in terms of variable naming - because “-Wshadow” is set, attempting to compile a C++ class on Linux using Clang 3.5 results in a warning when a function parameter has the same name as data member. As the flag “-Werror” is also set, this warning gets promoted to a full-blown error and interrupts the build.

Dropping “-Werror” from the compilation arguments should theoretically make these issues a visual log annoyance instead of a blocking issue. GCC has had the same issue as a bug report, but has apparently fixed it.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57709

The provided sample code below compiles fine on Windows 7 using Visual Studio 2013 Community, but fails with the following error on Linux Mint 17.2, using Qt Creator and Clang 3.5.

Sample code:

#pragma once

#include "GameProject.h"
#include "MemoryElement.generated.h"
/**
 * 
 */
USTRUCT()
struct GAMEPROJECT_API FMemoryElement
{
	GENERATED_USTRUCT_BODY();
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
		FString KeyName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
		FString Data;

	FMemoryElement()
	{
		KeyName = "";
		Data = "";
	}

	FMemoryElement(FString KeyName, FString Data)
	{
		this->KeyName = KeyName;
            this->Data = Data;
	}
};

Compilation Error:

In file included from /home//Programming/Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.cpp:9:
In file included from ../../../Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.dep.h:21:
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:25: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
        FMemoryElement(FString KeyName, FString Data)
                               ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:16:11: note: previous declaration is here
                FString KeyName;
                        ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:42: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
        FMemoryElement(FString KeyName, FString Data)
                                                ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:19:11: note: previous declaration is here
                FString Data;
                        ^

While workarounds are available (renaming member variables to have a trailing underscore, renaming the function parameter), it is a common idiom to give function parameters the same name as the variable they initialize or affect.

Distro: Linux Mint 17.2
Compiler: Clang 3.5
IDE: Qt Creator
Unreal Engine: 4.8.3 (Github 4.8 branch source build)

Continuing this on the forums, since it seems to be a quirk with UBT.