Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / g++.dg / warn / Wconversion-real-integer2.C
1 /* { dg-do compile }
2 /* { dg-options "-Wconversion -ftrack-macro-expansion=2" } */
3 /* { dg-require-effective-target int32plus } */
4
5 // Before the fix that came with this test, we'd output an error for
6 // the __INT_MAX__ token.  That token has a BUILTINS_LOCATION
7 // location, so the the location prefix in the warning message would
8 // be:
9 //     <built-in>:0:0: warning: conversion to 'float' alters 'int' constant value
10 //
11 // Note the useless and confusing <built-in>:0:0 prefix.  This is
12 // because '__INT_MAX__' being an internal macro token, it has a
13 // BUILTINS_LOCATION location.
14 //
15 // In this case, we want the error message to refer to the first
16 // location (in the macro expansion context) that is not a location
17 // for a built-in token.  That location would be the one for where (in
18 // real source code) the __INT_MAX__ macro has been expanded.
19 //
20 // That would be something like:
21 //
22 //     gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C:21:17: warning: conversion to 'float' alters 'int' constant value
23 //
24 // That is more useful.
25
26 #define INT_MAX __INT_MAX__ 
27
28 float  vfloat;
29
30 void h (void)
31 {
32     vfloat = INT_MAX; // { dg-warning "conversion to .float. alters .int. constant value" }
33 }