Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
      2 
      3 extern "C" {
      4 extern int scanf(const char *restrict, ...);
      5 extern int printf(const char *restrict, ...);
      6 }
      7 
      8 void f(char **sp, float *fp) {
      9   scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
     10 
     11   printf("%a", 1.0);
     12   scanf("%afoobar", fp);
     13   printf(nullptr);
     14   printf(*sp); // expected-warning {{not a string literal}}
     15 
     16   // PR13099
     17   printf(
     18     R"foobar(%)foobar"
     19     R"bazquux(d)bazquux" // expected-warning {{more '%' conversions than data arguments}}
     20     R"xyzzy()xyzzy");
     21 
     22   printf(u8"this is %d test", 0); // ok
     23   printf(u8R"foo(
     24       \u1234\U0010fffe
     25       %d)foo" // expected-warning {{more '%' conversions than data arguments}}
     26   );
     27 
     28   printf("init list: %d", { 0 }); // expected-error {{cannot pass initializer list to variadic function; expected type from format string was 'int'}}
     29   printf("void: %d", f(sp, fp)); // expected-error {{cannot pass expression of type 'void' to variadic function; expected type from format string was 'int'}}
     30   printf(0, { 0 }); // expected-error {{cannot pass initializer list to variadic function}}
     31 }
     32