8sa1-gcc/gcc/testsuite/g++.dg/cpp2a/inline-asm1.C
Marek Polacek 529bc4103b PR c++/91346 - Implement P1668R1, allow unevaluated asm in constexpr.
* constexpr.c (cxx_eval_constant_expression): Handle ASM_EXPR.
	(potential_constant_expression_1) <case ASM_EXPR>: Allow.
	* cp-tree.h (finish_asm_stmt): Adjust.
	* parser.c (cp_parser_asm_definition): Grab the locaion of "asm" and
	use it.  Change an error to a pedwarn.  Allow asm in C++2a, warn
	otherwise.
	* pt.c (tsubst_expr): Pass a location down to finish_asm_stmt.
	* semantics.c (finish_asm_stmt): New location_t parameter.  Use it.

	* g++.dg/cpp2a/inline-asm1.C: New test.
	* g++.dg/cpp2a/inline-asm2.C: New test.
	* g++.dg/cpp1y/constexpr-neg1.C: Adjust dg-error.

From-SVN: r274169
2019-08-07 14:20:40 +00:00

14 lines
357 B
C

// P1668R1: Permit unevaluated inline asm in constexpr functions
// PR c++/91346
// { dg-do compile { target c++14 } }
// { dg-options "" }
constexpr int
foo (int a, int b)
{
if (__builtin_is_constant_evaluated ())
return a + b;
asm (""); // { dg-warning ".asm. in .constexpr. function only available with" "" { target c++17_down } }
return a;
}