Skip to content

Commit 841a635

Browse files
committed
disallow volatile keyword
1 parent c763461 commit 841a635

8 files changed

Lines changed: 308 additions & 319 deletions

File tree

tools/clang/include/clang/Lex/Token.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ class Token {
312312
is(tok::kw_signed) || is(tok::kw_sizeof) || is(tok::kw_static_cast) ||
313313
is(tok::kw_template) || is(tok::kw_throw) || is(tok::kw_try) || is(tok::kw_typename) ||
314314
is(tok::kw_union) || is(tok::kw_using) ||
315-
is(tok::kw_virtual);
315+
is(tok::kw_virtual) ||
316+
is(tok::kw_volatile);
316317
}
317318
// HLSL Change Starts
318319

tools/clang/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,6 +4193,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
41934193
getLangOpts());
41944194
break;
41954195
case tok::kw_volatile:
4196+
if (getLangOpts().HLSL) { goto HLSLReservedKeyword; } // HLSL Change - volatile is reserved for HLSL
41964197
isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
41974198
getLangOpts());
41984199
break;

tools/clang/test/HLSL/cpp-errors-hv2015.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct s_with_friend {
6060
};
6161

6262
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}}
63-
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}}
63+
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}}
6464

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

tools/clang/test/HLSL/cpp-errors.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ _Bool g_Bool; // expected-error {{unknown type name '_Bool'}}
3333
_vector int altivec_vector; // expected-error {{expected unqualified-id}} expected-error {{unknown type name '_vector'}}
3434

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

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

5859
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}}
59-
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}}
60+
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}}
6061

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

tools/clang/test/HLSL/rewriter/correct_rewrites/varmods-syntax_gold.hlsl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ precise uniform const float g_pre_uni_init = 1.F;
3737
static float g_sta_init = 1.F;
3838
static const float g_sta_con_init = 1.F;
3939
uniform const float g_uni_init = 1.F;
40-
typedef volatile float2 t_pre_vol;
41-
typedef const volatile float2 t_pre_vol_con;
4240
typedef const float2 t_pre_con;
43-
typedef volatile float2 t_vol;
44-
typedef const volatile float2 t_vol_con;
4541
typedef const float2 t_con;
4642
struct s_storage_mods {
4743
precise float2 f_pre;
@@ -222,22 +218,12 @@ float4 foo_interpolation_different_decl(sample float4 val) {
222218
void vain() {
223219
precise float l_pre;
224220
static precise float l_pre_sta;
225-
static precise volatile float l_pre_sta_vol;
226-
static precise const volatile float l_pre_sta_vol_con;
227221
static precise const float l_pre_sta_con;
228-
precise volatile float l_pre_vol;
229222
static float l_sta;
230-
static volatile float l_sta_vol;
231-
static const volatile float l_sta_vol_con;
232223
static const float l_sta_con;
233-
volatile float l_vol;
234-
static precise const volatile float l_pre_sta_vol_con_init = 0.;
235224
static precise const float l_pre_sta_con_init = 0.;
236-
precise const volatile float l_pre_vol_con_init = 0.;
237225
precise const float l_pre_con_init = 0.;
238-
static const volatile float l_sta_vol_con_init = 0.;
239226
static const float l_sta_con_init = 0.;
240-
const volatile float l_vol_con_init = 0.;
241227
const float l_con_init = 0.;
242228
}
243229

tools/clang/test/HLSL/rewriter/varmods-syntax_noerr.hlsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ uniform float g_uni_init = 1.0f;
288288
//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'}} */
289289
//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'}} */
290290
//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'}} */
291-
typedef precise volatile float2 t_pre_vol;
292-
typedef precise volatile const float2 t_pre_vol_con;
291+
//typedef precise volatile float2 t_pre_vol;
292+
//typedef precise volatile const float2 t_pre_vol_con;
293293
typedef precise const float2 t_pre_con;
294294
//typedef static float2 t_sta; /* expected-error {{cannot combine with previous 'typedef' declaration specifier}} fxc-error {{X3000: syntax error: unexpected token 'static'}} */
295295
//typedef static volatile float2 t_sta_vol; /* expected-error {{cannot combine with previous 'typedef' declaration specifier}} fxc-error {{X3000: syntax error: unexpected token 'static'}} */
@@ -299,8 +299,8 @@ typedef precise const float2 t_pre_con;
299299
//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'}} */
300300
//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'}} */
301301
//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'}} */
302-
typedef volatile float2 t_vol;
303-
typedef volatile const float2 t_vol_con;
302+
//typedef volatile float2 t_vol;
303+
//typedef volatile const float2 t_vol_con;
304304
typedef const float2 t_con;
305305
// GENERATED_CODE:END
306306

@@ -668,25 +668,25 @@ void vain() {
668668
//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}} */
669669
precise float l_pre;
670670
precise static float l_pre_sta;
671-
precise static volatile float l_pre_sta_vol;
672-
precise static volatile const float l_pre_sta_vol_con;
671+
//precise static volatile float l_pre_sta_vol;
672+
//precise static volatile const float l_pre_sta_vol_con;
673673
precise static const float l_pre_sta_con;
674674
//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'}} */
675675
//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'}} */
676676
//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'}} */
677677
//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'}} */
678-
precise volatile float l_pre_vol;
678+
//precise volatile float l_pre_vol;
679679
//precise volatile const float l_pre_vol_con; /* fxc-error {{X3012: 'l_pre_vol_con': missing initial value}} */
680680
//precise const float l_pre_con; /* fxc-error {{X3012: 'l_pre_con': missing initial value}} */
681681
static float l_sta;
682-
static volatile float l_sta_vol;
683-
static volatile const float l_sta_vol_con;
682+
//static volatile float l_sta_vol;
683+
//static volatile const float l_sta_vol_con;
684684
static const float l_sta_con;
685685
//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'}} */
686686
//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'}} */
687687
//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'}} */
688688
//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'}} */
689-
volatile float l_vol;
689+
//volatile float l_vol;
690690
//volatile const float l_vol_con; /* fxc-error {{X3012: 'l_vol_con': missing initial value}} */
691691
//const float l_con; /* fxc-error {{X3012: 'l_con': missing initial value}} */
692692
// GENERATED_CODE:END
@@ -713,17 +713,17 @@ void vain() {
713713
//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'}} */
714714
//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}} */
715715
//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}} */
716-
precise static volatile const float l_pre_sta_vol_con_init = 0.0;
716+
//precise static volatile const float l_pre_sta_vol_con_init = 0.0;
717717
precise static const float l_pre_sta_con_init = 0.0;
718718
//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'}} */
719719
//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'}} */
720-
precise volatile const float l_pre_vol_con_init = 0.0;
720+
//precise volatile const float l_pre_vol_con_init = 0.0;
721721
precise const float l_pre_con_init = 0.0;
722-
static volatile const float l_sta_vol_con_init = 0.0;
722+
//static volatile const float l_sta_vol_con_init = 0.0;
723723
static const float l_sta_con_init = 0.0;
724724
//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'}} */
725725
//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'}} */
726-
volatile const float l_vol_con_init = 0.0;
726+
//volatile const float l_vol_con_init = 0.0;
727727
const float l_con_init = 0.0;
728728
// GENERATED_CODE:END
729729

@@ -969,4 +969,4 @@ class C
969969
//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'}} */
970970
//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'}} */
971971

972-
};
972+
};

tools/clang/test/HLSLFileCheck/hlsl/types/conversions/varmods-syntax_Mod.hlsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ const float g_con_init = 1.0f; /* fxc-warning {{X32
127127
// <py::lines('GENERATED_CODE')>modify(lines, gen_code('typedef %(mods)s float2 t_%(id)s;', storage_combos))</py>
128128
// GENERATED_CODE:BEGIN
129129
typedef precise float2 t_pre;
130-
typedef precise volatile float2 t_pre_vol;
131-
typedef precise volatile const float2 t_pre_vol_con;
130+
//typedef precise volatile float2 t_pre_vol;
131+
//typedef precise volatile const float2 t_pre_vol_con;
132132
typedef precise const float2 t_pre_con;
133-
typedef volatile float2 t_vol;
134-
typedef volatile const float2 t_vol_con;
133+
//typedef volatile float2 t_vol;
134+
//typedef volatile const float2 t_vol_con;
135135
typedef const float2 t_con;
136136
// GENERATED_CODE:END
137137

@@ -294,26 +294,26 @@ void main() {
294294
// GENERATED_CODE:BEGIN
295295
precise float l_pre;
296296
precise static float l_pre_sta;
297-
precise static volatile float l_pre_sta_vol;
298-
precise static volatile const float l_pre_sta_vol_con;
297+
//precise static volatile float l_pre_sta_vol;
298+
//precise static volatile const float l_pre_sta_vol_con;
299299
precise static const float l_pre_sta_con;
300-
precise volatile float l_pre_vol;
300+
//precise volatile float l_pre_vol;
301301
static float l_sta;
302-
static volatile float l_sta_vol;
303-
static volatile const float l_sta_vol_con;
302+
//static volatile float l_sta_vol;
303+
//static volatile const float l_sta_vol_con;
304304
static const float l_sta_con;
305-
volatile float l_vol;
305+
//volatile float l_vol;
306306
// GENERATED_CODE:END
307307
// Now with const vars initialized:
308308
// <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>
309309
// GENERATED_CODE:BEGIN
310-
precise static volatile const float l_pre_sta_vol_con_init = 0.0;
310+
//precise static volatile const float l_pre_sta_vol_con_init = 0.0;
311311
precise static const float l_pre_sta_con_init = 0.0;
312-
precise volatile const float l_pre_vol_con_init = 0.0;
312+
//precise volatile const float l_pre_vol_con_init = 0.0;
313313
precise const float l_pre_con_init = 0.0;
314-
static volatile const float l_sta_vol_con_init = 0.0;
314+
//static volatile const float l_sta_vol_con_init = 0.0;
315315
static const float l_sta_con_init = 0.0;
316-
volatile const float l_vol_con_init = 0.0;
316+
//volatile const float l_vol_con_init = 0.0;
317317
const float l_con_init = 0.0;
318318
// GENERATED_CODE:END
319319

@@ -378,4 +378,4 @@ class C
378378
// GENERATED_CODE:END
379379

380380

381-
};
381+
};

0 commit comments

Comments
 (0)