@@ -7479,6 +7479,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p,
if (assignment_operator != ERROR_MARK)
{
bool non_constant_p;
+ location_t saved_input_location;
/* Parse the right-hand side of the assignment. */
tree rhs = cp_parser_initializer_clause (parser, &non_constant_p);
@@ -7491,11 +7492,15 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p,
if (cp_parser_non_integral_constant_expression (parser,
NIC_ASSIGNMENT))
return error_mark_node;
- /* Build the assignment expression. */
+ /* Build the assignment expression. Its default
+ location is the location of the '=' token. */
+ saved_input_location = input_location;
+ input_location = loc;
expr = build_x_modify_expr (loc, expr,
assignment_operator,
rhs,
tf_warning_or_error);
+ input_location = saved_input_location;
}
}
}
new file mode 100644
@@ -0,0 +1,21 @@
+// { dg-options "-pedantic" }
+// { dg-do compile }
+
+#include <limits>
+
+// Compiling this with -pedantic was wrongly triggering this error:
+// libstdc++-v3/include/limits:1269:45: warning : use of C++0x long long integer constant [-Wlong-long]
+// min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; }
+// ^
+// libstdc++-v3/include/limits:1272:44: warning : use of C++0x long long integer constant [-Wlong-long]
+// max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; }
+// ^
+// libstdc++-v3/include/limits:1342:44: warning : use of C++0x long long integer constant [-Wlong-long]
+// max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1
+// ^
+
+int
+main ()
+{
+ return 0;
+}
@@ -10,6 +10,6 @@ const A& foo();
void bar()
{
- foo()=A(0); // { dg-error "12:no match for 'operator='" }
+ foo()=A(0); // { dg-error "8:no match for 'operator='" }
// { dg-message "candidate" "candidate note" { target *-*-* } 13 }
}
@@ -23,11 +23,11 @@
//
// That is more useful.
-#define INT_MAX __INT_MAX__ // { dg-warning "conversion to .float. alters .int. constant value" }
+#define INT_MAX __INT_MAX__
float vfloat;
void h (void)
{
- vfloat = INT_MAX; // { dg-message "in expansion of macro 'INT_MAX'" }
+ vfloat = INT_MAX; // { dg-warning "conversion to .float. alters .int. constant value" }
}
@@ -62,9 +62,9 @@ void func3()
/* At least one branch of ? does not fit in the destination, thus
warn. */
uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
- uchar_x = bar != 0
+ uchar_x = bar != 0 /* { dg-warning "negative integer implicitly converted to unsigned type" } */
? (unsigned char) 1024
- : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+ : -1;
}
void func4()
@@ -2,7 +2,7 @@
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
-struct S { // { dg-error "const|operator=" }
+struct S { // { dg-error "const member\[^\n\r\]*can't use default assignment operator" }
S();
T t;
};
@@ -755,13 +755,35 @@ linemap_location_in_system_header_p (struct line_maps *set,
{
const struct line_map *map = NULL;
- location =
- linemap_resolve_location (set, location, LRK_SPELLING_LOCATION, &map);
-
if (location < RESERVED_LOCATION_COUNT)
return false;
- return LINEMAP_SYSP (map);
+ /* Let's look at where the token for LOCATION comes from. */
+ while (true)
+ {
+ map = linemap_lookup (set, location);
+ if (map != NULL)
+ {
+ if (!linemap_macro_expansion_map_p (map))
+ /* It's a normal token. */
+ return LINEMAP_SYSP (map);
+ else
+ {
+ /* It's a token resulting from a macro expansion. */
+ source_location loc =
+ linemap_macro_map_loc_unwind_toward_spelling (map, location);
+ if (loc < RESERVED_LOCATION_COUNT)
+ /* This token might come from a built-in macro. Let's
+ look at where that macro got expanded. */
+ location = linemap_macro_map_loc_to_exp_point (map, location);
+ else
+ location = loc;
+ }
+ }
+ else
+ break;
+ }
+ return false;
}
/* Return TRUE if LOCATION is a source code location of a token coming