1 // RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=core -analyzer-output=text -verify %s
2 
3 typedef unsigned char uint8_t;
4 
5 #define UINT8_MAX 255
6 #define TCP_MAXWIN 65535
7 
8 uint8_t get_uint8_max() {
9   uint8_t rcvscale = UINT8_MAX; // expected-note{{'rcvscale' initialized to 255}}
10   return rcvscale; // expected-note{{Returning the value 255 (loaded from 'rcvscale')}}
11 }
12 
13 void shift_by_undefined_value() {
14   uint8_t shift_amount = get_uint8_max(); // expected-note{{'shift_amount' initialized to 255}}
15                                 // expected-note@-1{{Calling 'get_uint8_max'}}
16                                 // expected-note@-2{{Returning from 'get_uint8_max'}}
17   (void)(TCP_MAXWIN << shift_amount); // expected-warning{{The result of the left shift is undefined due to shifting by '255', which is greater or equal to the width of type 'int'}}
18                                       // expected-note@-1{{The result of the left shift is undefined due to shifting by '255', which is greater or equal to the width of type 'int'}}
19 }
20