brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · d94fd1b Raw
66 lines · c
1// RUN: %clang_cc1 -verify=all,c2x -std=c2x -fsyntax-only %s2// RUN: %clang_cc1 -verify=all -std=c17 -fsyntax-only %s3// RUN: %clang_cc1 -verify=none -Wno-deprecated-attributes -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS -std=c2x -fsyntax-only %s4// RUN: %clang_cc1 -verify=none -Wno-deprecated-attributes -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS -std=c17 -fsyntax-only %s5// none-no-diagnostics6 7// Test preprocessor functionality.8#if !__has_c_attribute(noreturn)9#error "No noreturn attribute support?"10#endif11 12#if !__has_c_attribute(_Noreturn)13#error "No _Noreturn attribute support?"14#endif15 16#if __has_c_attribute(noreturn) != __has_c_attribute(_Noreturn) || \17    __has_c_attribute(noreturn) != 202202L18#error "Wrong value for __has_c_attribute(noreturn)"19#endif20 21// If we're testings with deprecations disabled, we don't care about testing22// the scenarios that trigger errors because we're only interested in the23// deprecation warning behaviors.24#ifndef _CLANG_DISABLE_CRT_DEPRECATION_WARNINGS25// Test that the attribute accepts no args, applies to the correct subject, etc.26[[noreturn(12)]] void func4(void); // all-error {{attribute 'noreturn' cannot have an argument list}}27[[noreturn]] int not_a_func; // all-error {{'noreturn' attribute only applies to functions}}28void func5(void) [[noreturn]]; // all-error {{'noreturn' attribute cannot be applied to types}}29#endif30 31_Noreturn void func1(void); // ok, using the function specifier32[[noreturn]] void func2(void);33 34// This is deprecated because it's only for compatibility with inclusion of the35// <stdnoreturn.h> header where the noreturn macro expands to _Noreturn.36[[_Noreturn]] void func3(void); // all-warning {{the '[[_Noreturn]]' attribute spelling is deprecated in C23; use '[[noreturn]]' instead}}37 38// Test the behavior of including <stdnoreturn.h>39#include <stdnoreturn.h>40 41[[noreturn]] void func6(void);42 43void func7 [[noreturn]] (void);44 45noreturn void func8(void);46 47// Ensure the function specifier form still works.48void noreturn func9(void);49 50// Ensure that spelling the deprecated form of the attribute is still diagnosed.51[[_Noreturn]] void func10(void); // all-warning {{the '[[_Noreturn]]' attribute spelling is deprecated in C23; use '[[noreturn]]' instead}}52 53// Test preprocessor functionality after including <stdnoreturn.h>.54#if !__has_c_attribute(noreturn)55#error "No noreturn attribute support?"56#endif57 58#if !__has_c_attribute(_Noreturn)59#error "No _Noreturn attribute support?"60#endif61 62// Test that a macro which expands to _Noreturn is still diagnosed when it63// doesn't come from a system header.64#define NORETURN _Noreturn65[[NORETURN]] void func11(void); // all-warning {{the '[[_Noreturn]]' attribute spelling is deprecated in C23; use '[[noreturn]]' instead}}66