+2018-07-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grokdeclarator): Use rich_location::add_range in three
+ more places; include gcc-rich-location.h.
+
2018-07-07 Aldy Hernandez <aldyh@redhat.com>
* decl.c (build_enumerator): Change overflow type to overflow_type.
#include "builtins.h"
#include "gimplify.h"
#include "asan.h"
+#include "gcc-rich-location.h"
/* Possible cases of bad specifiers type used by bad_specifiers. */
enum bad_spec_place {
int ok = 0;
if (signed_p && unsigned_p)
- error_at (loc, "%<signed%> and %<unsigned%> specified together");
+ {
+ gcc_rich_location richloc (declspecs->locations[ds_signed]);
+ richloc.add_range (declspecs->locations[ds_unsigned], false);
+ error_at (&richloc,
+ "%<signed%> and %<unsigned%> specified together");
+ }
else if (long_p && short_p)
- error_at (loc, "%<long%> and %<short%> specified together");
+ {
+ gcc_rich_location richloc (declspecs->locations[ds_long]);
+ richloc.add_range (declspecs->locations[ds_short], false);
+ error_at (&richloc, "%<long%> and %<short%> specified together");
+ }
else if (TREE_CODE (type) != INTEGER_TYPE
|| type == char16_type_node || type == char32_type_node
|| ((long_p || short_p)
{
if (staticp == 2)
{
- rich_location richloc (line_table, declspecs->locations[ds_virtual]);
+ gcc_rich_location richloc (declspecs->locations[ds_virtual]);
richloc.add_range (declspecs->locations[ds_storage_class], false);
error_at (&richloc, "member %qD cannot be declared both %<virtual%> "
"and %<static%>", dname);
}
if (constexpr_p)
{
- rich_location richloc (line_table, declspecs->locations[ds_virtual]);
+ gcc_rich_location richloc (declspecs->locations[ds_virtual]);
richloc.add_range (declspecs->locations[ds_constexpr], false);
error_at (&richloc, "member %qD cannot be declared both %<virtual%> "
"and %<constexpr%>", dname);
if (virtualp)
{
/* Cannot be both friend and virtual. */
- error_at (declspecs->locations[ds_friend],
- "virtual functions cannot be friends");
+ gcc_rich_location richloc (declspecs->locations[ds_virtual]);
+ richloc.add_range (declspecs->locations[ds_friend], false);
+ error_at (&richloc, "virtual functions cannot be friends");
friendp = 0;
}
if (decl_context == NORMAL)
+2018-07-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/diagnostic/long-short.C: New.
+ * g++.dg/diagnostic/signed-unsigned.C: Likewise.
+ * g++.dg/diagnostic/virtual-friend.C: Likewise.
+ * g++.old-deja/g++.brendan/crash11.C: Adjust.
+
2018-07-09 Tom de Vries <tdevries@suse.de>
* gcc.dg/vla-1.c: New test.
--- /dev/null
+// { dg-options "-fdiagnostics-show-caret" }
+
+long short int a; // { dg-error "1:.long. and .short. specified together" }
+/* { dg-begin-multiline-output "" }
+ long short int a;
+ ^~~~ ~~~~~
+ { dg-end-multiline-output "" } */
+short long int b; // { dg-error "7:.long. and .short. specified together" }
+/* { dg-begin-multiline-output "" }
+ short long int b;
+ ~~~~~ ^~~~
+ { dg-end-multiline-output "" } */
--- /dev/null
+// { dg-options "-fdiagnostics-show-caret" }
+
+signed unsigned int a; // { dg-error "1:.signed. and .unsigned. specified together" }
+/* { dg-begin-multiline-output "" }
+ signed unsigned int a;
+ ^~~~~~ ~~~~~~~~
+ { dg-end-multiline-output "" } */
+unsigned signed int b; // { dg-error "10:.signed. and .unsigned. specified together" }
+/* { dg-begin-multiline-output "" }
+ unsigned signed int b;
+ ~~~~~~~~ ^~~~~~
+ { dg-end-multiline-output "" } */
--- /dev/null
+// { dg-options "-fdiagnostics-show-caret" }
+// { dg-do compile { target c++11 } }
+
+struct S
+{
+ virtual friend void foo(); // { dg-error "3:virtual functions cannot be friends" }
+/* { dg-begin-multiline-output "" }
+ virtual friend void foo();
+ ^~~~~~~ ~~~~~~
+ { dg-end-multiline-output "" } */
+ friend virtual void bar(); // { dg-error "10:virtual functions cannot be friends" }
+/* { dg-begin-multiline-output "" }
+ friend virtual void bar();
+ ~~~~~~ ^~~~~~~
+ { dg-end-multiline-output "" } */
+};
int h;
A() { i=10; j=20; }
virtual void f1() { printf("i=%d j=%d\n",i,j); }
- friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "2:virtual functions cannot be friends" }
+ friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "9:virtual functions cannot be friends" }
};
class B : public A {
public:
virtual void f1() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } member.*// ERROR - member.*
- friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "2:virtual functions cannot be friends" }
+ friend virtual void f2() { printf("i=%d j=%d\n",i,j); } // { dg-error "9:virtual functions cannot be friends" }
// { dg-error "private" "" { target *-*-* } .-1 }
};