aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C
blob: 0494588c15b7bd158a2ac25e176faa5246941712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* { dg-do compile }
/* { dg-options "-Wconversion -ftrack-macro-expansion=2" } */
/* { dg-require-effective-target int32plus } */

// Before the fix that came with this test, we'd output an error for
// the __INT_MAX__ token.  That token has a BUILTINS_LOCATION
// location, so the the location prefix in the warning message would
// be:
//     <built-in>:0:0: warning: conversion to 'float' alters 'int' constant value
//
// Note the useless and confusing <built-in>:0:0 prefix.  This is
// because '__INT_MAX__' being an internal macro token, it has a
// BUILTINS_LOCATION location.
//
// In this case, we want the error message to refer to the first
// location (in the macro expansion context) that is not a location
// for a built-in token.  That location would be the one for where (in
// real source code) the __INT_MAX__ macro has been expanded.
//
// That would be something like:
//
//     gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C:21:17: warning: conversion to 'float' alters 'int' constant value
//
// That is more useful.

#define INT_MAX __INT_MAX__ 

float  vfloat;

void h (void)
{
    vfloat = INT_MAX; // { dg-warning "conversion to .float. alters .int. constant value" }
}