view gcc/testsuite/g++.dg/warn/noreturn-1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Test that noreturn attributes are properly set.
// Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-06-18.
// { dg-do compile }
// { dg-options "-Wall -O2" }

#include <cstdlib>

int foo1 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  abort();
}

int foo2 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  std::abort();
}

int foo3 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  exit(1);
}

int foo4 (int i)
{
  switch (i)
    {
    case 1:
    case 2:
      return i;
    }
  std::exit(1);
}

void __attribute__ ((__noreturn__)) foo5 ()
{
  abort();
}

void __attribute__ ((__noreturn__)) foo6 ()
{
  std::abort();
}

void __attribute__ ((__noreturn__)) foo7 ()
{
  exit(1);
}

void __attribute__ ((__noreturn__)) foo8 ()
{
  std::exit(1);
}