From: Martin Liska Date: Thu, 12 Aug 2021 15:49:14 +0000 (+0200) Subject: c++: fix -fsanitize-coverage=trace-pc ICE [PR101331] X-Git-Tag: upstream/12.2.0~5210 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90ac6edc3c0123b6cf975781f70c8517db84bd63;p=platform%2Fupstream%2Fgcc.git c++: fix -fsanitize-coverage=trace-pc ICE [PR101331] PR c++/101331 gcc/ChangeLog: * asan.h (sanitize_coverage_p): Handle when fn == NULL. gcc/testsuite/ChangeLog: * g++.dg/pr101331.C: New test. --- diff --git a/gcc/asan.h b/gcc/asan.h index 8c0b2ba..820c18b 100644 --- a/gcc/asan.h +++ b/gcc/asan.h @@ -255,8 +255,9 @@ static inline bool sanitize_coverage_p (const_tree fn = current_function_decl) { return (flag_sanitize_coverage - && lookup_attribute ("no_sanitize_coverage", - DECL_ATTRIBUTES (fn)) == NULL_TREE); + && (fn == NULL_TREE + || lookup_attribute ("no_sanitize_coverage", + DECL_ATTRIBUTES (fn)) == NULL_TREE)); } #endif /* TREE_ASAN */ diff --git a/gcc/testsuite/g++.dg/pr101331.C b/gcc/testsuite/g++.dg/pr101331.C new file mode 100644 index 0000000..015aba2 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr101331.C @@ -0,0 +1,7 @@ +// PR c++/101331 +// { dg-do compile } +// { dg-options "-fsanitize-coverage=trace-pc -O2 -std=c++11" } + +int a[2]; +int b = 1; +int c { b && (a[b] = 0) };