This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++-11] User defined literals


On 10/27/2011 03:32 PM, Ed Smith-Rowland wrote:
+  if (TREE_CODE (TREE_TYPE (decl)) != LANG_TYPE)
+    argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));

If you have multiple overloaded operator"" _foo, you need to iterate over them looking for the one (or ones, in the case of numeric literals) you want.


+  if (argtypes != NULL_TREE
+      && TREE_VALUE (argtypes) != TREE_TYPE (value))

I think you want


 if (argtypes == NULL_TREE
     || !same_type_p (TREE_VALUE (argtypes), TREE_TYPE (value)))

+  if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE)
+    {
+      if (argtypes != NULL_TREE
+	  && TREE_CODE (TREE_VALUE (argtypes)) == REAL_TYPE)
+	{
+	  error ("unable to find %qD with %<unsigned long long int%> argument",
+		 name);
+	  return error_mark_node;
+	}
+    }
+  else if (TREE_CODE (TREE_TYPE (value)) == REAL_TYPE)
+    {
+      if (argtypes != NULL_TREE
+	  && TREE_CODE (TREE_VALUE (argtypes)) == INTEGER_TYPE)
+	{
+	  error ("unable to find %qD with %<long double%> argument", name);
+	  return error_mark_node;
+	}
+    }

This looks like it will break raw operators.


Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]