Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding object methods when in namespace #3284

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11767,18 +11767,17 @@ bool Sema::DiagnoseHLSLDecl(Declarator &D, DeclContext *DC, Expr *BitWidth,
"otherwise this is called without checking language first");

// NOTE: some tests may declare templates.
if (DC->isNamespace() || DC->isDependentContext()) return true;
if (DC->isDependentContext()) return true;

DeclSpec::SCS storage = D.getDeclSpec().getStorageClassSpec();
assert(!DC->isClosure() && "otherwise parser accepted closure syntax instead of failing with a syntax error");
assert(!DC->isDependentContext() && "otherwise parser accepted a template instead of failing with a syntax error");
assert(!DC->isNamespace() && "otherwise parser accepted a namespace instead of failing a syntax error");

bool result = true;
bool isTypedef = storage == DeclSpec::SCS_typedef;
bool isFunction = D.isFunctionDeclarator() && !DC->isRecord();
bool isLocalVar = DC->isFunctionOrMethod() && !isFunction && !isTypedef;
bool isGlobal = !isParameter && !isTypedef && !isFunction && (DC->isTranslationUnit() || DC->getDeclKind() == Decl::HLSLBuffer);
bool isGlobal = !isParameter && !isTypedef && !isFunction && (DC->isTranslationUnit() || DC->isNamespace() || DC->getDeclKind() == Decl::HLSLBuffer);
bool isMethod = DC->isRecord() && D.isFunctionDeclarator() && !isTypedef;
bool isField = DC->isRecord() && !D.isFunctionDeclarator() && !isTypedef;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %dxc -T ps_6_0 %s | FileCheck %s

// CHECK: dx.op.sample.f32
// CHECK: dx.op.sample.f32

namespace Textures {
Texture2D<float4> Color : register(t0);
}

namespace Samplers {
SamplerState Point : register(s0);
}

Texture2D<float4> GlobalTex : register(t1);
SamplerState GlobalSamp : register(s1);

float4 main(in float2 uv : TEXCOORD0) : SV_TARGET0
{
return (Textures::Color.Sample(Samplers::Point, uv) + GlobalTex.Sample(GlobalSamp, uv))/2.0;
}