1// Test this without pch.
2// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
3
4// Test with pch.
5// RUN: %clang_cc1 %s -emit-pch -o %t
6// RUN: %clang_cc1 %s -emit-llvm -include-pch %t -o - | FileCheck %s
7
8// The first run line creates a pch, and since at that point HEADER is not
9// defined, the only thing contained in the pch is the pragma. The second line
10// then includes that pch, so HEADER is defined and the actual code is compiled.
11// The check then makes sure that the pragma is in effect in the file that
12// includes the pch.
13
14// expected-no-diagnostics
15
16#ifndef HEADER
17#define HEADER
18#pragma clang optimize off
19
20#else
21
22int a;
23
24void f() {
25  a = 12345;
26}
27
28// Check that the function is decorated with optnone
29
30// CHECK-DAG: @f() [[ATTRF:#[0-9]+]]
31// CHECK-DAG: attributes [[ATTRF]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
32
33#endif
34