Permalink
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...
2 parents 7f00471 + 50e9f42 commit cc0cde2345e6921fc28bd688a503b03fc98f8b93 @WalterBright WalterBright committed Dec 11, 2011
Showing with 33 additions and 0 deletions.
  1. +8 −0 src/template.c
  2. +25 −0 test/runnable/template9.d
View
@@ -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;
@@ -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;

0 comments on commit cc0cde2

Please sign in to comment.