Exactly as @MichelKeijzers wrote the issue is caused by "IRremote" using same timer as "Tone" and the solution to this problem is a little dirty.
Since Tone is included in ArduinoCore (and compiled) we can't easilly modify it so the only thing that worked for me is to modify boarddefs.h file of IRremote library. Since it's code is easilly available after downloading it using "Library Manager" included in ArduinoIDE.
In my tests I used ATmega328P settings.
Edit C:\Users\youruser\Documents\Arduino\libraries\IRremote\boarddefs.h and look for your processor number.
For ATmega328 the definition is #define IR_USE_TIMER2
I simply changed it to use #define IR_USE_TIMER1
And compilation was successfull.
Sketch uses 2746 bytes (8%) of program storage space. Maximum is 30720 bytes.
Global variables use 242 bytes (11%) of dynamic memory, leaving 1806 bytes for local variables. Maximum is 2048 bytes.
My code:
#include "IRremote.h"
#define NOTE_C5 523
#define NOTE_E6 1319
#define USE_TIMER1
#define IR_USE_TIMER1
int melody[] = {NOTE_C5, NOTE_E6};
void setup() {}
void loop() {
for (int thisNote = 0; thisNote < 2; thisNote++) {
tone(3, melody[thisNote], 300);
}
}


