brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · c5586b8 Raw
24 lines · cpp
1// RUN: %clang_cc1 -triple=i386-unknown-unknown -verify -fcf-protection=branch -std=c++11 -fsyntax-only %s2 3// Function pointer definition.4[[gnu::nocf_check]] typedef void (*FuncPointerWithNoCfCheck)(void); // no-warning5typedef void (*FuncPointer)(void);6 7// Dont allow function declaration and definition mismatch.8[[gnu::nocf_check]] void testNoCfCheck();   // expected-note {{previous declaration is here}}9void testNoCfCheck(){}; //  expected-error {{conflicting types for 'testNoCfCheck'}}10 11// No variable or parameter declaration12int [[gnu::nocf_check]] i;                              // expected-error {{'gnu::nocf_check' attribute cannot be applied to types}}13void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} // expected-warning {{'gnu::nocf_check' attribute only applies to functions and function pointers}}14 15// Allow attributed function pointers as well as casting between attributed16// and non-attributed function pointers.17void testNoCfCheckMismatch(FuncPointer f) {18  FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-error {{cannot initialize a variable of type}}19  (*fNoCfCheck)();                         // no-warning20}21 22// 'nocf_check' Attribute has no parameters.23[[gnu::nocf_check(1)]] int testNoCfCheckParams(); // expected-error {{'gnu::nocf_check' attribute takes no arguments}}24