as forbidden, not deprecated.
* typeck.c (string_conv_p): Do a pedwarn in c++11 and above,
change the diagnostic for the Wwrite-strings case for c++11 and above.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218087
138bc75d-0d04-0410-961f-
82ee72b054a4
+2014-11-26 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Diagnose string constant conversion to char* in c++11 and above
+ as forbidden, not deprecated.
+ * typeck.c (string_conv_p): Do a pedwarn in c++11 and above,
+ change the diagnostic for the Wwrite-strings case for c++11 and above.
+
2014-11-24 Jason Merrill <jason@redhat.com>
* pt.c (lookup_template_variable): Always unknown_type_node.
|| TREE_CODE (TREE_OPERAND (exp, 0)) != STRING_CST)
return 0;
}
-
- /* This warning is not very useful, as it complains about printf. */
if (warn)
- warning (OPT_Wwrite_strings,
- "deprecated conversion from string constant to %qT",
- totype);
+ {
+ if (cxx_dialect >= cxx11)
+ pedwarn (input_location,
+ pedantic ? OPT_Wpedantic : OPT_Wwrite_strings,
+ "ISO C++ forbids converting a string constant to %qT",
+ totype);
+ else
+ warning (OPT_Wwrite_strings,
+ "deprecated conversion from string constant to %qT",
+ totype);
+ }
return 1;
}
int main()
{
- char* p = "Asgaard"; // { dg-warning "deprecated" }
+ char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" }
}
int main()
{
- char* p = "Asgaard"; // { dg-warning "deprecated" }
+ char* p = "Asgaard"; // { dg-warning "deprecated|forbids converting a string constant" }
}
class B : public A {
public:
char* m1 () { C::m1(); return ""; } // { dg-error "cannot call" }
- // { dg-warning "deprecated" "depr" { target *-*-* } 14 }
+ // { dg-warning "deprecated|forbids converting a string constant" "depr" { target *-*-* } 14 }
};
int main () {
const Regex NDAMName<'L'>::pattern("^[Ll](.*)$", 1);// { dg-error "type/value mismatch" "mismatch" }
// { dg-message "expected a type" "expected" { target *-*-* } 11 }
-// { dg-warning "deprecated" "depr" { target *-*-* } 11 }
+// { dg-warning "deprecated|forbids converting a string constant" "depr" { target *-*-* } 11 }
unsigned NDAMName<'L'>::sequence_number = 0;// { dg-error "type/value mismatch" "mismatch" }
// { dg-message "expected a type" "exp" { target *-*-* } 14 }
cookie ( foo * x) { v=x; }
};
-cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion" "dep" }
+cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion|forbids converting a string constant" "dep" }
// { dg-warning "taking address of temporary" "add" { target *-*-* } 19 }
// Check implicit conversion from string constants into typedefs
typedef char CHAR;
-void f2(CHAR *s=""); // { dg-warning "deprecated" }
+void f2(CHAR *s=""); // { dg-warning "deprecated|forbids converting a string constant" }