39
39
# define strtok_r strtok_s
40
40
#endif
41
41
42
+ CS_VAR_POOL * find_global_annotation (char * varName , TYPE_TABLE * typeTable );
42
43
extern char * csound_orcget_text ( void * scanner );
43
44
static int32_t is_label (char * ident , CONS_CELL * labelList );
44
45
extern uint64_t csound_orcget_locn (void * );
@@ -283,7 +284,7 @@ static int32_t isirate(/*CSOUND *csound,*/ TREE *t)
283
284
CS_VARIABLE * find_var_from_pools (CSOUND * csound , char * varName ,
284
285
char * varBaseName , TYPE_TABLE * typeTable ) {
285
286
CS_VARIABLE * var = NULL ;
286
-
287
+
287
288
/* VL: 16/01/2014
288
289
in a second compilation, the
289
290
typeTable->globalPool is incorrect and will not
@@ -632,9 +633,13 @@ char* get_arg_type2(CSOUND* csound, TREE* tree, TYPE_TABLE* typeTable)
632
633
633
634
if (* s == '#' )
634
635
s ++ ;
635
-
636
+
637
+ // strip @global if it exists, it's a non-op here
638
+ find_global_annotation (s , typeTable );
636
639
// find the variable in one of the variable pools
637
640
var = find_var_from_pools (csound , s , tree -> value -> lexeme , typeTable );
641
+
642
+
638
643
if (UNLIKELY (var == NULL )) {
639
644
synterr (csound , Str ("get_arg_type2: Variable '%s' used before defined\n"
640
645
"Line %d" ),
@@ -1470,10 +1475,8 @@ int32_t check_args_exist(CSOUND* csound, TREE* tree, TYPE_TABLE* typeTable) {
1470
1475
return 1 ;
1471
1476
}
1472
1477
1473
- // For explicit types only (T_TYPED_IDENT)
1474
- // returns the correct pool and as side effect
1475
- // removes the global annotation
1476
- // from variable name.
1478
+ // returns the correct pool (local or global) and as side effect
1479
+ // removes the global annotation from variable name.
1477
1480
// Expected syntax: var@global
1478
1481
CS_VAR_POOL * find_global_annotation (char * varName , TYPE_TABLE * typeTable ) {
1479
1482
CS_VAR_POOL * pool = typeTable -> localPool ;
@@ -1495,7 +1498,8 @@ CS_VAR_POOL *find_global_annotation(char *varName, TYPE_TABLE* typeTable) {
1495
1498
If the variable is found, a consistency check is made
1496
1499
to make sure the argument type matches the existing variable
1497
1500
*/
1498
- void add_arg (CSOUND * csound , char * varName , char * annotation , TYPE_TABLE * typeTable ) {
1501
+ void add_arg (CSOUND * csound , char * varName , char * annotation ,
1502
+ TYPE_TABLE * typeTable ) {
1499
1503
1500
1504
const CS_TYPE * type ;
1501
1505
CS_VARIABLE * var ;
@@ -1509,11 +1513,16 @@ void add_arg(CSOUND* csound, char* varName, char* annotation, TYPE_TABLE* typeTa
1509
1513
var = find_var_from_pools (csound , varName , varName , typeTable );
1510
1514
if (var == NULL ) {
1511
1515
if (annotation != NULL ) {
1512
- // check for global annotation
1516
+ // check for global annotation in explicit-type rhs vars
1513
1517
pool = find_global_annotation (varName , typeTable );
1514
1518
type = csoundGetTypeWithVarTypeName (csound -> typePool , annotation );
1515
1519
typeArg = (void * ) type ;
1516
1520
} else {
1521
+ // check for @global in implicit-type rhs vars
1522
+ // and if found, strip it and print warning
1523
+ if (find_global_annotation (varName , typeTable ) == typeTable -> globalPool )
1524
+ csound -> Warning (csound , "%s: @global annotation ignored" , varName );
1525
+
1517
1526
t = varName ;
1518
1527
argLetter [1 ] = 0 ;
1519
1528
0 commit comments