1 // Check to make sure clang is somewhat picky about -g options.
2 // (Delived from debug-options.c)
4 // RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
5 // RUN: | FileCheck -check-prefix=SAVE %s
7 // SAVE: "-cc1"{{.*}}"-E"{{.*}}"-debug-info-kind=
8 // SAVE: "-cc1"{{.*}}"-emit-llvm-bc"{{.*}}"-debug-info-kind=
9 // SAVE: "-cc1"{{.*}}"-S"{{.*}}"-debug-info-kind=
11 // SAVE-NOT: -debug-info-kind=
13 // Make sure that '-ggdb0' is not accidentally mistaken for '-g'
14 // RUN: %clang -### -ggdb0 -c -integrated-as -x assembler %s 2>&1 \
15 // RUN: | FileCheck -check-prefix=GGDB0 %s
18 // GGDB0-NOT: -debug-info-kind=
20 // Check to make sure clang with -g on a .s file gets passed.
22 // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \
23 // RUN: | FileCheck %s
26 // CHECK: "-debug-info-kind=constructor"
28 // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer.
30 // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \
31 // RUN: | FileCheck -check-prefix=P %s
34 // P: "-dwarf-debug-producer"
36 // Check that -gdwarf64 is passed to cc1as.
37 // RUN: %clang -### -c -gdwarf64 -gdwarf-5 -target x86_64 -integrated-as -x assembler %s 2>&1 \
38 // RUN: | FileCheck -check-prefix=GDWARF64_ON %s
39 // RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
40 // RUN: | FileCheck -check-prefix=GDWARF64_ON %s
41 // RUN: %clang -### -c -gdwarf64 -gdwarf-3 -target x86_64 -integrated-as -x assembler %s 2>&1 \
42 // RUN: | FileCheck -check-prefix=GDWARF64_ON %s
43 // GDWARF64_ON: "-cc1as"
44 // GDWARF64_ON: "-gdwarf64"
46 // Check that -gdwarf64 can be reverted with -gdwarf32.
47 // RUN: %clang -### -c -gdwarf64 -gdwarf32 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
48 // RUN: | FileCheck -check-prefix=GDWARF64_OFF %s
49 // GDWARF64_OFF: "-cc1as"
50 // GDWARF64_OFF-NOT: "-gdwarf64"
52 // Check that an error is reported if -gdwarf64 cannot be used.
53 // RUN: %clang -### -c -gdwarf64 -gdwarf-2 -target x86_64 -integrated-as -x assembler %s 2>&1 \
54 // RUN: | FileCheck -check-prefix=GDWARF64_VER %s
55 // RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target i386-linux-gnu %s 2>&1 \
56 // RUN: | FileCheck -check-prefix=GDWARF64_32ARCH %s
57 // RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64-apple-darwin %s 2>&1 \
58 // RUN: | FileCheck -check-prefix=GDWARF64_ELF %s
60 // GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
61 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
62 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
64 // Check that -gdwarf-N can be placed before other options of the "-g" group.
65 // RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
66 // RUN: | FileCheck -check-prefix=DWARF3 %s
67 // RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
68 // RUN: | FileCheck -check-prefix=DWARF3 %s
69 // RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
70 // RUN: | FileCheck -check-prefix=DWARF5 %s
71 // RUN: %clang -### -c -gdwarf-5 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
72 // RUN: | FileCheck -check-prefix=DWARF5 %s
75 // DWARF3: "-dwarf-version=3"
77 // DWARF5: "-dwarf-version=5"