Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #554 from 9rnsr/remove_topconst

Remove top const from dynamic array types and pointer types in IFTI.
  • Loading branch information...
commit cc0cde2345e6921fc28bd688a503b03fc98f8b93 2 parents 7f00471 + 50e9f42
@WalterBright WalterBright authored
Showing with 33 additions and 0 deletions.
  1. +8 −0 src/template.c
  2. +25 −0 test/runnable/template9.d
View
8 src/template.c
@@ -1222,6 +1222,14 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec
argtype = argtype->invariantOf();
}
}
+
+ /* Remove top const for dynamic array types and pointer types
+ */
+ if ((argtype->ty == Tarray || argtype->ty == Tpointer) &&
+ !argtype->isMutable())
+ {
+ argtype = argtype->mutableOf();
+ }
#endif
MATCH m;
View
25 test/runnable/template9.d
@@ -534,6 +534,30 @@ static assert(pow10_2550!(0) == 1);
/**********************************/
+void foo10(T)(T prm)
+{
+ pragma(msg, T);
+ static assert(is(T == const(int)[]));
+}
+void bar10(T)(T prm)
+{
+ pragma(msg, T);
+ static assert(is(T == const(int)*));
+}
+void test10()
+{
+ const a = [1,2,3];
+ static assert(is(typeof(a) == const(int[])));
+ foo10(a);
+
+ int n;
+ const p = &n;
+ static assert(is(typeof(p) == const(int*)));
+ bar10(p);
+}
+
+/**********************************/
+
int main()
{
test1();
@@ -558,6 +582,7 @@ int main()
test2778get();
test6994();
test3467();
+ test10();
printf("Success\n");
return 0;
Please sign in to comment.
Something went wrong with that request. Please try again.