diff --git a/doc/ref/create.xml b/doc/ref/create.xml
index c581e701e53..4f5ec77a4d6 100644
--- a/doc/ref/create.xml
+++ b/doc/ref/create.xml
@@ -967,7 +967,7 @@ following:
Global Variables in the Library
Global variables in the ⪆ library are usually read-only in order to
-avoid their being overwritten accidentally.
+prevent them from being overwritten accidentally.
See also Section .
diff --git a/hpcgap/lib/helpbase.gi b/hpcgap/lib/helpbase.gi
index d9662d62091..1766405e4a0 100644
--- a/hpcgap/lib/helpbase.gi
+++ b/hpcgap/lib/helpbase.gi
@@ -497,7 +497,7 @@ end);
# in second list: for each book a list
# [short name, long name,
# directory containing the manual.six file]
-InstallValue(HELP_KNOWN_BOOKS, [[],[]]);
+BindGlobal("HELP_KNOWN_BOOKS", [[],[]]);
if IsHPCGAP then
LockAndMigrateObj(HELP_KNOWN_BOOKS,HELP_REGION);
fi;
@@ -640,7 +640,7 @@ fi;
## components in this help book record depend on the format of the
## documentation and the corresponding handler functions.
##
-InstallValue(HELP_BOOKS_INFO, rec());
+BindGlobal("HELP_BOOKS_INFO", rec());
if IsHPCGAP then
LockAndMigrateObj(HELP_BOOKS_INFO,HELP_REGION);
fi;
@@ -1204,7 +1204,7 @@ if IsHPCGAP then
fi;
# here we store the last shown topic, initialized with 0 (leading to
# show "Tutorial: Help", see below)
-InstallValue(HELP_LAST, AtomicRecord( rec(MATCH := 0, BOOK := 0,
+BindGlobal("HELP_LAST", AtomicRecord( rec(MATCH := 0, BOOK := 0,
NEXT_VIEWER := false, TOPICS := [])));
NAMES_SYSTEM_GVARS:= "to be defined in init.g";
diff --git a/hpcgap/lib/integer.gi b/hpcgap/lib/integer.gi
index 7794912f5c7..3205b3da0ea 100644
--- a/hpcgap/lib/integer.gi
+++ b/hpcgap/lib/integer.gi
@@ -14,7 +14,7 @@
##
#V Integers . . . . . . . . . . . . . . . . . . . . . ring of the integers
##
-InstallValue( Integers, Objectify( NewType(
+BindGlobal( "Integers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -35,7 +35,7 @@ SetIsWholeFamily( Integers, false );
##
#V NonnegativeIntegers . . . . . . . . . . semiring of nonnegative integers
##
-InstallValue( NonnegativeIntegers, Objectify( NewType(
+BindGlobal( "NonnegativeIntegers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsNonnegativeIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -53,7 +53,7 @@ SetIsWholeFamily( NonnegativeIntegers, false );
##
#V PositiveIntegers . . . . . . . . . . . . . semiring of positive integers
##
-InstallValue( PositiveIntegers, Objectify( NewType(
+BindGlobal( "PositiveIntegers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsPositiveIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -71,7 +71,7 @@ SetIsWholeFamily( PositiveIntegers, false );
##
#V GaussianIntegers . . . . . . . . . . . . . . . ring of Gaussian integers
##
-InstallValue( GaussianIntegers, Objectify( NewType(
+BindGlobal( "GaussianIntegers", Objectify( NewType(
CollectionsFamily(CyclotomicsFamily),
IsGaussianIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -148,7 +148,7 @@ InstallMethod( Coefficients,
##
#V Primes . . . . . . . . . . . . . . . . . . . . . . list of small primes
##
-InstallValue( Primes,
+BindGlobal( "Primes",
[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
67, 71, 73, 79, 83, 89, 97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,
diff --git a/lib/ctbl.gd b/lib/ctbl.gd
index 9325accf376..34d5b1ea382 100644
--- a/lib/ctbl.gd
+++ b/lib/ctbl.gd
@@ -3591,7 +3591,7 @@ DeclareAttribute( "DisplayOptions", IsNearlyCharacterTable );
##
##
##
-DeclareGlobalVariable( "CharacterTableDisplayDefaults" );
+DeclareGlobalName( "CharacterTableDisplayDefaults" );
#############################################################################
diff --git a/lib/ctbl.gi b/lib/ctbl.gi
index 48a93fe6f5b..f42652e5d8f 100644
--- a/lib/ctbl.gi
+++ b/lib/ctbl.gi
@@ -5218,7 +5218,7 @@ fi;
##
#V CharacterTableDisplayDefaults
##
-InstallValue( CharacterTableDisplayDefaults, rec(
+BindGlobal( "CharacterTableDisplayDefaults", rec(
Global:= rec(
centralizers := true,
diff --git a/lib/ctblsolv.gd b/lib/ctblsolv.gd
index 658ad7ccff2..5b294795f46 100644
--- a/lib/ctblsolv.gd
+++ b/lib/ctblsolv.gd
@@ -27,7 +27,7 @@
##
##
##
-DeclareGlobalVariable( "BaumClausenInfoDebug" );
+DeclareGlobalName( "BaumClausenInfoDebug" );
#############################################################################
diff --git a/lib/ctblsolv.gi b/lib/ctblsolv.gi
index 05d2c8be80c..f5b02fc673e 100644
--- a/lib/ctblsolv.gi
+++ b/lib/ctblsolv.gi
@@ -849,7 +849,7 @@ InstallMethod( Irr,
##
#V BaumClausenInfoDebug . . . . . . . . . . . . . . testing BaumClausenInfo
##
-InstallValue( BaumClausenInfoDebug, rec(
+BindGlobal( "BaumClausenInfoDebug", rec(
makemat:= function( record, e )
local dim, mat, diag, gcd, i;
dim:= Length( record.diag );
diff --git a/lib/ctblsymm.gd b/lib/ctblsymm.gd
index 541800cd827..148dc8d9784 100644
--- a/lib/ctblsymm.gd
+++ b/lib/ctblsymm.gd
@@ -180,8 +180,7 @@ DeclareGlobalFunction( "CharValueSymmetric" );
##
##
##
-DeclareGlobalVariable( "CharTableSymmetric",
- "generic character table of symmetric groups" );
+DeclareGlobalName( "CharTableSymmetric" );
#############################################################################
@@ -195,8 +194,7 @@ DeclareGlobalVariable( "CharTableSymmetric",
##
##
##
-DeclareGlobalVariable( "CharTableAlternating",
- "generic character table of alternating groups" );
+DeclareGlobalName( "CharTableAlternating" );
#############################################################################
@@ -224,8 +222,7 @@ DeclareGlobalFunction( "CharValueWeylB" );
##
##
##
-DeclareGlobalVariable( "CharTableWeylB",
- "generic character table of Weyl groups of type B" );
+DeclareGlobalName( "CharTableWeylB" );
#############################################################################
@@ -239,8 +236,7 @@ DeclareGlobalVariable( "CharTableWeylB",
##
##
##
-DeclareGlobalVariable( "CharTableWeylD",
- "generic character table of Weyl groups of type D" );
+DeclareGlobalName( "CharTableWeylD" );
#############################################################################
@@ -366,8 +362,7 @@ DeclareGlobalFunction( "CharacterTableWreathSymmetric" );
##
##
##
-DeclareGlobalVariable( "CharTableDoubleCoverSymmetric",
- "gen. char. table of the standard Schur double cover of symm. groups" );
+DeclareGlobalName( "CharTableDoubleCoverSymmetric" );
#############################################################################
@@ -381,5 +376,4 @@ DeclareGlobalVariable( "CharTableDoubleCoverSymmetric",
##
##
##
-DeclareGlobalVariable( "CharTableDoubleCoverAlternating",
- "generic char. table of the Schur double cover of alternating groups" );
+DeclareGlobalName( "CharTableDoubleCoverAlternating" );
diff --git a/lib/ctblsymm.gi b/lib/ctblsymm.gi
index 88c55a904c3..f6092ff9ba7 100644
--- a/lib/ctblsymm.gi
+++ b/lib/ctblsymm.gi
@@ -382,7 +382,7 @@ end );
## Note that this record is accessed in the `Irr' method for natural
## symmetric groups.
##
-InstallValue( CharTableSymmetric, Immutable( rec(
+BindGlobal( "CharTableSymmetric", Immutable( rec(
isGenericTable:=
true,
identifier:=
@@ -486,7 +486,7 @@ InstallValue( CharTableSymmetric, Immutable( rec(
##
#V CharTableAlternating . . generic character table of alternating groups.
##
-InstallValue( CharTableAlternating, Immutable( rec(
+BindGlobal( "CharTableAlternating", Immutable( rec(
isGenericTable:=
true,
identifier:=
@@ -831,7 +831,7 @@ end );
##
#V CharTableWeylB . . . . generic character table of Weyl groups of type B.
##
-InstallValue( CharTableWeylB, Immutable( rec(
+BindGlobal( "CharTableWeylB", Immutable( rec(
isGenericTable:=
true,
identifier:=
@@ -886,7 +886,7 @@ InstallValue( CharTableWeylB, Immutable( rec(
##
#V CharTableWeylD . . . . generic character table of Weyl groups of type D.
##
-InstallValue( CharTableWeylD, rec(
+BindGlobal( "CharTableWeylD", rec(
isGenericTable:=
true,
identifier:=
@@ -1742,7 +1742,7 @@ BindGlobal( "OrderOfSchurLift", function( pi )
##
#V CharTableDoubleCoverSymmetric
##
-InstallValue( CharTableDoubleCoverSymmetric, MakeImmutable ( rec(
+BindGlobal( "CharTableDoubleCoverSymmetric", MakeImmutable ( rec(
isGenericTable:=
true,
identifier:=
@@ -1879,7 +1879,7 @@ InstallValue( CharTableDoubleCoverSymmetric, MakeImmutable ( rec(
##
#V CharTableDoubleCoverAlternating
##
-InstallValue( CharTableDoubleCoverAlternating, MakeImmutable( rec(
+BindGlobal( "CharTableDoubleCoverAlternating", MakeImmutable( rec(
isGenericTable:=
true,
identifier:=
diff --git a/lib/grpfp.gd b/lib/grpfp.gd
index e342e2486b8..019f49a9198 100644
--- a/lib/grpfp.gd
+++ b/lib/grpfp.gd
@@ -1353,4 +1353,4 @@ DeclareGlobalFunction("StringFactorizationWord");
DeclareGlobalFunction("CanMapFiniteAbelianInvariants");
# used in homomorphisms
-DeclareGlobalVariable("TRIVIAL_FP_GROUP");
+DeclareGlobalName("TRIVIAL_FP_GROUP");
diff --git a/lib/grpfp.gi b/lib/grpfp.gi
index 297babc492b..6e346f7d464 100644
--- a/lib/grpfp.gi
+++ b/lib/grpfp.gi
@@ -5670,4 +5670,4 @@ InstallMethod( IndependentGeneratorsOfAbelianGroup,
[ IsFpGroup and IsAbelian ],
IndependentGeneratorsOfMaximalAbelianQuotientOfFpGroup );
-InstallValue(TRIVIAL_FP_GROUP,FreeGroup(0,"TrivGp")/[]);
+BindGlobal("TRIVIAL_FP_GROUP",FreeGroup(0,"TrivGp")/[]);
diff --git a/lib/helpbase.gd b/lib/helpbase.gd
index c573b36510e..a5871ca2362 100644
--- a/lib/helpbase.gd
+++ b/lib/helpbase.gd
@@ -17,10 +17,10 @@ DeclareGlobalFunction("MATCH_BEGIN");
DeclareGlobalFunction("MATCH_BEGIN_COUNT");
DeclareGlobalFunction("FILLED_LINE");
DeclareGlobalFunction("SIMPLE_STRING");
-DeclareGlobalVariable("HELP_KNOWN_BOOKS");
+DeclareGlobalName("HELP_KNOWN_BOOKS");
DeclareGlobalFunction("HELP_ADD_BOOK");
DeclareGlobalFunction("HELP_REMOVE_BOOK");
-DeclareGlobalVariable("HELP_BOOKS_INFO");
+DeclareGlobalName("HELP_BOOKS_INFO");
DeclareGlobalFunction("HELP_BOOK_INFO");
DeclareGlobalFunction("HELP_SHOW_BOOKS");
DeclareGlobalFunction("HELP_SHOW_CHAPTERS");
@@ -35,6 +35,6 @@ DeclareGlobalFunction("HELP_GET_MATCHES");
DeclareGlobalFunction("HELP_SHOW_MATCHES");
DeclareGlobalFunction("HELP_SHOW_FROM_LAST_TOPICS");
DeclareGlobalFunction("HELP_LAB_FILE");
-DeclareGlobalVariable("HELP_LAST");
+DeclareGlobalName("HELP_LAST");
DeclareGlobalFunction("HELP");
diff --git a/lib/helpbase.gi b/lib/helpbase.gi
index adb70a58786..e4c5daff05b 100644
--- a/lib/helpbase.gi
+++ b/lib/helpbase.gi
@@ -490,7 +490,7 @@ end);
# in second list: for each book a list
# [short name, long name,
# directory containing the manual.six file]
-InstallValue(HELP_KNOWN_BOOKS, [[],[]]);
+BindGlobal("HELP_KNOWN_BOOKS", [[],[]]);
if IsHPCGAP then
LockAndMigrateObj(HELP_KNOWN_BOOKS,HELP_REGION);
fi;
@@ -629,7 +629,7 @@ fi;
## components in this help book record depend on the format of the
## documentation and the corresponding handler functions.
##
-InstallValue(HELP_BOOKS_INFO, rec());
+BindGlobal("HELP_BOOKS_INFO", rec());
if IsHPCGAP then
LockAndMigrateObj(HELP_BOOKS_INFO,HELP_REGION);
fi;
@@ -1174,7 +1174,7 @@ if IsHPCGAP then
fi;
# here we store the last shown topic, initialized with 0 (leading to
# show "Tutorial: Help", see below)
-InstallValue(HELP_LAST, rec(MATCH := 0, BOOK := 0,
+BindGlobal("HELP_LAST", rec(MATCH := 0, BOOK := 0,
NEXT_VIEWER := false, TOPICS := []));
NAMES_SYSTEM_GVARS:= "to be defined in init.g";
diff --git a/lib/helpdef.gd b/lib/helpdef.gd
index 9dea3f7d654..dfabbfbb50e 100644
--- a/lib/helpdef.gd
+++ b/lib/helpdef.gd
@@ -18,10 +18,10 @@
##
DeclareGlobalFunction("GapLibToc2Gap");
-DeclareGlobalVariable("HELP_CHAPTER_BEGIN");
-DeclareGlobalVariable("HELP_SECTION_BEGIN");
-DeclareGlobalVariable("HELP_FAKECHAP_BEGIN");
-DeclareGlobalVariable("HELP_PRELCHAPTER_BEGIN");
+DeclareGlobalName("HELP_CHAPTER_BEGIN");
+DeclareGlobalName("HELP_SECTION_BEGIN");
+DeclareGlobalName("HELP_FAKECHAP_BEGIN");
+DeclareGlobalName("HELP_PRELCHAPTER_BEGIN");
DeclareGlobalFunction("HELP_CHAPTER_INFO");
DeclareGlobalFunction("HELP_PRINT_SECTION_URL");
DeclareGlobalFunction("HELP_PRINT_SECTION_MAC_IC_URL");
diff --git a/lib/helpdef.gi b/lib/helpdef.gi
index 3cd8b1a9c6d..a9a4c658804 100644
--- a/lib/helpdef.gi
+++ b/lib/helpdef.gi
@@ -112,10 +112,10 @@ end);
#F HELP_CHAPTER_INFO( , ) . . . . get info about a chapter
##
## this is a helper function for `HELP_SHOW_SECTIONS'
-InstallValue(HELP_CHAPTER_BEGIN, Immutable("\\Chapter"));
-InstallValue(HELP_SECTION_BEGIN, Immutable("\\Section"));
-InstallValue(HELP_FAKECHAP_BEGIN, Immutable("%\\FakeChapter"));
-InstallValue(HELP_PRELCHAPTER_BEGIN, Immutable("\\PreliminaryChapter"));
+BindGlobal("HELP_CHAPTER_BEGIN", Immutable("\\Chapter"));
+BindGlobal("HELP_SECTION_BEGIN", Immutable("\\Section"));
+BindGlobal("HELP_FAKECHAP_BEGIN", Immutable("%\\FakeChapter"));
+BindGlobal("HELP_PRELCHAPTER_BEGIN", Immutable("\\PreliminaryChapter"));
InstallGlobalFunction(HELP_CHAPTER_INFO, function( book, chapter )
local info, filename, stream, poss, secnum, pos, line;
diff --git a/lib/integer.gd b/lib/integer.gd
index c6cadc6c2ee..3cf2c46ad53 100644
--- a/lib/integer.gd
+++ b/lib/integer.gd
@@ -74,12 +74,11 @@ DeclareCategory( "IsNonnegativeIntegers", IsSemiringWithOneAndZero );
##
## <#/GAPDoc>
##
-DeclareGlobalVariable( "Integers", "ring of integers" );
+DeclareGlobalName( "Integers" );
-DeclareGlobalVariable( "PositiveIntegers", "semiring of positive integers" );
+DeclareGlobalName( "PositiveIntegers" );
-DeclareGlobalVariable( "NonnegativeIntegers",
- "semiring of nonnegative integers" );
+DeclareGlobalName( "NonnegativeIntegers" );
#############################################################################
@@ -117,7 +116,7 @@ DeclareCategory( "IsGaussianIntegers", IsEuclideanRing and IsFLMLOR
##
## <#/GAPDoc>
##
-DeclareGlobalVariable( "GaussianIntegers", "ring of Gaussian integers" );
+DeclareGlobalName( "GaussianIntegers");
#############################################################################
@@ -144,7 +143,7 @@ DeclareGlobalVariable( "GaussianIntegers", "ring of Gaussian integers" );
##
## <#/GAPDoc>
##
-DeclareGlobalVariable( "Primes", "list of the 168 primes less than 1000" );
+DeclareGlobalName( "Primes" );
#############################################################################
diff --git a/lib/integer.gi b/lib/integer.gi
index 6620e35450c..9d6e2d6e9e8 100644
--- a/lib/integer.gi
+++ b/lib/integer.gi
@@ -14,7 +14,7 @@
##
#V Integers . . . . . . . . . . . . . . . . . . . . . ring of the integers
##
-InstallValue( Integers, Objectify( NewType(
+BindGlobal( "Integers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -35,7 +35,7 @@ SetIsWholeFamily( Integers, false );
##
#V NonnegativeIntegers . . . . . . . . . . semiring of nonnegative integers
##
-InstallValue( NonnegativeIntegers, Objectify( NewType(
+BindGlobal( "NonnegativeIntegers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsNonnegativeIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -53,7 +53,7 @@ SetIsWholeFamily( NonnegativeIntegers, false );
##
#V PositiveIntegers . . . . . . . . . . . . . semiring of positive integers
##
-InstallValue( PositiveIntegers, Objectify( NewType(
+BindGlobal( "PositiveIntegers", Objectify( NewType(
CollectionsFamily( CyclotomicsFamily ),
IsPositiveIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -71,7 +71,7 @@ SetIsWholeFamily( PositiveIntegers, false );
##
#V GaussianIntegers . . . . . . . . . . . . . . . ring of Gaussian integers
##
-InstallValue( GaussianIntegers, Objectify( NewType(
+BindGlobal( "GaussianIntegers", Objectify( NewType(
CollectionsFamily(CyclotomicsFamily),
IsGaussianIntegers and IsAttributeStoringRep ),
rec() ) );
@@ -148,7 +148,7 @@ InstallMethod( Coefficients,
##
#V Primes . . . . . . . . . . . . . . . . . . . . . . list of small primes
##
-InstallValue( Primes,
+BindGlobal( "Primes",
[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
67, 71, 73, 79, 83, 89, 97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,
diff --git a/lib/stbc.gd b/lib/stbc.gd
index c2bd0ff5ca9..7b8130eaeaa 100644
--- a/lib/stbc.gd
+++ b/lib/stbc.gd
@@ -211,8 +211,7 @@ DeclareAttribute( "StabChainOptions", IsPermGroup, "mutable" );
##
## <#/GAPDoc>
##
-DeclareGlobalVariable( "DefaultStabChainOptions",
- "default options for stabilizer chain calculations" );
+DeclareGlobalName( "DefaultStabChainOptions" );
#############################################################################
diff --git a/lib/stbc.gi b/lib/stbc.gi
index eddeb3db847..0641feab613 100644
--- a/lib/stbc.gi
+++ b/lib/stbc.gi
@@ -315,7 +315,7 @@ InstallMethod( StabChainOptions, true, [ IsPermGroup ], 0,
##
#V DefaultStabChainOptions . . . . . . options record for stabilizer chains
##
-InstallValue( DefaultStabChainOptions,rec( reduced := true,
+BindGlobal( "DefaultStabChainOptions",rec( reduced := true,
random := 1000,
tryPcgs := true ));
MakeThreadLocal("DefaultStabChainOptions");
diff --git a/src/gvars.c b/src/gvars.c
index 7a653fef33c..121f11ff35e 100644
--- a/src/gvars.c
+++ b/src/gvars.c
@@ -232,13 +232,6 @@ static Obj FopiesGVars;
// FlagsGVars contains information about global variables.
// Once cast to a GVarFlagInfo struct, this information is:
//
-// gvarWriteFlag: A value of type GVarWriteFlag which denotes if the variable
-// is Assignable, ReadOnly, or Constant.
-// hasExprCopiesFopies: If the variable has ever had a non-default value
-// assigned to ExprGVars, CopiesGVars or FopiesGVars. Note that this value is
-// never cleared at present, so it can be set to 1 while these three arrays
-// all have their default value, but if it is 0 these arrays definitely have
-// their default values.
typedef enum {
GVarAssignable = 0,
@@ -247,8 +240,21 @@ typedef enum {
} GVarWriteFlag;
typedef struct {
+ // 'gvarWriteFlag' is a value of type GVarWriteFlag which denotes whether
+ // the variable is assignable, read-only, or constant.
unsigned char gvarWriteFlag : 2;
+
+ // 'hasExprCopiesFopies' indicates whether the variable has ever had a
+ // non-default value assigned to ExprGVars, CopiesGVars or FopiesGVars.
+ // Note that this value is never cleared at present, so it can be set to 1
+ // while these three arrays all have their default value, but if it is 0
+ // these arrays definitely have their default values.
unsigned char hasExprCopiesFopies : 1;
+
+ // 'isDeclared' indicates whether the variable was marked by
+ // 'DeclareGlobalName' in which case no "Unbound global variable" syntax
+ // warnings should be issued for it.
+ unsigned char isDeclared : 1;
} GVarFlagInfo;
// If this size increases, the type used in GetGVarFlags and
@@ -290,13 +296,26 @@ static void SetGVarWriteState(Int gvar, GVarWriteFlag w)
SetGVarFlagInfo(gvar, info);
}
-static void SetHasExprCopiesFopies(Int gvar, Int set)
+static void SetHasExprCopiesFopies(Int gvar, BOOL set)
{
GVarFlagInfo info = GetGVarFlagInfo(gvar);
info.hasExprCopiesFopies = set;
SetGVarFlagInfo(gvar, info);
}
+static void SetIsDeclaredName(Int gvar, BOOL set)
+{
+ GVarFlagInfo info = GetGVarFlagInfo(gvar);
+ info.isDeclared = set;
+ SetGVarFlagInfo(gvar, info);
+}
+
+BOOL IsDeclaredGVar(UInt gvar)
+{
+ GVarFlagInfo info = GetGVarFlagInfo(gvar);
+ return info.isDeclared;
+}
+
/****************************************************************************
**
@@ -810,6 +829,18 @@ void MakeThreadLocalVar (
#endif
+/****************************************************************************
+**
+*F FuncDeclareGlobalName(,)
+*/
+Obj FuncDeclareGlobalName(Obj self, Obj name)
+{
+ RequireStringRep("DeclareGlobalName", name);
+ SetIsDeclaredName(GVarName(CONST_CSTR_STRING(name)), 1);
+ return 0;
+}
+
+
/****************************************************************************
**
*F FuncMakeReadOnlyGVar(,) make a global variable read only
@@ -1534,6 +1565,7 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC_1ARGS(IsConstantGVar, name),
GVAR_FUNC(AUTO, -3, "func, arg, names..."),
+ GVAR_FUNC_1ARGS(DeclareGlobalName, name),
GVAR_FUNC_0ARGS(IDENTS_GVAR),
GVAR_FUNC_0ARGS(IDENTS_BOUND_GVARS),
diff --git a/src/gvars.h b/src/gvars.h
index 730a95ce89f..52bf3ec7834 100644
--- a/src/gvars.h
+++ b/src/gvars.h
@@ -169,6 +169,8 @@ BOOL IsReadOnlyGVar(UInt gvar);
BOOL IsConstantGVar(UInt gvar);
+BOOL IsDeclaredGVar(UInt gvar);
+
/****************************************************************************
**
diff --git a/src/read.c b/src/read.c
index f31f18dbfc6..fce6215d1b1 100644
--- a/src/read.c
+++ b/src/read.c
@@ -710,10 +710,14 @@ static void CheckUnboundGlobal(ReaderState * rs, LHSRef ref)
if (ValGVar(ref.var) != 0)
return;
- // ... and isn't an auto var
+ // ... and isn't an auto var ...
if (ExprGVar(ref.var) != 0)
return;
+ // ... and was not "declared" via DeclareGlobalName
+ if (IsDeclaredGVar(ref.var))
+ return;
+
// don't warn if we are skipping/ignoring code
if (rs->intr.ignoring)
return;