2012-04-30 Dodji Seketeli <dodji@redhat.com>
+ Fix -Wuninitialized for -ftrack-macro-expansion
+ * tree-ssa.c (warn_uninit): Use the spelling location of the
+ variable declaration. Use linemap_location_before_p for source
+ locations.
+
Strip "<built-in>" loc from displayed expansion context
* input.c (expand_location_1): When expanding to spelling location
in a context of a macro expansion, skip reserved system header
2012-04-30 Dodji Seketeli <dodji@redhat.com>
+ Fix -Wuninitialized for -ftrack-macro-expansion
+ * gcc.dg/cpp/pragma-diagnostic-2.c: Fix this.
+
Strip "<built-in>" loc from displayed expansion context
* g++.dg/warn/Wconversion-real-integer2.C: New test.
* g++.dg/warn/Wconversion-real-integer-3.C: Likewise.
void f (unsigned);
#define CODE_WITH_WARNING \
- int a; /* { dg-message "expansion|declared here" } */ \
- f (a) /* { dg-message "expansion" } */
+ int a; /* { dg-message "was declared here" } */ \
+ f (a) /* { dg-warning "used uninitialized" } */
#pragma GCC diagnostic ignored "-Wuninitialized"
{
CODE_WITH_WARNING; /* { dg-message "expanded" } */
}
-
-/*
- { dg-message "some warnings being treated as errors" "" {target *-*-*} 0 }
-*/
-
-/* { dg-error "uninitialized" "" { target *-*-* } { 10 } } */
tree expr, tree var, const char *gmsgid, void *data)
{
gimple context = (gimple) data;
- location_t location;
+ location_t location, cfun_loc;
expanded_location xloc, floc;
if (!ssa_undefined_value_p (t))
location = (context != NULL && gimple_has_location (context))
? gimple_location (context)
: DECL_SOURCE_LOCATION (var);
+ location = linemap_resolve_location (line_table, location,
+ LRK_SPELLING_LOCATION,
+ NULL);
+ cfun_loc = DECL_SOURCE_LOCATION (cfun->decl);
xloc = expand_location (location);
- floc = expand_location (DECL_SOURCE_LOCATION (cfun->decl));
+ floc = expand_location (cfun_loc);
if (warning_at (location, wc, gmsgid, expr))
{
TREE_NO_WARNING (expr) = 1;
if (location == DECL_SOURCE_LOCATION (var))
return;
if (xloc.file != floc.file
- || xloc.line < floc.line
- || xloc.line > LOCATION_LINE (cfun->function_end_locus))
+ || linemap_location_before_p (line_table,
+ location, cfun_loc)
+ || linemap_location_before_p (line_table,
+ cfun->function_end_locus,
+ location))
inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
}
}