You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`volatile` is not a valid keyword in HLSL, it is meaningless in this
language.
However, it comes as a result of the fact that HLSL is build on a C/C++
compiler, so there are some C++ artifacts that are part of the language.
This scenario goes into more detail:
llvm/wg-hlsl#300
Though DXC currently does and seems to always have compiled with the
volatile keyword, this is not sensible and should be disallowed.
Fixes#8391
Assisted by: Github Copilot
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: tools/clang/test/HLSL/cpp-errors-hv2015.hlsl
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ struct s_with_friend {
60
60
};
61
61
62
62
typedefint (*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
-
typedefint (*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
+
typedefint (*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}}
64
64
65
65
voidfn_throw() throw() { } // expected-error {{exception specification is unsupported in HLSL}}
Copy file name to clipboardExpand all lines: tools/clang/test/HLSL/cpp-errors.hlsl
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ _Bool g_Bool; // expected-error {{unknown type name '_Bool'}}
33
33
_vector int altivec_vector; // expected-error {{expected unqualified-id}} expected-error {{unknown type name '_vector'}}
34
34
35
35
restrict int g_restrict; // expected-error {{expected unqualified-id}} expected-error {{unknown type name 'restrict'}}
36
+
volatileint g_volatile; // expected-error {{'volatile' is a reserved keyword in HLSL}}
36
37
37
38
__underlying_type(int) g_underlying_type; // expected-error {{__underlying_type is unsupported in HLSL}}
38
39
_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 {
56
57
};
57
58
58
59
typedefint (*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
-
typedefint (*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
+
typedefint (*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}}
60
61
61
62
voidfn_throw() throw() { } // expected-error {{exception specification is unsupported in HLSL}}
//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'}} */
289
289
//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'}} */
290
290
//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
-
typedefprecisevolatilefloat2 t_pre_vol;
292
-
typedefprecisevolatileconstfloat2 t_pre_vol_con;
291
+
//typedef precise volatile float2 t_pre_vol; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
292
+
//typedef precise volatile const float2 t_pre_vol_con; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
//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'}} */
300
300
//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'}} */
301
301
//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
-
typedefvolatilefloat2 t_vol;
303
-
typedefvolatileconstfloat2 t_vol_con;
302
+
//typedef volatile float2 t_vol; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
303
+
//typedef volatile const float2 t_vol_con; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
304
304
typedefconstfloat2 t_con;
305
305
// GENERATED_CODE:END
306
306
@@ -668,26 +668,26 @@ void vain() {
668
668
//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 static volatile float l_pre_sta_vol; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
672
+
//precise static volatile const float l_pre_sta_vol_con; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
673
673
precisestaticconstfloat l_pre_sta_con;
674
674
//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'}} */
675
675
//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'}} */
676
676
//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'}} */
677
677
//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'}} */
//static volatile float l_sta_vol; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
683
+
//static volatile const float l_sta_vol_con; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
684
684
staticconstfloat l_sta_con;
685
685
//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'}} */
686
686
//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'}} */
687
687
//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'}} */
688
688
//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'}} */
//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'}} */
714
714
//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}} */
715
715
//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; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
717
717
precisestaticconstfloat l_pre_sta_con_init = 0.0;
718
718
//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'}} */
719
719
//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'}} */
//static volatile const float l_sta_vol_con_init = 0.0; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
723
723
staticconstfloat l_sta_con_init = 0.0;
724
724
//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'}} */
725
725
//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
-
volatileconstfloat l_vol_con_init = 0.0;
726
+
//volatile const float l_vol_con_init = 0.0; /* expected-error {{'volatile' is a reserved keyword in HLSL}} */
727
727
constfloat l_con_init = 0.0;
728
728
// GENERATED_CODE:END
729
729
@@ -969,4 +969,4 @@ class C
969
969
//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'}} */
970
970
//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'}} */
0 commit comments