Skip to content
Open
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
31 changes: 12 additions & 19 deletions tools/clang/include/clang/Lex/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,25 +294,18 @@ class Token {

// HLSL Change Starts
bool isHLSLReserved() const {
return
is(tok::kw___is_signed) ||
is(tok::kw___declspec) ||
is(tok::kw___forceinline) ||
is(tok::kw_auto) ||
is(tok::kw_catch) || is(tok::kw_const_cast) ||
is(tok::kw_delete) || is(tok::kw_dynamic_cast) ||
is(tok::kw_enum) || is(tok::kw_explicit) ||
is(tok::kw_friend) ||
is(tok::kw_goto) ||
is(tok::kw_mutable) ||
is(tok::kw_new) ||
is(tok::kw_operator) ||
is(tok::kw_protected) || is(tok::kw_private) || is(tok::kw_public) ||
is(tok::kw_reinterpret_cast) ||
is(tok::kw_signed) || is(tok::kw_sizeof) || is(tok::kw_static_cast) ||
is(tok::kw_template) || is(tok::kw_throw) || is(tok::kw_try) || is(tok::kw_typename) ||
is(tok::kw_union) || is(tok::kw_using) ||
is(tok::kw_virtual);
return is(tok::kw___is_signed) || is(tok::kw___declspec) ||
is(tok::kw___forceinline) || is(tok::kw_auto) || is(tok::kw_catch) ||
is(tok::kw_const_cast) || is(tok::kw_delete) ||
is(tok::kw_dynamic_cast) || is(tok::kw_enum) ||
is(tok::kw_explicit) || is(tok::kw_friend) || is(tok::kw_goto) ||
is(tok::kw_mutable) || is(tok::kw_new) || is(tok::kw_operator) ||
is(tok::kw_protected) || is(tok::kw_private) || is(tok::kw_public) ||
is(tok::kw_reinterpret_cast) || is(tok::kw_signed) ||
is(tok::kw_sizeof) || is(tok::kw_static_cast) ||
is(tok::kw_template) || is(tok::kw_throw) || is(tok::kw_try) ||
is(tok::kw_typename) || is(tok::kw_union) || is(tok::kw_using) ||
is(tok::kw_virtual) || is(tok::kw_volatile);
}
// HLSL Change Starts

Expand Down
4 changes: 4 additions & 0 deletions tools/clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4193,6 +4193,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
getLangOpts());
break;
case tok::kw_volatile:
// HLSL Change - volatile is reserved for HLSL
if (getLangOpts().HLSL)
goto HLSLReservedKeyword;
// HLSL Change Ends
isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
getLangOpts());
break;
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/test/HLSL/cpp-errors-hv2015.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct s_with_friend {
};

typedef int (*fn_int_const)(int) const; // expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}
typedef int (*fn_int_volatile)(int) volatile; // expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}
typedef int (*fn_int_volatile)(int) volatile; // expected-error {{'volatile' is a reserved keyword in HLSL}} expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}

void fn_throw() throw() { } // expected-error {{exception specification is unsupported in HLSL}}

Expand Down
3 changes: 2 additions & 1 deletion tools/clang/test/HLSL/cpp-errors.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ _Bool g_Bool; // expected-error {{unknown type name '_Bool'}}
_vector int altivec_vector; // expected-error {{expected unqualified-id}} expected-error {{unknown type name '_vector'}}

restrict int g_restrict; // expected-error {{expected unqualified-id}} expected-error {{unknown type name 'restrict'}}
volatile int g_volatile; // expected-error {{'volatile' is a reserved keyword in HLSL}}

__underlying_type(int) g_underlying_type; // expected-error {{__underlying_type is unsupported in HLSL}}
_Atomic(something) g_Atomic; // expected-error {{'_Atomic' is a reserved keyword in HLSL}} expected-error {{HLSL requires a type specifier for all declarations}}
Expand All @@ -56,7 +57,7 @@ struct s_with_friend {
};

typedef int (*fn_int_const)(int) const; // expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}
typedef int (*fn_int_volatile)(int) volatile; // expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}
typedef int (*fn_int_volatile)(int) volatile; // expected-error {{'volatile' is a reserved keyword in HLSL}} expected-error {{expected ';' after top level declarator}} expected-error {{pointers are unsupported in HLSL}} expected-warning {{declaration does not declare anything}}

void fn_throw() throw() { } // expected-error {{exception specification is unsupported in HLSL}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ precise uniform const float g_pre_uni_init = 1.F;
static float g_sta_init = 1.F;
static const float g_sta_con_init = 1.F;
uniform const float g_uni_init = 1.F;
typedef volatile float2 t_pre_vol;
typedef const volatile float2 t_pre_vol_con;
typedef const float2 t_pre_con;
typedef volatile float2 t_vol;
typedef const volatile float2 t_vol_con;
typedef const float2 t_con;
struct s_storage_mods {
precise float2 f_pre;
Expand Down Expand Up @@ -222,22 +218,12 @@ float4 foo_interpolation_different_decl(sample float4 val) {
void vain() {
precise float l_pre;
static precise float l_pre_sta;
static precise volatile float l_pre_sta_vol;
static precise const volatile float l_pre_sta_vol_con;
static precise const float l_pre_sta_con;
precise volatile float l_pre_vol;
static float l_sta;
static volatile float l_sta_vol;
static const volatile float l_sta_vol_con;
static const float l_sta_con;
volatile float l_vol;
static precise const volatile float l_pre_sta_vol_con_init = 0.;
static precise const float l_pre_sta_con_init = 0.;
precise const volatile float l_pre_vol_con_init = 0.;
precise const float l_pre_con_init = 0.;
static const volatile float l_sta_vol_con_init = 0.;
static const float l_sta_con_init = 0.;
const volatile float l_vol_con_init = 0.;
const float l_con_init = 0.;
}

Expand Down
30 changes: 15 additions & 15 deletions tools/clang/test/HLSL/rewriter/varmods-syntax_noerr.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ uniform float g_uni_init = 1.0f;
//typedef precise uniform volatile float2 t_pre_uni_vol; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
//typedef precise uniform volatile const float2 t_pre_uni_vol_con; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
//typedef precise uniform const float2 t_pre_uni_con; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
typedef precise volatile float2 t_pre_vol;
typedef precise volatile const float2 t_pre_vol_con;
//typedef precise volatile float2 t_pre_vol;
//typedef precise volatile const float2 t_pre_vol_con;
typedef precise const float2 t_pre_con;
//typedef static float2 t_sta; /* expected-error {{cannot combine with previous 'typedef' declaration specifier}} fxc-error {{X3000: syntax error: unexpected token 'static'}} */
//typedef static volatile float2 t_sta_vol; /* expected-error {{cannot combine with previous 'typedef' declaration specifier}} fxc-error {{X3000: syntax error: unexpected token 'static'}} */
Expand All @@ -299,8 +299,8 @@ typedef precise const float2 t_pre_con;
//typedef uniform volatile float2 t_uni_vol; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
//typedef uniform volatile const float2 t_uni_vol_con; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
//typedef uniform const float2 t_uni_con; /* expected-error {{'uniform' is not a valid modifier for a typedef}} fxc-error {{X3000: syntax error: unexpected token 'uniform'}} */
typedef volatile float2 t_vol;
typedef volatile const float2 t_vol_con;
//typedef volatile float2 t_vol;
//typedef volatile const float2 t_vol_con;
typedef const float2 t_con;
// GENERATED_CODE:END

Expand Down Expand Up @@ -668,25 +668,25 @@ void vain() {
//extern const float l_ext_con; /* expected-error {{'extern' is not a valid modifier for a local variable}} fxc-error {{X3006: 'l_ext_con': local variables cannot be declared 'extern'}} fxc-error {{X3012: 'l_ext_con': missing initial value}} */
precise float l_pre;
precise static float l_pre_sta;
precise static volatile float l_pre_sta_vol;
precise static volatile const float l_pre_sta_vol_con;
//precise static volatile float l_pre_sta_vol;
//precise static volatile const float l_pre_sta_vol_con;
precise static const float l_pre_sta_con;
//precise uniform float l_pre_uni; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3047: 'l_pre_uni': local variables cannot be declared 'uniform'}} */
//precise uniform volatile float l_pre_uni_vol; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3047: 'l_pre_uni_vol': local variables cannot be declared 'uniform'}} */
//precise uniform volatile const float l_pre_uni_vol_con; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_pre_uni_vol_con': missing initial value}} fxc-error {{X3047: 'l_pre_uni_vol_con': local variables cannot be declared 'uniform'}} */
//precise uniform const float l_pre_uni_con; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_pre_uni_con': missing initial value}} fxc-error {{X3047: 'l_pre_uni_con': local variables cannot be declared 'uniform'}} */
precise volatile float l_pre_vol;
//precise volatile float l_pre_vol;
//precise volatile const float l_pre_vol_con; /* fxc-error {{X3012: 'l_pre_vol_con': missing initial value}} */
//precise const float l_pre_con; /* fxc-error {{X3012: 'l_pre_con': missing initial value}} */
static float l_sta;
static volatile float l_sta_vol;
static volatile const float l_sta_vol_con;
//static volatile float l_sta_vol;
//static volatile const float l_sta_vol_con;
static const float l_sta_con;
//uniform float l_uni; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3047: 'l_uni': local variables cannot be declared 'uniform'}} */
//uniform volatile float l_uni_vol; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3047: 'l_uni_vol': local variables cannot be declared 'uniform'}} */
//uniform volatile const float l_uni_vol_con; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_uni_vol_con': missing initial value}} fxc-error {{X3047: 'l_uni_vol_con': local variables cannot be declared 'uniform'}} */
//uniform const float l_uni_con; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_uni_con': missing initial value}} fxc-error {{X3047: 'l_uni_con': local variables cannot be declared 'uniform'}} */
volatile float l_vol;
//volatile float l_vol;
//volatile const float l_vol_con; /* fxc-error {{X3012: 'l_vol_con': missing initial value}} */
//const float l_con; /* fxc-error {{X3012: 'l_con': missing initial value}} */
// GENERATED_CODE:END
Expand All @@ -713,17 +713,17 @@ void vain() {
//extern uniform const float l_ext_uni_con_init = 0.0; /* expected-error {{'extern' is not a valid modifier for a local variable}} expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3006: 'l_ext_uni_con_init': local variables cannot be declared 'extern'}} fxc-error {{X3012: 'l_ext_uni_con_init': missing initial value}} fxc-error {{X3047: 'l_ext_uni_con_init': local variables cannot be declared 'uniform'}} */
//extern volatile const float l_ext_vol_con_init = 0.0; /* expected-error {{'extern' is not a valid modifier for a local variable}} fxc-error {{X3006: 'l_ext_vol_con_init': local variables cannot be declared 'extern'}} fxc-error {{X3012: 'l_ext_vol_con_init': missing initial value}} */
//extern const float l_ext_con_init = 0.0; /* expected-error {{'extern' is not a valid modifier for a local variable}} fxc-error {{X3006: 'l_ext_con_init': local variables cannot be declared 'extern'}} fxc-error {{X3012: 'l_ext_con_init': missing initial value}} */
precise static volatile const float l_pre_sta_vol_con_init = 0.0;
//precise static volatile const float l_pre_sta_vol_con_init = 0.0;
precise static const float l_pre_sta_con_init = 0.0;
//precise uniform volatile const float l_pre_uni_vol_con_init = 0.0; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_pre_uni_vol_con_init': missing initial value}} fxc-error {{X3047: 'l_pre_uni_vol_con_init': local variables cannot be declared 'uniform'}} */
//precise uniform const float l_pre_uni_con_init = 0.0; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_pre_uni_con_init': missing initial value}} fxc-error {{X3047: 'l_pre_uni_con_init': local variables cannot be declared 'uniform'}} */
precise volatile const float l_pre_vol_con_init = 0.0;
//precise volatile const float l_pre_vol_con_init = 0.0;
precise const float l_pre_con_init = 0.0;
static volatile const float l_sta_vol_con_init = 0.0;
//static volatile const float l_sta_vol_con_init = 0.0;
static const float l_sta_con_init = 0.0;
//uniform volatile const float l_uni_vol_con_init = 0.0; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_uni_vol_con_init': missing initial value}} fxc-error {{X3047: 'l_uni_vol_con_init': local variables cannot be declared 'uniform'}} */
//uniform const float l_uni_con_init = 0.0; /* expected-error {{'uniform' is not a valid modifier for a local variable}} fxc-error {{X3012: 'l_uni_con_init': missing initial value}} fxc-error {{X3047: 'l_uni_con_init': local variables cannot be declared 'uniform'}} */
volatile const float l_vol_con_init = 0.0;
//volatile const float l_vol_con_init = 0.0;
const float l_con_init = 0.0;
// GENERATED_CODE:END

Expand Down Expand Up @@ -969,4 +969,4 @@ class C
//out float fn_out() { return 1.0f; } /* expected-error {{HLSL usage 'out' is only valid on a parameter}} fxc-error {{X3000: syntax error: unexpected token 'out'}} */
//inout float fn_inout() { return 1.0f; } /* expected-error {{HLSL usage 'inout' is only valid on a parameter}} fxc-error {{X3000: syntax error: unexpected token 'inout'}} */

};
};
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ const float g_con_init = 1.0f; /* fxc-warning {{X32
// <py::lines('GENERATED_CODE')>modify(lines, gen_code('typedef %(mods)s float2 t_%(id)s;', storage_combos))</py>
// GENERATED_CODE:BEGIN
typedef precise float2 t_pre;
typedef precise volatile float2 t_pre_vol;
typedef precise volatile const float2 t_pre_vol_con;
//typedef precise volatile float2 t_pre_vol;
//typedef precise volatile const float2 t_pre_vol_con;
typedef precise const float2 t_pre_con;
typedef volatile float2 t_vol;
typedef volatile const float2 t_vol_con;
//typedef volatile float2 t_vol;
//typedef volatile const float2 t_vol_con;
typedef const float2 t_con;
// GENERATED_CODE:END

Expand Down Expand Up @@ -294,26 +294,26 @@ void main() {
// GENERATED_CODE:BEGIN
precise float l_pre;
precise static float l_pre_sta;
precise static volatile float l_pre_sta_vol;
precise static volatile const float l_pre_sta_vol_con;
//precise static volatile float l_pre_sta_vol;
//precise static volatile const float l_pre_sta_vol_con;
precise static const float l_pre_sta_con;
precise volatile float l_pre_vol;
//precise volatile float l_pre_vol;
static float l_sta;
static volatile float l_sta_vol;
static volatile const float l_sta_vol_con;
//static volatile float l_sta_vol;
//static volatile const float l_sta_vol_con;
static const float l_sta_con;
volatile float l_vol;
//volatile float l_vol;
// GENERATED_CODE:END
// Now with const vars initialized:
// <py::lines('GENERATED_CODE')>modify(lines, gen_code('%(mods)s float l_%(id)s_init = 0.0;', filter(lambda combo: 'const' in combo, storage_combos)))</py>
// GENERATED_CODE:BEGIN
precise static volatile const float l_pre_sta_vol_con_init = 0.0;
//precise static volatile const float l_pre_sta_vol_con_init = 0.0;
precise static const float l_pre_sta_con_init = 0.0;
precise volatile const float l_pre_vol_con_init = 0.0;
//precise volatile const float l_pre_vol_con_init = 0.0;
precise const float l_pre_con_init = 0.0;
static volatile const float l_sta_vol_con_init = 0.0;
//static volatile const float l_sta_vol_con_init = 0.0;
static const float l_sta_con_init = 0.0;
volatile const float l_vol_con_init = 0.0;
//volatile const float l_vol_con_init = 0.0;
const float l_con_init = 0.0;
// GENERATED_CODE:END

Expand Down Expand Up @@ -378,4 +378,4 @@ class C
// GENERATED_CODE:END


};
};
Loading