aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-08-21 14:33:13 +0200
committerBjörn Gustavsson <[email protected]>2014-09-01 14:37:15 +0200
commit9b786fc3114723d71383b184c4824d4498a1e6af (patch)
tree0751b28d73f17e18378efc83e35e085b94c6e153 /lib/asn1
parentf94cfe594e449799b1e97829483551572bb39f63 (diff)
downloadotp-9b786fc3114723d71383b184c4824d4498a1e6af.tar.gz
otp-9b786fc3114723d71383b184c4824d4498a1e6af.tar.bz2
otp-9b786fc3114723d71383b184c4824d4498a1e6af.zip
Check the formal parameter for parameterized type definitions
Check the formal parameters for a parameterized type definition. If the governor for a formal parameter is absent, the formal parameter must be in upper case.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_check.erl15
-rw-r--r--lib/asn1/test/error_SUITE.erl17
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl
index 2055f2e5eb..2e0e4d5977 100644
--- a/lib/asn1/src/asn1ct_check.erl
+++ b/lib/asn1/src/asn1ct_check.erl
@@ -2926,8 +2926,7 @@ get_canonic_type(S,Type,NameList) ->
check_ptype(S,Type,Ts) when is_record(Ts,type) ->
- %Tag = Ts#type.tag,
- %Constr = Ts#type.constraint,
+ check_formal_parameters(S, Type#ptypedef.args),
Def = Ts#type.def,
NewDef=
case Def of
@@ -2953,6 +2952,16 @@ check_ptype(S,Type,Ts) when is_record(Ts,type) ->
check_ptype(_S,_PTDef,Ts) when is_record(Ts,objectclass) ->
throw({asn1_param_class,Ts}).
+check_formal_parameters(S, Args) ->
+ _ = [check_formal_parameter(S, A) || A <- Args],
+ ok.
+
+check_formal_parameter(_, {_,_}) ->
+ ok;
+check_formal_parameter(_, #'Externaltypereference'{}) ->
+ ok;
+check_formal_parameter(S, #'Externalvaluereference'{value=Name}=Ref) ->
+ asn1_error(S, Ref, {illegal_typereference,Name}).
% check_type(S,Type,ObjSpec={{objectclassname,_},_}) ->
% check_class(S,ObjSpec);
@@ -6748,6 +6757,8 @@ format_error({illegal_instance_of,Class}) ->
[Class]);
format_error(illegal_octet_string_value) ->
"expecting a bstring or an hstring as value for an OCTET STRING";
+format_error({illegal_typereference,Name}) ->
+ io_lib:format("'~p' is used as a typereference, but does not start with an uppercase letter", [Name]);
format_error({invalid_fields,Fields,Obj}) ->
io_lib:format("invalid ~s in ~p", [format_fields(Fields),Obj]);
format_error({invalid_bit_number,Bit}) ->
diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl
index 8a0414708d..1edd60f7c8 100644
--- a/lib/asn1/test/error_SUITE.erl
+++ b/lib/asn1/test/error_SUITE.erl
@@ -20,7 +20,8 @@
-module(error_SUITE).
-export([suite/0,all/0,groups/0,
already_defined/1,bitstrings/1,enumerated/1,
- imports/1,instance_of/1,integers/1,objects/1,values/1]).
+ imports/1,instance_of/1,integers/1,objects/1,
+ parameterization/1,values/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -38,6 +39,7 @@ groups() ->
instance_of,
integers,
objects,
+ parameterization,
values]}].
parallel() ->
@@ -219,6 +221,19 @@ objects(Config) ->
} = run(P, Config),
ok.
+parameterization(Config) ->
+ M = 'Parameterization',
+ P = {M,
+ <<"Parameterization DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n"
+ " NotUppercase{lowercase} ::= INTEGER (lowercase)\n"
+ "END\n">>},
+ {error,
+ [{structured_error,{'Parameterization',2},asn1ct_check,
+ {illegal_typereference,lowercase}}
+ ]
+ } = run(P, Config),
+ ok.
+
values(Config) ->
M = 'Values',
P = {M,