summaryrefslogtreecommitdiff
path: root/vala/valaobjectcreationexpression.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2016-11-01 17:48:15 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2016-11-03 20:47:31 +0100
commita61dd80e4c4d25fe855692a0ddfded91999789bc (patch)
tree39b5c2c559f31110704be05e7576d9cfe7370609 /vala/valaobjectcreationexpression.vala
parent7a5ff26e941f79e85d0bcba37b3c9ec7322e39c5 (diff)
downloadvala-a61dd80e4c4d25fe855692a0ddfded91999789bc.tar.gz
Support [FormatArg] attribute for parameters
This attribute specifies that the method takes and returns a printf or scanf format string without modifying the order or types of expected arguments, e.g., to translate the format string. This allows the compiler to check the printf/scanf arguments.
Diffstat (limited to 'vala/valaobjectcreationexpression.vala')
-rw-r--r--vala/valaobjectcreationexpression.vala4
1 files changed, 2 insertions, 2 deletions
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 5a271b783..c4b119a44 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -388,7 +388,7 @@ public class Vala.ObjectCreationExpression : Expression {
StringLiteral format_literal = null;
if (last_arg != null) {
// use last argument as format string
- format_literal = last_arg as StringLiteral;
+ format_literal = StringLiteral.get_format_literal (last_arg);
if (format_literal == null && args.size == m.get_parameters ().size - 1) {
// insert "%s" to avoid issues with embedded %
format_literal = new StringLiteral ("\"%s\"");
@@ -457,7 +457,7 @@ public class Vala.ObjectCreationExpression : Expression {
Report.error (source_reference, "Invalid type for argument 1");
}
- var format_literal = ex as StringLiteral;
+ var format_literal = StringLiteral.get_format_literal (ex);
if (format_literal != null) {
var format = format_literal.eval ();
if (!context.analyzer.check_print_format (format, arg_it, source_reference)) {